05 January, 2019

Raspberry Pi and 3d printed Rain meter - Part 3 - Solution Structure

In this part I will briefly describe my solution / architecture.

Broadly speaking this is my overall use case:The Raspbeery pi will take the measurements. The Contabo (Ubuntu) server will use these measurements and formulate the rainfall, and make it available for consumption onto the internet (Example: Web page, API, SMS Telegram Bot)
Something must be built to check if the Raspberry Pi is up and running, and user (me) alerted when not able to be reached.

In future more more sensor data can be added.
This is my solution for the Raspberry Pi:
  1. SQLite database to store the tips.
  2. Command line program (aka sensorDeamon) that will be systemded to listen and save the tips to the db.
  3. The SensorDeamon will also send out an alert that a tip has occurred.
  4. An nginx hosted API to give remote access to the SQLite data.
This is my solution for the Ubuntu server
  1. An nginx hosted API that will listen for alerts.
  2. On receiving an alert it will go and retrieve all data since last retrieval from the RPi.
  3. Do the calculations, and store data in Postgres database.
  4. Make this data available via:
    1. SMS  (Send me an alert when it starts raining)
    2. Web   (So I am other people can view the info and history)
    3. API    (Other systems can query my data)
    4. Telegram (Get alerts and stats via telegram
  5. I would have loved to have done something for Whats app, but there is no public API available for it.
This is my proposed directory structure on the Pi:
  •  sensorpi
    • configs
    • database
      • scripts
    • sensordeamon
    • webapi
Some notes on the above structure:
  1. sensorpi just holds the whole solution in one place.
  2. configs folder will contain the configuration settings for:
    1. sensordaemon, and
    2. webapi
  3. This will allow me to put the source code onto git without revealing my private passwords and settings.
  4. Since the database only exists on the Pi and I dont have a dev I will put the database script in a sub folder and shell file for me to recreate it as needed.
  5. sensordeamon wfolder will contain the command line app that listens to the tips.
  6. webapi will allow remote access (from the Ubuntu server) to my database.

No comments: