Introduction: Blynk Arduino Multiple DS18B20 Thermometer Display on IOS or Android
This project uses the Blynk app on an iOS or Android device to display the values of several DS18B20 sensors.
Step 1: Display Several DS18B20 Sensors Using Blynk on IOS or Android Device
This is a follow up project from my First Project, that was made to display one sensor. I had a request to adapt the code to allow for more than one sensor to be displayed. This is it.
Step 2: The Code
There are two bits of code here. You will need the one to read your sensor numbers first and make a note of them. Then you need to fill in those numbers in the second bit of code to identify the sensors. The code just processes all the sensors it can find on the bus, till it finds no more and then starts from the first sensor again. The code sends out the data on the virtual pins V5 to V11. You must change this to suit your needs. If you use less than 7 sensors, delete the extra parts of code associated with them. If you you more you will need to add on more.
Step 3: The Wiring.
The sensor data is sent to pin 7. You should have one 4k7 resistor between the data and 5 V pin. For more details on how to wire up the DS18B20 sensor, see my First Project.
Step 4: This Is Work in Progress
The Arduino will send out the data on V5 - V11(for 7 sensors). In the Blynk app configure your sensor displays to use those Virtual pins.
I will still refine this project when I have some more time. Feel free to ask, if you have problems with this Instructable.
Thank you.

Participated in the
Full Spectrum Laser Contest 2016
13 Comments
Question 1 year ago on Step 4
Is there any way to calculate its precision?
Question 5 years ago
Hello, i am trying to make it working, but problem is with ds18b20 sensors addresses. I don't know how to write that address (28 EE C8 F8 1C 16 2 5E) what format to use, because it is impossiblle to compile. One way it works, but blynk shows all temperatures the same. Do you have example with those lines filled? Thanks.
Answer 4 years ago
I have that problem, can you help me solve it?
Question 5 years ago on Step 4
Hello
Thank you for a great job.
One wonder is if you can see the error when I try to drive with double one wire
would like to have 20 temp on an adruino
Tomas
/*******************************************************************
This sketch allows you to send values of multiple DS18B20 sensors to your iOS or Android device.
You will need to use the other sketch to read the sensor numbers for later identification.
You need to fill in those numbers below.If you use less than seven sensors, delete the unused sections
or you will get "expected primary-expression before '?' token" errors.
I thank all the people whose code I have adapted for their effords and making this sketck possible.
Blynk lets you create beautiful drag-and-drop visual interfaces
for your projects in 5 minutes. And it works with almost every
hardware out there.
Docs, Tutorials, everything: http://www.blynk.cc
Github: http://github.com/blynkkk
Blynk Community: http://community.blynk.cc
Follow Us: https://www.facebook.com/blynkapp
http://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
*********************************************************************
You’ll need, in general:
- Blynk App (download from AppStore or Google Play)
- Arduino UNO or similar microcontroller board
- Decide how to connect Arduino to the Internet (USB, Ethernet,
Wi-Fi, etc.). Bluetooth is on the way.
There is a bunch of great example sketches included to show you how to get
started. Think of them as LEGO bricks and combine them as you wish.
For example, take the Ethernet Shield sketch and combine it with the
Servo example, or choose a USB sketch and add a code from SendData
example.
*********************************************************************
Let’s turn ON your LED with Blynk!
In this example we'll use Arduino UNO + Ethernet Shield
5 Steps guide:
(watch video tutorial here: )
1. Connect LED to Pin 9
( http://arduino.cc/en/uploads/Tutorial/simplefade_bb.png )
In the Blynk App:
2. Create New Project
3. Email yourself Auth Token. You can do it later at any time
4. Add a Button Widget. Select Pin D9 in Widget's Settings
5. Press Play icon. Enjoy Blynking!
********************************************************************/
#define BLYNK_PRINT Serial // Enables Serial Monitor
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h> // This part is for Ethernet stuff
#include <OneWire.h>
// OneWire DS18S20, DS18B20, DS1822 Temperature Example
//
// http://www.pjrc.com/teensy/td_libs_OneWire.html
//
// The DallasTemperature library can do all this work for you!
// http://milesburton.com/Dallas_Temperature_Control_Library
#define ONE_WIRE_BUS_1 2
#define ONE_WIRE_BUS_2 3
OneWire ds (ONE_WIRE_BUS_1);
OneWire ds1 (ONE_WIRE_BUS_2);
//OneWire ds(3); // on pin 7 (a 4.7K resistor is necessary) make sure you change this from the original pin 10 to an unused pin.
int adr;
float s1;
float s2;
float s3;
float s4;
float s5;
float s6;
float s7;
float s8;
float s9;
float s10;
float s11;
float s12;
float s13;
float s14;
float s15;
float s16;
float s17;
float s18;
float s19;
float s20;
char auth[] = "dc48490ed0ad49489221febb51c8c03f"; // Put your Auth Token here. (see Step 3 above)
void setup()
{
Serial.begin(9600); // See the connection status in Serial Monitor
Blynk.begin(auth); // Here your Arduino connects to the Blynk Cloud.
}
void loop()
{
Blynk.run(); // All the Blynk Magic happens here...
// 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!
byte i;
byte present = 0;
byte type_s;
byte data[12];
byte addr[8];
float celsius, fahrenheit;
if ( !ds.search(addr)) {
Serial.println("No more addresses.");
Serial.println();
ds.reset_search();
if ( !ds1.search(addr)) {
Serial.println("No more addresses.");
Serial.println();
ds1.reset_search();
delay(250);
return;
}
}
// Serial.print("ROM =");
for( i = 0; i < 8; i++) { //we need to drop 8 bytes of data
}
adr = (addr[7]);
if (OneWire::crc8(addr, 7) != addr[7]) {
Serial.println("CRC is not valid!");
return;
}
Serial.println();
ds.reset();
ds.select(addr);
ds.write(0x44, 1); // start conversion, with parasite power on at the end
ds1.reset();
ds1.select(addr);
ds1.write(0x44, 1); // start conversion, with parasite power on at the end
delay(1000); // maybe 750ms is enough, maybe not
// we might do a ds.depower() here, but the reset will take care of it.
present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad
present = ds1.reset();
ds1.select(addr);
ds1.write(0xBE); // Read Scratchpad
for ( i = 0; i < 9; i++) { // we need 9 bytes to drop off
data[i] = ds.read();
for ( i = 0; i < 9; i++) { // we need 9 bytes to drop off
data[i] = ds1.read();
} }
Serial.println();
// Convert the data to actual temperature
// because the result is a 16 bit signed integer, it should
// be stored to an "int16_t" type, which is always 16 bits
// even when compiled on a 32 bit processor.
int16_t raw = (data[1] << 8) | data[0];
if (type_s) {
raw = raw << 3; // 9 bit resolution default
if (data[7] == 0x10) {
// "count remain" gives full 12 bit resolution
raw = (raw & 0xFFF0) + 12 - data[6];
}
} else {
byte cfg = (data[4] & 0x60);
// at lower res, the low bits are undefined, so let's zero them
if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms
else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
//// default is 12 bit resolution, 750 ms conversion time
}
celsius = (float)raw / 16.0;
fahrenheit = celsius * 1.8 + 32.0;
if(adr == 167) { //replace ??? with value of sensor number 1
s1 = celsius; //change celsius to fahrenheit if you prefer output in Fahrenheit
}
if(adr == 162) { //replace ??? with value of sensor number 2
s2 = celsius; //change celsius to fahrenheit if you prefer output in Fahrenheit
}
if(adr == 38) { //replace ??? with value of sensor number 3
s3 = celsius; //change celsius to fahrenheit if you prefer output in Fahrenheit
}
if(adr == 102) { //replace ??? with value of sensor number 4
s4 = celsius; //change celsius to fahrenheit if you prefer output in Fahrenheit
}
if(adr == 63) { //replace ??? with value of sensor number 5
s5 = celsius; //change celsius to fahrenheit if you prefer output in Fahrenheit
}
if(adr == 221) { //replace ??? with value of sensor number 6
s6 = celsius; //change celsius to fahrenheit if you prefer output in Fahrenheit
}
if(adr == 26) { //replace ??? with value of sensor number 7.
s7 = celsius; //change celsius to fahrenheit if you prefer output in Fahrenheit
}
if(adr == 35) { //replace ??? with value of sensor number 8
s8 = celsius; //change celsius to fahrenheit if you prefer output in Fahrenheit
}
if(adr == 211) { //replace ??? with value of sensor number 9
s9 = celsius; //change celsius to fahrenheit if you prefer output in Fahrenheit
}
if(adr == 207) { //replace ??? with value of sensor number 10
s10 = celsius; //change celsius to fahrenheit if you prefer output in Fahrenheit
}
if(adr == 182) { //replace ??? with value of sensor number 1
s11 = celsius; //change celsius to fahrenheit if you prefer output in Fahrenheit
}
if(adr == 43) { //replace ??? with value of sensor number 2
s12 = celsius; //change celsius to fahrenheit if you prefer output in Fahrenheit
}
if(adr == 38) { //replace ??? with value of sensor number 3
s13 = celsius; //change celsius to fahrenheit if you prefer output in Fahrenheit
}
if(adr == 102) { //replace ??? with value of sensor number 4
s14 = celsius; //change celsius to fahrenheit if you prefer output in Fahrenheit
}
if(adr == 63) { //replace ??? with value of sensor number 5
s15 = celsius; //change celsius to fahrenheit if you prefer output in Fahrenheit
}
if(adr == 221) { //replace ??? with value of sensor number 6
s16 = celsius; //change celsius to fahrenheit if you prefer output in Fahrenheit
}
if(adr == 26) { //replace ??? with value of sensor number 7.
s17 = celsius; //change celsius to fahrenheit if you prefer output in Fahrenheit
}
if(adr == 35) { //replace ??? with value of sensor number 8
s18 = celsius; //change celsius to fahrenheit if you prefer output in Fahrenheit
}
if(adr == 211) { //replace ??? with value of sensor number 9
s19 = celsius; //change celsius to fahrenheit if you prefer output in Fahrenheit
}
if(adr == 207) { //replace ??? with value of sensor number 10 If you use more sensors just add them below this section. Delete unused sections, or you will get "expected primary-expression before '?' token"
s20 = celsius; //change celsius to fahrenheit if you prefer output in Fahrenheit
}
Serial.print(" Sensor 1 = ");
Serial.print(s1);
Serial.print(" Sensor 2 = ");
Serial.print(s2);
Serial.print(" Sensor 3 = ");
Serial.print(s3);
Serial.print(" Sensor 4 = ");
Serial.print(s4);
Serial.print(" Sensor 5 = ");
Serial.print(s5);
Serial.print(" Sensor 6 = ");
Serial.print(s6);
Serial.print(" Sensor 7 = ");
Serial.print(s7);
Serial.print(" Sensor 8 = ");
Serial.print(s8);
Serial.print(" Sensor 9 = ");
Serial.print(s9);
Serial.print(" Sensor 10 = ");
Serial.print(s10);
Serial.print(" Sensor 11 = ");
Serial.print(s11);
Serial.print(" Sensor 12 = ");
Serial.print(s12);
Serial.print(" Sensor 13 = ");
Serial.print(s13);
Serial.print(" Sensor 14 = ");
Serial.print(s14);
Serial.print(" Sensor 15 = ");
Serial.print(s15);
Serial.print(" Sensor 16 = ");
Serial.print(s16);
Serial.print(" Sensor 17 = ");
Serial.print(s17);
Serial.print(" Sensor 18 = ");
Serial.print(s17);
Serial.print(" Sensor 19 = ");
Serial.print(s7);
Serial.print(" Sensor 20 = "); //add or delete if you need more or less
Serial.print(s20);
Blynk.virtualWrite(V5, s1);
Blynk.virtualWrite(V6, s2);
Blynk.virtualWrite(V7, s3);
Blynk.virtualWrite(V8, s4);
Blynk.virtualWrite(V9, s5);
Blynk.virtualWrite(V10, s6);
Blynk.virtualWrite(V12, s7);
Blynk.virtualWrite(V13, s8);
Blynk.virtualWrite(V14, s9);
Blynk.virtualWrite(V15, s10);
Blynk.virtualWrite(V16, s11);
Blynk.virtualWrite(V17, s12);
Blynk.virtualWrite(V18, s13);
Blynk.virtualWrite(V19, s14);
Blynk.virtualWrite(V20, s15);
Blynk.virtualWrite(V21, s16);
Blynk.virtualWrite(V22, s17);
Blynk.virtualWrite(V23, s18);
Blynk.virtualWrite(V24, s19);
Blynk.virtualWrite(V25, s20); //add or delete if you need more or less
}
Question 5 years ago
I figured out what to write instead of question marks. But something is wrong with code. All temperatures the same in one line and blynk show same values in all widgets.?
Answer 5 years ago
The problem with the sketch is that virtualwrite is in the void loop that if you read up on Blynk virtualwrite it states that putting it in void loop won't work.
This program works fine and can be used as a base starting point for your project
I fine that adding lines of programme then compiling it then add more lines and compiling it allows you to correct errors as you programe
Hope this is of some help
Peter
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h> // This part is for Ethernet stuff
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
char auth[] = "put auth code here before you start";
/* WiFi credentials */
/* TIMER */
#include <SimpleTimer.h>
SimpleTimer timer;
/* DS18B20 Temperature Sensor */
#include <OneWire.h>
#include<DallasTemperature.h>
#define ONE_WIRE_BUS 7
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
int temp_0;
int temp_1;
void setup()
{
Serial.begin(9600);
Blynk.begin(auth);
DS18B20.begin();
timer.setInterval(1000L, getSendData);
Serial.println(" ");
Serial.println("Testing Dual Sensor data");
}
void loop()
{
timer.run(); // Initiates SimpleTimer
Blynk.run();
} // End of Void Loop
/***************************************************
* Send Sensor data to Blynk
**************************************************/
void getSendData()
{
DS18B20.requestTemperatures();
temp_0 = DS18B20.getTempCByIndex(0); // Sensor 0 will capture Temp in Celcius
temp_1 = DS18B20.getTempCByIndex(1); // Sensor 0 will capture Temp in Celcius
Serial.print("Temp_0: ");
Serial.print(temp_0);
Serial.print(" oC . Temp_1: ");
Serial.print(temp_1);
Serial.println(" oF");
Blynk.virtualWrite(5, temp_0); //virtual pin V5 indoor temp
Blynk.virtualWrite(6, temp_1); //virtual pin V6 outdoor temp
}
6 years ago
Thanks a lot. Works perfect.
7 years ago
Hi,
I’m irinakim and I’m work in the Wiznet.
Thank you for using our product.
We are collecting so much data using ourproduct.
And I will post the this project on our Web site.( http://wiznetmuseum.com)
Can I post your product on our Web site?
7 years ago
It looks great. Have you gone further ?
Reply 7 years ago
Hi. No, I have done nothing further with that. It works and does what I wanted it to do.
7 years ago
It looks great. Have you gone further ?
7 years ago
It looks great. Have you gone further ?
7 years ago
Have you gone further ?