IoT101
A quick overview on the 'Internet of Things' for mere mortals
The topic of Internet-of-Things (IoT) is one of the most talked about among the tech or start-up circle as the most promising trend that potentially could lead to big financial rewards. Big companies continue to dominate the mindshare and sentiments of the IoT scene in various ways. For example, the Industrial 4.0 by Bosch, big data analytics by IBM, cloud platform by Google/Microsoft/AWS and connected hardware by Samsung/Intel, etc.
However in recent years, thanks mostly to cheap manufacturing in China together with the rise of open-source community and hacker/maker communities, we are beginning to see the emergence of low-cost yet powerful hardware that can allow anyone to participate (rather than watching from the sides) in the business of IoT.
Like the proverbial blind men trying to describe what an elephant is, it is impossible for anyone to be able to fully make sense of what this IoT is all about. Nevertheless, it worthwhile to understand the fundamentals of how ‘things’ are ‘connected’ at the device level, from the bottom-up. After all etymologically, IoT consists of ‘things’ connected to/by the ‘Internet’.
Fundamentally, any IoT framework would consists of three layers: Hardware, Communication & Software:
Sensors
Level 0: Hardware
Sensors are useful to collect data about something. They come in different types and variety e.g. temperature, acceleration, heat, light, weight etc.
Microcontroller
Level 1: Hardware
The data collected needs to be gathered, processed and prepared to be transmitted or 'published' to the cloud. At the same time, the microcontroller is used to control actuators based on whatever command that is transmitted or 'subscribed' from the cloud.
Communication Protocol
Level 2: Communication
There are a variety of network or data transport protocols e.g. Wi-Fi, Bluetooth, GSM, etc that allows sensor data to reach the 'cloud' or a backend hardware system.
This also include transfer protocols like TCP/IP, MQTT, etc too. In most cases MQTT is preferred for lightweight messaging.
Cloud
Level 3: Software
A central processing system infrastructure that can be located/re-located anywhere that allows data to be managed and acted upon.
Analytics
Level 4: Software
The data stored in the cloud can be visualized and analysed to gain insights and information that can be used to aid data-driven decision-making. In most cases, monetisation occurs here.
Interface
Software
Physical interfaces such as mobile phone (or smartphone), PCs and tablets are popular way to send instructions or display information on demand. They are connected or 'subscribed' to the cloud so that users can interact with the cloud with it.
Using the ESPresso Lite V2.0 (which technically is an integrated microcontroller with Wi-Fi communication protocol), novice learner can appreciate the relationship between these elements.
BASIC WI-FI CONCEPTS
The Big Picture of Connectivity
In order to be connected to the Internet, the 'wireless access point' (WAP) (aka 'access point' or AP) serves as the communication hub. An example of a WAP will be the home modem or router. Any other devices (e.g. the our laptop/desktop computer) that requires the WAP to be connected to the Internet are called 'stations'. The ESPresso Lite V2 board can either serves as a station or as an access point (and sometimes as both). The communication protocol that these devices use is Wi-Fi (IEEE 802.11 wireless LAN architecture).
Each WAP will have its own network identifier (known as 'service set identifier' or SSID) and often require a password before access to the Internet is granted. As such each station (e.g. ESPresso Lite V2) that is to be connected must be associated to the WAP.
Connecting to the internet
Method to configure the V2.0 board to have Internet access
1. Using the SmartConfig app method
The ESPert SmartConfig application is a quick and easy way to set up Internet connection for ESPresso Lite (both version 1 & 2) devices. This application can also be used by any ESP8266-based devices that can be configured wirelessly to accept existing Wi-Fi network SSID & password credentials broadcasted by the app.
Watch how the LED flashes
Look for long blinks/flashes
When the board is in 'SmartConfig mode', the LED will produce a long period of flashes. If it does not produce short blinks, hold the GPIO13 button for about 5 seconds and release it. The board should reset and enter another mode.
All in all there are a few modes:
If the board does not reset upon holding GPIO13 button, press the RESET button once to reset it, then try again.
If you have the OLED display*, use it
(*optional. not necessary but helpful)
Each time the GPIO13 is press and hold, the board will reboot.
Open the ESPert SmartConfig app.
Enter the password of the existing Internet connection between the smartphone and the WiFi.
Press 'Confirm' and wait for the ESPresso Lite to be successfully connected.
Success!
If the correct password is entered, the OLED display will indicate successful connection.
Else, it will simply reboot to either SmartConfig mode again or enter into AP mode (where you will have to manually configure the Internet access).
Once the board is connected to Internet (Via Wi-Fi), please go to the next section.
2. Using the AP mode (access point) method
When connecting to the Internet, the ESPresso Lite V2.0 is pre-programmed to cycle through several modes simply by holding the GPIO13 button (middle button) for about 5 seconds and releasing it.
Watch how the LED flashes
Look for short blinks/flashes
When the board is in 'AP mode', the LED will produce an intermittent burst of short blinks. If its does not produce short blinks, hold the GPIO13 button for about 5 seconds and release it. The board should reset and enter another mode.
All in all there are a few modes:
If the board does not reset upon holding GPIO13 button, press the RESET button once to reset it, then try again.
If you have the OLED display*, use it
(*optional, recommended)
The string of numbers after 'ESPert-' is the board unique id. A string of IP (internet protocol) numbers or IP address is also display. You will need to use the IP address later.
Scan the Wi-Fi networks
Select the corresponding board id
The board unique id will appear as a selectable SSID. Connect to this network.
(* Should your unique id is in hexadecimal format, please proceed to update the dependencies, libraries & sketch [_2000_Espert_Workshop] to the latest version over here).
Nevertheless, even if the id is in hexadecimal format, there's a way to make meaning out of this.
Use a scientific calcultator to convert hexidecimal to decimal format
Use scientific calcultator
Example uses iMac Calculator
Enter the alphanumerical digits into the scientific calculator in hexadecimal mode (base 16) and press the button '10' (base 10) for decimal format.
Board id in decimal format
This will be the format of the board id shown in OLED display or used in the MQTT topic.
Go to your Internet browser
Key in the IP address 192.168.4.1
Use the IP address as the URL and key it in your web browser and run it.
Choose your Wi-Fi network
Choose from the drop-down list
A box will appear and prompt you to choose the Wi-Fi network with Internet connectivity from a list of SSID. Key in the password and the board will reboot.
Success!
The LED stops flashing
When the board is successful connected to the Internet via the Wi-Fi network, the OLED will display the indicators. The LED will also stop flashing.
3. Connecting to WAP using direct coding
Open a new Arduino sketch
Include the header file
To use the ESPert library, include the header file at the top of the sketch.
#include <ESPert.h>
This 'wrapper' file automatically include the ESP8266WiFi library.
Provide login credentials
Provide SSID and password info
In this instance, the ESPresso Lite V2 will act as a station and will need to execute a function call WiFi.begin (ssid, password)
to connect to the WAP.
Allow for mode change
*will need OLED display
This example codes allows for mode changes in event the connection is not successful. The function call
espert.wifi.init()
will check for connectivity and will display the connect/disconnect states via the serial monitor or the OLED display.
Espert Pte Ltd © 2016