book collections email follower instructable user
Picture of IoT Made Simple: Monitoring Multiple Sensors
Block Diagram.png

A few weeks ago, I published here a tutorial about monitoring temperature using a DS18B20, a digital sensor that communicates over a 1-Wire bus, sending data over the internet with NodeMCU and Blynk:

IoT Made Simple: Monitoring Temperature Anywhere

But what we missed in exploration, was one of the great advantages of this kind of sensor that is the possibility of collecting multiple data, from multiple sensors connected to the same 1-wire bus. And, now it is time to also explore it.

We will expand what was developed on the last tutorial, monitoring now two DS18B20 sensors, configured one in Celcius and the another in Fahrenheit. The data will be sent to a Blynk App, as shown in the above block diagram.

Step 1: Bill of Material

(*) Any type of ESP device can be used here. The most common are the NodeMCU V2 or V3. Both will always work fine.
aimank101 month ago
Hello Sir, Im still new in this field. I want to make a project using arduino uno with esp 8266 and 2 sensor. And also i want to make that sensor will trigger an alarm and email when it reach a certain celcius. Can you do a favor with it.
I really appreciate if you willing to help me.
This is my coding that i still working on it

#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
char auth[] = "eZo7JABOxECZX_PV_A5B2t1Mx9uT4JVZ";
char ssid[] = "jinbei";
char pass[] = "cibektul";
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
BlynkTimer timer; // Announcing the timer
int flamepin = 2;
int flamepin1 = 4;
int threshold = 100;// sets threshold value for flame sensor
int flamesensvalue ; // initialize flamesensor reading
float temp1;
float temp2;
void setup()
{
Serial.begin(9600); // See the connection status in Serial Monitor
delay(10);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
// Setup a function to be called every second
timer.setInterval(1000L, sendUptime);
}
void sendUptime()
{
flamesensvalue = analogRead(flamepin);
flamesensvalue = analogRead(flamepin1);
// shows the value temp on virtual pin 10
Blynk.virtualWrite(5, temp1);
Blynk.virtualWrite(6, temp2);
}
void loop()
{
flamesensvalue=analogRead(flamepin); // reads analog data from flame sensor
if (flamesensvalue<=threshold) {
temp1 = analogRead(flamepin);
temp1 = temp1 * 0.48828125;
Serial.print ( "TEMPERATURE A: ");
Serial.print (temp1);
Serial.print ("*C");
Serial.println();
Serial.println("Fire! Fire!");
Serial.println(analogRead(flamepin1));
if (temp2< 30)
Blynk.email("aimankalim123@gmail.com", "Benkel ETN Terbakar", "YEAH...CUTI");
Blynk.notify("Fire! Fire!");
}
flamesensvalue=analogRead(flamepin1); // reads analog data from flame sensor
if (flamesensvalue<=threshold) {
temp2 = analogRead(flamepin1);
temp2 = temp2 * 0.48828125;
Serial.print ( "TEMPERATURE B: ");
Serial.print (temp2);
Serial.print ("*C");
Serial.println();
Serial.println("Fire! Fire!");
Serial.println(analogRead(flamepin1));
if (temp2< 30)
Blynk.email("aimankalim123@gmail.com", "Benkel ETN Terbakar", "YEAH...CUTI");
Blynk.notify("Fire! Fire!");
}
else{
Serial.println("Peace");
}
Blynk.run(); // Initiates Blynk
timer.run(); // Initiates SimpleTimer
}
IvanoSp9 months ago
Hello Marcelo,
thank you for your great job!
I need your help, I would like to add code (lwith Blynk) in order to send temperature info to sinric so I can ask to Google home / Alexa the temperature, Sinric is a interface between ESP8266 and Google/Alexa.
can you help me ?
let me know
thanks
Ivano
Zaniben made it!10 months ago
You made me do it, Mjrovai :-)
This project shall wireless monitor my heatingsystem in the cellar and display the result on a screen near my couch as shown in the (older) picture ~couchsurfing ;-?
The closeup pic shows a simple way to connect the temperature sensors.
And I'm using my DSO203 to monitor data signals - for the very first time.
Yeah, I'm still a n00b - aged 78, he ...
IMG_20181122_053611_678[1].jpgIMG_20181122_053755_599[1].jpgIMG_20170608_145007[1].jpg
woodnboats10 months ago
Thanks for this great Instructable. I would just like to add one change for those who are using a local Blynk server instead of Blynk Cloud. Replace

Blynk.begin(auth, ssid, pass);

with

Blynk.begin(auth, ssid, pass, IPAddress(XX, XX, XX, XX), 8080);

where XX, XX, XX, XX is your server address and port. And, yes, those are commas not periods.
CetinG21 year ago

How can I display the values with two decimal digits? It was ok with Serial Monitor but in Blynk no decimals. /pin.##/ written in Label field.

Thanks

Cetin

CetinG21 year ago

I've added the third sensor and changed them all to celsius

thanks

#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2 // DS18B20 on NodeMCU pin D4
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);

void setup()
{
Serial.begin(115200);
DS18B20.begin();
Serial.println("Testing Dual Sensor data");
}

void loop() {
float temp_0;
float temp_1;
float temp_2;
DS18B20.requestTemperatures();
temp_0 = DS18B20.getTempCByIndex(0); // Sensor 0 will capture Temp in Celcius
temp_1 = DS18B20.getTempCByIndex(1); // Sensor 1 will capture Temp in Celcius
temp_2 = DS18B20.getTempCByIndex(2); // Sensor 2 will capture Temp in Celcius
Serial.print("Temp_0: ");
Serial.print(temp_0);
Serial.print(" oC . Temp_1: ");
Serial.print(temp_1);
Serial.print(" oC . Temp_2:");
Serial.println(temp_2);
delay(2000);

CetinG2 made it!1 year ago

It was my first ESP project, works very well, thank you

IMG_1230.JPGDS18B20.jpg

hi. can we follow the same process uning 8 temperatures sensors?

TruthS32 years ago

Hello Marcelo,

I opened a new file in IDE, cleared out all the writing on the field followed your link to github and pasted the code there in the field and ran a check compile. Here is the error:

Arduino: 1.8.3 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200, 4M (3M SPIFFS)"

C:\Users\longb\Documents\Arduino\sketch_aug26b\sketch_aug26b.ino:21:25: fatal error: SimpleTimer.h: No such file or directory

#include <SimpleTimer.h>

^

compilation terminated.

exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Did I do something wrong? I tried it twice, it looks like some issue about the timer?

mjrovai (author)  TruthS32 years ago

As DavidW mentioned, install SimpleTimer library on your IDE it is missing. To facilitate your Job, I included the link on my answer below.

dBuggz TruthS32 years ago

Dave,

Another Dave here. I'll call myself DaveW..

I've read a few of your posts and I have to say, Slow down and take your time to read and understand what's going on.

e.g. when you put your "YOUR SSID" in look at the code

char ssid[] = "YOUR SSID".....

this says:

char.... which means it is the declaration of a 'character' array

ssid[].... is the name of the 'thing' and it may be easier to think of it as a 'String'

YOUR SSID .... is the 'value' being assigned to the String, and is put in quote marks to tell the computer is is text.

In the above errors,

SimpleTimer.h: No such file or directory....

the computer is telling your that it cannot find SimpleTimer.h.

You have to find that file (which is actually a library) and make sure it has been added to the Arduino IDE. You will have to look back through Marcelo's previous Instructable (he doesn't mention it here) to see where it comes from and check that you have added it.

'Regards,

DaveW

mjrovai (author)  dBuggz2 years ago

Hi DaveW,

Thanks for the help. Using the opportunity, the SimpleTimer Library can be downloaded from its GitHub here:

https://github.com/marcelloromani/Arduino-SimpleTimer

I really love to work with this library. It was developed to work primaryly with Arduino but works very well with NodeMCU. It is very simple and organize the job to be done in more complex projects. I used this library on my ArduFarmBot 2.0 project:

https://www.instructables.com/id/Automatic-Gardening-System-With-NodeMCU-and-Blynk-/

There, the timing to organ all different tasks was key.

Thanks

dBuggz2 years ago

Marcelo,

How do you work out which sensor is which?

DaveW

mjrovai (author)  dBuggz2 years ago

Hi DaveW,

I realized that the closest sensor to Pin D4, was the one that got the [0] index. Of course, when I put my finger over it, I confirmed that was the "Celsius"one and I labeled them.

TruthS32 years ago

Starting over.

Open new sketch, clear out all writing from field, follow link to github, copy code and paste it to the new sketch, then include libraries onewire and dallas. I did go back to part 2 and got the libraries again and tried to add them again but IDE told me they were already there. Check compile same error.

Paste:

Arduino: 1.8.3 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200, 4M (3M SPIFFS)"

C:\Users\longb\Documents\Arduino\sketch_aug26b\sketch_aug26b.ino:25:25: fatal error: SimpleTimer.h: No such file or directory

#include <SimpleTimer.h>

^

compilation terminated.

exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I'm stupid I guess, I can't seem to get a handle on what is wrong.

This other link you gave in your last response is it different? Was there a link to its zip file that I missed in part 3? I tried following that link in the reply but it didn't have a zip to download and I hesitated about it because I was unsure what I was supposed to do there.

As for just adding the lines to my previous part 2 code, I am unsure about what to do there, that is why I have been doing simple copy/pastes.

Thanks,

Dave

TruthS32 years ago
(removed by author or community request)
mjrovai (author)  TruthS32 years ago

seems to me that you are not using the correct libraries.

TruthS3 mjrovai2 years ago

Is it the same one you gave a link to on part 2?I've got that one.

The F657...zip?

The above github link doesn't seem to be the same and it doesn't show any way to download a zip. It leaves me confused.

Help appreciated.

Dave

mjrovai (author)  TruthS32 years ago

My code is correct and working. If you can not find where is your error, try to do the opposite: start from One Sensor code that you say it is working and adapt it to a dual sensor as I explained in my tutorial. Will be only a few lines of code.

Also, double check if you are using the correct libraries. The OneWire library must be the special one adapted from Adafrut to ESP 8266:

https://github.com/adafruit/ESP8266-Arduino/tree/e...

Good luck.