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. 







Read more ...

What is Internet Of Things??

                                              Internet of Things(IoT)
                                                                           - The next step in our Digital lives

 “The IoT is a big trend, that it ups the ante.‘Reach out and touch somebody’ is becoming ‘reach out and touch everything’.” 



What is IoT?
The Internet of Things (IoT) is a scenario in which objects, animals or people are provided with unique identifiers and the ability to transfer data over a network without requiring human-to-human or human-to-computer interaction.

Want to be Techgeek in IoT???
Make a Beginning now
                    In 2008, there were already more Internet connected objects than people. Previously a couple of outlets listed “Internet of Things” (IoT) as one of the words or phrases they hoped would die in 2015. Well, I hate to break it to you, but no matter what you call it, the Internet of Things is here to stay.

By 2020, that number is expected to grow to more than 50 billion objects. Projections estimate that the IoT market will sell more products than the PC, tablet, and phone markets combined. There is no need of worrying about running out of IP addresses (each connected thing needs one), because the latest version IPv6,has enough that there are 100 IP addresses for every single atom on earth.

Do You Go crazy for cars ? Ever had a thought of making it smart ?
Simple Get connected to IoT and show off..

Just 10 percent of cars are connected to the Internet and by 2020 can assay that 90 percent will be. Google Driverless cars will generate $5.6 trillion in savings worldwide. It is truly a great example of the Internet of Things technology and is one of the greatest Internet of Things application of all time.

Today, a vision is taking shape around the world of people being connected ubiquitously across smart cities, smart buildings, smart cars and, perhaps, even through sensors on or in their bodies, and the IoT is one of the foundational platforms on which this notion of the “connected person” is predicated. The IoT figures to touch all, and, so, all voices must be heard for the monumental benefits promised in the connected-person vision to  be fully realized.

Think of Smart Home or City!!
Connected homes will be the largest sector for IoT,.In future its estimated to be a $490 billion market, which is probably why Google acquired Nest (smart thermostat makers) for $3.2 billion. Well, chances  say that after few years from now, percent of consumers will own a smart watch or smart refrigerator etc. According  to a different survey, more than two-thirds of consumers plan to buy IoT technology for their homes.

Witnessed What GE says?
GE says that if IoT technology can make oil and gas exploration and development even 1 percent more efficient, they can save $90 billion and technology for industry has the potential to add $10 to $15 trillion to global GDP over the next 20 years.

Coolest IoT Gadgets:
Google Glass is a wearable head- mounted gadget from Google with a unique optical display, which provides users with a peripheral vision on being attached with especially designed lightweight glass frame.

Google Driver-less cars will generate $5.6 trillion in savings worldwide.

The Apple Watch is a slim and sleek gadget from this ace smart phone manufacturing company and it is capable of communicating and syncing with all the iOS powered devices without the need for any wired connections.
So What are your thoughts on the Internet of Things? Do you already own a smart device??
“If you think that the internet has changed your life, think again. The IoT is about to change it all over again!
STAY CONNECTED
                                                                                           By

                                                                                                     Vyjayanthi 
Read more ...