As you know, Internet Of Things is the hottest technical trend in the world recently. So we should study it. A old developers should learn it before becoming a backward guys. And a young developer should learn IOT to make the future better that today, or just simple to have a good job.
I heard about IOT the last year. From there, I thought about it when i have free time. I prepared basic knowledge about IOT as below:
- The Essentials of Electricity & Electronics
- IOT Concept
- IOT Architecture Overview
- MQTT Protocol
I am a Software Developer, I always want to start writing source code after leaning a bit theory. But I do not know how to start. So I joined Maker Hanoi ( A IOT Group in Hanoi Vietnam) and started study a IOT class for beginners there.
At the beginning, I bought a NodeMCU ESP8266 Dev Kit with price 9$ (200.000 VND)
NodeMCU ESP8266 Dev Kit
I also need a micro USB cable to connect Development Kit to my computer.
Micro USB Cable
After having DevKit, I took a look to ESP8266 Datasheet to understand ESP8266’s pins, functions. I also need to refer the image below to know Port Mapping between DevKit and ESP8266.
NodeMCU ESP8266 Dev Kit Pin Out
After the hardware was under my control, I went to the next step – studying software. I was suggested using Sming Framework to write firmware for ESP8266. Sming Framework is easy to understand and use. However, maybe you can have some issues with installation.
My first idea about IOT is pushing data from ESP8266 to an IOT Cloud Platform. Actually, there are many solutions for IOT Platform. For example, I can build a IOT Platform on my own by using open source, or try IBM IOT Platform. However, to simple and free, I chose Koor.IO – An IOT Platform for Developer.
With Koor.IO, I can have use Restful API, Websocket and MQTT. Koor.IO help me collect data and show on chart.
To implement my idea with Koor.IO, I just do the some steps below:
Step 1: Create Project
Create an account on Koor.IO and create my first project.
Create a IOT Project on Koor.IO
Waiting until Koor.IO finishing setup your project
After that, open your project, create Field to indicate what field you need KoorIO collect the data.
Now, you are done with Koor.IO
Step 2: Source code
In this step, you clone Koor.IO’s MQTTClient example.
You need to change configuration file include/config.h
// WIFI config
#define WIFI_SSID "PleaseEnterWifiSSID"
#define WIFI_PWD "PleaseEnterWifiPassword"
// MQTT config
#define MQTT_HOST "PleaseEnterMQTTHost"
#define MQTT_PORT 1883
#define MQTT_TOPIC "PleaseEnterMQTTTopic"
MQTT_TOPIC should be
field is the field you created on koor.io,
project_domain is the domain of your Koor.IO Project.
MQTT_HOST, you enter
And I entered your Wifi Information in WIFI_SSID, WIFI_PWD
Step 4: Build
After change the configuration file, We just need to build the source code and load into ESP6266 by the commands:
build flash was successful, I go to the dashboard of the project on Koor.IO to see the data was pushed from the device. The chart is updated realtime as below.
Koor.IO – Chart – ESP8266
With Linux, in case you can not load data to ESP8266, you should check the connection between DevKit and your computer by command
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
$ dmesg |grep ttyUSB0
[ 11.579581] usb 2-1: ch341-uart converter now attached to ttyUSB0
If you did not see the logs from ESP8266. You can use
screen /dev/ttyUSB0 -b 57600
Thank you for your reading!!!