GithubHelp home page GithubHelp logo

neoroy / sdg-controller Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 443 KB

ESP32 firmware to interface with the sensors and actuators in the SDG project

Home Page: https://www.protohaus.org/projekte/smart-digital-garden/

License: MIT License

C++ 99.67% C 0.33%

sdg-controller's Introduction

SDG Controller

Start Up

This is a controller's typical start up sequence (serial output):

  1. Read (or generate if unavailable) the stored UUID
  2. Connect to WiFi
  3. Ping the SDG server with its UUID or MAC
  4. Get the local IP address of the local coordinator
  5. Sync the local clock from an NTP server
  6. Connect to the coordinator's MQTT broker
  7. Register itself and its actions with the coordinator

Registration

The controller sends a JSON doc to the coordinator after connecting to its MQTT broker containing its

  • UUID
  • Action list

Actions

Actions are commands that can be sent via MQTT for the controllers to perform. It is formatted as:

action/<UUID>/<action-name>
action/a48b109f-975f-42e2-9962-a6fb752a1b6e/l293d_motor

The UUID specifies which controller should execute the action and the action name specifies which action should be executed. The payload is JSON formatted and an example for the pump action would be:

{"enable": {"name": "main_pump","power_percent": 44.3, }}

This tells the pump to activate for 40 seconds.

Formatting

The Google C++ code style is used. It is recommended to use clang-format to automatically format your code with the provided .clang-format file.

Temperature is 1-wire interface

Appendix

Start Up Output

a48b109f-975f-42e2-9962-a6fb752a1b6e
WiFi: Disconnected. Attempting to reconnect
WiFi: Attempting to connect to HasenbauOben
.
WiFi: Connected! IP address is 192.168.1.8
Send ping to: https://core.staging.openfarming.ai/api/v1/farms/controllers/ping/
{"uuid":"a48b109f-975f-42e2-9962-a6fb752a1b6e","wifi_mac_address":"30:AE:A4:45:C1:60"}
HTTP response code: 201
{"id": "6de4a1cb-8ff6-4d10-80e4-ba760240991c", "name": null, "wifi_mac_address": "30-AE-A4-45-C1-60", "external_ip_address": "112.134.232.78", "controller_type": "UNK"}

Waiting for NTP time sync:
Current time: Wed Dec 25 13:26:34 2019
Send ping to: https://core.staging.openfarming.ai/api/v1/farms/controllers/ping/
{"coordinator_local_ip_address": "192.168.1.102"}
Coordinator's local IP address: 192.168.1.102
192.168.1.102:1883
MQTT connecting to 192.168.1.102. Try #1
MQTT: Connected!
List of registered actions:
        pump

sdg-controller's People

Contributors

moritz89 avatar neoroy 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.