2019-01-25 03:46:05 +03:00
# ESP8266 basic example for Azure IoT Central
- Visit [AzureIoTCentral ](https://apps.azureiotcentral.com ) and create a `new application` .
- Select `Sample Devkits`
2019-02-28 06:22:42 +03:00
- Add a new `mxchip` device. (a real device) (under `Device Explorer` )
- Browse into device UI (by clicking to name of the device under `Device explorer` )
- Click/open `Connect` at top-right of the device UI
2019-01-29 02:40:31 +03:00
- Grab `scopeId` , `device Id` and `primary key` and fill the necessary parts under `ESP8266.ino`
2019-01-25 03:46:05 +03:00
```
2019-04-18 05:31:21 +03:00
#define WIFI_SSID "<ENTER WIFI SSID HERE>"
#define WIFI_PASSWORD "<ENTER WIFI PASSWORD HERE>"
2019-01-25 03:46:05 +03:00
2019-04-18 05:31:21 +03:00
const char* SCOPE_ID = "< ENTER SCOPE ID HERE > ";
const char* DEVICE_ID = "< ENTER DEVICE ID HERE > ";
const char* DEVICE_KEY = "< ENTER DEVICE primary / secondary KEY HERE > ";
2019-01-25 03:46:05 +03:00
```
2019-01-26 01:45:03 +03:00
Compile it! and deploy to your device. (see below)
2019-01-25 03:46:05 +03:00
- Download Arduino-CLI from [this link ](https://github.com/arduino/arduino-cli#download-the-latest-stable-release )
2019-04-18 01:37:32 +03:00
- FOR WINDOWS, use version 0.3.3 => [download ](https://github.com/arduino/arduino-cli/releases/download/0.3.3-alpha.preview/arduino-cli-0.3.3-alpha.preview-windows.zip )
- FOR WINDOWS, you will need a [driver for USB to UART ](https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers )
- Add additional url to board manager in arduino-cli.yml (this is usually located in the same folder of CLI executable)
2019-01-25 03:46:05 +03:00
2019-02-14 19:36:30 +03:00
```
board_manager:
additional_urls:
- http://arduino.esp8266.com/stable/package_esp8266com_index.json
```
2019-01-25 03:46:05 +03:00
Setup the environment; (under the project folder)
```
2019-04-18 01:37:32 +03:00
arduino-cli-0.3.... core update-index
arduino-cli-0.3.... core install esp8266:esp8266
arduino-cli-0.3.... board attach esp8266:esp8266:nodemcu
2019-01-25 03:46:05 +03:00
```
Compile!
```
2019-04-18 01:37:32 +03:00
arduino-cli-0.3.... compile
2019-01-25 03:46:05 +03:00
```
Upload
```
2019-04-18 01:37:32 +03:00
arduino-cli-0.3.... upload -p < PORT / DEV ? ? i . e . = > /dev/cu.SLAB_USBtoUART >
2019-01-25 03:46:05 +03:00
```
Monitoring?
```
npm install -g nodemcu-tool
```
Assuming the port/dev for the board is `/dev/cu.SLAB_USBtoUART`
```
nodemcu-tool -p /dev/cu.SLAB_USBtoUART -b 9600 terminal
```