[go: up one dir, main page]

0% found this document useful (0 votes)
83 views12 pages

DHT11 Thinkspeak

The document discusses configuring the ESP8266 microcontroller to send sensor data from a DHT11 temperature and humidity sensor to the ThingSpeak cloud platform. It provides steps to set up a ThingSpeak account and channel to receive and visualize the sensor data. It also outlines connecting the DHT11 sensor to the ESP8266 and writing code to read the sensor values, connect to WiFi, and post the data to the ThingSpeak channel.

Uploaded by

Malathi John
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views12 pages

DHT11 Thinkspeak

The document discusses configuring the ESP8266 microcontroller to send sensor data from a DHT11 temperature and humidity sensor to the ThingSpeak cloud platform. It provides steps to set up a ThingSpeak account and channel to receive and visualize the sensor data. It also outlines connecting the DHT11 sensor to the ESP8266 and writing code to read the sensor values, connect to WiFi, and post the data to the ThingSpeak channel.

Uploaded by

Malathi John
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

DAY 4 /SESSION 3

ESP8266 & ThingSpeak Cloud Platform


Overall Diagram:

Thingspeak:
ThingSpeak is an open-source IoT analytics platform service which allows users to
communicate with internet enabled devices. It facilitates data access, retrieval and logging of
data by providing an API to both the devices and social network websites. It allows users to
aggregate, visualize, and analyze live data streams in the cloud. The user can send data to
ThingSpeak from any device(ESP8266), create instant visualizations of live data, and send
alerts using web services like Twitter and Twilio. With MATLAB analytics inside ThingSpeak,
you can write and execute MATLAB code to perform preprocessing, visualizations, and
analyses. ThingSpeak enables engineers and scientists to prototype and build IoT systems
without setting up servers or developing web software.
DHT11:

DHT11 Image with Pin Details


DHT11 digital temperature and humidity sensor is a composite Sensor contains a calibrated
digital signal output of the temperature and humidity. Application of a dedicated digital modules
collection technology and the temperature and humidity sensing technology, to ensure that the
product has high reliability and excellent long-term stability. The sensor includes a resistive
sense of wet components and an NTC temperature measurement device, and connected with a
high-performance 8-bit microcontroller.
Data Format:
DHT11 uses a simplified single-bus communication. Single bus that has only one data line, the
system of data exchange, controlled by a single bus to complete. Device (master or slave)
through an open-drain or tri-state port connected to the data line to allow the device does not
send data to release the bus, while other devices use the bus; single bus usually require an
external one about 5.1kΩ pull-up resistor, so that when the bus is idle, its status is high.
Because they are the master-slave structure, and only when the host calls the slave, the slave
can answer, the host access devices must strictly follow the single-bus sequence, if the chaotic
sequence, the device will not respond to the host.
Single bus to transfer data defined DATA For communication and synchronization between the
microprocessor and DHT11, single-bus data format, a transmission of 40 data (The 8bit
humidity integer data + 8bit the Humidity decimal data +8 bit temperature integer data + 8bit
fractional temperature data +8 bit parity bit)
Steps to be followed to configure ThingSpeak:
Step – 1

Visit www.thingspeak.com.

Step - 2
Go with Get started for free
Step – 3
Create new account ( Click Create one)
Step – 4
1. Enter your mail id to create new ThingSpeak account
2. Enter your Location
3. Enter your First name and last name
4. Click Continue to next step

Step – 5
Need to verify your mail the verification mail is sent to your mail id
Click verify email
Step - 6
Click Continue after email verification

Step – 7
Choose Language

Step – 8
Profile verification done
Step – 9
Enter your password ThingSpeak account and give continue

Step – 10
ThingSpeak Sign-up completed success full
Click ok to continue

Step – 11
Choose Intent Usage of ThingSpeak and click ok
Step – 12
1. Account creation done
2. Need to create Channels to implement projects
3. Click New Channel to create new channel

Step – 13
1. Assign a name to the new channel
2. Inside the channel we can create Field Selecting the Field
3. Click Save Channel
Step – 14
1. Channel and field are created
2. You can see the channel id in channel settings
Step – 15
1. The channel API key is Available in API Keys

Steps to Configure Arduino IDE for DHT sensor:


Step 1: Open your Arduino IDE and go to Sketch > Include Library > Manage Libraries. The
Library Manager should open.
Step 2: Search for “DHT” on the Search box and install the DHT library from Adafruit.
Step3: Search for “Adafruit Unified Sensor” on the Search box and install the library from
Adafruit.

Step4: Search for “thingspeak” on the Search box and install the library from mathwork.

Displaying Temperature and Humidity in ThingSpeak


#include <ESP8266WiFi.h>
#include "ThingSpeak.h"s
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#define DHTPIN 2 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT 11
const char* ssid = "XX"; // your network SSID (name)
const char* password = "XXXXX"; // your network password
int i = 0;
WiFiClient client;
unsigned long myChannelNumber = 1896491;
const char * myWriteAPIKey = "C66AJ46VR9V2M6AI";
// Timer variables
unsigned long lastTime = 0;
unsigned long timerDelay = 30000;
DHT_Unified dht(DHTPIN, DHTTYPE);
uint32_t delayMS;
void setup() {
Serial.begin(115200); //Initialize serial
WiFi.mode(WIFI_STA);
ThingSpeak.begin(client); // Initialize ThingSpeak
dht.begin();
}
void loop() {
int temp,hum;
for (i = 0; i < 50; i++)
{
if ((millis() - lastTime) > timerDelay) {
// Connect or reconnect to WiFi
if (WiFi.status() != WL_CONNECTED) {
Serial.print("Attempting to connect");
while (WiFi.status() != WL_CONNECTED) {
WiFi.begin(ssid, password);
delay(5000);
}
Serial.println("\nConnected.");
}

// Get temperature event and print its value.


sensors_event_t event;
dht.temperature().getEvent(&event);
if (isnan(event.temperature)) {
Serial.println(F("Error reading temperature!"));
}
else {
Serial.print(F("Temperature: "));
Serial.print(event.temperature);
temp=event.temperature;
Serial.println(F("°C"));
}
// Get humidity event and print its value.
dht.humidity().getEvent(&event);
if (isnan(event.relative_humidity)) {
Serial.println(F("Error reading humidity!"));
}
else {
Serial.print(F("Humidity: "));
Serial.print(event.relative_humidity);
hum=event.temperature;
Serial.println(F("%"));
}
ThingSpeak.setField(1, temp);
ThingSpeak.setField(2, hum);
int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
if (x == 200) {
Serial.println("Channel update successful.");
}
else {
Serial.println("Problem updating channel. HTTP error code " + String(x));
}
lastTime = millis();
}
}
}

Pin Connection:

ESP8266 DHT11

GPIO2 (D4) DATA

3.3V Vcc

Gnd Gnd

You might also like