nodeMCU based moisture monitoring for plants 🌱 with a serverless backend
The hardware setup consists of a ESP8266 Microcontroller with a powersupply and two connected sensors.
To program the ESP8266 you need to clear the connection to RST
~80mA
when active and few µA
when in deepsleep12mA
10kOhm
resistor -> 3V3 / 10kOhm = 33mA
35mA
2.5mA
The ESP8266 chip is programmed with the esp8266.ino file using the Arduino IDE. Secrets for connecting to local WiFi and endpoints to post data need to be defined in a esp8266.secrets.c
file which is specified at esp8266.secrets.template.c.
As a backend solution the plantbuddy runs on Google's firebase 🔥 platform. The main functionalities used from firebase are:
Note: As outbound traffic is required to collect weather data, the project should run in BLAZE plan. Function and database usage should be within the free tier, only outbound traffic will be billed.
Before deploying the backend code several variables need to be set so the service can work correctly. An API token for OpenWeatherMap can be obtained from their website. A free account should suffice unless a LOT of plantbuddies are running on one account.
firebase functions:config:set owm.key=<OpenWeatherMap API Token>
firebase functions:config:set owm.city_id=2873776 // according to [OWM City ID List](https://openweathermap.org/current#cityid)
firebase functions:config:set header.secret=<some secret>
For developing the function locally:
# get a copy of the environment config
firebase functions:config:get > functions/.runtimeconfig.json
# start function host locally
firebase serve --only functions
All the Firebase stuff gets automatically deployed via Travis CI. To set it up create a encrypted token and update the Travis CI Config.
# create a firebase CI token
firebase login:ci
# encrypt the token to your project
docker run --rm caktux/travis-cli encrypt "<token from firebase login:ci>" -r anoff/plantbuddy