The Ultimate IBM Watson IoT Platform Guide
Here we present you the best guide for using IBM Watson IoT Platform (not saying much because there is no other guide online for this xD) and how to develop WEB applications with IoT devices.
Always use technology to improve the world, if you are a black hat or gray hat hacker please abstain at this point......... or at least leave your respected to make me feel less guilty XP.
Table of contents.
- PC Setup
- Management of the IBM Watson IoT Platform
- Handling of IoT devices using the IBM Watson IoT Platform (specifically ESP8266 using ArduinoIDE)
- Handling WEB pages with connectivity to IBM Watson IoT Platform
- Connectivity between IoT device and WEB application
- Connectivity between WEB application and IoT device
The software world is constantly changing and evolving.
The definition of cloud computing is to offer services through connectivity and the large scale of the Internet. Cloud computing provides access to software resources at an international level, without the need for a server of your own, as it is a software application that serves various clients. Multilocation is what differentiates cloud computing from simple outsourcing and from older application service provider models. Now, small businesses have the power to develop large-scale applications without large resources IMPORTANT.
Cloud computing offers individuals and businesses of all sizes the capacity of a pool of computing resources with good maintenance, secure, easily accessible and on demand, such as servers, data storage and application solution (for example MQTT in this case for IoT).
In a simple way, cloud computing is a technology that allows remote access to software, file storage and data processing through the Internet, being an alternative to running on a personal computer or local server. In the cloud model, there is no need to install applications locally on computers.
IMPORTANT NOTE: Watson does not installs on any computer, he "lives" in the cloud.
- IBM Account (Free accounts are perfect for testing applications but have the following limitations).
- It includes a maximum of 500 registered devices and a maximum of 200 MB of data metrics each.
- A maximum of 500 registered devices.
- A maximum of 500 application links.
- A maximum of 200 MB of data exchanged, analyzed data and limit data analyzed each.
- ESP8266 (This method can be applied to any IoT device such as ESP32, Raspberry, ETC) -----> Links: (https://goo.gl/gXFGzD or https://goo.gl/byRkGx)
- Computer with Apache or WebServer.
(Only if you use Apache server)
PC, MAC or Ubuntu (Linux):To be able to use the Apache service on a computer you need to install XAMPP.https://www.apachefriends.org/es/download.html
Only for Ubuntu (Linux) I prefer to follow the following tutorial to install Apache.
- Register in the IBM Bluemix platform in case you do not have an account.(https://console.bluemix.net).
- In the search box, we input "Watson IoT Platform".
- We select the Search option "Watson IoT Platform" in Catalog.
- We select "Internet of Things Platform".
- Put the name that the Service Name likes where it says "ExampleName" and select the corresponding region.
- In this case select the "Lite" plan to start developing and once selected press "Create".
- Press "Launch" to start the service.
- At this time we have managed to generate our IoT service at IBM.
(Specifically ESP8266 using ArduinoIDE)
- To add your first "Device" we select the "+ Add Device" box.
- Fill the fields of "Device Type" with the name you like to put on your device is only a label in our case we will put "ESP8266" and as Device ID we will put "Test001" but it can be any ID, it is recommended that this ID be the registration number of the device, after that press "Next".
- Insert the "Metadata" that you like and press "Next".
- Leave the field of "Authentication Token" empty, but if you like you can put your own Token, I recommend leaving empty for IBM to provide you with a unique code for your device, after that press "Next".
- In the following box just press "Done".
- In the next window you will find all the necessary data to be able to access the cloud (SAVE ALL THIS DATA SINCE THE AUTHENTICATION TOKEN CAN NOT SEE IT AGAIN).
- If you scrolling down the screen you will see the "Showing Raw Data" window and here you can see the data sent by the ESP8266 (stay on this screen while you flash your device).
Boards (To install the "board" use the following tutorial.).
- For the Arduino code to work we need to install the following boards and libraries.
- Once everything is installed, read the following code, understand the comments and try to compile the code (Download the code inside Arduino Folder).
- If everything went well up to this point you should see how the data appears (Do not worry if you see a strange message in the form of JSON, when we connect to our website this will not matter and we will see our message "Hello IBM").
- We press the "Apps" button in the left sidebar to create an API for our website.
- Click on the "Generate API Key" button.
- Fill in the description data and we will give you "Next".
- We select in the menu "Backend Trusted Application" and Generate Key button.
- The following window will appear to give access to the web page to our interface (SAVE ALL THESE DATA SINCE THE AUTHENTICATION TOKEN CAN NOT SEE IT AGAIN)
- Download the "html" folder where the basic page for mqtt connectivity with IBM comes from and follow the instructions below the image.
- Modify the org variable for your "organization id"
- Modify the variable apl by your "Api Key" but it is very important that you replace the "-" with ":" for example"a-example-example001" -> "a:example:example001"
- Modify userName for your "Api Key"
- Modify password for your "Authentication Token".
- For the example we have prepared, it is not necessary to modify the "topic" variable because the DeviceType and the DeviceID are already set.
- Once all this is done, open the "localhost" path in the browser once the Apache is turned on, also in the debug console you can see the message "onConnect".
- Once all the settings have been made, connect the IoT device and open the WEB page in order to start receiving messages from the device.
- If everything worked so far you should see an alert every time the device sends the value "Hello IBM", in this case every 30 seconds (Check the "Delay" variable in the Arduino Code).
- Surprise!, if you paid a little attention, you will have noticed that the "callback" is already integrated into the Arduino code and each time the device sends a message to the web page the page returns the same message as shown in the image.
- The section of the code of the web page that is responsible for sending data returned is this.
I recommend that if you are interested in this topic, look for the following terms to make a more landed application:
- Progressive Web App.
If this article reaches 50 Respects, we will publish a guide to link IBM watson IoT to Node-RED!