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.

Step 2: DS18B20 Temperature Sensor

We will use in this tutorial a waterproofed version of the DS18B20 sensor. It is very useful for remote temperature in wet conditions, for example on a humid soil. The sensor is isolated and can take measurements until 125oC (Adafrut does not recommend to use it over 100oC due to its cable PVC jacket).

The DS18B20 is a digital sensor what makes it good to use even over long distances! These 1-wire digital temperature sensors are fairly precise (±0.5°C over much of the range) and can give up to 12 bits of precision from the onboard digital-to-analog converter. They work great with the NodeMCU using a single digital pin, and you can even connect multiple ones to the same pin, each one has a unique 64-bit ID burned in at the factory to differentiate them.

The sensor works from 3.0 to 5.0V, what means that it can be powered directly from one of the 3.3V NodeMCU pins.

The first one will return a value from Sensor [0] (look the "index(0)") in Celcius ( look the portion of the code: "getTempC". The second line is related with Sensor[1] and will return data in Fahrenheit. You could have here "n" sensors since you have a different "index" for each one of them.

Upload now the code in your NodeMCU and monitor the temperature using the Serial Monitor.

The above photo shows the expected result. Hold each one of the sensors in your hand, you should see the temperature going up.

Step 6: Using Blynk

Once you start capturing temperature data, it's time to see it from anywhere. We will do this using Blynk. So, all captured data will be displayed in real time on your mobile device and also we will build a historical depository for that.

Follow the below steps:

Create a New Project.

Give it a name (in my case "Dual Temperature Monitor")

Select New Device - ESP8266(WiFi) as "My Devices"

Copy the AUTH TOKEN to be used in the code (you can send it to your email).

Includes two "Gauge" Widgets, defining:

Virtual pin to be used with each sensor: V10 (Sensor[0]) and V11 (Sensor[1])

The temperature range: -5 to 100 oC for Sensor [0]

The temperature range: 25 to 212 oC for Sensor [1]

The frequency to read data: 1 second

Includes a "History Graph" Widget, defining V10 and V11 as virtual pins

Press "Play" (The triangle at right up corner)

Of course, the Blynk App will tel you that the NodeMCU is off line. It's time to upload the full code at your Arduino IDE. You can get it here:

Bellow the full code. It is basically the previous code, where we entered with Blynk parameters and specific functions. Note the 2 last lines of the code. Those are the most important here. If you have more sensors collecting data, you should also have equivalent new lines as those ones (with pertinent new virtual pins defined).

First Time Author

PCB Contest

Toys Contest

15 Discussions

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 knowthanksIvano

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.

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:

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.

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 1Error 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.

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: