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

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

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.

am i into something here?

define BLYNK_PRINT Serial


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

long randomNumber;

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

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

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("been up high for ") + uptime + " minutes.");
}

void TweetwhenHIGH()
{
  // Invert state, since button is "Active LOW"
  //int isButtonPressed = !digitalRead(2);
  //if (isButtonPressed) {
if (digitalRead(2) == HIGH)  {
    timer.setInterval(500L, TweetwhenHIGH);
    Serial.println("Button is pressed.");
    randomNumber = random(300);
    Blynk.tweet(String("Testing ") + randomNumber + " HIGH");
    Serial.println("Button is pressed.");
    Blynk.tweet(" Pin Went from Low to HIGH, doing tweet");
  }
}

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("My Arduino project is tweeting again");

  // Reading analogRead to create a random Number
  randomSeed(analogRead(0));
  // Setup a function to be called every 2 minutes
  timer.setInterval(2L * 60000L, tweetUptime);

  // Setup twitter button on pin 2
  pinMode(2, INPUT_PULLUP);
  // Attach pin 2 interrupt to our handler
  //attachInterrupt(digitalPinToInterrupt(2), tweetOnButtonPress, CHANGE);
  timer.setInterval(500L, TweetwhenHIGH);
}

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

Let me know when your code is forum formatted. P.S. looks ok but I’m not going to try and read it with the format you have at the moment.

define BLYNK_PRINT Serial


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

long randomNumber;

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

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

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("been up high for ") + uptime + " minutes.");
}

void TweetwhenHIGH()
{
  // Invert state, since button is "Active LOW"
  //int isButtonPressed = !digitalRead(2);
  //if (isButtonPressed) {
if (digitalRead(2) == HIGH)  {
    timer.setInterval(500L, TweetwhenHIGH);
    Serial.println("PIN IS HIGH.");
    randomNumber = random(300);
    Blynk.tweet(String("Testing pin ") + randomNumber + " HIGH");
    Blynk.tweet(" Pin Went from Low to HIGH, doing tweet");
  }
}

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("My Arduino project is tweeting again");

  // Reading analogRead to create a random Number
  randomSeed(analogRead(0));
  // Setup a function to be called every 2 minutes
  timer.setInterval(2L * 60000L, tweetUptime);

  // Setup twitter button on pin 2
  pinMode(2, INPUT_PULLUP);
  // Attach pin 2 interrupt to our handler
  //attachInterrupt(digitalPinToInterrupt(2), tweetOnButtonPress, CHANGE);
  timer.setInterval(500L, TweetwhenHIGH);
}

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

here we go.

Since your first cod dump was unformatted… as REQUIRED in the Welcome Topic… I fixed it for you… Thank you for formatting the rest :slight_smile:

@Sondre_Wold remove timer.setInterval(500L, TweetwhenHIGH); from TweetwhenHIGH() function as you only need it in setup().

Change baud from 9600 to 115200, 9600 is for super slow Arduino’s not super fast ESP’s.

Consider using a “safe” pin like 4 and 5 not an ESP “special” pin like 2.

I FINALY got it to work :smiley: Thanks so much for you help Costas!!! I hope you are getting some good karma now :smiley: thanks again.

1 Like