Giter Site home page Giter Site logo

me-no-dev / esp8266-azure-iot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ritazh/esp8266-azure-iot

4.0 2.0 1.0 8.87 MB

:cloud: Stream data from/to ESP8266 to/from Azure IoT using MQTT protocol

License: MIT License

Makefile 0.32% HTML 40.66% CSS 0.66% JavaScript 1.34% C 48.80% C++ 6.41% Shell 0.01% Objective-C 1.80%

esp8266-azure-iot's Introduction

ESP8266 RTOS SDK with Azure IoT C SDK

The ESP8266 is a low-cost Wi-Fi chip with full TCP/IP stack and MCU (Micro Controller Unit) capability produced by Espressif Systems.

The ESP8266 RTOS SDK version v1.5 is based on FreeRTOS. This repo integrates ESP8266 RTOS SDK version 1.5 commit bbdf366 with the Azure IoT C SDK version 1.1.3 to stream data from ESP8266 to Azure IoT using MQTT protocol.

Installation / Dependencies

Get Build Environment:

  • Follow this guide
  • Under section 3.3. ESP8266 Toolkit, download VirtualBox and the lubuntu image.
  • Make sure to share a local folder with the VM

Get esptool.py on your host machine:

Clone this repo within the shared folder on your host:

git clone https://github.com/ritazh/ESP8266-Azure-IOT

Setup Azure IoT

To stream data to Azure IoT, you need to provision an Azure IoT Hub and an IoT Hub device. Follow this guide. Once you have completed this step, make sure to copy the device-specific connection string for testing later.

Update Variables

Update the following files within this solution:

/examples/project_template/user/user_main.c

Update these values with your own wifi ssid and password for ESP8266 to connect to

uint8 ssid[] =
uint8 password[] =

/examples/project_template/gen_misc4.sh

Update these variables to the path of the shared folder on the VM

export SDK_PATH=~/ESP8266-Azure-IOT
export BIN_PATH=~/ESP8266-Azure-IOT/bin

/examples/project_template/user/iothub_client_sample_mqtt.c

Update the connectionString variable to the device-specific connection string you got earlier from the Setup Azure IoT step:

static const char* connectionString = '[azure connection string]'

The azure connection string contains Hostname, DeviceId, and SharedAccessKey in the format:

"HostName=<host_name>;DeviceId=<device_id>;SharedAccessKey=<device_key>"

Compile

Now you are ready to compile From the VM, run the following command from a terminal:

./gen_misc4.sh

Once compliation is completed successfully, you should see something that looks like the following:

bin crc: 1a38d19
Support boot_v1.4 and +
Generate user1.4096.new.6.bin successully in BIN_PATH
boot.bin------------>0x00000
user1.4096.new.6.bin--->0x01000
!!!

Flash

Now you are ready to flash the binaries to your ESP8266. From your host machine, cd into /bin.

Run the following command on the host to flash the binaries to ESP8266 using:

esptool.py --port /dev/cu.SLAB_USBtoUART  write_flash --flash_freq 40m --flash_mode qio --flash_size 32m-c1 0x1000 ./upgrade/user1.4096.new.6.bin 0x0 ./boot_v1.5.bin 0x3FC000 ./esp_init_data_default.bin 0x3FE000 ./blank.bin

Test Your Setup

To test that the sample application is streaming data to Azure IoT, download the iothub-explorer on your computer. Use the device-specific connection string you got earlier from the Setup Azure IoT section to get messages received by Azure IoT. Run the following from terminal:

iothub-explorer '[azure connection string]' monitor-events [DeviceId]

The azure connection string contains Hostname, DeviceId, and SharedAccessKey in the format:

"HostName=<host_name>;DeviceId=<device_id>;SharedAccessKey=<device_key>"

To view logs generated by the application, you can install ESPlorer. Note: make sure to set the baud rate to 115200 within the ESPlorer tool.

Update Your Code

To customize this sample solution for your own use, update /examples/project_template/user/iothub_client_sample_mqtt.c with your own data to stream and your own logic.

What's in the Sample?

In the mqtt sample, it continues to send messages to Azure, until cloud sends a "quit" message to end the program. Before the program ends, you can send any message to the device by using the iothub-explorer like the following:

To send a message to a device named "RitaIoT":
iothub-explorer send RitaIoT "hello3" --ack=full

To quit the sample:
iothub-explorer send RitaIoT "quit" --ack=full

You can also send a direct method request to invoke a direct method on the device. For example, using Device Explorer to call a method and the method will return a payload: Direct method test

License

Licensed as MIT - please see LICENSE for details.

esp8266-azure-iot's People

Contributors

me-no-dev avatar ritazh avatar tzxespressio avatar ustccw avatar vjrantal avatar wujiangang avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

clarephang

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.