Multi nodemcus & dht22 sensors single blynk project

Hello,
i want use 3 nodemcu and 3 dht22 for home rooms temp.+hum. , is it possible with single blynk project can i see all of them or i need 4th mcu for collect data and send to blynk app how can do this

Yes and yes.

with device selector working tabs can we show all 3 devices in a single tab/page ?

Are you using local server or Blynk server? You can have as much devices as you want in your project, I have 10 of them in my home automation setup, not using device selector at all.

iwant use blynk server, can you share example code of it i cant find blynk docs and blynk example pages how can work with device selector

as @zodiac said, you do not need device selector, you can just simply display all data in realtime on a single tab.

just read the docs and study the examples.

ok i added 3 of them nopreoblem i found tzapu wifimanger and can you check is the code correct :slight_smile:
/*
Value Display widget attached to V5
Value Display widget attached to V6
*************************************************************/

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


#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>  
#include <BlynkSimpleEsp8266_SSL.h>
#include <DHT.h>

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


#define DHTPIN 2          // What digital pin we're connected to


#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321


DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;


void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
}

void setup()
{
  // Debug console
  Serial.begin(9600);
// wifi
  WiFiManager wifiManager;
  wifiManager.autoConnect("AutoConnectAP", "ronin");
  Serial.println("connected :)");
   WiFiManagerParameter custom_blynk_token("Blynk", "blynk token", blynk_token, 33);
   wifiManager.addParameter(&custom_blynk_token);
   wifiManager.autoConnect("Blynk");
    Blynk.config(custom_blynk_token.getValue());
  // wifi endz

//  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);

  dht.begin();

  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);
}

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

Yes, the code is correct except you should change serial speed from 9600 to 115200 when using ESP as standalone platform and DHT timer set interval should be at least 2000L, 1000L is too much for 22. Why would you need temperature or humidity readings every second anyway? DHT is slow sensor and frequent readings will slow down mcu. And I suppose you don’t want to use NodeMCU only for single temperature/humidity readings, because that would be shameful waste of resources. NodeMCU can do much more than that.

Don’t know if you really need wifi manager for your project or you just stumbled upon combined code for DHT and Blynk, but you could also hardcode authtokens without using wifi manager, you can even use the same auth and different pins/code on your Node’s, but it’s not important. It works now, if I understood you well?

thank you, changed baudrate and interval values, im using esp8266 standalon with dht22 now im not needed wiif manager for me but my firends wants this they are not interested electronic & iot etc. for them easy to modify pass when changed wifi password.

So everything ok now? Did you managed to add devices in the app and show all of the values you need?

its ok and yes managed all ofthem, but i wanna ask a question, blynk example page : https://examples.blynk.cc/?board=ESP8266&shield=ESP8266%20WiFi%20(SSL)&example=More%2FDHT11 shows example ino serial 9600 and Interval1000L is it much diffrence with 2000l etc ?

Example is very old one and adopted to work with Arduino boards, so that’s where slow serial communication came from. If using ESP as standalone platform, you should always use 115200 for serial communication.

Difference between 1000L and 2000L is one second. 1000L is reading interval for DHT-11, for DHT-22 it should be at least 2000L. So instead of reading sensor every second, with 2000L you will read sensor every two seconds. Glad you sorted that out.

Thank you all explanitaions and help.

1 Like

Personally, I prefer to use 74880 because this is the native baud rate of the ESP and it allows you to see the boot messages on the same serial monitor as the the other messages.

Pete.

1 Like

I will try that for sure, does not make too much difference. Never had any problems with 115200 speed, though.