Code Monkey home page Code Monkey logo

icarus_iot's Introduction

Architecture

Our entire system consists of three components - an embedded system, a webserver, and a webclient.

The embedded system runs on an ESP8266 WiFi module using micropython. The system connects to a WiFi network and a MQTT broker defined in the code, and subscribes and publishes to various topics, as defined bellow, to communicate with the webserver.

The webserver runs on Node.js and acts as a handler to interface between the webclient and embedded device. It communicates with the embedded device via MQTT and handles HTTP requests received from the webclient. The responsibilities of the webserver include:

  • Storing:
    • Profiles
    • Sensor data
    • Device state
  • Handling:
    • From device:
      • Initialisation request
      • Sensor data
    • From webclient:
      • Request for profiles
      • Creating new profiles
      • Turning device on/off
      • Current sensor data
      • Setting profile for the device

The webclient utilises the d3.js framework and AJAX to request and visualise the sensor data form the webserver in real time. Other services on the webclient include turning the device on/off, requesting the webserver to change the device profile, and create new profiles.

JSON

embedded to server - topic esys/icarus/status

{
    time: "str"
    temp: float
    hum: float
    plant: "str"
}

server to embedded - topic esys/icarus/params

{
    time: "str"
    temp: float
    hum: float
    plant: "str"
}

server to embedded toggle on/off - topic 'esys/icarus/power'

{
    power: int
}

Note: sensor should get start time when it initializes and track its own time

embedded to server alarm - topic esys/icarus/alarm

{
    alarm: "str"    # Error msg
}

Screen

screen /dev/tty* 115200

Uploading

ampy --port /dev/tty* put main.py

I2C API

writeto(bus_addr,data)
 - Opens write comm with slave at bus_addr, send each byte in data

readfrom(bus_addr,n)
 - Opens read comm with slave at bus_addr, read n bytes
 - Returns byte_array of n bytes

writeto_mem(bus_addr,reg_addr,data)
 - Opens write comm with slave at bus_addr, send reg_addr, send each byte in data

readfrom_mem(bus_addr,reg_addr,n)
 - Opens write comm with slave at bus_addr, send reg_addr, switch to read mode, read n bytes
 - Returns byte_array of n bytes

MQTT

client = MQTTClient(CLIENT_ID,BROKER_ADDRESS)
client.connect()

client.publish(TOPIC,bytes(data,'utf-8'))

Sensors

ESP8266

icarus_iot's People

Contributors

al2114 avatar manicben avatar nikonikolov avatar

Watchers

James Cloos avatar  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.