DISCO-STM32L475VG-IOT01A WiFi Sensor Thingspeak

Dependencies:   LPS22HB LSM6DSL HTS221 LIS3MDL VL53L0X

Committer:
mbed_official
Date:
Tue Nov 21 11:30:03 2017 +0000
Revision:
44:63be19b7a3db
Parent:
36:aa0b6789bbd2
Child:
49:d44cac40bf15
Add STM WiFi expansion boards `X-NUCLEO-IDW0XX1`

.
Commit copied from https://github.com/ARMmbed/mbed-os-example-wifi

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:857719181846 1 # mbed-os-example-wifi #
mbed_official 0:857719181846 2
mbed_official 0:857719181846 3 WiFi example for mbed OS
mbed_official 0:857719181846 4
mbed_official 0:857719181846 5 ## Getting started with the WiFi API ##
mbed_official 0:857719181846 6
mbed_official 0:857719181846 7 This is a quick example of a simple WiFi application using the WiFi and network-socket APIs that is provided as a part of [mbed-os](github.com/armmbed/mbed-os).
mbed_official 0:857719181846 8
mbed_official 0:857719181846 9 The program brings up the WiFi and the underlying network interface, and uses it to scans available networks, connects to a network, prints interface and connection details and performs simple HTTP operation.
mbed_official 0:857719181846 10
mbed_official 0:857719181846 11 ### Supported hardware ###
mbed_official 0:857719181846 12
mbed_official 22:887649aaedcb 13 * [UBLOX Odin board](https://developer.mbed.org/platforms/ublox-EVK-ODIN-W2/) built-in WiFi module
mbed_official 22:887649aaedcb 14 * [REALTEK_RTL8195AM](https://developer.mbed.org/platforms/REALTEK-RTL8195AM/) built-in WiFi module
mbed_official 44:63be19b7a3db 15 * [NUCLEO_F401RE](https://developer.mbed.org/platforms/ST-Nucleo-F401RE/) with [X-NUCLEO-IDW04A1](http://www.st.com/content/st_com/en/products/ecosystems/stm32-open-development-environment/stm32-nucleo-expansion-boards/stm32-ode-connect-hw/x-nucleo-idw04a1.html) WiFi expansion board using pins D8 D2 _(of the Arduino connector)_
mbed_official 44:63be19b7a3db 16 * [NUCLEO_F401RE](https://developer.mbed.org/platforms/ST-Nucleo-F401RE/) with [X-NUCLEO-IDW01M1](https://developer.mbed.org/components/X-NUCLEO-IDW01M1/) WiFi expansion board using pins PA_9 PA_10 _(of the Morpho connector)_
mbed_official 10:5b5beb106156 17 * [NUCLEO_F429ZI](https://developer.mbed.org/platforms/ST-Nucleo-F429ZI/) with ESP8266-01 module using pins D1 D0
mbed_official 10:5b5beb106156 18 * [NUCLEO_L476RG](https://developer.mbed.org/platforms/ST-Nucleo-L476RG/) with ESP8266-01 module using pins D8 D2
mbed_official 44:63be19b7a3db 19 * Other mbed targets with ESP8266 module, [X-NUCLEO-IDW04A1](http://www.st.com/content/st_com/en/products/ecosystems/stm32-open-development-environment/stm32-nucleo-expansion-boards/stm32-ode-connect-hw/x-nucleo-idw04a1.html), or [X-NUCLEO-IDW01M1](https://developer.mbed.org/components/X-NUCLEO-IDW01M1/) expansion board
mbed_official 32:bca3f5f442b3 20 *(the mbed target board the WiFi shield gets connected to shouldn't have any other network interface e.g. Ethernet)*
mbed_official 0:857719181846 21
mbed_official 32:bca3f5f442b3 22 ESP8266 is a fallback option and will be used if the build is for unsupported platform.
mbed_official 0:857719181846 23
mbed_official 32:bca3f5f442b3 24 #### Connecting the ESP8266 ####
mbed_official 27:b3c6dba3b6e9 25 To connect the ESP8266 module to your development board, look at the [ESP8266 Cookbook page](https://developer.mbed.org/users/4180_1/notebook/using-the-esp8266-with-the-mbed-lpc1768/). In general, this means hooking up the ESP8266 TX pin to `D0` and the ESP8266 RX pin to `D1` on your development board.
mbed_official 6:9944c5308062 26
mbed_official 32:bca3f5f442b3 27 **Note:** on NUCLEO development boards, pins `D0` and `D1` are used for serial communication with the computer. Use pins `D8` (to ESP8266 TX) and `D2` (to ESP8266 RX) instead.
mbed_official 32:bca3f5f442b3 28
mbed_official 44:63be19b7a3db 29 #### Connecting the X-NUCLEO-IDW0XX1 ####
mbed_official 44:63be19b7a3db 30 To connect the [X-NUCLEO-IDW04A1](http://www.st.com/content/st_com/en/products/ecosystems/stm32-open-development-environment/stm32-nucleo-expansion-boards/stm32-ode-connect-hw/x-nucleo-idw04a1.html) or [X-NUCLEO-IDW01M1](https://developer.mbed.org/components/X-NUCLEO-IDW01M1/) expansion board to your NUCLEO development board, just plug the expansion board on top of the NUCLEO board using the Arduino or Morpho connector, respectively.
mbed_official 6:9944c5308062 31
mbed_official 44:63be19b7a3db 32 ## Getting started ##
mbed_official 0:857719181846 33
mbed_official 0:857719181846 34 1. Import the example
mbed_official 0:857719181846 35
mbed_official 32:bca3f5f442b3 36 ```
mbed_official 32:bca3f5f442b3 37 mbed import mbed-os-example-wifi
mbed_official 32:bca3f5f442b3 38 cd mbed-os-example-wifi
mbed_official 32:bca3f5f442b3 39 ```
mbed_official 32:bca3f5f442b3 40 2. Configure the WiFi shield to use
mbed_official 0:857719181846 41
mbed_official 32:bca3f5f442b3 42 Edit ```mbed_app.json``` to include correct WiFi shield, SSID and Password:
mbed_official 0:857719181846 43
mbed_official 32:bca3f5f442b3 44 ```
mbed_official 33:12f0df4d51d7 45 "config": {
mbed_official 32:bca3f5f442b3 46 "wifi-shield": {
mbed_official 44:63be19b7a3db 47 "help": "Options are WIFI_ESP8266, WIFI_IDW0XX1",
mbed_official 44:63be19b7a3db 48 "value": "WIFI_ESP8266"
mbed_official 32:bca3f5f442b3 49 },
mbed_official 32:bca3f5f442b3 50 "wifi-ssid": {
mbed_official 32:bca3f5f442b3 51 "help": "WiFi SSID",
mbed_official 32:bca3f5f442b3 52 "value": "\"SSID\""
mbed_official 32:bca3f5f442b3 53 },
mbed_official 32:bca3f5f442b3 54 "wifi-password": {
mbed_official 32:bca3f5f442b3 55 "help": "WiFi Password",
mbed_official 32:bca3f5f442b3 56 "value": "\"Password\""
mbed_official 32:bca3f5f442b3 57 }
mbed_official 32:bca3f5f442b3 58 },
mbed_official 32:bca3f5f442b3 59 ```
mbed_official 0:857719181846 60
mbed_official 44:63be19b7a3db 61 Sample ```mbed_app.json``` files are provided for ESP8266 (```mbed_app_esp8266.json```), X-NUCLEO-IDW04A1 (```mbed_app_idw04a1.json```, and X-NUCLEO-IDW01M1 (```mbed_app_idw01m1```).
mbed_official 44:63be19b7a3db 62
mbed_official 33:12f0df4d51d7 63 For built-in WiFi, ignore the value of `wifi-shield`
mbed_official 33:12f0df4d51d7 64
mbed_official 44:63be19b7a3db 65 3. Compile and generate binary
mbed_official 0:857719181846 66
mbed_official 32:bca3f5f442b3 67 For example, for `GCC`:
mbed_official 32:bca3f5f442b3 68
mbed_official 32:bca3f5f442b3 69 ```
mbed_official 32:bca3f5f442b3 70 mbed compile -t GCC_ARM -m UBLOX_EVK_ODIN_W2
mbed_official 32:bca3f5f442b3 71 ```
mbed_official 36:aa0b6789bbd2 72
mbed_official 44:63be19b7a3db 73 4. Open a serial console session with the target platform using the following parameters:
mbed_official 36:aa0b6789bbd2 74 * **Baud rate:** 9600
mbed_official 36:aa0b6789bbd2 75 * **Data bits:** 8
mbed_official 36:aa0b6789bbd2 76 * **Stop bits:** 1
mbed_official 36:aa0b6789bbd2 77 * **Parity:** None
mbed_official 36:aa0b6789bbd2 78
mbed_official 44:63be19b7a3db 79 5. Copy or drag the application `mbed-os-example-wifi.bin` in the folder `mbed-os-example-wifi/BUILD/<TARGET NAME>/<PLATFORM NAME>` onto the target board.
mbed_official 36:aa0b6789bbd2 80
mbed_official 44:63be19b7a3db 81 6. The serial console should display a similar output to below, indicating a successful WiFi connection:
mbed_official 36:aa0b6789bbd2 82 ```
mbed_official 36:aa0b6789bbd2 83 WiFi example
mbed_official 36:aa0b6789bbd2 84
mbed_official 36:aa0b6789bbd2 85 Scan:
mbed_official 36:aa0b6789bbd2 86 Network: Dave Hot Spot secured: Unknown BSSID: 00:01:02:03:04:05 RSSI: -58 Ch: 1
mbed_official 36:aa0b6789bbd2 87 1 network available.
mbed_official 36:aa0b6789bbd2 88
mbed_official 36:aa0b6789bbd2 89 Connecting...
mbed_official 36:aa0b6789bbd2 90 Success
mbed_official 36:aa0b6789bbd2 91
mbed_official 36:aa0b6789bbd2 92 MAC: 00:01:02:03:04:05
mbed_official 36:aa0b6789bbd2 93 IP: 192.168.0.5
mbed_official 36:aa0b6789bbd2 94 Netmask: 255.255.255.0
mbed_official 36:aa0b6789bbd2 95 Gateway: 192.168.0.1
mbed_official 36:aa0b6789bbd2 96 RSSI: -27
mbed_official 36:aa0b6789bbd2 97
mbed_official 36:aa0b6789bbd2 98 Sending HTTP request to www.arm.com...
mbed_official 36:aa0b6789bbd2 99 sent 38 [GET / HTTP/1.1]
mbed_official 36:aa0b6789bbd2 100 recv 64 [HTTP/1.1 301 Moved Permanently]
mbed_official 36:aa0b6789bbd2 101
mbed_official 36:aa0b6789bbd2 102 Done
mbed_official 36:aa0b6789bbd2 103 ```
mbed_official 0:857719181846 104
mbed_official 0:857719181846 105 ## Documentation ##
mbed_official 0:857719181846 106
mbed_official 0:857719181846 107 More information on the network-socket API can be found in the [mbed handbook](https://docs.mbed.com/docs/mbed-os-api-reference/en/5.2/APIs/communication/network_sockets/).