The DHT22 sensor is a popular digital temperature and humidity sensor used in various electronic projects and applications. Also known as the AM2302, it's capable of measuring both temperature and humidity with high accuracy and reliability.
To send temperature and humidity measured by DHT22 from an Arduino board to a smartphone via Bluetooth, you can use Bluetooth modules like HC-06 and establish a serial communication link between the Arduino and the smartphone.
Components Needed:
Arduino board (e.g., Arduino Uno)
DHT22 sensor
HC-05 or HC-06 Bluetooth module
Jumper wires
Smartphone with a Bluetooth terminal app (e.g., Arduino Bluetooth Terminal)
Hardware Setup: Connect the Bluetooth module and DHT22 sensor to the Arduino.
Arduino Setup: Upload the necessary program to the Arduino board for sending data
Smartphone Setup:
1- Create a mobile app with App Inventor to receive data from the Arduino board via Bluetooth
2- Install this application on your smartphone
Testing:
1- Upload the Arduino code to your board.
2- Open the serial monitor to see the sensor values (optional).
3- Open the Bluetooth terminal app on your smartphone and connect to the Bluetooth module.
4- You should start receiving temperature and humidity data on your smartphone from the Arduino.
To display the temperature and humidity readings from the DHT22 sensor on smartphone using an Arduino, you'll need the following components:
Arduino UNO Board
The Arduino Uno board is a microcontroller board based on the ATmega328P microcontroller. It's one of the most popular and widely used boards in the Arduino family due to its simplicity and versatility.
It is the central control unit for your project.
HC-06 module bluetooth
The HC-06 Bluetooth module is a commonly used serial communication module that enables Bluetooth connectivity for various projects, including Arduino-based systems. It acts as a serial port Bluetooth module, allowing wireless communication between devices.
This module is used for sending the temperature and humidity from the DHT22 sensor to smartphone.
DHT22 sensor:
The DHT22 sensor is commonly used in weather stations, environmental monitoring systems, home automation projects, and wherever precise temperature and humidity measurements are required. Its relatively low cost and ease of use contribute to its popularity among hobbyists and professionals alike.
Jumper Wires:
For making temporary connections and wiring between components.
Breadboard:
A breadboard is a useful tool for creating temporary electronic circuits. It allows you to connect components without soldering .
To assemble the Arduino board with the DHT22 sensor and HC-06 Bluetooth module, follow these steps:
1- Connect the DHT22 Sensor to Arduino:
- (+) pin of DHT22 sensor to 3V3 pin of Arduino
- (-) pin of DHT22 sensor to GND pin of Arduino
- OUT pin of DHT22 sensor to digital pin 2 of Arduino
2- Connect the HC-06 Bluetooth Module to Arduino:
- VCC of HC-06 module to 5V pin of Arduino
- GND of HC-06 module to GND pin of Arduino
- TXD of HC-06 module to pin 6 of Arduino
- RXD of HC-06 to pin 7 of Arduino
Here's an example Arduino code using the dhtlib library for the DHT22 sensor and SoftwareSerial library for Bluetooth communication:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
#include <SoftwareSerial.h> #include <dht.h> #define dataPin 2 // Defines pin number to which the sensor is connected dht DHT; // Creats a DHT object // connecter le module HC-06 a l'Arduino SoftwareSerial hc06(6,7); void setup(){ hc06.begin(9600); } void loop(){ // read the data measured by the DHT22 sensor int readData = DHT.read22(dataPin); // DHT22/AM2302 float t = DHT.temperature; // Gets the values of the temperature float h = DHT.humidity; // Gets the values of the humidity delay(1000); // sends a message containing the temperature and humidity to the smartphone hc06.print((int)t*100+(int)h); } |
Use this code to program the Arduino. This code reads data from the DHT22 sensor and sends it via Bluetooth using the HC-06 module.
MIT App Inventor is a web-based visual development environment that allows users to create mobile applications for Android devices. It uses a drag-and-drop interface, making it accessible for people without extensive programming experience.
Design the mobile application with App Inventor:
1- Open MIT App Inventor and create a new project.
2- Design your app interface. You might have labels to display temperature and humidity :
3- Connect to Bluetooth by adding a BluetoothClient1 component.
The "BluetoothClient1" component in MIT App Inventor allows you to create mobile applications that can connect to Bluetooth devices, such as serial Bluetooth modules (eg HC-06) connected to microcontrollers, Bluetooth audio devices, etc. . This extension facilitates communication with these devices using serial Bluetooth connections.
4- Add buttons or a timer to initiate the Bluetooth connection and data retrieval.
Programming part of the application with App Inventor
Receive and Display Data:
1- Starting with Android 12, Bluetooth permissions have been enhanced to improve security and user data protection. This is why we must declare the authorizations that your application needs in the AndroidManifest.xml file. For Bluetooth, you'll need to include ACCESS_FINE_LOCATION, BLUETOOTH_SCAN, and possibly BLUETOOTH_CONNECT permissions, depending on the features you're using.
2- Add the the necessary blocks to connect the smartphone to the HC-06 Bluetooth module
3- Implement logic to receive data from the Arduino through Bluetooth.
Download project Download application
1- Power on the Arduino and ensure it's transmitting data via Bluetooth.
2- Install the app on your smartphone.
3- Open the app, establish a Bluetooth connection, and start receiving and displaying temperature and humidity data from the Arduino.
This integration between Arduino IDE for programming the board and App Inventor for developing the smartphone app allows for a straightforward means of displaying sensor data wirelessly on your phone. Adjustments might be needed based on your specific app design and Bluetooth communication requirements.
Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.
Zaouiet Kontech-Jemmel-Monastir-Tunisia
+216 92 886 231
medaliprof@gmail.com
Robotic site created by MedAli-Teacher info