Begin typing your search above and press return to search. Press Esc to cancel.

Upload DS18b20 Temperature Sensor Data to Thingspeak from Esp8266 (nodemcu)


Hello all in this tutorial you will know how to use Ds18b20 Temperature data to thingspeak.com, you can follow above fritzing circuit diagram to control the Ds18b20 temperature sensor, This sensor follows one wire protocol which means you can connect many sensors as you want to the single pin and access temperature data calling the sensor by address.

check the video below on how to work with this sensor and also proof of code working .



There is no much work to get work with this sensor, as there are plenty of example library that already available in the internet which anyone can make use and get started to work with this sensor. 

Test the below code to know check whether you can get reading from the temperature sensor with ESP8266 or Nodemcu

if you get any error , make sure you have downloaded library for Ds18b20 Temperature sensor. 
----------------------------------------------------------------------------------------------------------------------
#include <OneWire.h>
#include <DallasTemperature.h>
 
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
 
// Setup a oneWire instance to communicate with any OneWire devices 
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
 
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
 
void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();
}
 
 
void loop(void)
{
  // call sensors.requestTemperatures() to issue a global temperature
  // request to all devices on the bus
  Serial.print(" Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.println("DONE");

  Serial.print("Temperature for Device 1 is: ");
  Serial.print(sensors.getTempCByIndex(0)); // Why "byIndex"? 
    // You can have more than one IC on the same bus. 
    // 0 refers to the first IC on the wire
}


-----------------------------------------------------------------------------------------------------------------------

copy paste above code to your Arduino IDE and upload to your ESP8266 or Nodemcu if you are not sure about how to do this please check the video about to know how things work, if you don't know yet to search search on this blog for getting started with Esp8266 in Arduino IDE.

below you can see the code for sending temperature data to thingspeak.com from Esp8266 or Nodemcu to do this you need have thingspeak api key which can get easily by registering to the website.

change SSID and password to your router password and also update the Nodemcu api key.

--------------------------------------------------------------------------------------------------------------------------
#include <ESP8266WiFi.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define myPeriodic 15 //in sec | Thingspeak pub is 15sec
#define ONE_WIRE_BUS 2  // DS18B20 on arduino pin2 corresponds to D4 on physical board

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
float prevTemp = 0;
const char* server = "api.thingspeak.com";
String apiKey ="Things speak api key";
const char* MY_SSID = "your router name "; 
const char* MY_PWD = "your wifi password";
int sent = 0;
void setup() {
  Serial.begin(115200);
  connectWifi();
}

void loop() {
  float temp;
  //char buffer[10];
  DS18B20.requestTemperatures(); 
  temp = DS18B20.getTempCByIndex(0);
  //String tempC = dtostrf(temp, 4, 1, buffer);//handled in sendTemp()
  Serial.print(String(sent)+" Temperature: ");
  Serial.println(temp);
  
  //if (temp != prevTemp)
  //{
  //sendTeperatureTS(temp);
  //prevTemp = temp;
  //}
  
  sendTeperatureTS(temp);
  int count = myPeriodic;
  while(count--)
  delay(1000);
}

void connectWifi()
{
  Serial.print("Connecting to "+*MY_SSID);
  WiFi.begin(MY_SSID, MY_PWD);
  while (WiFi.status() != WL_CONNECTED) {
  delay(1000);
  Serial.print(".");
  }
  
  Serial.println("");
  Serial.println("Connected");
  Serial.println("");  
}//end connect

void sendTeperatureTS(float temp)
{  
   WiFiClient client;
  
   if (client.connect(server, 80)) { // use ip 184.106.153.149 or api.thingspeak.com
   Serial.println("WiFi Client connected ");
   
   String postStr = apiKey;
   postStr += "&field1=";
   postStr += String(temp);
   postStr += "\r\n\r\n";
   
   client.print("POST /update HTTP/1.1\n");
   client.print("Host: api.thingspeak.com\n");
   client.print("Connection: close\n");
   client.print("X-THINGSPEAKAPIKEY: " + apiKey + "\n");
   client.print("Content-Type: application/x-www-form-urlencoded\n");
   client.print("Content-Length: ");
   client.print(postStr.length());
   client.print("\n\n");
   client.print(postStr);
   delay(1000);
   
   }//end if
   sent++;
 client.stop();
}//end send







--------------------------------------------------------------------------------------------------------------------------


if you like the above tutorial and if you want try out with cool projects you can also check this link here , that's the amazon book link where you can use that book to make IoT with Esp8266 or Nodemcu, that books gives you basic coverage on how to do simple things and get yourself started with arduino and goes on developing projects like sending data to webserver and creating a webserver, uploading and controlling data from a webpage, how to interface TFT LCD and I2C devices and many more things can find on the link.

Thanks for stopping by and read this blog. 







118 comments:

  1. Very nice and helpful information has been given in this article. I like the way you explain the things. Keep posting. Thanks..

    http://jakinid.com/iot-solutions/

    ReplyDelete
    Replies
    1. Upload Ds18B20 Temperature Sensor Data To Thingspeak From Esp8266 (Nodemcu) >>>>> Download Now

      >>>>> Download Full

      Upload Ds18B20 Temperature Sensor Data To Thingspeak From Esp8266 (Nodemcu) >>>>> Download LINK

      >>>>> Download Now

      Upload Ds18B20 Temperature Sensor Data To Thingspeak From Esp8266 (Nodemcu) >>>>> Download Full

      >>>>> Download LINK mN

      Delete
  2. hello.

    PLEASE HELP ME SORTING THIS ERROR

    ""exit status 1
    Error compiling for board Arduino/Genuino Uno.""

    THIS ERROR OCCUR IN EACH AND EVERY BOARD I HAVE SELECTED.

    ReplyDelete
    Replies
    1. MY ALSO SHOWING SAME PROBLEM.. have you got any solution

      Delete
    2. Install the wificlient board from board manager and make sure that the spelling is spelled in correct way

      Delete
  3. Hello!
    Why I have this erorr ?? : #error "Please define I/O register types here"
    Thanks !

    ReplyDelete
  4. https://github.com/adafruit/ESP8266-Arduino/tree/esp8266/libraries/OneWire

    ReplyDelete
  5. in arduino software i am unable to see port:COM14 it is showing COM3 for me .so how to change the port to COM14 you mentioned in the video .if any change i have to do please send it to mothe.manideep502@gmail.com

    ReplyDelete
  6. This is gigantic thus exact here. Much obliged to you for posting them. Extraordinary bit of writing given that much drawing closer into the part. These sorts of articles are truly prepared to assist for the humanity and one who are secretive with these. Custom essay Writing Service is an accomplished, multitasking and solid online custom writing affiliation, went for giving competent writing help to understudies wherever all through the world. this service center their endeavors on the understudies' most astonishing results, smart illuminating improvement and information change.

    ReplyDelete
  7. Hi, I have problem: stray '\302' in program. Any ideas?

    ReplyDelete
  8. I think that all it's correct but always temperature is -127. I tried with differents DS18b.... Some ideas?

    ReplyDelete
    Replies
    1. Did you solve the problem and how ????

      Delete
    2. Me too, i also try with VCC+GND of DS18B20 join together but the function hang-up.
      Try to put DS18B20 data to pin D3 and D0, change the pullup into 10K, also always got -127.00. My nodeMCU is Lolin.

      Delete
  9. Hi,

    I've got the same probems like nelun and Abhinav. (#error "Please define I/O register types here")
    I saw that dubnikov replied with a solution but I still don't understand.
    Can I have more information about that. Thanks

    ReplyDelete
  10. Hi, Problem solved for the I/O register.
    Now got problem that connect wifi was not declared. Anybody some info?
    Thanks

    ReplyDelete
  11. Thanks for this. I've been trying to do this by various means but this work straight off. Just needed to change the pin number. I would say that a delay in the first code is needed because it reads too quickly. Thank you.

    ReplyDelete
  12. I have enjoyed reading through the article and the comments. I have learned a lot and understood the topic under discussion from a different point of view. I take this opportunity to thank the author for the continual commitment to keep us updated with quality articles that are not only entertaining but also educative. Feel free to hire our professional writers by clicking on PhD Dissertation Data Analysis Using Stata Software.

    ReplyDelete
  13. The internet has changes the way the people apply their thinking into the development of their own ideas. I am very sure that the scholars are one of the categories of people who are applying the internet of thinking into their Research Paper Sentences so as to produce high-quality research content. this article has clearly unveiled the importance of the internet of thinking.

    ReplyDelete
  14. I enjoyed the artical.I learn lot of topics under discussion from a point of view Iot is the inter networking of physical device and electronics,software, sensors,actuators,and network connectivity which enable objects to collect and exchange data.
    If you are looking for the internetofthinkings and sevices then very big company

    ReplyDelete
  15. i got code compiled and uploaded and serial monitor is showing this result
    {⸮⸮⸮{⸮_⸮{⸮_⸮{⸮_⸮{⸮_{Ÿ⸮{⸮_⸮{Ο⸮⸮⸮_⸮{⸮⸮⸮{⸮⸮⸮⸮Λ⸮{Ÿ⸮{⸮_⸮⸮_⸮⸮⸮_⸮{⸮_⸮⸮⸮_⸮⸮⸮_⸮⸮_⸮. any help is much appreciated. Thank you very much for posting this huge code block. I would never have been able to do it. This really helps me to focus on the project, not the code.

    ReplyDelete
    Replies
    1. i got the answer to this on another site. I had to increase the speed of the monitor to match the coded level of 115,200. Still have not been able to update my channel but now know the wifi is connected via the message on the serial monitor.

      Delete
    2. This comment has been removed by the author.

      Delete
    3. how to increase the speed of monitor?

      Delete
  16. waoo well written post regarding "Upload DS18b20 Temperature Sensor Data to Thingspeak from Esp8266 (nodemcu)"

    Thanks,

    Commodity Tips Free Trial

    ReplyDelete
  17. pls help with this error
    error: Failed to open COM1
    error: espcomm_open failed
    error: espcomm_upload_mem failed
    I cant select any port.What could be the reason

    ReplyDelete
  18. This comment has been removed by the author.

    ReplyDelete
  19. " Board nodemcuv2 (platform esp8266, package esp8266) is unknown

    Error compiling for board NodeMCU 1.0 (ESP-12E Module). "


    i have this problem. what should i do?? please help me.

    ReplyDelete
  20. Can you help me to add more sensor and send data to another field under same channel on thingspeak.com

    ReplyDelete
  21. hai seeing video would you please share me mobile number or call me 9940594278

    ReplyDelete
  22. thanks for sharing the more valuable information.
    Indian Cyber Army credibility in Ethical hacking training & Cybercrime investigation training is acknowledged across nation as we offer hands on practical knowledge and full assistance with basic as well as advanced level ethical hacking & cybercrime investigation courses. The training is conducted by subject specialist corporate professionals with wide experience in managing real-time ethical hacking/ cyber security projects. Indian Cyber Army implements a blend of academic learning and practical sessions to give the candidate optimum exposure.Ethical hacking training ,Ethical hacking course

    ReplyDelete
  23. It is a very valuable piece of data. I believe it can have a great impact in the field of the internet of things development. We need to take great care to never let any information or attachment go to waste hence it's vital we are able to use such pieces of code to fix the rest of it.

    ReplyDelete
  24. This comment has been removed by the author.

    ReplyDelete
  25. Tidak hanya memperhatikan kartu, pastikan menghitung keseluruhan jumlah kartu yang tersisa dalam permainan.
    asikqq
    dewaqq
    sumoqq
    interqq
    pionpoker
    bandar ceme terpercaya
    hobiqq
    paito warna terlengkap
    bocoran sgp

    ReplyDelete
  26. Some us know all relating to the compelling medium you present powerful steps on this blog and therefore strongly encourage contribution from other ones on this subject while our own child is truly discovering a great deal. Have fun with the remaining portion of the year.
    Surya Informatics

    ReplyDelete
  27. Good Post. I like your blog. Thanks for Sharing
    Ping Speed Test

    ReplyDelete

  28. شركة تنسيق حدائق بالمدينة المنورة
    الحدائق من الأماكن الجميلة والتميزة ودائماً يرغب أهل المدينة المنورة أن يستغلوا بعض من المساحات في منازلهم في إنشاء حديقة منزلية وفي تلك الحالة فأنت تحتاج إلى شركة تنسيق حدائق بالمدينة المنورة التي تساعدكم في الحصول على حدائق منسقة ونظيفة، فنحن لدينا فريق محترف يمكنه القيام بكل هذا وأكثر على أعلى مستوى.

    ReplyDelete
  29. Great Post got useful information from blog looking. forward to read more articles of this author. Thanks!
    iot training

    ReplyDelete
  30. Very Very good Tutorial! It works like a charm. Thanks for taking the time to make such an excellent Lesson!

    ReplyDelete
  31. Your project is awesome, but what happened with this blog??? I check this blog (Internet of Things) weekly and I don't see any update on him, I haven't seen any project or/and tutorial since months, counting that I follow this blog since 5 months ago.

    ReplyDelete
  32. This is truly an practical and pleasant information for all. Thanks for sharing this to us and more poweriot training in noida

    ReplyDelete
  33. After reading your article I was amazed. I know that you explain it very well. And I hope that other readers will also experience how I feel after reading your article.
    Ethical Hacking Course in Bangalore

    ReplyDelete
  34. Great tips and very easy to understand. This will definitely be very useful for me when I get a chance to start my blog.

    Data Science Training

    ReplyDelete
  35. Very impressive article with very useful information thanks for sharing.
    Data Analytics Course Online 360DigiTMG

    ReplyDelete
  36. Just a shine from you here. I have never expected anything less from you and you have not disappointed me at all. I guess you will continue the quality work.

    Business Analytics Course in Bangalore

    ReplyDelete
  37. The regular visits listed here are the easiest way to appreciate its energy, which is why I go to the website every day for new and interesting information. Thank you so much!

    Data Analytics Course in Bangalore

    ReplyDelete
  38. I was very happy to find this site. I wanted to thank you for this excellent reading !! I really enjoy every part and have bookmarked you to see the new things you post.

    Artificial Intelligence Course in Bangalore

    ReplyDelete
  39. Really fantastic and interesting blog enjoyed reading this one waiting for next blog thanks for sharing.
    Data Science Training in Hyderabad

    ReplyDelete
  40. You've made some good points there. I looked on the internet for additional information about the issue and found most people will go along with your views on this website.
    Technology

    ReplyDelete
  41. Impressive blog to be honest definitely this post will inspire many more upcoming aspirants. Eventually, this makes the participants to experience and innovate themselves through knowledge wise by visiting this kind of a blog. Once again excellent job keep inspiring with your cool stuff.

    Digital Marketing training in Bhilai

    ReplyDelete
  42. Truly mindblowing blog went amazed with the subject they have developed the content. These kind of posts really helpful to gain the knowledge of unknown things which surely triggers to motivate and learn the new innovative contents. Hope you deliver the similar successive contents forthcoming as well.

    Digital Marketing Course

    ReplyDelete
  43. This is really fascinating, You’re an overly skilled blogger.
    I’ve joined your feed and sit up for in quest of more of your great post.

    Java Training in Chennai

    Java Course in Chennai

    ReplyDelete
  44. Thanks a lot very much for the high quality and results-oriented help beard is free

    ReplyDelete
  45. https://k2incenseonlineheadshop.com/
    info@k2incenseonlineheadshop.com
    k2incenseonlineheadshop Buy liquid incense cheap Buy liquid incense cheap For Sale At The Best Incense Online Shop

    ReplyDelete
  46. https://syntheticworldwide.com/
    sales@syntheticworldwide.com

    Buy cheap liquid herbal incense at your best online shop

    ReplyDelete
  47. Thanks for Sharing your Blog, it is very helpful and more information.Buy sensors online in India

    ReplyDelete
  48. Good and knowledgeable information shared through this blog. Very well explained concepts. Thanks for sharing this useful information.
    Wifi antenna manufacturer

    ReplyDelete
  49. Good and knowledgeable information shared through this blog. Very well explained concepts. Thanks for sharing this useful information.... Buy Google voice numbers

    ReplyDelete

  50. Hi there,
    Thank you so much for the post you do and also I like your post, Are you looking for Buy Apple Celato , Cheetah Plss, Grandi Guava, Horchata, Blue Gotti,Ruby Red,Italian Ice, Insane Christmas Lights, Rainbow Chip, INSANE Hony Moon, NO MORE Partiez, NO MORE Partiez, Hony Bun, White Runtz, buy horchata online, Buy Rainbow Chip online, buy Blue Gotti online, buy Ruby Red online, buy Italian Ice online, buy Insane Christmas Lights online, Buy INSANE Hony Moon online, Buy NO MORE Parties online, Buy White Cherry Celato online, Buy Peanut Butter Celato online, Buy Lechoza online, Buy Grandi Candi online, Buy Chronic carts online, Buy Cannabis Chocolate Chip Cookies online, Buy Cannabis Trim Capsules online, Buy Blue Diamond Vape Cartridge online,


    with the well price and our services are very fast. Click here for
    Call us: +1406 9441867‬

    E-mail: info@backpackexotics.com




    ReplyDelete
  51. Acknowledges for penmanship such a worthy column, I Apk Write For Us

    ReplyDelete
  52. i feel strongly that love and read extra in this subject matter
    SEO write for us

    ReplyDelete
  53. Your site is truly cool and this is an extraordinary moving article and If it's not too much trouble share more like that. Thank You....
    Facebook pva accounts
    Buy Instagram pva accounts
    Google voice numbers for sale
    Buy pinterest pva accounts

    ReplyDelete
  54. You have completed certain reliable points there. I did some research on the subject and found that almost everyone will agree with your blog.

    AWS Training in Hyderabad

    ReplyDelete
  55. KINGDOMGROUP SITUS BETTING ONLINE TERBESAR DAN TERPERCAYA
    ʟᴏᴍʙᴀ ʀᴀᴛᴜsᴀɴ ᴊᴜᴛᴀ!!!

    LINK DAFTAR : https://kingdom899.wixsite.com/linkbaru

    PREDIKSI SILAKAN DI KLIK: : https://v.gd/3pp3Ff

    ᴍɪɴ ʙᴇᴛ : 100 ʀᴜᴘɪᴀʜ
    𝚃𝚘𝚝𝚊𝚕 𝟷𝟶𝟸 𝙿𝚊𝚜𝚊𝚛𝚊𝚗
    ♥️ Pasaran Populer ♥️
    💢sɪɴɢᴀᴘᴏʀᴇ
    💢ʜᴏɴɢᴋᴏɴɢ
    💢sʏᴅɴᴇʏ
    💢ʙᴜʟʟsᴇʏᴇ
    💢ᴄᴀʀᴏʟɪɴᴀᴅᴀʏ
    💢ᴍᴀɢɴᴜᴍ4ᴅ
    💢ᴘᴄsᴏ
    💢ғʟᴏʀɪᴅᴀ
    💢ɴᴇᴡʏᴏʀᴋ
    💢ᴏʀᴇɢᴏɴ
    💢ᴄᴀʟɪғᴏʀɴɪᴀ
    TERSEDIAH 8 GAME TERFAVORIT :
    💢 SPADE GAMING ( TERBARU 🔥🔥 ) CASHBACK 10%
    - SPADEGAMING SLOT
    - SPADEGAMING FISHING HUNTER
    - SPADEGAMING VIRTUAL GAMES
    💢 SBOBET (NEW GAME)
    💢 QUEENMAKER SLOT
    💢 SEXY GAMES (BACCARAT DENGAN PENAMPILAN SEXY)
    💢 PRAMATIC LIVE
    💢 JOKER
    💢 IDN PLAY
    💢 PRAMATIC SLOT
    💢 HABANERO SLOT
    💢 TEMBAK IKAN
    UNTUK SEMUA GAME SLOT CASH BACK 10% (DARI KEKALAHAN MINIMAL 200RB) DAN UNTUK IDNLIVE CASH BACK 10% ( DARI KEKALAHAN MINIMAL 1JT) DI BAGI SETIAP HARI SENIN

    LINK GRUP LOMBA BERHADIAH : https://www.facebook.com/groups/Kingdom.Offficial88

    ReplyDelete
  56. The question is, why would anyonebuy linkedin accountbuy craigslist accountplace? Is it just to impress people or do they have some Buy snapchat accounts kind of business behind the nice blog? Well, I believe you should take a look at how these two factors play into your decision on whether or not to set up a nice blog. The more you know before you get started the better chance you have at success with your new site.
    Buy tinder accounts
    Buy facebook accounts
    Buy yahoo accounts
    Buy gmail Accounts

    ReplyDelete
  57. You have completed certain reliable points there. I did some research on the subject and found that almost everyone will agree with your blog.
    Business Analytics Course

    ReplyDelete
  58. If you are looking for a fast and easy way to start building your own website, why not try the "Einstein's Ebel" method which is one of the many important things to remember if you are going to build your own website. You see, in the "Einstein's Ebel" method, you have to start with a blank canvas or a sheet of paper. Then you have to draw up a few main concepts and ideas that you want to express on your website before you can even begin the actual building process. You may even want to take a course on web building so that you can learn as much as possible about him from others who have gone through the process and have built websites that are just like yours. buy google voice accounts

    ReplyDelete
  59. This comment has been removed by the author.

    ReplyDelete
  60. I wanted to leave a little comment to support you and wish you the best of luck. We wish you the best of luck in all of your blogging endeavors.

    Ethical Hacking Training in Bangalore

    ReplyDelete
  61. to the medical condition of most patients. many people suffering from cancer, chronic pain, anxiety and man more have overcome their illment with cannabis. you can order weed from our store





    ReplyDelete

  62. Very good message. I came across your blog and wanted to tell you that I really enjoyed reading your articles.

    Artificial Intelligence Courses in Bangalore

    ReplyDelete
  63. I think this is an informative and very useful and knowledgeable blog. therefore, I would like to thank you for your effort.
    Data Science Course in Amritsar

    ReplyDelete
  64. Thanks for sharing for such a great blog with us.Post Guerilla

    ReplyDelete
  65. Upload Ds18B20 Temperature Sensor Data To Thingspeak From Esp8266 (Nodemcu) >>>>> Download Now

    >>>>> Download Full

    Upload Ds18B20 Temperature Sensor Data To Thingspeak From Esp8266 (Nodemcu) >>>>> Download LINK

    >>>>> Download Now

    Upload Ds18B20 Temperature Sensor Data To Thingspeak From Esp8266 (Nodemcu) >>>>> Download Full

    >>>>> Download LINK

    ReplyDelete
  66. Very informative message! There is so much information here that can help any business start a successful social media campaign


    Data Science Course in Gorakhpur

    ReplyDelete
  67. This comment has been removed by the author.

    ReplyDelete
  68. Kudos to the developer for their insightful exploration! Your article brilliantly navigates through the intricacies of this fundamentals & shedding light on its versatility and practical applications. Your thorough analysis and clear explanations serve as an invaluable resource for both beginners and flutter app development company alike. Keep up the exceptional work, empowering the Tech community with your expertise!

    ReplyDelete