RESTcatalog.py
- Home server, uses GET, PUT,POST to send and process data
- Deploys freeboard
- Publishes ip using mqtt
- Stores data in data.json,devices.json,users.json.
device_connector.py
- Must be run on raspberry pi
- Uses Adafruit_DHT, RPi.GPIO libraries
- Reads sensor data, publishes to respective mqtt topics.
emulatedsoilpub.py
- Mqtt publisher and subscriber.
- Depends on temp, humidity and waterflow.
simplepub.py
- Bare bones publisher, used in RESTcatalog, emulatedsoilpub, device_connector, watering system
simplesub.py
- Bare bones subscriber, used in device_connector, thingspeakConnector,emulatedsoilpub
thingspeakConnector.py
- Displays all the values over time
- Mqtt subscriber to all of the topics, POST data to thingspeak
- https://thingspeak.com/channels/1011118
- saves data to data.json (currently a workaround, but works)
alarm_controller.py
- ●● Mqtt publisher and subscriber
- ●● Subscribes to 'Motion' and 'Temperature' topics data, publishes to 'alarm' topic if a movement is detected or temperature too high
watering_system.py
- Mqtt subscriber
- Subscribes to mqtt topics and controls the waterflow, to keep the soilhumidity at a good level.
- Subscribes to 'Motion' topic and stop the waterflow if a movement is detected.
**dataCollector.py **
- subscribes to mqtt topics and connects the telegram bot
wheatherController.py
- connetcs to an external wheater forecast API
- publishes to wheathertopic
freeboard
- Displays Current temperature, humidity, waterflow and soilhumidity.
- GET requests to home server to get data
- POST requests to save dashboard
Wheater topic
polito/01QWRBH/SmartFarm/weatherForecast
mqtt publisher of the wheater forecast
ex json:
{"three": 0, "six": 0, "nine": 1, "twelve": 1, "fifteen": 1, "eighteen": 1, "twenty_one": 1, "twenty_four": 1}
Alarm topic:
polito/01QWRBH/SmartFarm/device1/sensors/alarm
Json only if alarm is raised. Ex:
{'nature': 'Temperature', 'Value': '19.0', 'time': '2020-03-16 17:18:51.008323'}
Humidity topic
polito/01QWRBH/SmartFarm/device1/sensors/humidity
Float every 5.
Soil humidity topic:
polito/01QWRBH/SmartFarm/device1/sensors/soilhumidity
Float every 5, emulated value.
Temp topic:
polito/01QWRBH/SmartFarm/device1/sensors/temperature
Float every 5 seconds
Motion topic:
polito/01QWRBH/SmartFarm/device1/sensors/motion
Bool every 5 seconds, True if motion detected
Ip topic:
polito/01QWRBH/SmartFarm/home/ip
String every 5. Ip of home server
Used for initializing a new connection.
Waterflow topic:
polito/01QWRBH/SmartFarm/device1/outputs/waterflow
Float every 5.
- cherrypy
- json
- paho.mqtt.client
- time
- threading
- from os.path import abspath
- socket
- requests
- math
- from telegram.ext import Updater, CommandHandler
- urllib
- datetime
- Adafruit_DHT
- RPi.GPIO