# Home

Enter the world of smart measurement devices with ease, there is no need of any programming knowledge.

We offer you the easiest and fastest way to dive into the world of smart measurement devices. Start now and develop your first prototype in just a few minutes.

{% content-ref url="/pages/-MPJDn0m3LminPzsdkbE" %}
[Easy Starter Kit Tutorial](/getting-started/easy-starter-kit-tutorial)
{% endcontent-ref %}


# Easy Starter Kit Tutorial

With our Easy Starter Kit, you will easily learn how to develop smart measuring devices.

The Easy Starter Kit comes with a Developer Gateway that can connect to the Internet via a cellular connection. This development kit is designed for prototyping your smart product.&#x20;

In this tutorial you will see how you can easily transfer temperature and humidity values from an Arduino to the app using the Gateway. With the app you can create your custom dashboard to see all the data and you can build your own alert system, such as receiving an E-Mail or SMS when thresholds are exceeded or the device goes offline.

## Requirements

All you need for the following tutorial is the Easy Starter Kit. This comes with the following things:

* Developer Gateway
* Arduino Mega
* DHT11 Temperature & Humidity Sensor
* Wire
* SIM Card

## 1. Set up your Gateway

The Gateway and the Arduino work on different logic levels. Mostly you can ignore this for prototypes. If the communication doesn't work properly for you, you should use a logic level shifter. To keep it simple, we will not use this logic level shifter here. If the communication doesn't work properly for you, you should use a logic level shifter.

In this tutorial we operate the Gateway via the 5V interface of the Arduino. This way the Gateway does not have to be powered by its own power source. For this the 5V line of the Arduino must be connected to the 5V IN and GND line of the Gateway.

The Gateway communicates with the Arduino via UART. For this the Gateway and the Arduino must be connected via GND, TX and RX line.

![](https://1448869960-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOb77mW1-Ky_sezok91%2F-MPJMmX2r9yQjJVlr1WH%2F-MPK9VcaG6gOfrzLXGt7%2Fgateway-arduino.png?alt=media\&token=30fba669-82d3-4666-ba4c-edea69208fe1)

## 2. Set up your Sensor

Next you have to connect your DHT11 sensor to your Arduino. Connect the signal pin of the DHT11 with pin2 of the Arduino, VCC pin with the 5V pin of the Arduino and GND with GND.

{% hint style="info" %}
It may be that you have a different DHT11 breakout board. In this case, VCC, GND and signal pin may be assigned differently. Check the datasheet for your DHT11.
{% endhint %}

## 3. Gateway Onboarding

{% hint style="success" %}
Your Gateway is delivered already linked to your account and configured by our team.
{% endhint %}

## 4. Set up your Arduino IDE

First, download the latest version of the [Arduino IDE](https://www.arduino.cc/en/software).

For this tutorial we need two Arduino libraries. The first one for the DHT11 sensor, the second one for the connection to the Gateway, that implements our [Communication Protocol](/gateway/communication-protocol) for the Arduino. The Arduino IDE offers a library manager, which can be used to install the libraries. Open the library manager `Tools --> Manage Libraries...`&#x20;

![](https://1448869960-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOb77mW1-Ky_sezok91%2F-MPKA-wnHo_vtVxGGoKk%2F-MPKFOxWSbf7dFl9rjye%2Farduino-ide-lib-management.png?alt=media\&token=62aaff1a-1c83-4186-afd2-ba218c3e0209)

Search for the OneIoT Connectivity library by entering `oneiot` in the search bar. Click on `Install`.Now the library is installed and you can easily call the [Communication Protocol](/gateway/communication-protocol) using the library.

![](https://1448869960-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOb77mW1-Ky_sezok91%2F-MPKA-wnHo_vtVxGGoKk%2F-MPKHXNbfcg5WyPiD6Bb%2Farduino-lib-oneiot.png?alt=media\&token=e8dd9312-69a9-40e6-b0b4-8f5589e46e03)

Search for the DHT sensor library by entering `dht sensor library` in the search bar. Click on `Install`. Now the library is installed and you can use it in the Arduino code to read the DHT11 sensor data.

![](https://1448869960-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOb77mW1-Ky_sezok91%2F-MPKA-wnHo_vtVxGGoKk%2F-MPKHZqLu8NQc8HaN7xo%2Farduino-lib-dht11.png?alt=media\&token=55529806-7531-4641-bf1b-b83ee694d9c2)

## 5. Transfer Data to the App

Open the Arduino IDE with a new sketch and make sure that the two libraries are installed. We include the libraries in the code using the `#include` statements. We also define the pin for the DHT sensor and the sensor type.

```
#include <Connectivity.h>
#include "DHT.h" 

#define DHTPIN 2
#define DHTTYPE DHT11
```

The next step is to configure the item numbers. The item numbers are matching the [Digital Twin](/gateway/digital-twin) that we created in the cloud with the [Device Template](/app/device-template).

```
const int ITEM_TEMP = 1;
const int ITEM_MOISTURE = 2;
```

Now we need to create the Arduino objects for the sensor and the Gateway connectivity module.

```
DHT dht(DHTPIN, DHTTYPE);
Connectivity connectivity;
```

An Arduino sketch always consists of a setup() method where you do the things you want to be done when you start the program and a loop() method that is executed continuously. In our setup method we initialize sensor and Gateway connectivity module.

```
void setup() {
  connectivity.begin(&Serial1);
  dht.begin();
}
```

In the loop method we read the sensor values every two seconds and check if they are correct. The DHT11 sensor returns the temperature in degrees Celsius and the humidity in %. Both values are returned as float from the DHT library.&#x20;

The Gateway connectivity library uses double values, so we still need to do cast the values to double datatype. In addition to the sensor values, we can also pass a status code for the sensor. For this we have `STATUS_OK`, `STATUS_WARN`and `STATUS_ERROR` to choose from. The code for our loop method then looks like this.

```
void loop() {

  // Every two seconds we read the values and send them to the cloud
  delay(2000);                   
  
  // Humidity measured value from sensor dht11  
  double humidity = (double) dht.readHumidity(); 
  
  // Temperature measured value from sensor dht11   
  double temperature = (double) dht.readTemperature(); 
  
  // We check whether the sensor values have been read correctly
  if (isnan(humidity)){ 
  
    // If not send a STATUS_ERROR status code
    connectivity.send_item_status(ITEM_MOISTURE, STATUS_ERROR);
    
  } else {
  
    // If everything is ok send STATUS_OK status code
    connectivity.send_state_change_double(ITEM_MOISTURE, humidity, STATUS_OK);
  }

  // And the same again for the temperature
  if (isnan(temperature)) {
    connectivity.send_item_status(ITEM_TEMP, STATUS_ERROR);
  }else{
    connectivity.send_state_change_double(ITEM_TEMP, temperature, STATUS_OK);
  }
}
```

That was already everything. If you now upload the code to the Arduino and have wired everything as described above, power supply is correct and if necessary a SIM card is inserted, then your DHT11 values are transmitted to the cloud. You can find all the code again [here](https://github.com/1IoT/cloud-connectivity-lib/tree/1.1.0/examples/HelloWorld_DHT).&#x20;

You can now log into the [app ](https://app.easytoi.com)and view your data and play around with all the app features.


# akYtec PR200 Prototype V1

Short overview to get started with the akYtec PR200 Prototype

## Prototype features

The **akYtec PR200** prototype comes with the following functionality:

* 2 digital outputs (DO1 and DO2 on the **PR200**)
* 2 analog inputs (AI1 and AI2 on the **PR200**) (currently 0-10V)
* Digital outputs can be monitored and controlled (switched) via the OneIoT Cloud and [Dashboard](/app/dashboard).
* Analog inputs can be monitored via the OneIoT Cloud and [Dashboard](/app/dashboard).

It is easy to extend this functionality via the [Instrument Driver.](/gateway/instrument-driver-1)

## Quick Start Guide

* Connect the **OneIoT Gateway** via USB Micro B connector (5 Volts)

{% hint style="danger" %}
Make sure you only connect 5 Volts DC to the Gateway.
{% endhint %}

* Connect the RJ45 Jack of the **OneIoT Gateway** to a LAN which provides access to internet&#x20;

{% hint style="info" %}
In some LANs outgoing ports might be blocked. In case the device will not connect to the cloud, you need to open ports 8883 for MQTTs-Connection and 9090 for Over-The-Air Updates.
{% endhint %}

* Connect the OneIoT Gateway to the device via Modbus. A+ (green wire) has to be connected to the D+ port of the **PR200** and B- (blue wire) has to be connected to the D- port of the **PR200**. Use the first (left most) RS485 interface of the **PR200**.

{% hint style="info" %}
For the prototype, make sure the RS485 connector of the **OneIoT Gateway** is connected to the **OneIoT Gateway** (all for wires should be connected).
{% endhint %}

* Connect some analog inputs or digital outputs.
* Connect 24V DC power supply to the **PR200** power input. Also, consult the **PR200** manual for more details or in case of any doubts.

{% hint style="danger" %}
Make sure you never connect >24V DC to the **PR200** power input.
{% endhint %}

* Login to the[ OneIoT Dashboard.](https://app.easytoi.com)&#x20;
* In case the **OneIoT Gateway** is not connected to your account yet, see [here how to link new devices.](/app/device-onboarding)
* If the OneIoT Gateway is connected and linked to your account, it will be shown as online (green circle) in the [device list.](https://app.easytoi.com/devices)

{% hint style="info" %}
In case the gateway is not shown in the list, you need to [link it to your account first.](/app/device-onboarding) If it is shown in the list but does not appear to be online (grey circle), check the power connection and make sure that the gateway can connect to the internet via the LAN.
{% endhint %}

* If the OneIoT Gateway is online, you can create or modify your own [dashboard](/app/dashboard).&#x20;

## The PR200  prototype showcase

There is a small ALP program running on the **PR200**.  It has the following responsibilities:

* The PR200 is in Modbus Slave-Mode and available via *address 16.*
* The network variables *Eingang1* and *Eingang2* are mapped to r*egister 512 and 513*, respectively.
* *Eingang1* and *Eingang2* are connected to the *digital output Q1 and Q2*, respectively.
* Analog inputs are made available by default via Modbus as described in the **PR200** manual.
* Analog input 1 is shown in the **PR200** display.

{% hint style="success" %}
The demo program is included on the USB stick.
{% endhint %}

In the **OneIoT Cloud** there is a so called *Device Template* for the **PR200*****.*** This template describes the device in the cloud. The mapping is based on the [OneIoT Digital Twin ](/gateway/digital-twin)concept. Variables are mapped to so called *Items:*

| PR200 | OneIoT Item             |
| ----- | ----------------------- |
| AI1   | Analog Input 1 (Item 1) |
| AI2   | Analog Input 2 (Item 2) |
| Q1    | Relais 1 (Item 3)       |
| Q2    | Relais 2 (Item 4)       |

The Device Template can then be used to define Dashboards.

{% hint style="success" %}
The Device Template can be changed and extended at anytime. The [Instrument Driver](/gateway/instrument-driver-1), which can also be changed at runtime (e.g., by the user or by OneIoT) is responsible to fetch the data from the **PR200** and forward it to the cloud via the defined items.&#x20;
{% endhint %}

There is already a [**OneIoT Dashboard**](/app/dashboard) for this showcase.

![The default dashboard for the PR200 showcase.](https://1448869960-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOb77mW1-Ky_sezok91%2F-Mf9hU2SPEAXbRq2iu5C%2F-Mf9xMYYsB_wtjY0WKf2%2FScreenshot%20from%202021-07-21%2023-24-51.png?alt=media\&token=e9c0f9be-e1f2-4c8d-adf7-141d3c752def)

## Custom driver to support every possible use case

A [Instrument Driver ](/gateway/instrument-driver-1)is responsible for the communication between **OneIoT Gateway** and **PR200**.

{% hint style="success" %}
The Instrument Driver can also be adapted at runtime!&#x20;
{% endhint %}

{% hint style="info" %}
In the future, there will be an easier to use Domain Specific Language for Modbus-based drivers.
{% endhint %}

The current prototype instrument driver is given below. It just fetches some values via Modbus every 30 seconds and sends them to the cloud. Furthermore, incoming commands from the **OneIoT Cloud,** that is, switching one of the relays are mapped to the corresponding Modbus commands and send to the **PR200**.

This code can easily extended to read all registers from the **PR200** or to write and read all network variables. Furthermore, I can be adapted to specific use cases. For example, sensor readings can be evaluated and aggregated and complex logic can be implemented here.

{% hint style="success" %}
OneIoT provides support in writing instrument drivers.
{% endhint %}

```python
import struct
import uasyncio as asyncio
import logging
from serial_communication import Serial
from queue import MESSAGE_BUS, Event, EVENT_TO_CLOUD_FOR_MQTT, EVENT_ERROR
import message_util
from libs.modbus_facade import ModbusFacade

class CustomHandler:

    def __init__(self, serial:Serial):
        # Every 30sec
        self.fire_every = 30
        self.modbus = ModbusFacade(serial)

    async def loop(self):
        # Read every x seconds
        while True:
            await asyncio.sleep_ms(self.fire_every*1000)
            # Address 0x10, 0x0B00-0x0B01 is AI1
            answer_double_list = await self.modbus.read_holding_registers(0x10, 0x0B00, 0x02, double_valued=True)
            # Item 1 mapped to AI 1
            await self.send_double(1, answer_double_list[0])
            # Address 0x10, 0x0B02-0x0B03 is AI1
            answer_double_list = await self.modbus.read_holding_registers(0x10, 0x0B02, 0x02, double_valued=True)
            # Item 2 mapped to AI 2
            await self.send_double(2, answer_double_list[0])
            # Address 0x10, 0x2000 is network variable 1
            answer_bool_list = await self.modbus.read_coils(0x10, 0x2000, 0x01)
            print(answer_bool_list)
            # Item 3 mapped to network variable 1
            await self.send_bool(3, answer_bool_list[0])
             # Address 0x10, 0x2001 is network variable 2
            answer_bool_list = await self.modbus.read_coils(0x10, 0x2010, 0x01)
            print(answer_bool_list)
            # Item 3 mapped to network variable 1
            await self.send_bool(4, answer_bool_list[0])
            
    async def handle_incoming(self, message):
        if message_util.get_state_content_for_payload(message) is not None:
            item_number, state_str = message_util.get_state_content_for_payload(message)
            item_number = int(item_number)
            # state is expected to be boolean and we'll send it via single_coil function code
            if state_str == "0":
                state = 0x0000
            elif state_str == "1":
                state = 0xFF00
            # Only network variables 1 and 2 bound to item 3 and 4 will be handled
            if item_number == 3:
                register = 0x2000
            if item_number == 4:
                register = 0x2010
            # write single coil
            if not await self.modbus.write_single_coil(0x10, register, state):
                logging.log("Writing register failed.")        
        else:
            logging.log(str("Cannot handle message %s." % str(message)))        
        
            
    async def send_bool(self, item, value):
        if value:
            await self.send_message(item, "1", "BOOLEAN")
        else:
            await self.send_message(item, "0", "BOOLEAN")
        
    async def send_double(self, item, value):
        value = str(value)
        await self.send_message(item, value, "DOUBLE")
        

    async def send_message(self, item, value_string, type="DOUBLE"):
        message = None
        if value_string:
            message =  "S:" + str(item) + ":20:" + type + ":" + value_string
        else:
            message =  "S:" + str(item) + ":50"
            logging.log("No answer received for command...")

        await self.finalize_serial_to_cloud(message)
        # TODO log to cloud

    '''
    This finalizes a serial message given the OneIoT protocol. Timestamp is added and message is checked.
    Then it is sent to the cloud.
    '''
    async def finalize_serial_to_cloud(self, message):
        message = message_util.add_timestamp(message)
        correct = message_util.check_serial_message(message)
        if not correct:
            await MESSAGE_BUS.send(Event(EVENT_ERROR, "Incorrect handled serial: " + message))
        else:
            # just forward to devicecloud via MQTT
            await MESSAGE_BUS.send(Event(EVENT_TO_CLOUD_FOR_MQTT, [message]))

```

## Mobus Settings

**PR200** modbus settings:

| Property  | Value                     |
| --------- | ------------------------- |
| Address   | 16 (decimal) = 0x10 (hex) |
| Baud      | 9600                      |
| Stop Bits | 1                         |
| Parity    | None                      |
| Data Bits | 8                         |

## Troubleshooting

### 1.) Device does not show up online in the Device Cloud, there is only a grey circle!

Check your connection, make sure all necessary outgoing ports are open (9090, 8883, 80, 443). Make sure, the device has access to the internet. In case you are using a mobile connection, make sure you have sufficient radio reception. You can also move the gateway to another location to check reception issues.

### 2.) Device does not show up at all!

You need to[ onboard the device ](/app/device-onboarding)first.

### 3.) Device seems to be online (green circle) but I can see no Dashboard!

**Option 1:**  Go to another device page, for example the Debugging Page and then back to the Dashboard. If the Dashboard does not show up then, you have not created one yet (see Option 2).\
**Option 2:** Create a new [Dashboard](/app/dashboard).

### 4.) Device seems to be online (green circle) but I don't receive any data!

**Option 1:** Refresh (Press F5 on the keyboard) the Dashboard.\
**Option 2: I**f you can not see any data, even though you know some sensor readings should have been received, make sure your mapping (Device Template) to the items is correct (i.e., the Dashboard displays the right data in the widgets). \
**Option 3:** If mapping is correct and data should be received but is not shown in the cloud, make sure your physical connection is correct. Test the OneIoT Gateway or your device also with another device or Modbus master, respectively.&#x20;


# Digital Twin

We bring your devices into the digital world.

## What is a digital twin?

The digital twin is the digital replica of your physical device. A device can be an instrument, sensors or any other device you can think of. This digital twin lives in the cloud and represents your device with all its states. All properties, behavior and functions of your device can thus be digitized so that your device can be used in the digital world. Among many other awesome advantages, this means that the device can be used online. With our app you can fully operate the device so that all work with the device can be done remotely.

## What does a digital twin look like?

A device usually consists of several data units that provide e.g. measured values. In order to be able to represent each device individually, we use a powerful data model to enable the representation of a device in the digital world. This means that a digital twin can be flexibly created for all types of devices, precisely for your individual requirements.

The data model consists of two components, a device and an item. A device consists of any number of items. An item is the digital representative of any measured value or any operation provided by the device. An item can therefore be used to represent any value and any actor in your physical device.

Every change of state in your physical device causes the digital twin to assume this state as well. This allows a permanently reliable representation of your device to be mapped in the digital world.

![Representation of a physical device to a digital twin in the cloud with our powerful data model](https://1448869960-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOb77mW1-Ky_sezok91%2F-MOers2-B20UpdOXP8UH%2F-MOezrNlFJV8tKnRiL9d%2Fdigital-twin.jpg?alt=media\&token=d3ef9127-a5e0-4b36-b25d-4d6ebab50bdb)

## How it works?

To bring your device into the cloud, a device template must first be created. A device template is the blueprint for a digital twin. With this device template, the digital blueprint for your device is defined on the basis of the above-mentioned data model. To learn how you can create a device template for your digital twin, see

{% content-ref url="/pages/-MOcGyZoxxqqRTOz-wrn" %}
[Device Onboarding](/app/device-onboarding)
{% endcontent-ref %}


# Gateway Adapter

Can be combined like building blocks, making it easy for your use case for every instrument.

## Overview

The Industrial Gateway 4.0 offers a simple solution to get all the data from your instrument into your instrument application. With its modular adapter concept, it can be configured for your use case to use any connectivity solution for your individual communication. All adapters are freely selectable and can be easily exchanged at any time.&#x20;

![](https://1448869960-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOb77mW1-Ky_sezok91%2F-MWybnr0oezmgYo2gBbU%2F-MWyc2fC_QYzKWQLgpq5%2Finstrument-gateway-system-overview%20\(2\).png?alt=media\&token=dc806a06-9947-472f-8595-229cb58c6c35)

## Instrument Adapter

The Industrial Gateway 4.0 has a port for an instrument adapter on the left side to communicate with your measuring device.&#x20;

We offer both wireless and wired connectivity solutions for your instrument. Thus, either one measuring device can be connected to a gateway via a wired-based instrument adapter or several measuring devices can be connected to only one gateway via a wireless-based instrument adapter. These combination options ensure a high degree of flexibility for almost any use case.

| **Adapter**              | Description                                                                                                                                                                                  |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **UART Pin Interface**   | <ul><li>Flexible 3-wire UART interface to connect your instrument</li></ul>                                                                                                                  |
| **Analog Pin Interface** | <ul><li>Simply connect sensors</li></ul>                                                                                                                                                     |
| **Modbus**               | <ul><li>RS-232, RS-485 or Ethernet connector</li></ul>                                                                                                                                       |
| **RS-232, RS-485**       | <ul><li>Serial communication connector</li></ul>                                                                                                                                             |
| **LoRa**                 | <ul><li>Connects a high number of devices with only one gateway</li><li>Wireless up to 10km range</li><li>High energy efficiency</li><li>Low bandwidth and no Over-The-Air Updates</li></ul> |

### Instrument Driver

The instrument driver connects your instrument with the gateway on software level to provide your instrument with a fully flexible link. It does not matter how your instrument communicates and in what format all the data arrives at the gateway. The gateway has an individual instrument driver that can be configured for your instrument communication. The instrument driver is a powerful tool to provide new functionality for your instrument. For more information about the instrument driver concept see

{% content-ref url="/pages/-MX1JPTlnjNwqyHWLBfi" %}
[Instrument Driver](/gateway/instrument-driver-1)
{% endcontent-ref %}

Via Over-The-Air Updates the instrument driver can be updated at any time. For more information about how to update the gateway and the instrument driver see

{% content-ref url="/pages/-MWyL7in9to-P4fSpqJq" %}
[Over-The-Air Updates](/gateway/over-the-air-updates)
{% endcontent-ref %}

## Cloud Adapter

On the right side, it has a port for a cloud adapter to communicate with the cloud platform to bring all instrument data into your instrument application.

| **Adapter**  | Description                                                                                                       |
| ------------ | ----------------------------------------------------------------------------------------------------------------- |
| **LTE-M**    | <ul><li>Low energy consumption</li><li>Extensive range</li><li>High signal penetration inside buildings</li></ul> |
| **NB-IoT**   | <ul><li>Low energy consumption</li><li>Extensive range</li><li>High signal penetration inside buildings</li></ul> |
| **GPRS**     | <ul><li>Fallback option</li></ul>                                                                                 |
| **LoRaWAN**  | <ul><li>Integration in LoRaWAN network</li></ul>                                                                  |
| **Wi-Fi**    | <ul><li>High bandwidth</li><li>Wireless connection without SIM card</li></ul>                                     |
| **Ethernet** | <ul><li>Wired internet connection required </li><li>No wireless communication </li><li>High bandwidth</li></ul>   |


# Communication Protocol

The communication protocol was designed to be simple to use, human readable, and easy to parse or serialize.

## How it works?

Using this protocol, your measuring device is able to communicate with our cloud via our gateway. All you need to do is send a simple message to our gateway. Our gateway takes care of everything else to establish and perform secure and reliable communication with the cloud. Once you have connected the measuring device to the gateway, you can send messages to the gateway via its interfaces as shown in the following protocol definition. To learn how to connect the gateway to your measuring device, see

{% content-ref url="/pages/-MOf4jrVRhVjCG\_eecby" %}
[Quick Setup Guide](/gateway/connect-the-gateway)
{% endcontent-ref %}

An open source implementation of the communication protocol based on Arduino can be found on our [Github page](https://github.com/1IoT/cloud-connectivity-lib).

## ✉️ Send ➡ Device Status Code

{% tabs %}
{% tab title="Protocol" %}

```
S:D:Statuscode
```

The device status code can be used to transfer the status of the device to the cloud. The status code is applied to the entire device, thus the status of the device can be read via the app.&#x20;

The app can also be used to define status codes messages for used status codes. This has the advantage that the messages can be adapted flexibly without modifying the code of the device. For more information see

{% content-ref url="/pages/-MOcHB6iH36HOnDScvNJ" %}
[Diagnostic Tool](/app/diagnostic-tool)
{% endcontent-ref %}

| **Statuscode** | **Description**                                                   |
| -------------- | ----------------------------------------------------------------- |
| **2x**         | Statuscodes starting with 2 are interpreted as everything is okay |
| **4x**         | Statuscodes starting with 4 indicate some expected failures       |
| **5x**         | Statuscodes starting with 5 indicate errors                       |

{% hint style="info" %}
You can define your own status codes but we recommend sticking to these semantics
{% endhint %}
{% endtab %}

{% tab title="Example" %}

```
S:D:20
```

With this message you send the status code **20** to the cloud. This means that the entire device is working as expected and everything is ok. The **S** is used to inform the cloud that this is a status message. The **D** is used to inform the cloud that the status code applies to the entire device. Our gateway generates a timestamp for this message automatically.

```
1608104328:S:D:20
```

If you want to define your own timestamp for the message, you can prepend it to the message.&#x20;
{% endtab %}
{% endtabs %}

## ✉️ Send ➡ Item Status Code

{% tabs %}
{% tab title="Protocol" %}

```
S:ItemNumber:Statuscode
```

Status codes can be sent not only at the level of the entire device, they can also be sent for each item individually. This allows items to share individualized information about their current condition. The ItemNumber is the id of an item as it was created in a device template for the digital twin. For information about the device template and how to find out the ItemNumber of an item see

{% content-ref url="/pages/-MOcGyZoxxqqRTOz-wrn" %}
[Device Onboarding](/app/device-onboarding)
{% endcontent-ref %}

As before in the protocol description for Device Status Code, we recommend our default status code semantic.
{% endtab %}

{% tab title="Example" %}

```
S:4:50
```

Use this message to send status code **50** to the cloud for the item with id **4**. In this case it is set that the status of the given item is incorrect. This means that there is an error. The **S** is used to inform the cloud that this is a status message. Our gateway generates a timestamp for this message automatically.

```
1608104328:S:4:20
```

If you want to define your own timestamp for the message, you can prepend it to the message.&#x20;
{% endtab %}
{% endtabs %}

## ✉️ Send ➡ Item State + Item Status Code

{% tabs %}
{% tab title="Protocol" %}

```
S:ItemNumber:Statuscode:DataType:Data
```

The main use case is transmitting and receiving state to and from the cloud. This message can be used to change the value of an item. An item can be any sensor or actor of the measuring device. When sending an item state, you should also send an item status code, which indicates if there are any problems with the item or if anything is still working as expected.

As before in the protocol description for Device Status Code, we recommend our default status code semantic.

| DataType     | Description                                                           |
| ------------ | --------------------------------------------------------------------- |
| **INT**      | Sends integer values. Can also be used to send percentage values      |
| **DOUBLE**   | Sends floating point numbers                                          |
| **BOOLEAN**  | Sends true (1) or false (0). Can be used to turn something on and off |
| {% endtab %} |                                                                       |

{% tab title="Example" %}

```
S:1:20:INT:1337
```

With the data type **INT** you can transfer integer values for an item state. In this message the item with id **1** is set to **1337**. In addition, the item status code **20** is transmitted to describe that everything is ok with the value and with the item. The **S** is used to inform the cloud that this is a status message.

```
S:4:20:INT:100
```

The data type **INT** can also be used to map a percentage scale. For this purpose, you can define the corresponding value range in your measuring device so that only values between 0 and 100 can be transmitted for this item. In the app, you can then flexibly set that a percentage scale is to be used for this item. In this example, the item with id **4** is set to **100**%. Once again, the item status code **20** is transmitted to indicate that the item works fine.

```
S:5:50:DOUBLE:41.99
```

Floating point numbers can be sent with the **DOUBLE** data type. In this message, the value of the item with id **5** is set to **41.99**. The item status code **50** is also appended to the status change. This means that this item is currently incorrect and therefore the value is probably also incorrect.

```
S:8:20:BOOLEAN:1
```

A **BOOLEAN** data type can be used for items that can have two states, e.g. on and off. This message sets the item with id **8** to **true (1)**. At the same time the item status code is set to **20** which means that the item is working correctly.

```
1608104328:S:4:20:INT:1337
```

If you want to define your own timestamp for these messages, you can prepend it to the message. Otherwise the timestamp will be added automatically by the gateway.
{% endtab %}
{% endtabs %}

## ✉️ Send ➡ Log Message for Device

{% tabs %}
{% tab title="Protocol" %}

```
N:LOG:D:Level:Message
```

You can send log messages to the cloud. The log messages will then be stored and can be analyzed via the app with the help of our diagnostic tool.

{% content-ref url="/pages/-MOcHB6iH36HOnDScvNJ" %}
[Diagnostic Tool](/app/diagnostic-tool)
{% endcontent-ref %}

We use a standard protocol level hierarchy to set the definition for the protocol message. This allows messages of different importance and significance to be separated from each other. This also allows sorting and filtering via the app. So it allows to search for logs of a certain level.

| **Level**    | **Description**                                                             |
| ------------ | --------------------------------------------------------------------------- |
| **DEBUG**    | Information that is diagnostically helpful to track the flow of your device |
| **INFO**     | Generally useful information that highlight the progress your device        |
| **WARN**     | Anything that can potentially cause issues on your device                   |
| **ERROR**    | Any error which is fatal to the operation of your device                    |
| {% endtab %} |                                                                             |

{% tab title="Example" %}

```
N:LOG:D:ERROR:An error has occurred
```

In this example, an **ERROR LOG** message is sent to the cloud that affects the entire device with the message **An error has occurred**. The **N** is used to inform the cloud that this is a notification message and the the **D** is used to inform that the log message applies to the entire device

```
1608104328:N:LOG:D:ERROR:An error has occurred
```

If you want to define your own timestamp for these messages, you can prepend it to the message. Otherwise the timestamp will be added automatically by the gateway.
{% endtab %}
{% endtabs %}

## ✉️ Send ➡ Log Message for Item

{% tabs %}
{% tab title="Protocol" %}

```
N:LOG:ItemNumber:Level:Message
```

With an item log message, a message can be sent explicitly for exactly one item. This makes it easier to assign messages to specific areas of the measuring device.

As before in the protocol description for Log Message for Item, we use a lightweight log level hierarchy.&#x20;
{% endtab %}

{% tab title="Example" %}

```
N:LOG:3:INFO:Hello World
```

In this example, an **INFO LOG** message is sent to the cloud that affects only the item with the id **3** with the message **Hello World**. The **N** is used to inform the cloud that this is a notification message.

```
1608104328:N:LOG:3:INFO:Hello World
```

If you want to define your own timestamp for these messages, you can prepend it to the message. Otherwise the timestamp will be added automatically by the gateway
{% endtab %}
{% endtabs %}

## ✉️ Send ➡ Deep Sleep

{% tabs %}
{% tab title="Protocol" %}

```
N:DEEPSLEEP:TimeInSeconds
```

Your device can initiate a deep sleep for the gateway. For this, it sends a deep sleep message via serial with the sleep time in seconds. The gateway will then go into deep sleep for the requested time.
{% endtab %}

{% tab title="Example" %}

```
N:DEEPSLEEP:3600
```

This message sends a **DEEPSLEEP** notification to the gateway. It sends the gateway into a deep sleep mode for **3600** seconds. The **N** is used to inform that this is a notification message.

```
1608104328:N:DEEPSLEEP:3600
```

If you want to define your own timestamp for these messages, you can prepend it to the message. Otherwise the timestamp will be added automatically by the gateway.
{% endtab %}
{% endtabs %}

## ✉️ Receive ⬅ Item State

{% tabs %}
{% tab title="Protocol" %}

```
Timestamp:S:ItemNumber:Statuscode:DataType:Data
```

For incoming messages, your device must also receive the messages from the gateway. This allows your device to be remotely controlled via the app.
{% endtab %}
{% endtabs %}

## ✉️ Check Health State

{% tabs %}
{% tab title="Protocol" %}
The digital twin of your device in the cloud always has a health state that indicates the current state in terms of connectivity. The health state of the digital twin indicates the state of the connectivity of your physical device.

| **Health State** | **Description**                                                                                                                                                                                                                                                                 |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **ONLINE**       | When any message is received in the cloud, independent of the message type, the health status is updated.                                                                                                                                                                       |
| **UNRESPONSIVE** | The digital twin of your device is considered unresponsive, when message from the gateway are transmitted to the cloud but your device is not sending any message to the gateway. This means that there is a problem with the connectivity between your device and the gateway. |
| **OFFLINE**      | The digital twin of your device is offline if no messages are received in the cloud at all.                                                                                                                                                                                     |

### ✉️ Send ➡ Pong

```
N:Pong
```

When there are no status messages to send from your device to the cloud, PONG messages can be sent to keep the digital twin in an online health state. The timeout, i.e., the period after which a device is considered offline/unresponsive when no message is received, can be configured via the app, see

{% content-ref url="/pages/-MOm70SMbQrCNTEBidkK" %}
[Device Configuration](/app/device-configuration)
{% endcontent-ref %}

### ✉️ Receive ⬅ Ping

```
Timestamp:N:Ping
```

It is also possible, that the cloud pings your device (e.g., when a user wants to check or update the health state vie the app). In this case a ping message will be received. This ping message should be answered with a pong message as soon as possible. Otherwise the device will be considered unresponsive.
{% endtab %}
{% endtabs %}


# Instrument Driver

## Basic Overview

The *Instrument Driver* is responsible to handle the communication to the devices that are attached to the **OneIoT Gateway**. There are two possible communication modes.&#x20;

1. Command Mode
2. Stream Mode

#### Command Mode

In *command mode* the **OneIoT Gateway** serves as a master devic&#x65;*.* It sends commands to the slave devices attached to the gateway, handles their responses and communicates with the **OneIoT Cloud**. The basic skeleton for a command based Instrument Driver looks like the following (Modbus example).&#x20;

```python
import struct
import uasyncio as asyncio
import logging
from serial_communication import Serial
from queue import MESSAGE_BUS, Event, EVENT_TO_CLOUD_FOR_MQTT, EVENT_ERROR
import message_util
from libs.modbus_facade import ModbusFacade

class CustomHandler:

    def __init__(self, serial:Serial):
        # Every 30sec
        self.fire_every = 30
        self.modbus = ModbusFacade(serial)

    async def loop(self):
        # Read every x seconds
        while True:
            await asyncio.sleep_ms(self.fire_every*1000)
                # SEND COMMANDS OR READ VALUES HERE
                # PROCESS RESPONSES FROM DEVICE
                # EXAMPLE:
                answer_double = 
                    await self.modbus.read_holding_registers(0x10, 0x01, 0x02, double_valued=True)[0]
                await self.send_double(1, answer_double)
            
    async def handle_incoming(self, message):
        # Messages from the cloud are send to the driver and can be handled here
        if message_util.get_state_content_for_payload(message) is not None:
            item_number, state_str = message_util.get_state_content_for_payload(message)
            item_number = int(item_number)
            # DO SOMETHING WITH THE ITEM AND STATE, FOR EXAMPLE, SEND COMMAND TO DEVICES
            # EXAMPLE:
            state = int(state_str)
            if not await self.modbus.write_single_coil(0x10, 0x01, state):
                logging.log("Writing register failed.")        
        else:
            logging.log(str("Cannot handle message %s." % str(message)))        

    async def send_double(self, item, value):
        value = str(value)
        await self.send_message(item, value, "DOUBLE")

    async def send_message(self, item, value_string, type="DOUBLE"):
        message = None
        if value_string:
            message =  "S:" + str(item) + ":20:" + type + ":" + value_string
        else:
            message =  "S:" + str(item) + ":50"
            logging.log("No answer received for command...")

        await self.finalize_serial_to_cloud(message)
        # YOU CAN ALSO SEND SOME LOGS TO THE CLOUD HERE

    '''
    This finalizes a serial message given the OneIoT protocol. Timestamp is added and message is checked.
    Then it is sent to the cloud.
    '''
    async def finalize_serial_to_cloud(self, message):
        message = message_util.add_timestamp(message)
        correct = message_util.check_serial_message(message)
        if not correct:
            await MESSAGE_BUS.send(Event(EVENT_ERROR, "Incorrect handled serial: " + message))
        else:
            # just forward to devicecloud via MQTT
            await MESSAGE_BUS.send(Event(EVENT_TO_CLOUD_FOR_MQTT, [message]))
```

#### Stream Mode

In Stream Mode, the device proactively sends messages to the OneIoT Gateway. For this, the OneIoT [Communication Protocol](/gateway/communication-protocol) can be used and no further driver is used. If your device sends serial messages in other formats, a driver needs to be used.&#x20;

```python
class CustomHandler:

    def __init__(self):

    async def handle_message(self, message):
        # PARSE MESSAGE; EXAMPLE:
        item, value = parse_message(message)
        # SEND TO CLOUD; EXAMPLE:
        await send_double(item, value)
        
        
    def parse_message(message):
        # Semikolon  separated data (example only)
        data = message.split(';')
        item = int(data[0])
        value = data[1]
        return item, value
        
    async def send_double(self, item, value):
        await self.send_message(item, value, "DOUBLE")

    async def send_message(self, item, value_string, type="DOUBLE"):
        message = None
        if value_string:
            message =  "S:" + str(item) + ":20:" + type + ":" + value_string
        else:
            message =  "S:" + str(item) + ":50"
            logging.log("No answer received for command...")

        await self.finalize_serial_to_cloud(message)
        # YOU CAN ALSO SEND SOME LOGS TO THE CLOUD HERE

    '''
    This finalizes a serial message given the OneIoT protocol. Timestamp is added and message is checked.
    Then it is sent to the cloud.
    '''
    async def finalize_serial_to_cloud(self, message):
        message = message_util.add_timestamp(message)
        correct = message_util.check_serial_message(message)
        if not correct:
            await MESSAGE_BUS.send(Event(EVENT_ERROR, "Incorrect handled serial: " + message))
        else:
            # just forward to devicecloud via MQTT
            await MESSAGE_BUS.send(Event(EVENT_TO_CLOUD_FOR_MQTT, [message]))
        
        
        

```

## API Specification

### Modbus Facade

TBD

### Message Util


# Over-The-Air Updates

TBA


# Quick Setup Guide

V2

## General

### Power Connection

#### Battery

Input Supply Voltage: -0.3V - 8V\
Input Currents: < 1000mA

| Battery Status                                       | LED (rot)      | LED (grün/blau) |
| ---------------------------------------------------- | -------------- | --------------- |
| Charging                                             | permanently on | off             |
| Charging finished                                    | off            | permanently on  |
| Supply Voltage to high; Battery voltage to high/low; | off            | off             |
| No battery connected                                 | flashing       | permanently on  |

| Batterie Status                                                                                         | LED (rot) | LED (grün/blau) |
| ------------------------------------------------------------------------------------------------------- | --------- | --------------- |
| Akku wird geladen                                                                                       | leuchtet  | aus             |
| Ladevorgang beendet                                                                                     | aus       | leuchtet        |
| <p>Eingangsspannung zu niedrig;<br>Temperatur des Akkus zu niedrig/hoch;<br>kein Akku angeschlossen</p> | aus       | aus             |
| kein Akku angeschlossen                                                                                 | blinkt    | leuchtet        |

| Blue ESP LED Speed | Description                    |
| ------------------ | ------------------------------ |
| Fast               | Connection not yet established |
| Slow \~5s          | Successfully connected         |

## Using NB-IoT/LTE-M Modem

| Green Modem LED Speed | Description      |
| --------------------- | ---------------- |
| Slow \~1s             | Not connected    |
| Slow \~2s             | Radio cell found |
| Fast                  | Data mode        |


# Gateway Application Manual

This is the manual for the Gateway V2.

## Contents

Make sure that you have all contents listed below:

* The Gateway
* GSM/LTE antenna
* A micro USB Power Cable. Only use this power the device.

## Intended use

## General Information

## Safety Precautions

## Information for compliance with Commission Regulation 801/2013

Power consumption (Idle) TBD

Power consumption (mobile Connection) TBD

## Recycling Information

## Battery Operations

| Battery Status                                       | LED (rot)      | LED (grün/blau) |
| ---------------------------------------------------- | -------------- | --------------- |
| Charging                                             | permanently on | off             |
| Charging finished                                    | off            | permanently on  |
| Supply Voltage to high; Battery voltage to high/low; | off            | off             |
| No battery connected                                 | flashing       | permanently on  |

## Power saving mode

The gateway provides a power saving mode. This can be turned on via the serial protocol. Have a look at the protocol specification for more details. In a power saving setting, it is further recommended to remove all LEDs from the board. There **Gateway base** has 3 LEDs (2 for the Battery and 1 info LED). Furthermore, depending on your **Cloud-Adapter**, there might be further LEDs. The LEDs can be safely removed from the board and adapters. This will reduce the power dissipation by up to *160mW* depending on your setting.&#x20;


# Datasheet Gateway

Datasheet for the Gateway V2 (Q4 2020).

## Features

* Pluggable Cloud Connectivity (WiFi, LTE-M, GSM, ETH\*)
* OTA Firmware Updates
* OTA Adapter Updates
* GNSS (GPS/GLONASS/BD)
* 3V3 and 5V UART serial input
* 20 GPIOs
* 3.7V Battery-/5V Power Supply mode
* Input Voltage Options: USB, Screw Terminal, Battery
* 5V /2A Output power supply
* LiPo Charging
* * overcharge protection (4.25V)
  * overdischarge protection (2.90V)
  * trickle charge
* Power Saving Mode
* Dimensions: 47.88mm x 70.10mm x 7.90mm (w x d x h)

\*Note: The optional Ethernet cloud connectivity module is not part of this datasheet.

## Applications

The Gateway is intended for monitoring and control in areas without any access to Ethernet or WiFi. The gateway is suited for solar operation in conjunction with a sufficiently large rechargeable battery.

* Smart Farming
* Smart City
* Asset Tracking&#x20;
* Weather Station
* Environmental Monitoring
* Extension for mobile/handheld instruments

## General Description

![PCB layout of the gateway.](https://1448869960-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOb77mW1-Ky_sezok91%2F-MUoJNCjzw0OgX0BlC1l%2F-MV8HqGPOxMsRW0Wmbnm%2Fgateway-pcb.png?alt=media\&token=9ec96aa5-502e-4cf9-9c37-7f04bf7f3365)

![Blockdiagram and pinout for the Gateway. The sketched component is optional.](https://1448869960-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOb77mW1-Ky_sezok91%2F-MV8OrNxWX9yRf7odDb5%2F-MV8cD9MJlymsAvO7UJa%2Fgateway_block_diagram.png?alt=media\&token=5726d66c-ccf6-4a95-b15a-5bfafafe5ea5)

### **General information**

This document gives a functional overview of the OneIoT Gateway and describes electronic specification, RF specifications, interfaces as well as product dimensions.

This datasheet is valid for the following products:

| Product              | Version |
| -------------------- | ------- |
| OneIoT Gateway - LTE | V2      |

If some products differ for some characteristics it will be mentioned in the corresponding section.

### **Copyright**

This datasheet contains technical information that are intellectual property of the OneIoT UG. Replicating, forwarding, using or communicating the contents of this document are forbidden without consent of OneIoT UG.&#x20;

Copyright OneIoT UG , 2021

### Functional Overview

#### **Power supply**

The gateway can either be powered by USB with 5V and >0.7A. Note that most USB outputs only provide 0.5A of current. Therefore, the gateway should only be powered with the included power supply or one that can supply >0.7A.&#x20;

Another option is to battery power the device. The battery can be charged via USB.

Furthermore, you can provide power via the screw terminal with 5V and >0.7A. This power interface can also be used to charge the battery.

#### **SIM interface**

The gateway has a micro-SIM interface. The SIM card will be provided with the gateway and can not be used with other devices.

#### Cloud connectivity

The Gateway comes with four different connection modes:

* Wi-Fi connection
* LTE-M
* NB-IoT
* GSM/EGPRS (fallback)

For details on how to configure these modes, have a look at the [Gateway Application Manual.](/gateway/gateway-manual)

#### **Info LED State**

There is a blue info LED on the board, which informs about the current state of the gateway.&#x20;

| Battery Status                                | LED (blue)                |
| --------------------------------------------- | ------------------------- |
| Trying to establish a connection to the cloud | Fast blinking (10/s)      |
| Error, trying to reconnect                    | Slow blinking (1/s)       |
| Normal operation, connection established      | Very slow blinking (1/5s) |

#### Battery Mode

The gateway can be operated with batteries, e.g., in conjunction with a solar module. The battery will be charged and protected by circuits provided by the gateway. There are two indicator LED to provide information about the charging state of the battery.

#### !Only use High-Quality 3.7V LiPos with the gateway.!

**Indicator Light State**

| Battery Status                                       | LED (red)      | LED (green)    |
| ---------------------------------------------------- | -------------- | -------------- |
| Charging                                             | permanently on | off            |
| Charging finished                                    | off            | permanently on |
| Supply Voltage to high; Battery voltage to high/low; | off            | off            |
| No battery connected                                 | flashing       | permanently on |

For details and further features have a look at the [TP4056 datasheet.](https://dlnmh9ip6v2uc.cloudfront.net/datasheets/Prototyping/TP4056.pdf)

#### Satellite navigation (GNSS)

TBD

## Electrical Specifications

Unless otherwise noted, all specification hold over operating free-air temperature range of -40°C to 85°C (TA). The normal operation temperature for the mobile modem is -30°C to 85°C. The performance of the modem will be slightly reduced outside the normal temperature range.

### Absolute Maximum Ratings

| Symbol | Parameter               | Min  | Max | Unit |
| ------ | ----------------------- | ---- | --- | ---- |
| VIN    | Power supply voltage    | -0.3 | 5.5 | V    |
| I\_OUT | Output current supplied | -    | 2   | A    |
| TS     | Storage Temperature     | -40  | 90  | °C   |

### Recommended Operating Conditions

| Symbol | Parameter                                 | Min  | Typical | Max | Unit |
| ------ | ----------------------------------------- | ---- | ------- | --- | ---- |
| VIN    | Power supply voltage                      | 3.6  | 5.0     | 5.5 | V    |
| I\_VIN | Current delivered to the gateway          | 0.7  | -       | -   | A    |
| I\_GSM | Current delivered to support GSM fallback | 2.1A | -       | -   | A    |
| TA     | Free-air operating temperature            | -40  | -       | 85  | °C   |

### Battery Mode

| Parameter                     | Value        |
| ----------------------------- | ------------ |
| Input Supply Voltage          | -0.3V - 8.0V |
| Input Current (Programmable)  | < 1000mA     |
| Charge Voltage (Programmable) | 4.2V         |
| Trickle Charge Threshold      | 2.9V         |

### Power Consumption

The following values have all been measured at 25°C, 45% humidity.

| Mode                          | Power consumption  |
| ----------------------------- | ------------------ |
| NB-IoT/LTE-M/Connection Setup | 0.479W/0.576W/1W\* |
| WiFi mode                     | 0.920W             |
| Idle                          | 0.132W             |
| Sleep Mode                    | 0.010W             |
| LEDs                          | \~0.100W           |

\*Power consumption with a mobile connection depends on the signal strength and the used bands and category. For more details, consult the [SIM7000E datasheet](https://simcom.ee/documents/SIM7000E/SIM7000%20Hardware%20Design_V1.05.pdf).&#x20;

## RF Characteristics

### Wi-Fi

The gateway supports Wi-Fi 802.11 b/g/n at a frequency rane of 2.4GHz \~ 2.5GHz. For the Wi-Fi RF characteristics, take a look at the [ESP32 datasheet](https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf), section 5.6.

### LTE

The gateway supports LTE-FDD B3, B8, B20 and B28  (LTE-M1 and LTE-NB1). For the LTE RF characteristics, take a look at the [SIM7000E datasheet](https://simcom.ee/documents/SIM7000E/SIM7000%20Hardware%20Design_V1.05.pdf), section 4.1.

### GPRS

As a fallback option, the gateway is also able to establish the cloud connection via GPRS. It supports EGSM 900MHz as well as DCS 1800MHz. For the  GPRS RF characteristics, take a look at the [SIM7000E datasheet](https://simcom.ee/documents/SIM7000E/SIM7000%20Hardware%20Design_V1.05.pdf), section 4.1.

### GNSS

The gateway provides location information via GNSS enhanced with network information. It supports GPS, GLONASS and BD. For the  GPRS RF characteristics, take a look at the [SIM7000E datasheet](https://simcom.ee/documents/SIM7000E/SIM7000%20Hardware%20Design_V1.05.pdf), section 4.3.

## ESD Notes

TBD

## Interface applications

### UART Interface

The gateway provides an 3-wire UART interface to connected devices. The recommended logic level for this interface is 3V3 but it also operates with 5V logic level. It supports RS232 and RS485 and can communicate at a speed of up to Mbps.

### GPIOs

For the GPIOs DC characteristics, take a look at the [ESP32 datasheet](https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf), since they are directly connected to the corresponding ESP32 pins.

## Further characteristics

For further information about electrical characteristics and RF characteristics, please consult the datasheets of the Espressif ESP32 and SIMCOM SIM7000E.

## Power saving mode

The gateway provides a power saving mode. This can be turned on via the serial protocol. Have a look at the protocol specification for more details. In a power saving setting, it is further recommended to remove all LEDs from the board. There **Gateway base** has 3 LEDs (2 for the Battery and 1 info LED). Furthermore, depending on your **Cloud-Adapter**, there might be further LEDs. The LEDs can be safely removed from the board and adapters. This will reduce the power dissipation by up to 100*mW* depending on your setting.&#x20;

## Gateway dimensions

![ 47.879mm x 70.104mm](https://1448869960-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOb77mW1-Ky_sezok91%2F-MVDQP3JKuCoZNBwmm3m%2F-MVDYrNvYYi0IS9IHK7N%2Fboard-outline.png?alt=media\&token=5ac22211-e22d-413c-ad61-d40d8d3d018c)

The height of the board depends on the selected components. The PCB has a height of 1.4mm and the largest component (power switch) 6.50mm totalling 7.9mm.

## Case dimensions (optional)

![57.0mm x 87.0mm x 22.0 mm (width x depth x height)](https://1448869960-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOb77mW1-Ky_sezok91%2F-MVDQP3JKuCoZNBwmm3m%2F-MVDUSkzx8eRbP5UYT5w%2Fcase-dimensions.png?alt=media\&token=043bce4d-a7ea-4553-977c-03ed9c1463c0)


# Device Onboarding

Device Onboarding is the process of configuring the **OneIoT Gateway** for your use case and linking the Gateway to your **OneIoT User Account**. In case you are using the Gateway via LAN or with pre-installed SIM card (mobile connection) you don't need any further configuration on the Gateway and you can onboard the device via WebApp (Option 1). In other cases, the Gateway needs to know some configuration for your connection, for example, your WiFi SSID and WiFi Key. You can configure these information using the **OneIoT App.**

## Option 1: OneIoT WebApp

{% hint style="info" %}
This option is only to link a gateway to your account. That means, when your gateway needs any configuration to connect to the network, you will have to use the Mobile App (Option 2).

This Option is applicable if the gateway has already been connected or if the gateway is connected via pre-installed SIM card or LAN
{% endhint %}

Every gateway has a so called **Device Id** and an **Proof-Of-Ownership Token.** There is a card in your Gateway Package with a QR-Code and also the plain text Device Id and Ownership Token. In the upper right corner of the **Device List** you will see a button to add new devices.

![](https://1448869960-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOb77mW1-Ky_sezok91%2F-Mg267r0_gwB_xcjtPj7%2F-Mg28a4Mf2ufe-a69Eip%2FScreenshot%20from%202021-08-01%2021-15-31.png?alt=media\&token=247b7d60-1366-4f0c-97e0-eca31a99192e)

A screen will popup which asks you for the **Device Id** and **Proof-Of-Ownership Token.** All you have to do is to copy the information from your card (or an E-Mail containing this information) and your all set! You will then find the device list.

## Option 2: Using the QR Code and the OneIoT Android App

TBD


# Dashboard

Create your own data dashboard for your measuring devices without programming knowledge.

You can quickly and easily set up your own dashboard according to the individual needs of your measurement device, no matter what the specifications of your measuring device and sensors are. The dashboard always displays the latest measurement data and makes it available to you in real time. Configure your individual dashboard

## Widgets

### Diagram Widget&#x20;

With the diagram widget you can plot measurement data of your measurement device on a chart. This allows the time history of the measurement data to be displayed. There are a few options for displaying the chart with different interpolation functions that you can select.

### Value Widget&#x20;

The value widget allows you to display a latest measurement value of your measurement device. Additionally, you can assign a unit to the displayed value.

### Toggle Widget

TBA

### Button Widget

TBA

## Create or edit your Dashboard

In the Device List, you can click on a device and then go to it's Dashboard. If you have not created any you will see an empty Dashboard. Click on the *Editor Button*, to enter the *Editor:*

![Dashboard Page. Editor can be opened by klicking the Editor Button on the upper right.](https://1448869960-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOb77mW1-Ky_sezok91%2F-Mf9yxZxlgGSjCMjXce9%2F-MfCCPd3BjcSSuXvaNrD%2FScreenshot%20from%202021-07-22%2009-47-25.png?alt=media\&token=aaa06ce2-9994-4d42-a0e1-12334f505148)


# Alert System

TBA


# Diagnostic Tool

TBA


# Device Configuration

TBA


# Device Template

TBA


# OpenID Connect

TBA


# Proof Of Ownership

TBA


