├── .azurecomponent └── azureconfig.json ├── .github └── workflows │ ├── close-resolved-issues.yml │ ├── need-attention-issues.yml │ └── stale-issues.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── Device ├── .iotworkbenchproject ├── .vscode │ ├── arduino.json │ └── settings.json └── device.ino ├── LICENSE ├── README.md ├── SECURITY.md ├── media ├── esp32-get-started │ ├── azure-function-streaming-log.png │ ├── azure-function-streaming-result.png │ ├── change-board.png │ ├── copy-connection-string.png │ ├── create-project.png │ ├── esp32-device-uploaded.png │ ├── esp32-install-sdk.jpg │ ├── hardware.jpg │ ├── install-workbench.png │ ├── monitor-c2d-message.png │ ├── monitor-d2c-message.png │ ├── new-select-board.jpg │ ├── open-example-esp32getstarted.jpg │ ├── project-template.jpg │ └── select-port.png ├── iot-workbench-cloud-deploy.png ├── iot-workbench-cloud-provision-steps2.png ├── iot-workbench-cloud-provision-steps3.png ├── iot-workbench-cloud-provision.png ├── iot-workbench-cloud-provision2.png ├── iot-workbench-device-settings.png ├── iot-workbench-device-upload.png ├── iot-workbench-examples-board.png ├── iot-workbench-examples-cmd.png ├── iot-workbench-examples.png ├── iot-workbench-stream-analytics-and-cosmos-db-data-explorer.png ├── iot-workbench-stream-analytics-and-cosmos-db-provision-step.png └── iot-workbench-stream-analytics-and-cosmos-db-query.png └── project.code-workspace /.azurecomponent/azureconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "componentConfigs": [ 3 | { 4 | "id": "8341d26d-3fd9-3f82-aabf-3000238ff89f", 5 | "folder": "", 6 | "name": "", 7 | "dependencies": [], 8 | "type": "IoTHub" 9 | } 10 | ] 11 | } -------------------------------------------------------------------------------- /.github/workflows/close-resolved-issues.yml: -------------------------------------------------------------------------------- 1 | name: Close resolved issues 2 | 3 | on: 4 | schedule: 5 | - cron: "0 * * * *" 6 | 7 | jobs: 8 | stale: 9 | 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: blackchoey/stale@releases/v1.2 14 | with: 15 | repo-token: ${{ secrets.GITHUB_TOKEN }} 16 | stale-issue-message: 'This issue has been resolved and it will be closed if no further activity occurs within 3 days. Thank you for your contributions.' 17 | stale-issue-label: 'pending close' 18 | days-before-stale: 7 19 | only-labels: 'resolved' 20 | last-updated-user-type: 'collaborator' 21 | days-before-close: 3 22 | operations-per-run: 150 23 | -------------------------------------------------------------------------------- /.github/workflows/need-attention-issues.yml: -------------------------------------------------------------------------------- 1 | name: Pickup issues that needs attention 2 | 3 | on: 4 | schedule: 5 | - cron: "0 * * * *" 6 | 7 | jobs: 8 | stale: 9 | 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: blackchoey/stale@releases/v1.2 14 | with: 15 | repo-token: ${{ secrets.GITHUB_TOKEN }} 16 | stale-issue-message: 'This issue has no recent activities, please take a look and provide updates for it.' 17 | stale-issue-label: 'need attention' 18 | days-before-stale: 3 19 | last-updated-user-type: 'non-collaborator' 20 | days-before-close: 999 21 | operations-per-run: 150 22 | -------------------------------------------------------------------------------- /.github/workflows/stale-issues.yml: -------------------------------------------------------------------------------- 1 | name: Mark stale issues and close them 2 | 3 | on: 4 | schedule: 5 | - cron: "0 * * * *" 6 | 7 | jobs: 8 | stale: 9 | 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: blackchoey/stale@releases/v1.2 14 | with: 15 | repo-token: ${{ secrets.GITHUB_TOKEN }} 16 | stale-issue-message: 'This issue has been automatically marked as stale because it has no recent activities. It will be closed if no further activity occurs within 3 days. Thank you for your contributions.' 17 | stale-issue-label: 'stale' 18 | days-before-stale: 7 19 | only-labels: 'need more info' 20 | last-updated-user-type: 'collaborator' 21 | days-before-close: 3 22 | operations-per-run: 150 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015/2017 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # Visual Studio 2017 auto generated files 33 | Generated\ Files/ 34 | 35 | # MSTest test Results 36 | [Tt]est[Rr]esult*/ 37 | [Bb]uild[Ll]og.* 38 | 39 | # NUNIT 40 | *.VisualState.xml 41 | TestResult.xml 42 | 43 | # Build Results of an ATL Project 44 | [Dd]ebugPS/ 45 | [Rr]eleasePS/ 46 | dlldata.c 47 | 48 | # Benchmark Results 49 | BenchmarkDotNet.Artifacts/ 50 | 51 | # .NET Core 52 | project.lock.json 53 | project.fragment.lock.json 54 | artifacts/ 55 | **/Properties/launchSettings.json 56 | 57 | # StyleCop 58 | StyleCopReport.xml 59 | 60 | # Files built by Visual Studio 61 | *_i.c 62 | *_p.c 63 | *_i.h 64 | *.ilk 65 | *.meta 66 | *.obj 67 | *.iobj 68 | *.pch 69 | *.pdb 70 | *.ipdb 71 | *.pgc 72 | *.pgd 73 | *.rsp 74 | *.sbr 75 | *.tlb 76 | *.tli 77 | *.tlh 78 | *.tmp 79 | *.tmp_proj 80 | *.log 81 | *.vspscc 82 | *.vssscc 83 | .builds 84 | *.pidb 85 | *.svclog 86 | *.scc 87 | 88 | # Chutzpah Test files 89 | _Chutzpah* 90 | 91 | # Visual C++ cache files 92 | ipch/ 93 | *.aps 94 | *.ncb 95 | *.opendb 96 | *.opensdf 97 | *.sdf 98 | *.cachefile 99 | *.VC.db 100 | *.VC.VC.opendb 101 | 102 | # Visual Studio profiler 103 | *.psess 104 | *.vsp 105 | *.vspx 106 | *.sap 107 | 108 | # Visual Studio Trace Files 109 | *.e2e 110 | 111 | # TFS 2012 Local Workspace 112 | $tf/ 113 | 114 | # Guidance Automation Toolkit 115 | *.gpState 116 | 117 | # ReSharper is a .NET coding add-in 118 | _ReSharper*/ 119 | *.[Rr]e[Ss]harper 120 | *.DotSettings.user 121 | 122 | # JustCode is a .NET coding add-in 123 | .JustCode 124 | 125 | # TeamCity is a build add-in 126 | _TeamCity* 127 | 128 | # DotCover is a Code Coverage Tool 129 | *.dotCover 130 | 131 | # AxoCover is a Code Coverage Tool 132 | .axoCover/* 133 | !.axoCover/settings.json 134 | 135 | # Visual Studio code coverage results 136 | *.coverage 137 | *.coveragexml 138 | 139 | # NCrunch 140 | _NCrunch_* 141 | .*crunch*.local.xml 142 | nCrunchTemp_* 143 | 144 | # MightyMoose 145 | *.mm.* 146 | AutoTest.Net/ 147 | 148 | # Web workbench (sass) 149 | .sass-cache/ 150 | 151 | # Installshield output folder 152 | [Ee]xpress/ 153 | 154 | # DocProject is a documentation generator add-in 155 | DocProject/buildhelp/ 156 | DocProject/Help/*.HxT 157 | DocProject/Help/*.HxC 158 | DocProject/Help/*.hhc 159 | DocProject/Help/*.hhk 160 | DocProject/Help/*.hhp 161 | DocProject/Help/Html2 162 | DocProject/Help/html 163 | 164 | # Click-Once directory 165 | publish/ 166 | 167 | # Publish Web Output 168 | *.[Pp]ublish.xml 169 | *.azurePubxml 170 | # Note: Comment the next line if you want to checkin your web deploy settings, 171 | # but database connection strings (with potential passwords) will be unencrypted 172 | *.pubxml 173 | *.publishproj 174 | 175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 176 | # checkin your Azure Web App publish settings, but sensitive information contained 177 | # in these scripts will be unencrypted 178 | PublishScripts/ 179 | 180 | # NuGet Packages 181 | *.nupkg 182 | # The packages folder can be ignored because of Package Restore 183 | **/[Pp]ackages/* 184 | # except build/, which is used as an MSBuild target. 185 | !**/[Pp]ackages/build/ 186 | # Uncomment if necessary however generally it will be regenerated when needed 187 | #!**/[Pp]ackages/repositories.config 188 | # NuGet v3's project.json files produces more ignorable files 189 | *.nuget.props 190 | *.nuget.targets 191 | 192 | # Microsoft Azure Build Output 193 | csx/ 194 | *.build.csdef 195 | 196 | # Microsoft Azure Emulator 197 | ecf/ 198 | rcf/ 199 | 200 | # Windows Store app package directories and files 201 | AppPackages/ 202 | BundleArtifacts/ 203 | Package.StoreAssociation.xml 204 | _pkginfo.txt 205 | *.appx 206 | 207 | # Visual Studio cache files 208 | # files ending in .cache can be ignored 209 | *.[Cc]ache 210 | # but keep track of directories ending in .cache 211 | !*.[Cc]ache/ 212 | 213 | # Others 214 | ClientBin/ 215 | ~$* 216 | *~ 217 | *.dbmdl 218 | *.dbproj.schemaview 219 | *.jfm 220 | *.pfx 221 | *.publishsettings 222 | orleans.codegen.cs 223 | 224 | # Including strong name files can present a security risk 225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 226 | #*.snk 227 | 228 | # Since there are multiple workflows, uncomment next line to ignore bower_components 229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 230 | #bower_components/ 231 | 232 | # RIA/Silverlight projects 233 | Generated_Code/ 234 | 235 | # Backup & report files from converting an old project file 236 | # to a newer Visual Studio version. Backup files are not needed, 237 | # because we have git ;-) 238 | _UpgradeReport_Files/ 239 | Backup*/ 240 | UpgradeLog*.XML 241 | UpgradeLog*.htm 242 | ServiceFabricBackup/ 243 | *.rptproj.bak 244 | 245 | # SQL Server files 246 | *.mdf 247 | *.ldf 248 | *.ndf 249 | 250 | # Business Intelligence projects 251 | *.rdl.data 252 | *.bim.layout 253 | *.bim_*.settings 254 | *.rptproj.rsuser 255 | 256 | # Microsoft Fakes 257 | FakesAssemblies/ 258 | 259 | # GhostDoc plugin setting file 260 | *.GhostDoc.xml 261 | 262 | # Node.js Tools for Visual Studio 263 | .ntvs_analysis.dat 264 | node_modules/ 265 | 266 | # Visual Studio 6 build log 267 | *.plg 268 | 269 | # Visual Studio 6 workspace options file 270 | *.opt 271 | 272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 273 | *.vbw 274 | 275 | # Visual Studio LightSwitch build output 276 | **/*.HTMLClient/GeneratedArtifacts 277 | **/*.DesktopClient/GeneratedArtifacts 278 | **/*.DesktopClient/ModelManifest.xml 279 | **/*.Server/GeneratedArtifacts 280 | **/*.Server/ModelManifest.xml 281 | _Pvt_Extensions 282 | 283 | # Paket dependency manager 284 | .paket/paket.exe 285 | paket-files/ 286 | 287 | # FAKE - F# Make 288 | .fake/ 289 | 290 | # JetBrains Rider 291 | .idea/ 292 | *.sln.iml 293 | 294 | # CodeRush 295 | .cr/ 296 | 297 | # Python Tools for Visual Studio (PTVS) 298 | __pycache__/ 299 | *.pyc 300 | 301 | # Cake - Uncomment if you are using it 302 | # tools/** 303 | # !tools/packages.config 304 | 305 | # Tabs Studio 306 | *.tss 307 | 308 | # Telerik's JustMock configuration file 309 | *.jmconfig 310 | 311 | # BizTalk build output 312 | *.btp.cs 313 | *.btm.cs 314 | *.odx.cs 315 | *.xsd.cs 316 | 317 | # OpenCover UI analysis results 318 | OpenCover/ 319 | 320 | # Azure Stream Analytics local run output 321 | ASALocalRun/ 322 | 323 | # MSBuild Binary and Structured Log 324 | *.binlog 325 | 326 | # NVidia Nsight GPU debugger configuration file 327 | *.nvuser 328 | 329 | # MFractors (Xamarin productivity tool) working folder 330 | .mfractor/ 331 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Microsoft Open Source Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 4 | 5 | Resources: 6 | 7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 10 | -------------------------------------------------------------------------------- /Device/.iotworkbenchproject: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Device/.vscode/arduino.json: -------------------------------------------------------------------------------- 1 | { 2 | "board": "espressif:esp32:m5stack-core-esp32", 3 | "sketch": "device.ino", 4 | "configuration": "FlashMode=qio,FlashFreq=80,PartitionScheme=default,UploadSpeed=921600,DebugLevel=none", 5 | "output": "./.build" 6 | } 7 | -------------------------------------------------------------------------------- /Device/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.exclude": { 3 | ".build": true, 4 | ".iotworkbenchproject": true 5 | } 6 | } -------------------------------------------------------------------------------- /Device/device.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * A simple Azure IoT example for sending telemetry to Iot Hub. 3 | */ 4 | 5 | #include 6 | #include "Esp32MQTTClient.h" 7 | 8 | #define INTERVAL 10000 9 | #define MESSAGE_MAX_LEN 256 10 | // Please input the SSID and password of WiFi 11 | const char* ssid = ""; 12 | const char* password = ""; 13 | 14 | /*String containing Hostname, Device Id & Device Key in the format: */ 15 | /* "HostName=;DeviceId=;SharedAccessKey=" */ 16 | /* "HostName=;DeviceId=;SharedAccessSignature=" */ 17 | static const char* connectionString = ""; 18 | const char *messageData = "{\"messageId\":%d, \"Temperature\":%f, \"Humidity\":%f}"; 19 | static bool hasIoTHub = false; 20 | static bool hasWifi = false; 21 | int messageCount = 1; 22 | static bool messageSending = true; 23 | static uint64_t send_interval_ms; 24 | 25 | static void SendConfirmationCallback(IOTHUB_CLIENT_CONFIRMATION_RESULT result) 26 | { 27 | if (result == IOTHUB_CLIENT_CONFIRMATION_OK) 28 | { 29 | Serial.println("Send Confirmation Callback finished."); 30 | } 31 | } 32 | 33 | static void MessageCallback(const char* payLoad, int size) 34 | { 35 | Serial.println("Message callback:"); 36 | Serial.println(payLoad); 37 | } 38 | 39 | static void DeviceTwinCallback(DEVICE_TWIN_UPDATE_STATE updateState, const unsigned char *payLoad, int size) 40 | { 41 | char *temp = (char *)malloc(size + 1); 42 | if (temp == NULL) 43 | { 44 | return; 45 | } 46 | memcpy(temp, payLoad, size); 47 | temp[size] = '\0'; 48 | // Display Twin message. 49 | Serial.println(temp); 50 | free(temp); 51 | } 52 | 53 | static int DeviceMethodCallback(const char *methodName, const unsigned char *payload, int size, unsigned char **response, int *response_size) 54 | { 55 | LogInfo("Try to invoke method %s", methodName); 56 | const char *responseMessage = "\"Successfully invoke device method\""; 57 | int result = 200; 58 | 59 | if (strcmp(methodName, "start") == 0) 60 | { 61 | LogInfo("Start sending temperature and humidity data"); 62 | messageSending = true; 63 | } 64 | else if (strcmp(methodName, "stop") == 0) 65 | { 66 | LogInfo("Stop sending temperature and humidity data"); 67 | messageSending = false; 68 | } 69 | else 70 | { 71 | LogInfo("No method %s found", methodName); 72 | responseMessage = "\"No method found\""; 73 | result = 404; 74 | } 75 | 76 | *response_size = strlen(responseMessage) + 1; 77 | *response = (unsigned char *)strdup(responseMessage); 78 | 79 | return result; 80 | } 81 | 82 | 83 | 84 | void setup() { 85 | Serial.begin(115200); 86 | Serial.println("ESP32 Device"); 87 | Serial.println("Initializing..."); 88 | Serial.println(" > WiFi"); 89 | Serial.println("Starting connecting WiFi."); 90 | 91 | delay(10); 92 | WiFi.mode(WIFI_AP); 93 | WiFi.begin(ssid, password); 94 | while (WiFi.status() != WL_CONNECTED) { 95 | delay(500); 96 | Serial.print("."); 97 | hasWifi = false; 98 | } 99 | hasWifi = true; 100 | 101 | Serial.println("WiFi connected"); 102 | Serial.println("IP address: "); 103 | Serial.println(WiFi.localIP()); 104 | Serial.println(" > IoT Hub"); 105 | if (!Esp32MQTTClient_Init((const uint8_t*)connectionString, true)) 106 | { 107 | hasIoTHub = false; 108 | Serial.println("Initializing IoT hub failed."); 109 | return; 110 | } 111 | hasIoTHub = true; 112 | Esp32MQTTClient_SetSendConfirmationCallback(SendConfirmationCallback); 113 | Esp32MQTTClient_SetMessageCallback(MessageCallback); 114 | Esp32MQTTClient_SetDeviceTwinCallback(DeviceTwinCallback); 115 | Esp32MQTTClient_SetDeviceMethodCallback(DeviceMethodCallback); 116 | Serial.println("Start sending events."); 117 | randomSeed(analogRead(0)); 118 | send_interval_ms = millis(); 119 | 120 | } 121 | 122 | void loop() { 123 | if (hasWifi && hasIoTHub) 124 | { 125 | if (messageSending && 126 | (int)(millis() - send_interval_ms) >= INTERVAL) 127 | { 128 | // Send teperature data 129 | char messagePayload[MESSAGE_MAX_LEN]; 130 | float temperature = (float)random(0,500)/10; 131 | float humidity = (float)random(0, 1000)/10; 132 | snprintf(messagePayload, MESSAGE_MAX_LEN, messageData, messageCount++, temperature, humidity); 133 | Serial.println(messagePayload); 134 | EVENT_INSTANCE* message = Esp32MQTTClient_Event_Generate(messagePayload, MESSAGE); 135 | Esp32MQTTClient_SendEventInstance(message); 136 | send_interval_ms = millis(); 137 | } 138 | else 139 | { 140 | Esp32MQTTClient_Check(); 141 | } 142 | } 143 | delay(10); 144 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > ### Stop! Before you proceed: 2 | > 3 | > _This Get Started Guide is an **older version** and it is neither maintained nor supported anymore._ 4 | > 5 | > _It is kept here for **reference only** and should not be used for any new development._ 6 | > 7 | > _If you’re looking for a Get Started guide to the Espressif ESP32 there are two alternatives available:_ 8 | > 9 | > 1. _[Azure IoT SDK for C](https://github.com/Azure/azure-sdk-for-c-arduino/blob/main/examples/Azure_IoT_Hub_ESP32/readme.md) which uses a bare metal approach (no RTOS) and support for Arduino IDE._ 10 | > 2. _[Azure IoT middleware for FreeRTOS](https://github.com/Azure-Samples/iot-middleware-freertos-samples) which uses ESP-IDF._ 11 |
12 | 13 | ## Get Started with ESP32 Devices 14 | 15 | For first-time users of ESP32 devices, follow these quick steps to: 16 | - Prepare your development environment. 17 | - Send information from the device to the Azure IoT Hub 18 | - Listen to cloud to device message with ESP32 19 | 20 | ## What you learn 21 | 22 | * How to install the development environment. 23 | * How to create an IoT Hub and register a ESP32 device. 24 | * How to send sample data to your IoT hub. 25 | 26 | ## What you need 27 | 28 | * A ESP32 device. 29 | 30 | > **[NOTE] 31 | > We use [M5Stack](www.m5stack.com) in this tutorial, but the steps below could also be applied to other ESP32 devices.** 32 | 33 | * A computer running Windows 10 or macOS 10.10+. 34 | * An active Azure subscription. [Activate a free 30-day trial Microsoft Azure account](https://azure.microsoft.com/en-us/free/). 35 | 36 | ![Required hardware](media/esp32-get-started/hardware.jpg) 37 | 38 | ## Prepare your hardware 39 | 40 | For M5Stack, please follow the [guide](http://www.m5stack.com/assets/docs/index.html) to prepare the hardware. 41 | 42 | ## Install development environment 43 | 44 | We recommend [Azure IoT Device Workbench](https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.vscode-iot-workbench) extension for Visual Studio Code to develop on the ESP32 devices. 45 | 46 | Azure IoT Device Workbench provides an integrated experience to develop IoT solutions. It helps both on device and cloud development using Azure IoT and other services. You can watch this [Channel9 video](https://channel9.msdn.com/Shows/Internet-of-Things-Show/IoT-Workbench-extension-for-VS-Code) to have an overview of what it does. 47 | 48 | Follow these steps to prepare the development environment for ESP32 devices: 49 | 50 | 1. Download and install [Arduino IDE](https://www.arduino.cc/en/Main/Software). It provides the necessary toolchain for compiling and uploading Arduino code. 51 | * Windows: Use Windows Installer version 52 | * macOS: Drag and drop the Arduino into `/Applications` 53 | * Ubuntu: Unzip it into `$HOME/Downloads/arduino-1.8.5` 54 | 55 | 2. Install [Visual Studio Code](https://code.visualstudio.com/), a cross platform source code editor with powerful developer tooling, like IntelliSense code completion and debugging. 56 | 57 | 3. Look for **Azure IoT Device Workbench** in the extension marketplace and install it. 58 | ![Install IoT Device Workbench](media/esp32-get-started/install-workbench.png) 59 | Together with the IoT Device Workbench, other dependent extensions will be installed. 60 | 61 | 4. Open **File > Preference > Settings** and add following lines to configure Arduino. 62 | 63 | * Windows 64 | 65 | ```JSON 66 | "arduino.path": "C:\\Program Files (x86)\\Arduino", 67 | "arduino.additionalUrls": "https://dl.espressif.com/dl/package_esp32_index.json" 68 | ``` 69 | 70 | * macOS 71 | 72 | ```JSON 73 | "arduino.path": "/Application", 74 | "arduino.additionalUrls": "https://dl.espressif.com/dl/package_esp32_index.json" 75 | ``` 76 | 77 | * Ubuntu 78 | 79 | ```JSON 80 | "arduino.path": "/home/{username}/Downloads/arduino-1.8.5", 81 | "arduino.additionalUrls": "https://dl.espressif.com/dl/package_esp32_index.json" 82 | ``` 83 | 84 | 5. Use `F1` or `Ctrl+Shift+P` (macOS: `Cmd+Shift+P`) to open the command palette, type and select **Arduino: Board Manager**. Search for **esp32** and install the latest version. 85 | 86 | ![Install DevKit SDK](media/esp32-get-started/esp32-install-sdk.jpg) 87 | 88 | ## Build your first project 89 | 90 | Now you are all set with preparing and configuring your development environment. Let us build a "Hello World" sample for IoT: sending simulated telemetry data to Azure IoT Hub. 91 | Make sure your device is **not connected** to your computer. Start VS Code first, and then connect the ESP32 device to your computer. 92 | 93 | ## Open the project folder 94 | 95 | ### Open Azure IoT Device Workbench Examples 96 | 97 | Use `F1` or `Ctrl+Shift+P` (macOS: `Cmd+Shift+P`) to open the command palette, type **Azure IoT Device Workbench**, and then select **Open Examples...**. 98 | 99 | ![IoT Device Workbench: Examples](media/iot-workbench-examples-cmd.png) 100 | 101 | Select **ESP32 Arduino**. 102 | 103 | ![IoT Device Workbench: Examples -> Select board](media/iot-workbench-examples-board.png) 104 | 105 | Then the **IoT Device Workbench Example** window is shown up. 106 | 107 | ![IoT Device Workbench, Examples window](media/iot-workbench-examples.png) 108 | 109 | Find **ESP32 Get Started** and click **Open Sample** button. A new VS Code window with a project folder in it opens. 110 | 111 | ![IoT Device Workbench, select ESP32 Get Started example](media/esp32-get-started/open-example-esp32getstarted.jpg) 112 | 113 | ### Provision Azure service 114 | 115 | In the solution window, open the command palette and select **Azure IoT Device Workbench: Cloud: Provision Azure Services...**. 116 | 117 | ![IoT Device Workbench: Cloud -> Provision](media/iot-workbench-cloud-provision.png) 118 | 119 | Then VS Code guides you through provisioning the required Azure services. 120 | 121 | ![IoT Device Workbench: Cloud -> Provision steps](media/iot-workbench-cloud-provision-steps2.png) 122 | 123 | The whole process includes: 124 | * Select an existing IoT Hub or create a new IoT Hub. 125 | * Select an existing IoT Hub device or create a new IoT Hub device. 126 | 127 | ### Config Device Code 128 | 129 | 1. Open the source file(.ino) for device code and update the following lines with your WiFi ssid and password: 130 | ```csharp 131 | // Please input the SSID and password of WiFi 132 | const char* ssid = ""; 133 | const char* password = ""; 134 | ``` 135 | 136 | 2. Open the command palette and select **Azure IoT Device Workbench: Config Device Settings...**. 137 | 138 | ![IoT Device Workbench: Device -> Settings](media/iot-workbench-device-settings.png) 139 | 140 | 3. Select **Copy device connection string**. 141 | 142 | ![IoT Device Workbench: Device copy connection string](media/esp32-get-started/copy-connection-string.png) 143 | 144 | This copies the connection string that is retrieved from the `Provision Azure services` step. 145 | 146 | 4. Paste the device connection string into the following line in device code 147 | ```csharp 148 | /*String containing Hostname, Device Id & Device Key in the format: */ 149 | /* "HostName=;DeviceId=;SharedAccessKey=" */ 150 | /* "HostName=;DeviceId=;SharedAccessSignature=" */ 151 | static const char* connectionString = ""; 152 | ``` 153 | 154 | ### Build and upload the device code 155 | 156 | 1. Open the command palette and select **Azure IoT Device Workbench: Upload Device Code**. 157 | 158 | ![IoT Device Workbench: Device -> Upload](media/iot-workbench-device-upload.png) 159 | 160 | 2. VS Code then starts verifying and uploading the code to your DevKit. 161 | 162 | ![IoT Device Workbench: Device -> Uploaded](media/esp32-get-started/esp32-device-uploaded.png) 163 | 164 | 3. The ESP32 device reboots and starts running the code. 165 | 166 | ## Test the project 167 | 168 | ### Send D2C message 169 | 170 | Open serial monitor: 171 | 172 | The sample application is running successfully when you see the following results: 173 | 174 | * The Serial Monitor displays the message sent to the IoT Hub. 175 | 176 | ![azure-iot-toolkit-output-console](media/esp32-get-started/monitor-d2c-message.png) 177 | 178 | ### Listen to C2D message 179 | 180 | You can send message to your device with Azure Portal or other API. Please Make sure that serial monitor is open. Then you can see the message content from serial monitor. 181 | 182 | ![azure-iot-toolkit-output-console](media/esp32-get-started/monitor-c2d-message.png) 183 | 184 | ## Problems and feedback 185 | 186 | If you encounter problems, you can reach out to us from: 187 | * [Gitter.im](https://gitter.im/Microsoft/vscode-iot-workbench) 188 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [many more](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets Microsoft's [definition](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)) of a security vulnerability, please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /media/esp32-get-started/azure-function-streaming-log.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/esp32-get-started/azure-function-streaming-log.png -------------------------------------------------------------------------------- /media/esp32-get-started/azure-function-streaming-result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/esp32-get-started/azure-function-streaming-result.png -------------------------------------------------------------------------------- /media/esp32-get-started/change-board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/esp32-get-started/change-board.png -------------------------------------------------------------------------------- /media/esp32-get-started/copy-connection-string.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/esp32-get-started/copy-connection-string.png -------------------------------------------------------------------------------- /media/esp32-get-started/create-project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/esp32-get-started/create-project.png -------------------------------------------------------------------------------- /media/esp32-get-started/esp32-device-uploaded.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/esp32-get-started/esp32-device-uploaded.png -------------------------------------------------------------------------------- /media/esp32-get-started/esp32-install-sdk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/esp32-get-started/esp32-install-sdk.jpg -------------------------------------------------------------------------------- /media/esp32-get-started/hardware.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/esp32-get-started/hardware.jpg -------------------------------------------------------------------------------- /media/esp32-get-started/install-workbench.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/esp32-get-started/install-workbench.png -------------------------------------------------------------------------------- /media/esp32-get-started/monitor-c2d-message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/esp32-get-started/monitor-c2d-message.png -------------------------------------------------------------------------------- /media/esp32-get-started/monitor-d2c-message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/esp32-get-started/monitor-d2c-message.png -------------------------------------------------------------------------------- /media/esp32-get-started/new-select-board.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/esp32-get-started/new-select-board.jpg -------------------------------------------------------------------------------- /media/esp32-get-started/open-example-esp32getstarted.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/esp32-get-started/open-example-esp32getstarted.jpg -------------------------------------------------------------------------------- /media/esp32-get-started/project-template.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/esp32-get-started/project-template.jpg -------------------------------------------------------------------------------- /media/esp32-get-started/select-port.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/esp32-get-started/select-port.png -------------------------------------------------------------------------------- /media/iot-workbench-cloud-deploy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/iot-workbench-cloud-deploy.png -------------------------------------------------------------------------------- /media/iot-workbench-cloud-provision-steps2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/iot-workbench-cloud-provision-steps2.png -------------------------------------------------------------------------------- /media/iot-workbench-cloud-provision-steps3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/iot-workbench-cloud-provision-steps3.png -------------------------------------------------------------------------------- /media/iot-workbench-cloud-provision.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/iot-workbench-cloud-provision.png -------------------------------------------------------------------------------- /media/iot-workbench-cloud-provision2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/iot-workbench-cloud-provision2.png -------------------------------------------------------------------------------- /media/iot-workbench-device-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/iot-workbench-device-settings.png -------------------------------------------------------------------------------- /media/iot-workbench-device-upload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/iot-workbench-device-upload.png -------------------------------------------------------------------------------- /media/iot-workbench-examples-board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/iot-workbench-examples-board.png -------------------------------------------------------------------------------- /media/iot-workbench-examples-cmd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/iot-workbench-examples-cmd.png -------------------------------------------------------------------------------- /media/iot-workbench-examples.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/iot-workbench-examples.png -------------------------------------------------------------------------------- /media/iot-workbench-stream-analytics-and-cosmos-db-data-explorer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/iot-workbench-stream-analytics-and-cosmos-db-data-explorer.png -------------------------------------------------------------------------------- /media/iot-workbench-stream-analytics-and-cosmos-db-provision-step.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/iot-workbench-stream-analytics-and-cosmos-db-provision-step.png -------------------------------------------------------------------------------- /media/iot-workbench-stream-analytics-and-cosmos-db-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/esp32-iot-devkit-get-started/1ca9b3de05e93c4a1ac2a91006acc4a172210330/media/iot-workbench-stream-analytics-and-cosmos-db-query.png -------------------------------------------------------------------------------- /project.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "Device" 5 | } 6 | ], 7 | "settings": { 8 | "IoTWorkbench.BoardId": "esp32", 9 | "IoTWorkbench.DevicePath": "Device" 10 | } 11 | } 12 | --------------------------------------------------------------------------------