Code Monkey home page Code Monkey logo

edge-device-handler's Introduction

TDM Edge Dispatcher

In TDM Edge Gateway Reference Architecture the Edge Gateway can have sensors directly attached to its connectors. Depending on the type of interface or bus to which they are connected, a different micro-service takes care of establishing the connection, configuring the sensors on that interface and polling them periodically. For the sensor used in this reference design, the HTU21D temperature and humidity sensor, the handler is called Edge Device Handler (HTU21D Publisher is the legacy name and will be changed in the future).

This handler opens the interface on the I2C bus on which the sensor operates and, at time interval set in the configuration file or command line, pools the sensor and sends to the local MQTT broker the message with the parameters detected, in this case temperature, humidity and the dew point calculated from the first two.

Other data sent are internal housekeeping data like, kernel version, memory in use, current cpu load and others. See 'Data collected' section below.

Configurations

Settings are retrieved from both configuration file and command line. Values are applied in the following order, the last overwriting the previous:

  1. configuration file section 'GENERAL' for the common options (logging, local MQTT broker...);
  2. configuration file section 'HTU21D_publisher' for both common and specific options;
  3. command line options.

Configuration file

The options mqtt_host and mqtt_port now are deprecated and no longer recognized. mqtt_local_host and mqtt_local_port must be used instead.

  • mqtt_local_host

    hostname or address of the local broker (default: localhost)

  • mqtt_local_port

    port of the local broker (default: 1883)

  • logging_level

    threshold level for log messages (default: 20)

  • influxdb_host

    hostname or address of the influx database (default: localhost)

  • influxdb_port

    port of the influx database (default: 8086)

  • gps_location

    GPS coordinates of the sensor as latitude,longitude (default: 0.0,0.0)

  • htu_interval

    interval in seconds for HTU21D sensor data acquisition and publication (default: 60 secs)

  • hkp_interval

    interval in seconds for Housekeeping data acquisition and publication (default: 60 secs)

  • i2c_bus

    I2C bus number to which the sensor is attached (default: 1)

When a settings is present both in the GENERAL and application specific section, the application specific is applied to the specific handler.

Options accepted in GENERAL section

  • mqtt_local_host
  • mqtt_local_port
  • influxdb_host
  • influxdb_port
  • logging_level
  • gps_location

In this example, the logging_level settings is overwritten to 1 only for this handler, while other handlers use 0 from the section GENERAL:

[GENERAL]
mqtt_local_host = mosquitto
mqtt_local_port = 1883
influxdb_host = influxdb
influxdb_port = 8086
gps_location=0.0,0.0
logging_level = 0

[HTU21D_publisher]
htu_interval=60
hkp_interval=3600
logging_level = 1
i2c_bus = 1

Command line

  • -h, --help

    show this help message and exit

  • -c FILE, --config-file FILE

    specify the config file

  • -l LOGGING_LEVEL, --logging-level LOGGING_LEVEL

    threshold level for log messages (default: 20)

  • --mqtt-host MQTT_HOST

    hostname or address of the local broker (default: localhost)

  • --mqtt-port MQTT_PORT

    port of the local broker (default: 1883)

  • --i2c-bus I2C_BUS

    I2C bus number to which the sensor is attached (default: 1)

  • --htu-interval INTERVAL

    interval in seconds for HTU21D sensor data acquisition and publication (default: 60 secs)

  • --hkp-interval INTERVAL

    interval in seconds for Housekeeping data acquisition and publication (default: 60 secs)

  • --influxdb-host INFLUXDB_HOST

    hostname or address of the influx database (default: localhost)

  • --influxdb-port INFLUXDB_PORT

    port of the influx database (default: 8086)

  • --gps-location GPS_LOCATION

    GPS coordinates of the sensor as latitude,longitude (default: 0.0,0.0)

Data Collected

Data collected by the Edge Device Handler are sent with two MQTT messages to the TDM Cloud:

HTU21 Message

  • dateObserved measurement date in ISO format;
  • timestamp measurement date as Unix Epoch;
  • latitude from configuration file/command line;
  • longitude from configuration file/command line;
  • temperature from HTU21D sensor (also stored in the internal Influx DB);
  • humidity from HTU21D sensor (also stored in the internal Influx DB);
  • dewpoint computed from data HTU21D sensor (also stored in the internal Influx DB).

HOUSEKEEPING Message

  • dateObserved measurement date in ISO format;
  • timestamp measurement date as Unix Epoch;
  • latitude from configuration file/command line;
  • longitude from configuration file/command line;
  • lastBoot date of the last boot;
  • operatingSystem Operating System (Linux);
  • kernelRelease release of the kernel;
  • kernelVersion build of the current kernel;
  • systemArchitecture CPU architecture;
  • cpuCount total CPU number;
  • diskTotal total DISK (SD) space in MB;
  • diskFree free DISK (SD) space available in MB;
  • memoryTotal total RAM memory in MB;
  • memoryFree free RAM memory available in MB
  • swapTotal total Swap space in MB;
  • swapFree free Swap memory available in MB.

edge-device-handler's People

Contributors

mgaggero avatar

Watchers

 avatar  avatar  avatar

Forkers

mgaggero

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.