Nextcloud / Owncloud sensorlogger python example script using urllib3 Example for extended data
- calculation of dew point (temperature / humidity required)
- Python 3 with urllib3 and Adafruit_DHT installed
- Sensor (e.g. DHT22) connected to Raspberry Pi
-
Nextcloud: install sensorlogger plugin
-
Nextcloud: generate device password: https://docs.nextcloud.com/server/15/user_manual/session_management.html#managing-devices
-
First edit register.py:
- invent deviceId
- add URL to the sensorlogger api endpoint (must end with /)
- nextcloud username and (2.) generated device password
- edit the payload section to match with your configuration (e.g. different data types)
-
Run register.py once (You should see successful response message.)
-
The response message should contain an index for each individual data type you specified (1, 2, 3 - one for each data type)
-
Edit senddata.py:
- same deviceId as in register.py
- url to api endpoint (/createlog/ with / at the end)
- change your sensor type (if != DHT22)
- set your sensor pin to the one the sensor is connected to
- edit payload to match with the description of the data types in register.py and the indices from the response message
- edit username and device passwort
- Run senddata.py and in your Nextcloud instance you should see the new values being uploaded.
- To run at startup:
sudo crontab -e
Add at the bottom:@reboot python3 /path/to/your/script/senddata.py &