I found that using ESP32 as Arduino gives huge power to an average hobbyist. IBM Watson IoT like services has a lot of tools (most are free at the basic level of usage) but working guides, snippets are not easy to find by the hobbyists. So I re-written 3 sketches for ESP32 Arduino and also I have "step by step" guides on my blog to use them, modify other codes, write own code to build stuff.
ESP32 boards are sold as generic boards (usually they are clones of DO IT's version 1 board) at $8 to $10 price and have Wi-Fi, Bluetooth. Many new users fear the word NodeMCU. If you can use Arduino, you can use ESP32 as ESP32 is Arduino IDE compatible.
First part is the setup of ESP32 with Arduino IDE. There are several step by step guides on the internet for the required setup. You can read them to follow or simply read our guide to setup ESP32 with Arduino IDE .
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Required Steps to Be Done on IBM Watson IoT
The initial first step was set up of ESP32 with Arduino IDE. There are several guides on the official website of IBM for the setup. However, we have an easy guide to do the basic setup . From that guide, I am copy-pasting the important part :
You’ll need an IBM Cloud account, start an instance of the Watson IoT Platform service from the service catalogue....
Add a device from the Watson IoT Platform. In the Overview dashboard, from the menu pane, select Devices and then click Add Device.Enter a device name, such as my_device_type, enter a device ID, for example, my_first_device. For network-connected devices, the device ID could be the device MAC address without any separating colons. Accept an automatically generated token.
Step 2: Test the Codes
On IBM IoT dashboard, go to Security > Connection Security > TLS Optional (select and save). Install PubSubClient library from Arduino IDE
I have kept the three codes on my GitHub repository as simple-connect.ino, simple-https.ino and temperature.ino. The last one, temperature.ino is easy to start. With this code, the onboard LED on pin 2 will blink each time data published and Arduino IDE's serial monitor will give OK output each time data published. As for "what to edit on the codes", you'll see the parameters required to edit is marked :
// <------- CHANGE PARAMETERS BELOW THIS LINE ------------>
const char ledPin = 2;
const char* ssid = "YOUR-HOTSPOT-NAME"; const char* password = "YOUR-HOTSPOT-PASSWORD";
#define ORG "YOUR-ORG-NAME-ON-IBM-DASHBOARD" #define DEVICE_TYPE "YOUR-SET-DEVICE-TYPE" #define DEVICE_ID "YOUR-SET-DEVICE-ID" #define TOKEN "YOUR-SET-TOKEN-OR-AUTOGENERATED-TOKEN"
// <------- CHANGE PARAMETERS ABOVE THIS LINE ------------>
You can see the log of connection, data on IBM's dashboard and also they provide some widgets to plot graphs.
This ends this short instructable. I hope some peoples can use the codes and develop more things.
Step 3: Visualize on IBM Cloud Dashboard
Using the temperature.ino file, we can check the basic visualization/graphing of data. For this, on the dashboard of Internet of Things control panel, go to "Usage Overview" > click "Add new card" > add a line chart widget. The required data to fill the web form will be populated as drop-down options. You will get a live graph like that of the included screenshot.