Skill Level: Beginner

Basic programming and node-RED experience

Physical comfort at work depends on the right combination of temperature, airflow and humidity. Using an STM F401RE and MEMS shield, workplace temperature, humidity and pressure data will be collected and visualized within IBM Watson in real time.



  • 1 x STM32 Nucleo-F401RE
  • 1 x X-Nucleo-IDW01M1 (Wi-Fi Shield)
  • 1 x X-Nucleo-IKS01A1 (MEMS Sensor Shield)


  • Terminal emulator (communications) program (e.g. Tera-Term)
  • Google APIs


  • IBM Bluemix
  • Google
  • Git


  1. STM32 Nucleo board software prerequisites

    Download STSWLINK009 “STM32 STLink utility” at:


    Download Terminal Emulator (if you do not have one)



    • Once you plug the board into the USB port of you PC, it will create a default drive
    • Drag and drop the bin file “MQTT_IBM_STM32F401RE_Nucleo-IKS01A1_8sec.bin” into the “Nucleo_F401RE” folder on your PC
  2. STM32 Nucleo board hardware prerequisites

    • 1 x STM 32 Nucleo development board (Nucleo-F401RE)



    • 1 x Wi-Fi expansion board (X-NUCLEO-IDW01M1)




    • 1 x motion MEMS expansion board (X-NUCLEO-IKS01A1)



  3. Configure the Tera Term emulator

    Run TeraTerm

    • Select “Setup” > “Serial Port Setup”                                              
    • Set “Port: to the last COM port
    • Set the following parameters
    • BaudRate: 460800
    • Data: 8 bit
    • Parity: none
    • Stop: 1 bit
    • Flow control: none
    • Click OK




    • Select “ Setup” > “Terminal”
    • Select the check box labeled Local echo and select “CR+LF” from Transmit drop-down list under New-Line menu


    • Press the black button on the STM32 Nucleo board



    • When you see the message below, hold the blue button(user button) for at least 5 seconds



    Once you get the prompt to enter the wifi SSID set the board aside and move to the next step in this recipe.


  4. Bluemix application creation and device setup

    Step 1: In IBM Bluemix select the “Internet of Things Platform Starter” boilerplate. By default several services are started – IoTF, Cloudant DB, DevOps, and Node-Red.

    Step 2: Once the application is created, at least one (1) device must be added to the Watson IOT platform service.  That is,

    1. Lunch “Watson IOT platform service”
    2. Click on the “Devices” tab
    3. Click “Add Device” button
    4. Create device type
    5. Enter unique device id
    6. Enter optional parameters if necessary
    7. Click Finish

    Once step 2 is complete, you should see a screen similar to that in figure 1.  The generated token will be used as part of the device configuration process to connect to the IBM Bluemix Watson IOT service (*** Do not lose this information.  If you do, you will have to restart the entire process ***).


      Figure 1: Device credentials


    Resume work on Tera Term… 

    • Enter the details of your wifi network (SSID and password)
    • Enter 2 for the authentication mode


    • Enter the following parameters when prompted:



    ****  Consult the information generated by IBM at the begnning of this step.

    • username: use-token-auth 
    • password: Authentication token generated by IBM Watson
    • hostname: OrgId.messaging.internetofthings.ibmcloud.com
    • Device Type: Created by user in IBM Watson
    • Org_ID: Provided by IBM Watson
    • DeviceID: Created by user in IBM Watson 

    Expected end result:


  5. Application data flow

    Figure 2 below represents how the JSON data being transmitted by the St-Nucleo board is visualized within IBM Bluemix.


    Figure 2: Application data flow

    The “IBM IOT event receiver” is deployed to listen and transmit data to the Web server using web sockets.  The “Analyses” block is used to accumulate and generate statistics, which are then aggregated and sent to the Web server through the web sockets.  This application requires the use of two different web sockets in order to transmit the data asynchronously.


  6. Working with Node-Red

    In order to access the Node-Red JavaScript editor, click on the link generated at the time of application creation.  Figure 3 depicts the Node Red application flow created using the Node-Red editor within IBM Bluemix.


    Figure 3: Application Node-Red flow

    To accumulate and derive the average for a period of time, the “aggregator” node was added to the list of nodes in the Node Red editor (Figure 4).  This process was done from the IBM Bluemix DevOps services. The Eclipse Orion Web IDE was used to update the “package.json” file (added “node-red-contrib-aggregator”:”1.0.4” to the end of the list “dependencies”). Alternatively, it can be done from a local computer by cloning the code using Git and then after modification, commit and push it to the main repository.


    Figure 4: Adding nodes in Node-Red


    From figure 3, the HTTP request/response nodes are used to render an HTML page. A corresponding Web server on the GET request is rendering an HTML page that is loading CSS and JavaScript parts.

    In the JavaScript part there are two listeners:

    1.     Main data (Temperature, Humidity, and Pressure)

    2.     Aggregated data (minimum, maximum value for a defined period of time (1 minute for demo only)).

    To enable the IBM IoT node (event receiver) to receive events, it is necessary to add the unique API key and token into the node configuration (see figure 6). The API key and token can be found in the environment variables section of the Cloud Foundry application (see figure 5).


    Figure 5: Cloud Foundry – environmental variables 



     Figure 6: Double-click the node to configure

  7. Device connectivity

    In order to check if the device is connected – open the IBM Watson IOT platform service, and click on the “Devices” tab (see figure 7).



    Figure 7: Devices section of the IBM Watson platform

  8. Implementing Google APIs

    To visualize the generated dataset, a Google Javascript API was used.  More specifically two APIs were used – one for the “Gauges” and another for the “Line Charts”.

    The Google API key must then be added into the environment variables of the application (DevOps service -> Runtime) – see figure 8.


    Figure 8: Environment variable modification


  9. The final dashboard application

    Figure 9 represents the visual presentation of the data sent from the ST Nucleo board.


    Figure 9: Key Data Visualized Using Gauges and Line Charts


    If the temperature exceeds 26 degrees Celsius, a warning message is displayed (see figure 10).


    Figure 10: ALERT: Temperature Threshold Exceeded

1 comment on"Measuring Thermal Comfort and Temperature - Workplace Design Considerations"

  1. AndreaTrotta January 15, 2020

    where i can find “MQTT_IBM_STM32F401RE_Nucleo-IKS01A1_8sec.bin” and download it?

Join The Discussion