Giter Site home page Giter Site logo

starnop / plantbuddy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anoff/plantbuddy

0.0 2.0 0.0 1.13 MB

nodeMCU based moisture monitoring for plants ๐ŸŒฑ with a serverless backend

Home Page: https://plantbuddy.site

C++ 9.76% C 0.60% JavaScript 62.28% HTML 1.45% Vue 25.90%

plantbuddy's Introduction

plantbuddy

nodeMCU based moisture monitoring for plants ๐ŸŒฑ with a serverless backend

Main Features

  1. Collect sensor readings every 5 minutes
  2. Submit values to serverless infrastructure using local WiFi network
  3. Automatically fetch weather report for each reading using backend function
  4. later have a UI as well ๐Ÿ™„

system overview

Hardware

The hardware setup consists of a ESP8266 Microcontroller with a powersupply and two connected sensors.

  • DHT22 connected to D2 digital input pin
  • Soil moisture sensor connected to A0
  • Bridge between D0 and RST to enable deep sleep for optimizing battery life
  • switch off sensors during deepsleep using a transistor driven via pin D1

To program the ESP8266 you need to clear the connection to RST

Fritzing diagram

Power consumption

  • ESP8266 draws ~80mA when active and few ยตA when in deepsleep
  • Maximum output current per GPIO pin is 12mA
  • Photo resistor has 10kOhm resistor -> 3V3 / 10kOhm = 33mA
  • Moisture sensor consumes 35mA
  • DHT222 max current 2.5mA

Microcontroller

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.

esp8266 flowchart

Setup

Serverless backend

As a backend solution the plantbuddy runs on Google's firebase ๐Ÿ”ฅ platform. The main functionalities used from firebase are:

  1. Firestore database to store all sensor readings and heartbeats
  2. Firebase functions for providing an HTTP endpoint as well as querying for weather data for each sensor reading

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.

Backend code

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>

Local development

For devleoping 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

Deployment

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

Useful links

plantbuddy's People

Contributors

anoff avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.