Easy Starter Kit Tutorial
With our Easy Starter Kit, you will easily learn how to develop smart measuring devices.
Last updated
With our Easy Starter Kit, you will easily learn how to develop smart measuring devices.
Last updated
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.
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.
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
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.
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.
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.
Your Gateway is delivered already linked to your account and configured by our team.
First, download the latest version of the Arduino IDE.
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 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...
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 using the library.
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.
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.
The next step is to configure the item numbers. The item numbers are matching the Digital Twin that we created in the cloud with the Device Template.
Now we need to create the Arduino objects for the sensor and the Gateway connectivity module.
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.
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.
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.
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.
You can now log into the app and view your data and play around with all the app features.