Skip to content

Python Script for logging the humidity and the temperature 🌡️ on a Date Base (MySQL/MariaDB) from a DHT22 sensor

License

Notifications You must be signed in to change notification settings

bicconess-swteam/dht22-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Temperature and Humidity 🌡️

This is a Python Script for logging the humidity and the temperature on a Date Base (MySQL/MariaDB) from a DHT22 sensor.

Requirements

Instalation

For this project we need to have the Adafruit library installed on our raspberry.

Create a new user on our SQL Database.

CREATE USER 'username'@'localhost' IDENTIFIED BY 'pass';

Create a new database.

CREATE DATABASE DHT22;

Permissions to our user for that database.

GRANT ALL PRIVILEGES ON *.* TO ‘username’@‘localhost’;

Create a new table where we save this information.

CREATE TABLE Reading (
    id INT AUTO_INCREMENT NOT NULL,
	date DATETIME NOT NULL,
	temperature DECIMAL(5,2) NOT NULL,
	humidity DECIMAL(5,2) NOT NULL,
	PRIMARY KEY (id)
	);

Now, if we execute the script, we have in our database the information of humidity and temperature, but...What happens if we want this to be done automatically? We could use the crontab file to automate this process!!!😎😎

crontab -e

And in this file we want to create a new line with our service. For example:

*/5 * * * *  /home/pi/Development/dht22-logger/logger-temp-hum.py &> /dev/null

About

Python Script for logging the humidity and the temperature 🌡️ on a Date Base (MySQL/MariaDB) from a DHT22 sensor

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages