loading

Temperature being displayed on my Android device.

Step 1: Introduction

In this Instructable I am going to attempt to show you how to put together a little project to use the Blynk app (optainable at http://www.blynk.cc/) to display the temperature remotely on a iOS or Android device.

I came across an posting on my Google+ where somebody required some help with this. It looked interesting, so I decided to have a try myself.

This is my first attempt to write an Instructable. I have found many articles published here useful. So I thought it is time to do my part.

The main parts I used are:

Arduino UNO clone

Ethernet shield

Dallas DS18B20 sensor

A 4k7 resistor is also required as a pull-up resistor for the data line.

Optional Breadboard

An iOS or Android device

Step 2: The DS18B20 Sensor

The DS18B20 sensor connections are as follows, looking at the label:

Left leg = GND

Middle leg = Data

Right leg = 5 V

Step 3: Let's Start

I used a mini breadboard just to connect the pull-up resistor to the 5 V and Data connection. You could just solder the resistor straight onto the legs.

Step 4: Wiring

That is how it is all wired up.

Vcc -> 5V

GND -> Gnd

Data -> pin 7

4k7 resistor between 5 V and Data legs

Step 5: Getting Some Code to Work

I don't believe in reinventing the wheel. Download the library from the Blynk website and install it into your Arduino libraries folder.

I used the BlynkBlink scetch from the Blynk examples and the DS18x20_temperature example from the OneWire Library. I combined the two into one sketch. I did change the pin for the DS18B20 data into the Arduino to pin 7. The reason for this is because pin 10 is used by the Ethernet shield. I also added a line to the end of the DS18x20 data processing section. Blynk.virtualWrite(V5, celsius); This sends the celsius result. You can change that to Blynk.virtualWrite(V5, fahrenheit); to send the Fahrenheit result.

Step 6: Result

On the device side, you have to use V5 as an input and set up the range. Detailed instructions relating to the software side and iOS and Android device setup are in the sketch and on the Blynk website. Once you worked out the basics, it is easy to change it to use a different display mode on your device, like "Value Display", "Gauge", "LCD" and "Graph".

I want to thank all the people who made this possible. The people who designed and made the hardware and wrote the software that I have used for this project. Without them life would be different.

Do not hesitate to make suggestions and ask questions, if you get stuck. I'm still learning how to write a good Instructable.

Step 7: The Code

The first file is for a single display only. The second one is a demo using different types of displays.

Step 8: Multi Display Demo

Screenshot of several different displays using the second code file.

<p>now i wanne connect 1 cannel relais bord</p>
<p>i used this one works :</p><p><br>#define BLYNK_PRINT Serial // Comment this out to disable prints and save space<br>#include &lt;ESP8266WiFi.h&gt;<br>#include &lt;BlynkSimpleEsp8266.h&gt;<br>#include &lt;OneWire.h&gt;<br><br>// You should get Auth Token in the Blynk App.<br>// Go to the Project Settings (nut icon).<br><br>OneWire ds(D2); // on pin D4 op wemos d1 (a 4.7K resistor is necessary)<br><br>char auth[] = &quot;822b2ffc4ccc44c0af582a582f91d8a7&quot;;<br><br>void setup(void)<br>{<br> Serial.begin(9600);<br> Blynk.begin(auth, &quot;telenet-xxxxx&quot;, &quot;xxxxxxxxxxx&quot;);<br>}<br><br>void loop(void)<br>{<br> Blynk.run();byte i;<br> byte present = 0;<br> byte type_s;<br> byte data[12];<br> byte addr[8];<br> float celsius, fahrenheit;<br> <br> if ( !ds.search(addr)) {<br> Serial.println(&quot;No more addresses.&quot;);<br> Serial.println();<br> ds.reset_search();<br> delay(250);<br> return;<br> }<br> <br> Serial.print(&quot;ROM =&quot;);<br> for( i = 0; i &lt; 8; i++) {<br> Serial.write(' ');<br> Serial.print(addr[i], HEX);<br> }<br><br> if (OneWire::crc8(addr, 7) != addr[7]) {<br> Serial.println(&quot;CRC is not valid!&quot;);<br> return;<br> }<br> Serial.println();<br> <br> // the first ROM byte indicates which chip<br> switch (addr[0]) {<br> case 0x10:<br> Serial.println(&quot; Chip = DS18S20&quot;); // or old DS1820<br> type_s = 1;<br> break;<br> case 0x28:<br> Serial.println(&quot; Chip = DS18B20&quot;);<br> type_s = 0;<br> break;<br> case 0x22:<br> Serial.println(&quot; Chip = DS1822&quot;);<br> type_s = 0;<br> break;<br> default:<br> Serial.println(&quot;Device is not a DS18x20 family device.&quot;);<br> return;<br> } <br><br> ds.reset();<br> ds.select(addr);<br> ds.write(0x44, 1); // start conversion, with parasite power on at the end<br> <br> delay(1000); // maybe 750ms is enough, maybe not<br> // we might do a ds.depower() here, but the reset will take care of it.<br> <br> present = ds.reset();<br> ds.select(addr); <br> ds.write(0xBE); // Read Scratchpad<br><br> Serial.print(&quot; Data = &quot;);<br> Serial.print(present, HEX);<br> Serial.print(&quot; &quot;);<br> for ( i = 0; i &lt; 9; i++) { // we need 9 bytes<br> data[i] = ds.read();<br> Serial.print(data[i], HEX);<br> Serial.print(&quot; &quot;);<br> }<br> Serial.print(&quot; CRC=&quot;);<br> Serial.print(OneWire::crc8(data, 8), HEX);<br> Serial.println();<br><br> // Convert the data to actual temperature<br> // because the result is a 16 bit signed integer, it should<br> // be stored to an &quot;int16_t&quot; type, which is always 16 bits<br> // even when compiled on a 32 bit processor.<br> int16_t raw = (data[1] &lt;&lt; 8) | data[0];<br> if (type_s) {<br> raw = raw &lt;&lt; 3; // 9 bit resolution default<br> if (data[7] == 0x10) {<br> // &quot;count remain&quot; gives full 12 bit resolution<br> raw = (raw &amp; 0xFFF0) + 12 - data[6];<br> }<br> } else {<br> byte cfg = (data[4] &amp; 0x60);<br> // at lower res, the low bits are undefined, so let's zero them<br> if (cfg == 0x00) raw = raw &amp; ~7; // 9 bit resolution, 93.75 ms<br> else if (cfg == 0x20) raw = raw &amp; ~3; // 10 bit res, 187.5 ms<br> else if (cfg == 0x40) raw = raw &amp; ~1; // 11 bit res, 375 ms<br> //// default is 12 bit resolution, 750 ms conversion time<br> }<br> celsius = (float)raw / 16.0;<br> fahrenheit = celsius * 1.8 + 32.0;<br> Serial.print(&quot; Temperature = &quot;);<br> Serial.print(celsius);<br> Serial.print(&quot; Celsius, &quot;);<br> Serial.print(fahrenheit);<br> Serial.println(&quot; Fahrenheit&quot;);<br> Blynk.virtualWrite(V5, celsius);<br>}</p>
Hi, <br><br>Figured it out. In the sketch, do not use OneWire ds(7);, but use OneWire ds(2);.<br><br>I used a NodeMCU v0.9 to test it. Connect sensor to D4.<br><br>This will only read and send data for a single sensor. <br><br>Also change the first Delay time from 10000 to 100. If that delay is too long, it disconnects from the network.<br><br>Regards<br><br>Maroelawerner<br>
<p>Hi, can you help me?</p><p>I try this, the blynk app says &quot;d1 wemos is not in network&quot;</p><p>It works with a led and wifi standalone, but after adding the one wire i cant connect???</p><p>#define BLYNK_PRINT Serial // Enables Serial Monitor<br>#include &lt;ESP8266WiFi.h&gt;<br>#include &lt;BlynkSimpleEsp8266.h&gt;<br>#include &lt;OneWire.h&gt;<br><br>// OneWire DS18S20, DS18B20, DS1822 Temperature Example<br>//<br>// <a href="http://www.pjrc.com/teensy/td_libs_OneWire.html"> http://www.pjrc.com/teensy/td_libs_OneWire.html</a><br>//<br>// The DallasTemperature library can do all this work for you!<br>// <a href="http://milesburton.com/Dallas_Temperature_Control_Library"> http://milesburton.com/Dallas_Temperature_Control...</a><br><br>OneWire ds(7); // on pin 7 (a 4.7K resistor is necessary) make sure you change this from the original pin 10 to an unused pin.<br><br><br>char auth[] = &quot;822b2ffc4ccc44c0af582a582f91d8a7&quot;; // Put your Auth Token here. (see Step 3 above)<br><br>void setup()<br>{<br> Serial.begin(9600); // See the connection status in Serial Monitor<br> Blynk.begin(auth, &quot;xxx&quot;, &quot;xxx&quot;); // Here your Arduino connects to the Blynk Cloud.<br>}<br><br>void loop()<br>{<br> Blynk.run(); // All the Blynk Magic happens here...<br><br> // You can inject your own code or combine it with other sketches.<br> // Check other examples on how to communicate with Blynk. Remember<br> // to avoid delay() function!<br> delay(10000);<br> byte i;<br> byte present = 0;<br> byte type_s;<br> byte data[12];<br> byte addr[8];<br> float celsius, fahrenheit;<br><br> if ( !ds.search(addr)) {<br> Serial.println(&quot;No more addresses.&quot;);<br> Serial.println();<br> ds.reset_search();<br> delay(250);<br> return;<br> }<br><br> Serial.print(&quot;ROM =&quot;);<br> for ( i = 0; i &lt; 8; i++) {<br> Serial.write(' ');<br> Serial.print(addr[i], HEX);<br> }<br><br> if (OneWire::crc8(addr, 7) != addr[7]) {<br> Serial.println(&quot;CRC is not valid!&quot;);<br> return;<br> }<br> Serial.println();<br><br> // the first ROM byte indicates which chip<br> switch (addr[0]) {<br> case 0x10:<br> Serial.println(&quot; Chip = DS18S20&quot;); // or old DS1820<br> type_s = 1;<br> break;<br> case 0x28:<br> Serial.println(&quot; Chip = DS18B20&quot;);<br> type_s = 0;<br> break;<br> case 0x22:<br> Serial.println(&quot; Chip = DS1822&quot;);<br> type_s = 0;<br> break;<br> default:<br> Serial.println(&quot;Device is not a DS18x20 family device.&quot;);<br> return;<br> }<br><br> ds.reset();<br> ds.select(addr);<br> ds.write(0x44, 1); // start conversion, with parasite power on at the end<br><br> delay(1000); // maybe 750ms is enough, maybe not<br> // we might do a ds.depower() here, but the reset will take care of it.<br><br> present = ds.reset();<br> ds.select(addr);<br> ds.write(0xBE); // Read Scratchpad<br><br> Serial.print(&quot; Data = &quot;);<br> Serial.print(present, HEX);<br> Serial.print(&quot; &quot;);<br> for ( i = 0; i &lt; 9; i++) { // we need 9 bytes<br> data[i] = ds.read();<br> Serial.print(data[i], HEX);<br> Serial.print(&quot; &quot;);<br> }<br> Serial.print(&quot; CRC=&quot;);<br> Serial.print(OneWire::crc8(data, 8), HEX);<br> Serial.println();<br><br> // Convert the data to actual temperature<br> // because the result is a 16 bit signed integer, it should<br> // be stored to an &quot;int16_t&quot; type, which is always 16 bits<br> // even when compiled on a 32 bit processor.<br> int16_t raw = (data[1] &lt;&lt; 8) | data[0];<br> if (type_s) {<br> raw = raw &lt;&lt; 3; // 9 bit resolution default<br> if (data[7] == 0x10) {<br> // &quot;count remain&quot; gives full 12 bit resolution<br> raw = (raw &amp; 0xFFF0) + 12 - data[6];<br> }<br> } else {<br> byte cfg = (data[4] &amp; 0x60);<br> // at lower res, the low bits are undefined, so let's zero them<br> if (cfg == 0x00) raw = raw &amp; ~7; // 9 bit resolution, 93.75 ms<br> else if (cfg == 0x20) raw = raw &amp; ~3; // 10 bit res, 187.5 ms<br> else if (cfg == 0x40) raw = raw &amp; ~1; // 11 bit res, 375 ms<br> //// default is 12 bit resolution, 750 ms conversion time<br> }<br> celsius = (float)raw / 16.0;<br> fahrenheit = celsius * 1.8 + 32.0;<br> Serial.print(&quot; Temperature = &quot;);<br> Serial.print(celsius);<br> Serial.print(&quot; Celsius, &quot;);<br> Serial.print(fahrenheit);<br> Serial.println(&quot; Fahrenheit&quot;);<br> Blynk.virtualWrite(V5, celsius);<br> <br>}<br></p>
<p>if you resolve this problem can you please share the code?</p><p>I'm having the exact same problem.</p><p>I will aprpriciated you help :)</p>
Hi,<br><br>Yes, there problem. After trying your sketch I got the same problem. <br><br>A quick look at the code revealed that there is no code to connect to the WiFi network.<br><br>Need to fix that.<br><br>Regards<br><br>Maroelawerner
<p>Hello, need a little help,</p><p>Used the Multiple ds18b20 and when i added a gauge or value widget a strange thing happens. it scrolls threw all the six ds18b20's i have connected. basically i cannot create a widget for each temp prob because it rolls threw all the temps.</p>
Hi, <br><br>Sorry for the delay, but I was unable to reply up to now.<br><br>Please send me the code that you are using and give me details of your setup. Tell me how many sensors you are using and their addresses.<br><br>I am currently not able to use Blink as I am no longer using it, but I am sure we can get the problem resolved.<br><br>Regards<br><br>Maroelawerner
<p>i find the working code !!!!! Simply put me well on the right track . Some adjustments made for the Wemos d1r2</p>
<p>Hi,</p><p>I&rsquo;m irinakim and I&rsquo;m work in the Wiznet.</p><p>Thank you for using our product.</p><p>We are collecting so much data using ourproduct.</p><p>And I will post the this project on our Web site.( <a href="http://wiznetmuseum.com/" rel="nofollow">http://wiznetmuseum.com</a>)</p><p>Can I post your product on our Web site?</p>
Hi, <br><br>Yes, you may post my project on your website.<br><br>Regards<br><br>maroelawerner
<p>This is very cool... Any have this on a wireless module instead of the Ethernet module they can share?</p>
<p>This is very cool... Any have this on a wireless module instead of the Ethernet module they can share?</p>
<p>This is great! Is there anyway you could get it to work with a 4 channel rely?</p>
<p>Yes, what do you want the 4 relays to do?</p>
<p>This is great! Is there anyway you could get it to work with a 4 channel rely?</p>
<p>This is great! Is there anyway you could get it to work with a 4 channel rely?</p>
<p>you need to update your hardware to esp8266 and remake this instructable. i need help with just that... it's a $5 board and has built in wifi, program it just like arduno.!! <a href="http://www.ebay.com/itm/1PCS-NodeMcu-Lua-ESP8266-CH340G-WIFI-Internet-Development-Board-Module-/401009563436?hash=item5d5e08572c:g:7VQAAOSwI-BWG4vN">http://www.ebay.com/itm/1PCS-NodeMcu-Lua-ESP8266-C...</a><br></p>
<p>I will do that on an ESP8266 some other day. I play with those as well. One of my other projects uses the Olimex ESP8266-EVB. That is basically a ESP8266 with some extra circuit to power the relay and has access to more GPIO pins. It is about &pound;10.00 with shipping, but well worth it.</p>
<p>Nice way to display the output of an Arduino project.</p>

About This Instructable

17,573views

48favorites

License:

Bio: I love keeping my mind busy with useful things. Have been involved in Electronics since school. Built my first computer from a kit in the ... More »
More by maroelawerner:High / Low WiFi hot water thermostat Blynk Arduino multiple DS18B20 Thermometer display on iOS or Android  Blynk Arduino DS18B20 Thermometer display on iOS or Android 
Add instructable to: