Connecting Multiple device with single software

Dear all,

I have written few testing code on Nodemcu & its working well. Now i would like to connect multiple Nodemcu unit in common software. Each project allow you to add multiple device

these are doubt i had related to connect multiple device

  1. How many device can be connected ?

  2. Weather virtual tags are restricted to 125 tags or it can be increased??

  3. when multiple device is connected to common wifi network. if any of the device is stopped working weather application also stop working

  4. Is it possible to check active device in software,.

All of these answers are available from reading the documentation and topics… :stuck_out_tongue_winking_eye:

1 - Search Link: How many devices can I add to one project?

2 - Doc Link: http://docs.blynk.cc/#faq - see the “How many Virtual Pins I can use?” answer

3 - Acquired knowledge from use and reading. No, the App and other devices should keep running, unless for some reason your code requires it and locks up without some device feedback.

4 - Acquired knowledge from use and reading. The Server/App sees it, but as far as other devices… not that I am aware of. You would have to code something somehow.

But Push Notification Widget can already be set to alert when a device goes offline.

Yes Today. I have tested my code with multiple nodemcu unit. I have 2 different multiple nodemcu, I have created single project with 2 device attached.
Both device has unique authorization code. Here i am pasting sample code here. I could able to update data from single device not from second salve.

I_f i use single same authorization code .the data get update once later went offline. If i use differnet authorization code both device is connected but i get update fr single device only. other device wont read at all._

For second device i only assigned further virtual pins to avoid conflict by dislecting unused pins from nodemcu1.Serially i could see data being printed. But not updated in blynk app

    #define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <WidgetRTC.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
char auth[] = "AUTH_CODE1";
char ssid[] = "HOT SPOT";
char pass[] = "PASSWORD";
unsigned int  data1[100];

void setup() {

  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  //setSyncInterval(100);
  timer.setInterval(1, BLYNKWRITE);

}

void loop()
{
  data1[0] = 500;
  data1[1] = 00;
  data1[2] = 2300;
  data1[3] = 2120;
  data1[4] = 2150;
  data1[5] = 3150;
  data1[6] = 3120;
  data1[7] = 3125;
  data1[8] = 28;
  data1[9] = 30;
  data1[10] = 45;
  data1[11] = 9;
  data1[12] = 9;
  data1[13] = 9;
  data1[14] = 9;
  data1[15] = 10;
  data1[16] = 12;
  data1[17] = 14;
  data1[18] = 36;
  data1[19] = 2;
  data1[20] = 2;
  data1[21] = 2;
  data1[22] = 6;

  for (int i = 0; i < 30; i++)
  {
    //data1[i] = node.getResponseBuffer(i);
    Serial.println(data1[i]);
  }
  Serial.println("............");



  Blynk.run();
  timer.run();
}


void BLYNKWRITE()
{
  Blynk.virtualWrite(V0, (data1[0] / 10.0));
  Blynk.virtualWrite(V1, (data1[1] / 10.0));
  Blynk.virtualWrite(V2, (data1[2] / 10.0));
  Blynk.virtualWrite(V3, (data1[3] / 10.0));
  Blynk.virtualWrite(V4, (data1[4] / 10.0));
  Blynk.virtualWrite(V5, (data1[5] / 10.0));
  Blynk.virtualWrite(V6, (data1[6] / 10.0));
  Blynk.virtualWrite(V7, (data1[7] / 10.0));
  Blynk.virtualWrite(V8, (data1[8] / 10.0));
  Blynk.virtualWrite(V9, (data1[9] / 10.0));
  Blynk.virtualWrite(V10, (data1[10] / 10.0));
  Blynk.virtualWrite(V11, (data1[11] / 10.0));
  Blynk.virtualWrite(V12, (data1[12] / 10.0));
  Blynk.virtualWrite(V13, (data1[13] / 10.0));
  Blynk.virtualWrite(V14, data1[14]);
  Blynk.virtualWrite(V15, data1[15]);
  Blynk.virtualWrite(V16, data1[16]);
  Blynk.virtualWrite(V17, data1[17]);
  Blynk.virtualWrite(V18, data1[18]);
  Blynk.virtualWrite(V19, data1[19]);
  Blynk.virtualWrite(V20, data1[20]);
  Blynk.virtualWrite(V21, data1[21]);

}


BLYNK_CONNECTED()
{
  Blynk.syncVirtual(V0); // sync timeinput widget
  Blynk.syncVirtual(V1); // sync timeinput widget
  Blynk.syncVirtual(V2); // sync timeinput widget
  Blynk.syncVirtual(V3); // sync timeinput widget
  Blynk.syncVirtual(V4);
  Blynk.syncVirtual(V5);
  Blynk.syncVirtual(V6); // sync timeinput widget
  Blynk.syncVirtual(V7); // sync timeinput widget
  Blynk.syncVirtual(V8);
  Blynk.syncVirtual(V9);
  Blynk.syncVirtual(V10); // sync timeinput widget
  Blynk.syncVirtual(V11); // sync timeinput widget
  Blynk.syncVirtual(V12);
  Blynk.syncVirtual(V13); // sync timeinput widget
  Blynk.syncVirtual(V14); // sync timeinput widget
  Blynk.syncVirtual(V15);
  Blynk.syncVirtual(V16);
  Blynk.syncVirtual(V17); // sync timeinput widget
  Blynk.syncVirtual(V18); // sync timeinput widget
  Blynk.syncVirtual(V19);
  Blynk.syncVirtual(V20);
  Blynk.syncVirtual(V21);
}

I am trying to connect multiple nodemcu unit to common Blynk application software.

I have currently 2 device connected each device has different authorization code. The changes are made as below code . Below code is meant for nodemcu unit1 with its authorization code. I have modified code2 for second device with change in virtual pin after 23-44.when both device comes online , I am getting updates from single device only other device display 00. if i check serial monitor both device could able to recorda and display data. what changes need to made to get both device data

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <WidgetRTC.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
char auth[] = "AUTH_CODE1";
char ssid[] = "HOT SPOT";
char pass[] = "PASSWORD";
unsigned int  data1[100];

void setup() {

  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  //setSyncInterval(100);
  timer.setInterval(1, BLYNKWRITE);

}

void loop()
{
  data1[0] = 500;
  data1[1] = 00;
  data1[2] = 2300;
  data1[3] = 2120;
  data1[4] = 2150;
  data1[5] = 3150;
  data1[6] = 3120;
  data1[7] = 3125;
  data1[8] = 28;
  data1[9] = 30;
  data1[10] = 45;
  data1[11] = 9;
  data1[12] = 9;
  data1[13] = 9;
  data1[14] = 9;
  data1[15] = 10;
  data1[16] = 12;
  data1[17] = 14;
  data1[18] = 36;
  data1[19] = 2;
  data1[20] = 2;
  data1[21] = 2;
  data1[22] = 6;

  for (int i = 0; i < 30; i++)
  {
    //data1[i] = node.getResponseBuffer(i);
    Serial.println(data1[i]);
  }
  Serial.println("............");



  Blynk.run();
  timer.run();
}


void BLYNKWRITE()
{
  Blynk.virtualWrite(V0, (data1[0] / 10.0));
  Blynk.virtualWrite(V1, (data1[1] / 10.0));
  Blynk.virtualWrite(V2, (data1[2] / 10.0));
  Blynk.virtualWrite(V3, (data1[3] / 10.0));
  Blynk.virtualWrite(V4, (data1[4] / 10.0));
  Blynk.virtualWrite(V5, (data1[5] / 10.0));
  Blynk.virtualWrite(V6, (data1[6] / 10.0));
  Blynk.virtualWrite(V7, (data1[7] / 10.0));
  Blynk.virtualWrite(V8, (data1[8] / 10.0));
  Blynk.virtualWrite(V9, (data1[9] / 10.0));
  Blynk.virtualWrite(V10, (data1[10] / 10.0));
  Blynk.virtualWrite(V11, (data1[11] / 10.0));
  Blynk.virtualWrite(V12, (data1[12] / 10.0));
  Blynk.virtualWrite(V13, (data1[13] / 10.0));
  Blynk.virtualWrite(V14, data1[14]);
  Blynk.virtualWrite(V15, data1[15]);
  Blynk.virtualWrite(V16, data1[16]);
  Blynk.virtualWrite(V17, data1[17]);
  Blynk.virtualWrite(V18, data1[18]);
  Blynk.virtualWrite(V19, data1[19]);
  Blynk.virtualWrite(V20, data1[20]);
  Blynk.virtualWrite(V21, data1[21]);

}


BLYNK_CONNECTED()
{
  Blynk.syncVirtual(V0); // sync timeinput widget
  Blynk.syncVirtual(V1); // sync timeinput widget
  Blynk.syncVirtual(V2); // sync timeinput widget
  Blynk.syncVirtual(V3); // sync timeinput widget
  Blynk.syncVirtual(V4);
  Blynk.syncVirtual(V5);
  Blynk.syncVirtual(V6); // sync timeinput widget
  Blynk.syncVirtual(V7); // sync timeinput widget
  Blynk.syncVirtual(V8);
  Blynk.syncVirtual(V9);
  Blynk.syncVirtual(V10); // sync timeinput widget
  Blynk.syncVirtual(V11); // sync timeinput widget
  Blynk.syncVirtual(V12);
  Blynk.syncVirtual(V13); // sync timeinput widget
  Blynk.syncVirtual(V14); // sync timeinput widget
  Blynk.syncVirtual(V15);
  Blynk.syncVirtual(V16);
  Blynk.syncVirtual(V17); // sync timeinput widget
  Blynk.syncVirtual(V18); // sync timeinput widget
  Blynk.syncVirtual(V19);
  Blynk.syncVirtual(V20);
  Blynk.syncVirtual(V21);
}

No need to duplicate topics on same subject… I merged both into here.

2 Likes

Is there any restrictions . why i am facing such issue, weather 2 nodemcu cant be connected ?? weather any example code available for connecting multiple salve device. Device are connected with 2 different authorization code. Only issue updating with blynk app. only one data parameter being updated. other is replicate code with change in register value.

Please spend some time reading the documentation and searching through this forum… common issues include processing to many commands at once as that sends too much data at the same time, causing disconnections.

Your void loop() is very bad :frowning:

Yoiut timer is a whole millisecond long :scream:

And finally you are processing way to many virtual writes, syncs and well… everything way too much too fast

I have tried with timer and updating same .
timer.setInterval(1000, BLYNKWRITE);
timer.setInterval(1000, Load_function);

In both case i found max update time is 6S. So every 6 data get populated when i take input from modbus slave.I kept in loop only because of testing.Load_function() is timer interrupt where i could read data for every 1s.

Ok i will post my both code here.

you have to stage timers !

Here is my code. With below code i could able to establish connection with single device.
I am changing only . below code is for nodemcu unit 2

  1. autorization code
  2. BLYNKWRITE() function where i am sending data to virtual PIN V0-V21. other oart of code work remain same.

when i check indivually with their authorization code working very well. But when club together only one device will communcate. some time only one device connected .

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <WidgetRTC.h>
BlynkTimer timer;
char auth[] = "Auth_cod1";
char ssid[] = "HOT SPOT";
char pass[] = "airtel123";
unsigned int  data1[100];

ModbusMaster232 node(2);// change device address here.

// Define one address for reading
#define address 0
// Define the number of bits to read
#define bitQty 60


void setup()
{
  Serial.begin(9600);
  // Initialize Modbus communication baud rate
  node.begin(9600);
  Blynk.begin(auth, ssid, pass);
  setSyncInterval(100);
  timer.setInterval(2000, ModBusRead);  // Update Time Check every 10 seconds
  timer.setInterval(1000, BLYNKWRITE);

}

void loop()
{

  Blynk.run();
  timer.run();
}

BLYNK_CONNECTED()
{
  Blynk.syncAll();
 
}

void BLYNKWRITE()
{
  Blynk.virtualWrite(V22, (data1[0] / 10.0)); // frequency
  Blynk.virtualWrite(V23, (data1[2] / 10.0)); // VRphase
  Blynk.virtualWrite(V24, (data1[4] / 10.0)); // VYphase
  Blynk.virtualWrite(V25, (data1[6] / 10.0)); // VBphase
  Blynk.virtualWrite(V26, (data1[8] / 10.0)); // VR-VY
  Blynk.virtualWrite(V27, (data1[10] / 10.0)); // VY-VB
  Blynk.virtualWrite(V28, (data1[12] / 10.0)); // VB-VR
  Blynk.virtualWrite(V29, (data1[14] / 10.0)); //IRph
  Blynk.virtualWrite(V30, (data1[16] / 10.0)); //IYph
  Blynk.virtualWrite(V31, (data1[18] / 10.0)); //IBph
  Blynk.virtualWrite(V32, (data1[20] / 10.0)); //PFRph
  Blynk.virtualWrite(V33, (data1[22] / 10.0)); //PFYph
  Blynk.virtualWrite(V34, (data1[24] / 10.0)); //PFBph
  Blynk.virtualWrite(V35, (data1[26] / 10.0)); //Total_PF
  Blynk.virtualWrite(V36, data1[28]);
  Blynk.virtualWrite(V37, data1[30]);
  Blynk.virtualWrite(V38, data1[32]);
  Blynk.virtualWrite(V40, data1[34]);
  Blynk.virtualWrite(V41, data1[36]);
  Blynk.virtualWrite(V42, data1[38]);
  Blynk.virtualWrite(V43, data1[40]);


}

void ModBusRead()
{
int result =  node.readHoldingRegisters(address, bitQty);
  //Read_Modbus_data1();

  data1[0] = node.getResponseBuffer(0);// holds value of Frequency
  data1[1] = node.getResponseBuffer(1);
  data1[2] = node.getResponseBuffer(2);// holds value of VRph
  data1[3] = node.getResponseBuffer(3);
  data1[4] = node.getResponseBuffer(4);// holds value of VYph
  data1[5] = node.getResponseBuffer(5);

  data1[6] = node.getResponseBuffer(6);// holds value of VBph
  data1[7] = node.getResponseBuffer(7);
  data1[8] = node.getResponseBuffer(8);// holds value of VRph-VYph
  data1[9] = node.getResponseBuffer(9);
  data1[10] = node.getResponseBuffer(10);// holds value of Vyph-Vbph
  data1[11] = node.getResponseBuffer(11);

  data1[12] = node.getResponseBuffer(12);// holds value of VBph-VYph
  data1[13] = node.getResponseBuffer(13);
  data1[14] = node.getResponseBuffer(14);// hold value of IRCurrent
  data1[15] = node.getResponseBuffer(15);
  data1[16] = node.getResponseBuffer(16);// hold value of IYCurrent
  data1[17] = node.getResponseBuffer(17);

  data1[18] = node.getResponseBuffer(18);// hold value of IBCurrent
  data1[19] = node.getResponseBuffer(19);
  data1[20] = node.getResponseBuffer(20);// hold value of PFR
  data1[21] = node.getResponseBuffer(21);
  data1[22] = node.getResponseBuffer(22);// hold value of PFY
  data1[23] = node.getResponseBuffer(23);

  data1[24] = node.getResponseBuffer(24);// hold value of PFB
  data1[25] = node.getResponseBuffer(25);
  data1[26] = node.getResponseBuffer(26);// hold value of TP
  data1[27] = node.getResponseBuffer(27);
  data1[28] = node.getResponseBuffer(28);// hold value of ACTPOWR
  data1[29] = node.getResponseBuffer(29);

  data1[30] = node.getResponseBuffer(30);// hold value of ACTPOWY
  data1[31] = node.getResponseBuffer(31);
  data1[32] = node.getResponseBuffer(32);// hold value of ACTPOWB
  data1[33] = node.getResponseBuffer(33);
  data1[34] = node.getResponseBuffer(34);// hold value of TotalACTPOWR
  data1[35] = node.getResponseBuffer(35);
  data1[36] = node.getResponseBuffer(36);// hold value of ACTENERR
  data1[37] = node.getResponseBuffer(37);
  data1[38] = node.getResponseBuffer(38);//hold value of ACTENERY
  data1[39] = node.getResponseBuffer(39);

  data1[40] = node.getResponseBuffer(40);//hold value of ACTENERB
  data1[41] = node.getResponseBuffer(41);
  data1[42] = node.getResponseBuffer(42);//hold value of Total Active power
  data1[43] = node.getResponseBuffer(43);
  data1[44] = node.getResponseBuffer(44);
  data1[45] = node.getResponseBuffer(45);
  data1[46] = node.getResponseBuffer(46);
  data1[47] = node.getResponseBuffer(47);
  data1[48] = node.getResponseBuffer(48);
  data1[49] = node.getResponseBuffer(49);


  for (int i = 0; i < 10; i++)
  {
    //data1[i] = node.getResponseBuffer(i);
    Serial.println(data1[i]);
  }
  Serial.println("............");
  
}

too many request at same time !
:wink:

#include “ModbusMaster.h” is missing ?

Don’t worry. Those library proper attached.i am pasting my part of my code. I found both device indivuly working. With authorization code. But not working both connected. Software code look like this