项目作者: eduarias

项目描述 :
IoT Fog computing application
高级语言: Python
项目地址: git://github.com/eduarias/iot_fog.git
创建时间: 2016-05-30T15:20:08Z
项目社区:https://github.com/eduarias/iot_fog

开源协议:GNU General Public License v3.0

下载


build status Codacy Badge Codacy Badge

Cloud connector installation guide

Install prerequisites

Install system prerequisites:

Requires Python > 3.3.

  1. sudo apt-get update
  2. sudo apt-get install python3-pip python3-dev

Install application libraries:

  1. sudo pip install -r requirements.txt

Configuration

In the folder cloud_connector use the file config.yml to configure the application. There are sections for device, tsdb and cloud

REST API

There is an endpoint open for devices to send data.
PUT /sensor/data

  1. {"device_name": <String>,
  2. "data": {
  3. "measure1": <Float>,
  4. "measure2": <Float>
  5. }
  6. }

There are two required fields: name and data, name is a string to differentiate devices and data it’s a JSON object with key for the measure name and a value.

Devices

Openmote is not currently, since coap library by OpenWSN does not support Python 3. At this moment this section can be simulated only.

There is a version for Python 2.7 that supports Openmote: (https://github.com/eduarias/iot_fog_openmote)

To configure the devices, there should be a read interval (in seconds) and for each device the ipv6 address ana a name

  1. devices:
  2. read_interval: 5
  3. sim01:
  4. name: mote01

TSDB

Only InfluxDB supported.

Configure parameters for influxDB, like the following example:

  1. tsdb:
  2. influxdb:
  3. host: 192.168.1.44
  4. port: 8086
  5. user: root
  6. password: root
  7. database: iot_values

Cloud

Supported cloud services are AWS IoT, thethings.iO and PubNub.

Each service is configure by it’s name if its used: aws, pubnub, thethingsio. There is no need to configure all the services, only one can be configured. The parameters are different depending the cloud configuration parameters.

Also an strategy should be configure for each cloud service.

AWS IoT

  1. cloud:
  2. aws:
  3. host: A2KYAWFNAAAAAA.iot.eu-west-1.amazonaws.com
  4. port: 8883
  5. ca_path: ../keys/aws-iot-rootCA.crt
  6. cert_path: ../keys/cert.pem
  7. key_path: ../keys/privkey.pem

thethings.iO

There need one token for each device, the key of the token must match the device name defined on devices.

  1. cloud:
  2. thethingsio:
  3. tokens:
  4. mote01: l0M5BEaDdzt40VqGy6omEqZyDY62CxA6XwCJixxxxxx

PubNub

  1. cloud:
  2. pubnub:
  3. publish_key: pub-c-b3d6a6e3-ce77-4a89-9e0b-49e52edddddd
  4. subscribe_key: sub-c-d74fa040-16f4-11e6-8bc8-0619f89ddddd

Strategies

It’s defined for each cloud service, there are different kinds of strategies: All, MessageLimit, TimeLimit, Variation.

  • All: Send all messages.
  • MessageLimit: Send a limited maximum number of messages per day.
  • TimeLimit: Send message only if there has passed some times between the latest one.
  • Variation: Only send message if there is a defined variation of a value. It defines a time_low below no message is sent, a time_high after a message will be sent even if variation threshold has not been reach and variability for each value.
  1. strategy:
  2. type: Variation
  3. parameters:
  4. time_low: 10
  5. time_high: 300
  6. variability:
  7. temperature: 0.5
  8. humidity: 2
  9. light: 5

Execution

Run in cloud_connector folder:

  1. python ./runner.py