This commit is contained in:
Your Name
2025-01-30 11:42:02 +01:00
parent a8ca15505e
commit 578721a9f2
6 changed files with 156 additions and 23 deletions

View File

@@ -66,7 +66,7 @@ sudo chmod 777 /dev/ttyAMA*
## I2C
Decibel meter and BME280 is connected via I2C.
Decibel meter, BME280 and the RTC module (DS3231) is connected via I2C.
Need to activate by modifying `sudo nano /boot/firmware/config.txt`
@@ -82,14 +82,23 @@ sudo chmod 777 /dev/i2c-1
Attention: sometimes activation with config.txt do not work, you need to activate i2c with `sudo raspi-config` and go to "Interface" -> I2C -> enable.
I2C addresses: use `sudo i2cdetect -y 1` to check the connected devices.
### BME280
The python script is triggered by the main loop every minutes to get instant temp, hum and press values (no need to have a minute average).
BME280 address is 0x76.
### RTC module (DS3231)
### Noise sensor
As noise varies a lot, we keep the C program running every seconds to create a moving average for the last 60 seconds (we also gather max and min values).
To keep the script running at boot and stay on we create a systemd service
To keep the script running at boot and stay on we create a systemd service.
Nois sensor address is 0x48.
Create the service with `sudo nano /etc/systemd/system/sound_meter.service` and add:
```
@@ -151,11 +160,10 @@ And set the base URL for Sara R4 communication:
### With only 1 NPM
Loop every minutes to get the PM values and send it to the server:
Loop every minutes to get the PM values and send it to the server (we use flock to be sure the previous script is over before start the new one):
```
* * * * * /usr/bin/python3 /var/www/nebuleair_pro_4g/loop/1_NPM/send_data.py >> /var/www/nebuleair_pro_4g/logs/loop.log 2>&1
* * * * * flock -n /var/www/nebuleair_pro_4g/loop/1_NPM/send_data.lock /usr/bin/python3 /var/www/nebuleair_pro_4g/loop/1_NPM/send_data.py >> /var/www/nebuleair_pro_4g/logs/loop.log 2>&1
```
All in one:
@@ -164,7 +172,7 @@ All in one:
@reboot chmod 777 /dev/ttyAMA*
@reboot /var/www/nebuleair_pro_4g/boot_hotspot.sh >> /var/www/nebuleair_pro_4g/logs/app.log 2>&1
@reboot sleep 30 && /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_setURL.py ttyAMA2 data.nebuleair.fr >> /var/www/nebuleair_pro_4g/logs/app.log 2>&1
* * * * * /usr/bin/python3 /var/www/nebuleair_pro_4g/loop/1_NPM/send_data.py >> /var/www/nebuleair_pro_4g/logs/loop.log 2>&1
* * * * * flock -n /var/www/nebuleair_pro_4g/loop/1_NPM/send_data.lock /usr/bin/python3 /var/www/nebuleair_pro_4g/loop/1_NPM/send_data.py >> /var/www/nebuleair_pro_4g/logs/loop.log 2>&1
0 0 */2 * * > /var/www/nebuleair_pro_4g/logs/loop.log
```