64 lines
1.7 KiB
Markdown
64 lines
1.7 KiB
Markdown
# dht22 Temperature Stats
|
|
|
|
## Raspberry Pi
|
|
|
|
### Dependencies
|
|
|
|
`apt install mariadb-server mariadb-client libmariadbclient-dev libmariadbclient-dev-compat libconfig-dev wiringpi libcurl4-openssl-dev (-s)`
|
|
|
|
### mySQL
|
|
|
|
Login: `mysql --user=root --password=password`
|
|
|
|
Creating new user: `create user 'dhtuser'@'localhost' IDENTIFIED BY 'raspberry';`
|
|
|
|
Permissions: `grant all privileges on *.* to 'dhtuser'@'localhost';`
|
|
|
|
Create database: `create database dhtstats;`
|
|
|
|
Use database: `use dhtstats`
|
|
|
|
Create new table:
|
|
```
|
|
CREATE TABLE stats (id MEDIUMINT NOT NULL AUTO_INCREMENT, node_id int not null, pin int not null, humidity FLOAT NOT NULL, temperature FLOAT NOT NULL, isoutside int not null, gm3 float not null, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id) );
|
|
```
|
|
and
|
|
```
|
|
CREATE TABLE average_stats (id MEDIUMINT NOT NULL AUTO_INCREMENT, humidity FLOAT NOT NULL, temperature FLOAT NOT NULL, gm3 float not null, isoutside int not null, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id) );
|
|
```
|
|
|
|
|
|
|
|
|
|
Show all entries in table: `select * from stats;`
|
|
|
|
### Compile & Install
|
|
|
|
To compile and install humidityPi use this oneliner: `make && make install`
|
|
|
|
### Configuration
|
|
|
|
#### Settings
|
|
|
|
The settings file ist located under `/etc/humiditypi/settings.cfg`
|
|
|
|
#### Cronjob
|
|
|
|
If you like to run humidityPi in a desired time intervall you can enable a cronjob by entering `crontab -e` and paste the following to the bottom of the text file:
|
|
|
|
``` bash
|
|
#Cronjob that will repeat every minute
|
|
#Pipe the output to /dev/null to suppress mails from cron
|
|
* * * * * humiditypi > /dev/null
|
|
```
|
|
|
|
|
|
### ESP-8266
|
|
[aRest](https://github.com/marcoschwartz/aREST)
|
|
|
|
|
|
# Used sources
|
|
|
|
[cJSON](https://github.com/DaveGamble/cJSON)
|
|
|