Visualizing Temperature and Humidity Data using ESP8266 in Cayenne

by Oct 6, 2023nodemcu projects

Temperature and humidity play crucial roles in industrial processes, and monitoring and controlling them is essential for optimal production conditions. Temperature and humidity sensors are deployed in process control systems to uphold specific environmental parameters. This is critical for maintaining product quality, ensuring safety, and optimizing operational efficiency within production settings. For example, in a chemical manufacturing plant, these sensors are employed to oversee conditions during chemical reactions, guaranteeing that reactions progress as intended and resulting in the desired product quality.

Additionally, temperature and humidity sensors are integral components of closed-loop control systems, offering feedback to the control system to autonomously adjust temperature and humidity levels and sustain desired setpoints. Such control systems are prevalent in HVAC setups, where temperature and humidity sensors help maintain optimal indoor conditions. In summary, temperature and humidity sensors serve as indispensable tools for process control across diverse industries, empowering manufacturers to streamline production processes, enhance quality control, and prioritize worker safety.


List of Components

  1. DHT-11 SENSOR
  2. JUMPER WIRES
  3. ESP8266 WIFI MODULE
  4. CONNECTING WIRES

DHT-11 sensor

The DHT-11 sensor, a widely utilized and cost-effective digital temperature and humidity sensor, interfaces seamlessly with popular microcontrollers like Arduino and Raspberry Pi. It accurately measures temperatures within the range of 0°C to 50°C with an accuracy of ±2°C, as well as humidity ranging from 20% to 90% RH with an accuracy of ±5% RH, making it a favored choice among hobbyists and developers.

The DHT-11 sensor functions by utilizing a thermistor and a capacitive humidity sensor to measure temperature and humidity, respectively. The thermistor gauges temperature by changing its resistance in response to temperature variations, while the capacitive humidity sensor assesses humidity by monitoring changes in the capacitance of a thin polymer film.

Notably, the DHT-11 sensor simplifies its integration with microcontrollers through a single-wire digital interface. Communication between the sensor and the microcontroller occurs using the 1-wire protocol, employing a single data wire. This approach results in a straightforward and user-friendly interface for sensor utilization and data retrieval.

Jumper wires

Jumper wires, fundamental components in electronics projects, enable the connection of various components with ease due to their flexible nature and connectors at both ends. These wires establish either temporary or permanent connections within a circuit, whether on a breadboard, prototyping board, or in a finalized circuit.

ESP8266

The ESP8266 is an affordable microcontroller with built-in Wi-Fi, perfect for IoT projects. It utilizes a powerful 32-bit microcontroller and the ESP8266 chip, allowing programming in various environments like Arduino IDE and Lua scripting. The module offers multiple GPIO pins, simplifying connections to sensors, actuators, and devices, enabling smooth Wi-Fi communication through HTTP, MQTT, and more.

Both DIY electronics enthusiasts and professionals appreciate the ESP8266 module for its cost-effectiveness and adaptability in IoT projects. Its versatility makes it ideal for diverse applications, including smart home devices and remote monitoring systems, demanding both Wi-Fi connectivity and microcontroller functionality. In summary, the ESP8266 module is a versatile tool for Wi-Fi enabled IoT projects, appealing to hobbyists and professionals for its cost-effectiveness and flexibility.

Schematic Diagram

MQTT

MQTT, or Message Queuing Telemetry Transport, is a lightweight and efficient messaging protocol widely used in IoT (Internet of Things) and connected devices. It facilitates seamless communication between devices, allowing for real-time data exchange and synchronization. MQTT operates on a client-server architecture and employs a publish-subscribe model, enabling multiple clients to subscribe to specific topics and receive updates when relevant data is published. This makes it an ideal choice for applications demanding low bandwidth, high reliability, and minimal overhead. Implementing MQTT ensures efficient data transmission, making it a fundamental protocol in building robust IoT ecosystems.

Methodology for Temperature and Humidity Monitoring using DHT11 and ESP8266:

To set up a temperature and humidity monitoring system, you will need essential components: jumper wires, a DHT11 temperature and humidity sensor, an ESP8266 module, and a USB cable.

  1. Connections:
    • Connect the GND pin of the DHT11 sensor to the GND pin of the ESP8266 module.
    • Connect the VCC pin of the DHT11 sensor to the 3.3V pin of the ESP8266 module.
    • Connect any GPIO pin on the ESP8266 module to the DATA pin of the DHT11 sensor.
    • The NC (Not Connected) pin of the DHT11 sensor remains unconnected.
  2. Programming:
    • Use the Arduino IDE to program the ESP8266 module.
    • Utilize the DHT library to read temperature and humidity data from the DHT11 sensor.
    • Write a program that acquires temperature and humidity information from the DHT11 sensor and transmits it to a cloud-based platform like Cayenne.
  3. Uploading Program:
    • Connect the ESP8266 module to your computer using the USB cable.
    • Open the Arduino IDE and load the program.
    • Upload the program to the ESP8266 module.

By following this methodology, you will have a functional temperature and humidity monitoring system using the DHT11 sensor, ESP8266 module, and Arduino IDE, transmitting data to a cloud-based platform for further analysis and monitoring.

Cayenne


Cayenne is a user-friendly cloud platform widely used for IoT applications. It offers a simple and intuitive interface that allows users to visualize and analyze data from connected devices easily. Cayenne supports a variety of devices and microcontrollers, making it versatile and adaptable for different projects. With Cayenne, users can create custom dashboards, set triggers, and automate actions based on sensor data, providing a comprehensive solution for monitoring and control. This platform facilitates seamless integration of IoT devices into one unified system, making it a preferred choice for both beginners and experienced IoT enthusiasts.

Code

/*
Cayenne DHT11 Sensor Project
*/
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#define DHTPIN 0 // D3
/ Uncomment whatever type you're using! In this project we used DHT11
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21 // DHT 21, AM2301
#include <CayenneMQTTESP8266.h>
#include <DHT.h>
/ WiFi network info.
char ssid[] = "xxxxx";
char wifiPassword[] = "xxxxx";
Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "dfsfdfdfs";
char password[] = "sdsdsd";
char clientID[] = "dsdsdsd";
DHT dht(DHTPIN, DHTTYPE);
/Variables for DHT11 values
float h;
float t;
bool humidity = false;
bool Temperature = false;
void setup()
{
Serial.begin(9600);
Serial.print("Setup");
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
humidity = false;
Temperature = false;
}
void loop()
{
//Run Cayenne Functions
Cayenne.loop();
}
CAYENNE_OUT(V0){
//Serial.println("humidity");
//Check if read failed and try until success
do {
//Read humidity (percent)
h = dht.readHumidity();
delay(1000);
} while (isnan(h));
Serial.print("humidity: ");
Serial.println(h);
//Set Humidity to true so we know when to sleep
humidity = true;
//Write to Cayenne Dashboard`
Cayenne.virtualWrite(V0, h);
}
CAYENNE_OUT(V1){
//Serial.println("temperature");
//Check if read failed and try until success
do {
//Read temperature as Celsius
t = dht.readTemperature();
delay(1000);
} while (isnan(t));
Serial.print("temperature: ");
Serial.println(t);
//Set Temperature to true so we know when to sleep
//Temperature = true;
//Write to Cayenne Dashboard
Cayenne.virtualWrite(V1, t);
}

Results

Creating a multiplication Skill in Alexa using python

Written By Monisha Macharla

Hi, I'm Monisha. I am a tech blogger and a hobbyist. I am eager to learn and explore tech related stuff! also, I wanted to deliver you the same as much as the simpler way with more informative content. I generally appreciate learning by doing, rather than only learning. Thank you for reading my blog! Happy learning!

RELATED POSTS

Smart Traffic Light System using NodeMCU(ESP32)

Smart Traffic Light System using NodeMCU(ESP32)

In this tutorial, we are going to make an IoT based Smart Traffic Light system. We will connect the lights by using ESP32. Let's begin! Contents: IntroductionMaterials RequiredThe CircuitCode and it's ExplanationThe Final Run Introduction First of all, we will create...

4×4 Keypad Door Lock using NodeMCU with E-Mail Alerts

4×4 Keypad Door Lock using NodeMCU with E-Mail Alerts

This project will show you how to interface a 4x4 Keypad with the NodeMCU to make a simple code-based door lock. Entering the wrong code three times in a row or changing the existing code will send an E-mail alert to the specified recipient or the owner of the...

VIDEOS – FOLLOW US ON YOUTUBE

EXPLORE OUR IOT PROJECTS

IoT Smart Gardening System – ESP8266, MQTT, Adafruit IO

Gardening is always a very calming pastime. However, our gardens' plants may not always receive the care they require due to our active lifestyles. What if we could remotely keep an eye on their health and provide them with the attention they require? In this article,...

How to Simulate IoT projects using Cisco Packet Tracer

In this tutorial, let's learn how to simulate the IoT project using the Cisco packet tracer. As an example, we shall build a simple Home Automation project to control and monitor devices. Introduction Firstly, let's quickly look at the overview of the software. Packet...

All you need to know about integrating NodeMCU with Ubidots over MQTT

In this tutorial, let's discuss Integrating NodeMCU and Ubidots IoT platform. As an illustration, we shall interface the DHT11 sensor to monitor temperature and Humidity. Additionally, an led bulb is controlled using the dashboard. Besides, the implementation will be...

All you need to know about integrating NodeMCU with Ubidots over Https

In this tutorial, let's discuss Integrating NodeMCU and Ubidots IoT platform. As an illustration, we shall interface the DHT11 sensor to monitor temperature and Humidity. Additionally, an led bulb is controlled using the dashboard. Besides, the implementation will be...

How to design a Wireless Blind Stick using nRF24L01 Module?

Introduction Let's learn to design a low-cost wireless blind stick using the nRF24L01 transceiver module. So the complete project is divided into the transmitter part and receiver part. Thus, the Transmitter part consists of an Arduino Nano microcontroller, ultrasonic...

Sending Temperature data to ThingSpeak Cloud and Visualize

In this article, we are going to learn “How to send temperature data to ThingSpeak Cloud?”. We can then visualize the temperature data uploaded to ThingSpeak Cloud anywhere in the world. But "What is ThingSpeak?” ThingSpeak is an open-source IoT platform that allows...

Amaze your friend with latest tricks of Raspberry Pi and Firebase

Introduction to our Raspberry Pi and Firebase trick Let me introduce you to the latest trick of Raspberry Pi and Firebase we'll be using to fool them. It begins with a small circuit to connect a temperature sensor and an Infrared sensor with Raspberry Pi. The circuit...

How to implement Machine Learning on IoT based Data?

Introduction The industrial scope for the convergence of the Internet of Things(IoT) and Machine learning(ML) is wide and informative. IoT renders an enormous amount of data from various sensors. On the other hand, ML opens up insight hidden in the acquired data....

Smart Display Board based on IoT and Google Firebase

Introduction In this tutorial, we are going to build a Smart Display Board based on IoT and Google Firebase by using NodeMCU8266 (or you can even use NodeMCU32) and LCD. Generally, in shops, hotels, offices, railway stations, notice/ display boards are used. They are...

Smart Gardening System – GO GREEN Project

Automation of farm activities can transform agricultural domain from being manual into a dynamic field to yield higher production with less human intervention. The project Green is developed to manage farms using modern information and communication technologies....