How to create a test account on IBM Watson IoT Platform + WiFi SPWF04Sx + TLS and MQTT

If you like it, share it

The demo do this:
Connect the KIT (see details below) to IBM Watson IoT Platform and send to it the pressure sensor data.
For do this we use MQTT and TLS.
The SW is write in uPython and run on the SPWF04Sx WiFi module.

The final result is shown below.

For this example we use this KIT:
X-NUCLEO-IDW04A1 (WiFi evaboard) with FW version 1.1
STEVAL-PCC018V1 (USB/RS232TTL adapter board)
X-NUCLEO-IKS01A2 (Mems Sensor evaboard)
IBM Watson IoT Platform
Firefox browser ver.53.0.3

NOTE:
The FW version used on the SPWF01Sx module is ver.1.1
It will be available soon.

See below the HW kit.


First go to IBM Watson IoT Platform and create your account, see below

Now is necessary get the security certificate from IBM Watson and save it in .der format.
Follow the steps show below.

Connect to the PC your X-NUCLEO-IDW04A1 using an RS232-TTL/USB adapter (we suggest the STEVAL-PCC018V1). See below.

Now open TeraTerm and configure it as shown below.

Verify the dimension of your .der file, see below.

In TeraTerm type this command:

at+s.tlscert=ca,1360

1360 is the dimension of our certificate.

Go to file menu (TeraTerm) and click on: send file
Now select your certificate file (.crt) exported before, make sure to put the check on binary option. See below.

At the end you must see something like below.

Now type, in TeraTerm, the commands below:

  1. AT+S.PYTHON (for enter in uPython mode)
  2. Then type: CTRL E
  3. Modify the file: SPWF04-Bluemix.py
    change SSID, PASSWORD and the name of the IBM Watson account. See below.
  4. Now copy and paste the file SPWF04-Bluemix.py in TeraTerm
  5. Then type: CTRL D
if (w.ssid() != 'PocketCube-A1A2'):
            w.init(mode=WLAN.STA, ssid='PocketCube-A1A2', auth=(WLAN.WPA,'R3TDF0NJ'))
            print ('SSID properly configured')


m.init(ID='d:quickstart:nucleo:123456789emcu')

On the IBM Watson page, you will see pressure sensor data (in mBar).


NOTE:
This example does not handle disconnections, it’s just a test; after a dozen of data the connection is suspended.

ATTENTION:
The SPWF04-Bluemix.py is protected by a password.
For the momente the SPWF04-Bluemix.py is only for AVNET-SILICA customers.
If you are AVNET-SILICA customers, write me an email and request the password for: SPWF04-Bluemix.py
please specify also your Name, City, Country and your contact in AVNET-SILICA.
NOTE:
If you are STM customer please contact directly your local office of STM.