Quantcast
Viewing all articles
Browse latest Browse all 3285

ESP8266 and HCP Internet Of Things Services (BETA) - Part 1

Motivation

 

I was working on a low cost option to connect some sensors to Hana Cloud Platform. HCP Internet Of Things Services (BETA) helped me realize this quicker and in standardized way. On searching internet for possibilities, I came across wifi modules using SoC called ESP8266 from Espressif Systems. I was able to connect DHT11 (Temperature and Humidity sensor) via ESP8266 to HCP IOT Services (BETA). This blog is just to share my experience.

 

What is ESP8266

 

ESP8266 is a low cost Wifi Chip from Espressif Systems. Some vendors have used this chip and provided various WiFi modules. All ESP8266 WIFI Modules come with built in TCP/IP Stack. They have a programmable 32bit Microcontroller and device can be programmed as an internet router to which other devices can connect to or it can be programmed to act as WiFi Client to connect to other servers or both at the same time.

 

Depending on the modules (ESP-1 to ESP-12) you purchase, There are several GPIOs (General Purpose I/O pins) along with SPI, UART and more which enables connecting many types of devices with this module.

 

Some advantages

  • Low cost device for IOT applications. (1/10th of Raspberry Pi)
  • Community support. You need not go through pages of data sheet.
  • Small size.

 

Some limitations that bothered me

  • It cannot connect to a network which has WPA2-Enterprise security. This is pretty easy to overcome, just use an Access Point which is not configured with WPA2-Enterprise security. Easiest one to get is, your cellular network and sharing internet via phone.
  • Cannot POST to HTTPS enabled websites. I had to write a small HTTPS relay service to overcome this.

 

More information on the module can be found here

 

Programming ESP8266

 

Espressif has released their SDK to program this module. It is a complex and needs a fair amount of effort to use the SDK. Open source communities have made this simple by providing two easy ways to do it.

 

  1. A Development Kit and a open source firmware called NodeMCU is available which can be used to program ESP8266 easily with few lines of LUAScripts.: http://nodemcu.com/index_en.html
  2. Arduino IDE for ESP8266 which provides familiar Arduino Environment. For those are who have worked on Arduino, this will be a peice of cake. We will use this option for our project.

 

 

Setting up HCP IOT Services for our project

 

We have to create Device Type, Message Type and Device in IOT cockpit which we can use while sending messages from a particular device.

 

Following are the links where you get more information on HCP IoT Services.

Try out SAP HANA Cloud Platform Internet of Things (IoT) Services (BETA) and Starter Kit

 

 

I assume you already have Hana Cloud Platform Account. If not, you can follow this link to create one.

 

Enable Internet of Things Services (BETA) and Go to the service.

 

  1. Click on Services
  2. Click on Enable
  3. Click on Go to Service -> This will take you to Internet of Things Services Cockpit (BETA)

 

Image may be NSFW.
Clik here to view.
01.png

 

Install Message Management Service from Internet of Things Services Cockpit (BETA)

 

  1. Click on Install Message Management Service.

 

Image may be NSFW.
Clik here to view.
02.png

 

Provide

  1. username,
  2. password and
  3. Install the service. Once the service is successfully installed, iotmms dashboard link is displayed.
  4. Click on the link (4) will not work as you have not assigned the role to access the dashboard. We will do it in next step.

Image may be NSFW.
Clik here to view.
03.png

 

Next step is to add user to the role Iot-MMS-User.

 

Go to the Java Applications in Hana Cloud Platform Cockpit and select "iotmms" from the list of java applications.

 

  1. Select Roles
  2. Click on Assign (This is accessible before the popup is shown)
  3. Provide User ID
  4. Click on Assign

 

Image may be NSFW.
Clik here to view.
04.png

 

  1. Click on Overview
  2. Click on Application URL

 

Image may be NSFW.
Clik here to view.
05.png

 

In the resulting screen as shown below, you can go to Internet of Services Cockpit by clicking on the tile View registered devices and device types.

 

Image may be NSFW.
Clik here to view.
06.png

 

Now It is time to configure our device. Follow the steps mentioned in the images below.

 

Image may be NSFW.
Clik here to view.
07.png

 

Add a device type

 

Image may be NSFW.
Clik here to view.
08.png

 

Add a Message Type as shown in the image below

 

Image may be NSFW.
Clik here to view.
09.png

 

Create a Device as shown in the picture below.

 

Image may be NSFW.
Clik here to view.
10.png

 

Copy the Device ID and token and save it somewhere. We will be using it while sending message from the device.

 

Image may be NSFW.
Clik here to view.
11.png

 

This completes the configuration steps you need to do before actually sending sensor data to HCP.

 

Testing our Device an Message configuration


We have a Device called ESP8266_DHT11 with ID () which is of type TemperatureAndHumidity. We can send message from this device to Hana Cloud Platform IoT services using a pre-defined JSON format. We have to send OAuth token along with message to HCP.


A HTTP Client is provided in the iotmms application itself. We can also use an external http client to test our configuration. I used a Chrome App called Advanced Rest Client to send messages to HCP to mock the message is from a device.

 

Request

Image may be NSFW.
Clik here to view.
12.png

 

Response for first request

 

Image may be NSFW.
Clik here to view.
13.png

 

Response for next requests

 

Image may be NSFW.
Clik here to view.
14.png

 

You can view the messages that were automatically stored HCP by going to iotmms application

 

Image may be NSFW.
Clik here to view.
15.png

 

Image may be NSFW.
Clik here to view.
16.png

 

Hardware setup

 

ESP8266 can be programmed by connecting it to a computer via USB 2.0 to TTL Converter. I used CP2102 converter.

Image may be NSFW.
Clik here to view.
ESP8266_Pinout.png

Connecting ESP8266 to CP2102 converter.

 

ESP8266CP2102
RXTX
TXRX
CH_PD3.3V
GPIO0GND
VCC3.3V
GNDGND

 

Image may be NSFW.
Clik here to view.
17.png

 

Connect DHT11 Data pin to GPIO2 and VCC and GND of the ESP8266.

 

Image may be NSFW.
Clik here to view.
DHT11_Pins.png

 

Once these connections are made, You are ready to program the ESP8266.

 

Part-2 will describe

 

1. Overcoming limitations of ESP8266 Modules.

2. Programming ESP8266 using Arduino IDE to read temperature and humidity from DHT11 sensor and sending it to HCP IoT Services.

 

To be continued...

 

 

 

 


Viewing all articles
Browse latest Browse all 3285

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>