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

Blynk for Beginners and help with your project


#22

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


#23

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


#24

@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.


#25

I just needed help with my project … but that’s for your time .


#26

@Vivianatej9 hello, what have you tried so far?


#27

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!!


#28

@Edu_Ferrer paste your formatted bad code.


#29

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!
}

#30

@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


#31

Thanks @Costas going to try it out!!


#32

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.


#33

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!


#34

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.


#35

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!


#36

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!


#37

@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);
  }
}

#38

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?


#39

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


#40

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.


#41

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