BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

How to get past (Twitter doesn't allow identical subsequent messages. )

Hello, im wondering how to get past this, I have 2 buttons. ( Going to make it digitalread from another arduino, would also like some input in how to do this.) But well, i press the 1 button it sends a message on twitter, i press another one ands it sends button 2 on twitter, But when i try to press button 1 again it doesnt come up? How can i fix this?

Add something like millis() to the message to make it unique.

Got it fixed with RandNumbers from the analogSeed. But, how to write a low to the esp8266 from another arduino to make it trigger a message ?

I don’t really know what you are doing but the bridge widget can send low from MCU1 to MCU2. Lots of other ways too but it depends how you have you hardware configured.


/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app
23ce7e0cf4a4463eb8d07990184a689c
  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************

  You’ll need:
   - Blynk App (download from AppStore or Google Play)
   - ESP8266 board
   - Decide how to connect to Blynk
     (USB, Ethernet, Wi-Fi, Bluetooth, ...)

  There is a bunch of great example sketches included to show you how to get
  started. Think of them as LEGO bricks  and combine them as you wish.
  For example, take the Ethernet Shield sketch and combine it with the
  Servo example, or choose a USB sketch and add a code from SendData
  example.
 *************************************************************/

/* Comment this out to disable prints and save space */
/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************

  Simple tweet example

  App project setup:
    Twitter widget (connect it to your Twitter account!)

  Connect a button to pin 2 and GND...
  Pressing this button will also tweet a message! ;)
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "23ce7e0cf4a4463eb8d07992184a689c";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "MYNET";
char pass[] = "MYPW";


long randNumber;
long randNumber2;

BlynkTimer timer;

void tweetUptime()
{
  long uptime = millis() / 60000L;
  Serial.println("Tweeting every 10 minutes ;)");

  // Actually send the message.
  // Note:
  //   We allow 1 tweet per 15 seconds for now.
  //   Twitter doesn't allow identical subsequent messages.
  Blynk.tweet(String("Running for ") + uptime + " minut");
}

void tweetOnButtonPress()
{
  // Invert state, since button is "Active LOW"
   if (digitalRead(2) == HIGH)  {
    Serial.println("Button is pressed.");
    randNumber = random(300);
    Blynk.tweet(String("Testing ") + randNumber + " HIGH");
  }
}

void tweetOnButtonPress2()
{
  // Invert state, since button is "Active LOW"
 if (digitalRead(4) == LOW)  {
    Serial.println("Button is pressed.");
    Blynk.tweet(String("Testing ") + randNumber2 + " LOW");
  }
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);

  // Tweet immediately on startup
  Blynk.tweet("Testing stuff Again 10 .");

  // Setup a function to be called every 10 minutes
  timer.setInterval(10L * 60000L, tweetUptime);
  randomSeed(analogRead(0));
  // Setup twitter button on pin 2
  pinMode(2, INPUT); // IS this correct?
  pinMode(4, INPUT); // is this correct?
  // Attach pin 2 interrupt to our handler
  //attachInterrupt(digitalPinToInterrupt(2), tweetOnButtonPress, CHANGE);
   // attachInterrupt(digitalPinToInterrupt(4), tweetOnButtonPress2, CHANGE);
}

void loop()
{
  Blynk.run();
  timer.run();
}

Here is my code example. Trying to send a low or high from another arduino to trigger a Tweet. How can i do this?

Describe the hardware you want to use and the reason you are not using a single ESP to do everything.

its so many things that is running that i cant use a single arduino. I got a mega that im trying to send the signals from.

If the arduino mega HCR04 ultra sensor is under lets say 30 cm send a signal to the Espduino card so it tweets its.

Is the Mega connected to Blynk with Ethernet or ESP8266 WiFi?

Or is it hardwired to the ESP via rx and tx?

it hardwired to just the digital pins, witch sends high and low into the esp8266

In that case surely when HCR04 < 30cm Mega writes to a digital pin on the ESP, ESP has a 500ms timer checking state of this pin and then sends the tweet.

hmm. so how do i change :

void tweetOnButtonPress()
{
// Invert state, since button is "Active LOW"
if (digitalRead(2) == HIGH) {
Serial.println(“Button is pressed.”);
randNumber = random(300);
Blynk.tweet(String("Testing “) + randNumber + " HIGH”);
} 

To make it work with that ? Didnt quite understand, the void there is abit annoying, not 100% sure what it does.

Look up examples of BlynkTimer like PUSH_DATA and put the contents of void tweetOnButtonPress() into the timed function say checkPin() or keep the same function name you currently have.

Hmm. Push data uses virtual pins. Im trying to not use the app on my android for now.

Just pick out the timer parts from PUSH_DATA.

what would that help with? Aint going to read a low or high from the mega then? Sorry for the question, im a total newb when it comes to blynk.

Which part of this do you not understand?

How to do the checking state

You already have the code:

if (digitalRead(2) == HIGH) {
// ........
}

haha okey, Then dont understand how to implement the timer on it…-.-

Like lots of other users and that’s why we point you to PUSH_DATA.

You could check the timer on the Arduino site but it’s not very clearly written and generally easier to pick out the required parts from PUSH_DATA.