A complete weather station for the Raspberry Pi, using forecast.io and adafruit sensors to log all weather data to a file which can be used for SPLUNK data analysis. I included the scroll pHAT from Pimoroni to display some of the weather data. There are also some examples shown who to make some nice outputs with string transformations. Some data is send to adafruit.io. perhaps you have to change the feed names and io-data to your individual likings. Read the adafruit.io api documentation for more details.
For controlling the adafruit BME280 sensor i added the necessary and lightly modified sensor and I2C driver, to get everything setup in python3. so please use python3 to run this.
Feel free to change it in any way you want... Sorry that the output is in german. The forecast.io data are also fetched in german. You can change it via the options string in the python script. Read the forecast.io api documentation for more details.
cd
git clone https://github.com/LoveBootCaptain/RPI-Weather-Log.git
cd RPI-Weather-Log
cp config.example.json config.json
sudo nano config.json
- Replace the
"xxxx..."
with your forecast.io-API-KEY in"FORECAST_IO_KEY"
. - Replace the
"xxxx..."
with your Adafruit.io-API-KEY in"ADAFRUIT_IO_KEY"
. - Change the size of the log file in
"LOG_SIZE"
(in Bytes). 10MB is default. - Change the number of log file backups in
"BACKUP_COUNT"
. 100 is default. - Change the refresh rate of weather data in
"REFRESH_RATE"
. 5min is default.
CTRL + S
for save and CTRL + X
for quit
sudo chmod +x rpi_weather_log.sh
make the .sh script executable, this will run as servicesudo mv rpi_weather_log.sh /etc/init.d/
move the script to /etc/init.d/ so it can be used in CLI
sudo shutdown -r now
reboot
To test if everything is set up correctly just try:
sudo python3 /home/pi/RPI-Weather_Log/rpi_weather_log.py
CTRL + C
to quit
If it works you can also try the service:
sudo service rpi_weather_log start
to startsudo service rpi_weather_log stop
to stopsudo service rpi_weather_log restart
to restartsudo service rpi_weather_log status
for status
If everything is working correctly you can run the service on boot with:
sudo update-rc.d rpi_weather_log defaults
for enabling start at bootsudo update-rc.d rpi_weather_log remove
for disabling start at boot
- adafruit for great open source code and hardware
- pimoroni for great open source code and hardware
- christian for his great splunk knowledge