The Flora Client is an AWS IoT client to enable the measurement and submission of sensor data to the Flora Backend.
Future Enhancements
- Automatic client registration
- Multichannel MQTT distribution
- OTA update capability
- Device configuration settings (e.g. C/F temperature settings)
Attach an Adafruit Soil Sensor, Atmospheric Sensor, and Light Sensor to your pi's I2C interface. Verify each sensor individually utilizing the Adafruit documentation before proceeding with setup.
git clone https://github.com/Brandon-Galloway/Flora-Client.gitpip install -r requirements.txtNavigate to AWS IoT Core and then to:
Manage -> All devices -> Things
Select "Create Things" and proceed to create a new thing, selecting "Auto-generate a new certificate" and attaching the "Flora_Policy" previously configured during backend deployment.
When prompted, download the supplied private key, public key, certificate, and AmazonRootCA1 files provided and place them in a /certs directory below the project root with the names AmazonRootCA1.pem, cert.pem, private.key, and public.key
Create a config.ini file in the project root following the below format:
[aws]
iot_endpoint =
thing_name =
[flora]
serial_number =
Your AWS IoT endpoint can be found under Settings. Security policy may need to be adjusted. thing_name should be set to the above-configured thing name and serial_number can be any unique string, though the UUID V4 format is suggested.
On your pi run crontab -e and add the entries below:
0 0 * * * echo -n > SCRIPT_DIR/output.log
*/5 * * * * /usr/bin/python3 SCRIPT_DIR/flora_client_upload.py >> SCRIPT_DIR/output.log 2>&1This will schedule your pi to run the flora_client_upload script once every 5 minutes, logging the results each time and clearing the log file at midnight.
Following these steps, your pi should now be able to run the flora client and publish data to AWS IoT. To troubleshoot issues, the client can be manually ran and verified.
*Note the I2C interface does NOT support simulanious multi-connection to sensors. If two instances of the script are executed in parallel they will not complete succesfully.
Brandon Galloway