STM32 Nucleo board software prerequisites
Download STSWLINK009 ‚ÄúSTM32 STLink utility‚ÄĚ at:
- Download the ‚Äústswlink009.zip‚ÄĚ file
- Extract the installer
- Run it
Download Terminal Emulator (if you do not have one)
- Pro is available (for free) at:¬†http://download.cnet.com/Tera-Term/3000-20432_4-75766675.html
- Download ‚Äúteraterm-4.89.exe‚Äô‚ÄĚ (or later)
- Run it
- 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
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)
Configure the Tera Term emulator
- 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.
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:
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.
Working with Node-Red
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
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
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
Implementing Google APIs
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
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