Blynk for Beginners and help with your project

Hlo Blynk Employees i think you need to prepare one ppt for blynk server how controlling happend with phone thats good for your company plz focus on it

I need to make a weekday timer ā€¦ is there a way you can help me ? Iā€™m new to arduino and Blynk ā€¦ please contact me vivianatej9@gmail.com

@Vivianatej9 This forum is for Blynk users to share and assist other Blynk users with ideas and guidance.

We are not a for-hire code factory, nor is begging for code considered acceptable, here in the open forum nor via private messaging, as you have also been doing.

Please cease from sending out these types of requests or you risk getting blocked from the forums.

1 Like

I just needed help with my project ā€¦ but thatā€™s for your time .

@Vivianatej9 hello, what have you tried so far?

Hi, Iā€™m struggling with the bridge widget!

What I need seems pretty simple but canā€™t make it work, the Blynk library examples arenā€™t helping.

I want to connect two Arduino boards via the bridge widget and that whenever a led in board A is ON turn an led in board B ON. And whenever the led of board A is OFF the led of board B is OFF.

I would really appreciate some help with the code, Iā€™m completely stuck!

Thanks!!

@Edu_Ferrer paste your formatted bad code.

Code Arduino A

#define BLYNK_PRINT SwSerial
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11); // RX, TX
#include <BlynkSimpleStream.h>


char auth[] = "c4338d1814324794ba0802364381f740"; //Arduino A

WidgetBridge bridge1(V1);

static bool value = true;

BLYNK_CONNECTED() {
  bridge1.setAuthToken("4059dde6593b444592d25b53c36089ea"); // Arduino B
}

void setup()
{

  SwSerial.begin(9600);
  Serial.begin(9600);
  Blynk.begin(Serial, auth);

}

void loop()
{
  Blynk.run();

  if (value) {
    bridge1.digitalWrite(9, HIGH);  // Digital Pin 9 on the second board will be set HIGH
    bridge1.virtualWrite(V5, 1); // Sends 1 value to BLYNK_WRITE(V5) handler on receiving side.

  } else {
    bridge1.digitalWrite(9, LOW); // Digital Pin 9 on the second board will be set LOW
    bridge1.virtualWrite(V5, 0); // Sends 0 value to BLYNK_WRITE(V5) handler on receiving side.
  }
  // Toggle value
  value = !value;
}

Code Arduino B

#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11); // RX, TX
#include <BlynkSimpleStream.h>

char auth[] = "4059dde6593b444592d25b53c36089ea";

 BLYNK_WRITE(V5){
    int pinData = param.asInt(); // pinData variable will store value that came via Bridge
    }

void setup()
{
  SwSerial.begin(9600);
  Serial.begin(9600);
  Blynk.begin(Serial, auth);
}

void loop()
{
  Blynk.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

@Edu_Ferrer is Arduino A being disconnected from the server as you look to be sending far too much data i.e. 1000ā€™s of times a second.

Before the line value = !value; add:

delay(1000); // NEVER USE DELAY WITH BLYNK, USE BLYNK TIMER

Thanks @Costas going to try it out!!

The delay(1000) is only for test purposes to see if bridge works. Once you have it running study SimpleTimer on the Arduino site as this is how BlynkTimer works and must be used in place of the delay() function.

Hello there,

Iā€™m programming a nodemcu without the nodemcu, I mean, I have not right now it but I have too many free timeā€¦
I have to send multiples values to blynk, im reading them from softserial port (in this moment I have 20 values) I have to send them to different widgets, it is possible to send them with 20 Blynk.virtualWrite one after the other?
Blynk.virtualWrite (V1, variable1);
Blynk.virtualWrite (V2, variable2);
Blynk.virtualWrite (V3, variable3);
ā€¦

I set the BLYNK_MSG_LIMIT to 100 and Iā€™m running a local server with also a limit of 100 messages per second.

Could those 20 messages overflow the server or the hardware?

Thanks!

So 1 message allowed every 0.01 seconds or every 10ms.
Maybe sandwich a delay(11) between each virtualWrite.

I have found that itā€™s not wise to go beyond 3 or 4 consecutive virtualWrites.

Well, should be good to know if the overflow is triggered each second, or each 10ms orā€¦ should be a watchdogā€¦ the sandwitch could be so each 3 virtualWrites?
I think I have to test it, I like test and error procedure! But if not nodemcu, not test and no error :frowning:

Thanks!

This time Iā€™m doing tests with webhooksā€¦

using this code in my project:

#define BLYNK_MAX_READBYTES 1024

BLYNK_WRITE(V0)
{
  Serial.println("WebHook data:");
  Serial.println(param.asStr());
}

BLYNK_WRITE(V10)
{
  if (param.asInt())
  {
  //Blynk.virtualWrite(V0, "https://raw.githubusercontent.com/blynkkk/blynk-library/master/extras/logo.txt");
  Blynk.virtualWrite(V0, "https://api.sunrise-sunset.org/json?lat=41.58491773&lng=1.612949&date=today");
  }
}

I receive this:

[15062] <[14]o:[00]Pvw[00]0[00]https://api.sunrise-sunset.org/json?lat=41.58491773&lng=1.612949&date=today
[15206] >[14]o[1E|00|07]
[15206] >vw[00]10[00]0
[25162] <[06|00|02|00|00]
[25210] >[00|00|02|00|C8]
[32972] >[14]d[A8|00|07]
[32973] >vw[00]10[00]1
[32973] <[14]d[A8|00]Pvw[00]0[00]https://api.sunrise-sunset.org/json?lat=41.58491773&lng=1.612949&date=today
[33179] >[14]uV[00|07]
[33179] >vw[00]10[00]0
[43162] <[06|00|03|00|00]
[43262] >[00|00|03|00|C8]

But no data received even that trying in the explorer all seems working.
If I use the Blynk logo url, it works perfectā€¦

V0 = webhook URL=/pin/ METHOD=GET CONTENT TYPE=application/json BODY=(Cant write nothing here using GET)
V10 = button

Searching in Blynk I found the same issue, itā€™s set as [SOLVED] but there is no solution insideā€¦ @Costas, did you help him by PM? [Solved] Webhook problem

Thanks!

@darkmoon the power of the Webhook widget is the ability to easily modify the API call.

Manually entering the url in the widget is a pain so itā€™s better to email the url to yourself and paste it into the widget.

Once you have allocated a ā€œpin arrayā€ you can easily change the array to get revised data without changing the url.

Just knocked up a project for your call and the original call you referred to.

Data from Serial Monitor is:

41.58
1.61
{"results":{"sunrise":"4:28:04 AM","sunset":"7:12:19 PM","solar_noon":"11:50:11 AM","day_length":"14:44:15","civil_twilight_begin":"3:55:47 AM","civil_twilight_end":"7:44:36 PM","nautical_twilight_begin":"3:15:07 AM","nautical_twilight_end":"8:25:16 PM","astronomical_twilight_begin":"2:28:38 AM","astronomical_twilight_end":"9:11:45 PM"},"status":"OK"}
20151106
1358
20108
{"id":380876,"matchnr":20108,"datetime":"2015-11-06T19:00:00.000Z","matchtypeid":1,"teams":[{"id":1067751,"name":"DOV 4","teamplayers":[{"id":2137382,"name":"M. Petiet","subst":0},{"id":3294276,"name":"S. de Hoogt","subst":0},{"id":3413244,"name":"J. van der Aar","subst":0},{"id":3829013,"name":"D. Bendter","subst":0},{"id":4060662,"name":"R. Holscher","subst":0}],"matchplayers":[{"id":4060662,"name":"R. Holscher","dbl":1},{"id":3413244,"name":"J. van der Aar","dbl":1},{"id":3294276,"name":"S. de Hoogt","dbl":0}]},{"id":1067383,"name":"Stede Broec 5","teamplayers":[{"id":2220119,"name":"J. Broer","subst":0},{"id":3031636,"name":"R. Pronk","subst":0},{"id":3031644,"name":"J. Neuvel","subst":0},{"id":3033183,"name":"P. Sijm","subst":0},{"id":3293759,"name":"T. Buijsman","subst":0}],"matchplayers":[{"id":3293759,"name":"T. Buijsman","dbl":1},{"id":3033183,"name":"P. Sijm","dbl":1},{"id":3031644,"name":"J. Neuvel","dbl":0}]}]}

Sketch is:

// WebhookNEW.ino https://community.blynk.cc/t/blynk-for-beginners-and-help-with-your-project/10000/36
// and https://community.blynk.cc/t/solved-webhook-problem/10279/20 by Costas 21 May 2017

#define BLYNK_MAX_READBYTES 1024
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>


char auth[] = "xxx";
char ssid[] = "xxx";
char pass[] = "xxx";
char server[] = "blynk-cloud.com";

// reference https://ttapp.nl/sbapi?getmatch&date=20151106&clubid=1358&matchnr=20108
int datum =  20151106;
int clubid=  1358;
int matchnr= 20108;

// reference https://api.sunrise-sunset.org/json?lat=41.58491773&lng=1.612949&date=today
float latitude  = 41.58491773;
float longitude = 1.612949;
void setup()
{
  Serial.begin(115200);
  Serial.println("\nStarted");
  Blynk.begin(auth, ssid, pass, server);
}

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

/************************************************************************************************************************/

BLYNK_WRITE(V1){      // Webhook enter https://ttapp.nl/sbapi?getmatch&date=/pin[0]/&clubid=/pin[1]/&matchnr=/pin[2]/
  if (param.asInt() == 1) {
    Blynk.virtualWrite(V2,datum,clubid,matchnr);
    Serial.println(datum);
    Serial.println(clubid);
    Serial.println(matchnr);
  }
}

BLYNK_WRITE(V2){       // Webhook button for https://ttapp.nl/sbapi?getmatch&date=20151106&clubid=1358&matchnr=20108
  String webhookdata = param.asStr();
  Serial.println(webhookdata);
}

/************************************************************************************************************************/

BLYNK_WRITE(V0){   // webhook for sunrise  https://api.sunrise-sunset.org/json?lat=/pin[0]/&lng=/pin[1]&date=today
  String webhookdata = param.asStr();
  Serial.println(webhookdata);
}

BLYNK_WRITE(V3){      // Webhook button for https://api.sunrise-sunset.org/json?lat=41.58491773&lng=1.612949&date=today
  if (param.asInt() == 1) {
    Blynk.virtualWrite(V0,latitude, longitude);
    Serial.println(latitude);
    Serial.println(longitude);
  }
}

Still no luckā€¦

[121504] <[14]55[00|11]vw[00]0[00]41.585[00]1.613
41.58
1.61
[121658] >[14]][AE|00|07]
[121658] >vw[00]10[00]0

could be some configuration on local server side?

There are webhook settings in server.properties, take a look and see if you find anything.

I donā€™t know whats happening with this url, but I tried with a different one and it worksā€¦ test again with first one and still donā€™t workā€¦ soā€¦ now itā€™s working

Thanks again @Costas.

@darkmoon count the characters in each json with Notepad++ (or similar) and ensure READBYTES is before the Blynk libraries in your sketch.