This repository was archived by the owner on Jul 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 93
Update AzureIoT Library with support for more boards #1
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
5b57a49
Update SDK to support SAMD and ESP8266
stefangordon 93675c3
Update library.properties
stefangordon c48c29a
Cleanup.
stefangordon 69c5783
move/rename esp samples so they show up in ide
obsoleted 5db97d6
Merge pull request #5 from obsoleted/espsampledir
stefangordon 1ed5b4c
Update README.md
stefangordon 2c208ac
Update Library name and add esp8266 to supported archs
obsoleted db42b07
Single HttpsClient implementation for all arch
obsoleted 162884c
Merge pull request #6 from obsoleted/master
stefangordon eba5b0e
Documentation updates.
stefangordon a88cea8
Move NTP stuff to sketch for SAMD
obsoleted 1a7cfe1
Merge pull request #7 from obsoleted/time_to_sketch
stefangordon 5296198
Sync from master
stefangordon 9b964ce
Esp: Update logging use of PSTR
obsoleted 7b001af
Clean up samples a bit
obsoleted 614ae72
Merge pull request #8 from obsoleted/esp_fix_and_samples
stefangordon b10ee9d
Save upstream commit hash when updating sdk
obsoleted a332a6c
ESP8266 (Huzzah and Thing Dev) and SAMD (Feather M0) remote monitorin…
DavidBradburyAttunix e0136d6
Merge pull request #9 from AttunixCorp/master
obsoleted File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,59 @@ | ||
# AzureIoT - Azure IoT library for Arduino | ||
# AzureIoT - Azure IoT Hub library for Arduino | ||
|
||
This library is a port of the [Microsoft Azure IoT device SDK for C](https://github.com/Azure/azure-iot-sdks/blob/master/c/readme.md) to Arduino. It allows you to use your Arduino/Genuino with the [Azure IoT Hub](https://azure.microsoft.com/en-us/services/iot-hub/). | ||
This library is a port of the [Microsoft Azure IoT device SDK for C](https://github.com/Azure/azure-iot-sdks/blob/master/c/readme.md) to Arduino. It allows you to use several Arduino compatible boards with Azure IoT Hub. | ||
|
||
For the Arduino/Genuino [MKR1000](https://www.arduino.cc/en/Main/ArduinoMKR1000) or [Zero](https://www.arduino.cc/en/Main/ArduinoBoardZero) and [WiFi Shield 101](https://www.arduino.cc/en/Main/ArduinoWiFiShield101) only. | ||
Currently supported hardware: | ||
- Atmel SAMD Based boards | ||
- Arduino/Genuino [MKR1000](https://www.arduino.cc/en/Main/ArduinoMKR1000) | ||
- Adafruit [Feather M0](https://www.adafruit.com/products/3010) | ||
- Arduino/Genuino [Zero](https://www.arduino.cc/en/Main/ArduinoBoardZero) and [WiFi Shield 101](https://www.arduino.cc/en/Main/ArduinoWiFiShield101) | ||
- ESP8266 based boards with [esp8266/arduino](https://github.com/esp8266/arduino) | ||
- SparkFun [Thing](https://www.sparkfun.com/products/13711) | ||
- Adafruit [Feather Huzzah](https://www.adafruit.com/products/2821) | ||
|
||
[![Microsoft Azure Certified][Microsoft-Azure-Certified-Badge]][azure-certifiedforiot] | ||
|
||
## Getting started | ||
|
||
See the [Microsoft Azure IoT device SDK for C - Arduino WiFi Shield 101 and MKR1000 Setup Guide](https://github.com/Azure/azure-iot-sdks/blob/master/c/doc/run_sample_on_arduino_wifi101.md). | ||
## Prerequisites | ||
|
||
You should have the following ready before beginning with any board: | ||
- [Setup your IoT hub](https://github.com/Azure/azure-iot-sdks/blob/master/doc/setup_iothub.md) | ||
- [Provision your device and get its credentials](https://github.com/Azure/azure-iot-sdks/blob/master/doc/manage_iot_hub.md) | ||
- [Arduino IDE 1.6.8](https://www.arduino.cc/en/Main/Software) | ||
- Install the `AzureIoTHub` library via the Arduino IDE Library Manager | ||
|
||
## ESP8266 | ||
##### Sparkfun Thing, Adafruit Feather Huzzah, or generic ESP8266 board | ||
|
||
1. Install esp8266 board support into your Arduino IDE. | ||
* Start Arduino and open Preferences window. | ||
* Enter `http://arduino.esp8266.com/stable/package_esp8266com_index.json` into Additional Board Manager URLs field. You can add multiple URLs, separating them with commas. | ||
* Open Boards Manager from Tools > Board menu and install esp8266 platform 2.1.0 or later | ||
* Select your ESP8266 board from Tools > Board menu after installation | ||
|
||
2. Open the AzureIoTHub ESP8266 sample from the Arduino IDE File->Examples menu. | ||
3. Update Wifi SSID/Password in simplesample_http.ino | ||
* Ensure you are using a wifi network that does not require additional manual steps after connection, such as opening a web browser. | ||
4. Update IoT Hub Connection string in simplesample_http.c | ||
|
||
|
||
## Adafruit Feather M0 | ||
1. Install Feather M0 board support into your Arduino IDE. | ||
* Start Arduino and open Preferences window. | ||
* Enter `https://adafruit.github.io/arduino-board-index/package_adafruit_index.json` into Additional Board Manager URLs field. You can add multiple URLs, separating them with commas. | ||
* Open Boards Manager from Tools > Board menu and install Adafruit SAMD Boards 1.0.7 or later. | ||
* Select your Adafruit Feather M0 from Tools > Board menu after installation | ||
2. Install the [Adafruit WINC1500 wifi library](https://learn.adafruit.com/adafruit-feather-m0-wifi-atwinc1500/using-the-wifi-module) | ||
3. Install the `RTCZero` library from the Arduino IDE Library Manager. | ||
2. Open the AzureIoTHub SAMD sample from the Arduino IDE File->Examples menu. | ||
3. Update Wifi SSID/Password in simplesample_http.ino | ||
* Ensure you are using a wifi network that does not require additional manual steps after connection, such as opening a web browser. | ||
4. Update IoT Hub Connection string in simplesample_http.c | ||
|
||
## MKR1000 or Zero + Wifi101 | ||
1. Open the AzureIoTHub SAMD sample from the Arduino IDE File->Examples menu. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: the library is still name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is a good idea. Library.properties has been updated, updating the repo name also seems reasonable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, I'll do so after this is merged. We'll have to do some clean up to remove older releases with the old name. |
||
2. Update Wifi SSID/Password in simplesample_http.ino | ||
* Ensure you are using a wifi network that does not require additional manual steps after connection, such as opening a web browser. | ||
3. Update IoT Hub Connection string in simplesample_http.c | ||
|
||
## License | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
// This example only works with Arduino IDE 1.6.8 or later. | ||
|
||
#include <ESP8266WiFi.h> | ||
#include <time.h> | ||
#include "command_center_http.h" | ||
|
||
|
||
const char ssid[] = "[SSID]"; // your WiFi SSID (name) | ||
const char pass[] = "[PASSWORD]"; // your WiFi password (use for WPA, or use as key for WEP) | ||
const char connectionString[] = "HostName=[HubName].azure-devices.net;DeviceId=[DeviceName];SharedAccessKey=[KEY]"; | ||
|
||
int status = WL_IDLE_STATUS; | ||
|
||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
void setup() { | ||
initSerial(); | ||
initWifi(); | ||
initTime(); | ||
|
||
// This function doesn't exit. | ||
simplesample_http_run(); | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
void loop() { | ||
// Not used. | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
void initSerial() { | ||
// Start serial and initialize stdout | ||
Serial.begin(115200); | ||
Serial.setDebugOutput(true); | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
void initWifi() { | ||
// Attempt to connect to Wifi network: | ||
Serial.print("Attempting to connect to SSID: "); | ||
Serial.println(ssid); | ||
|
||
// Connect to WPA/WPA2 network. Change this line if using open or WEP network: | ||
status = WiFi.begin(ssid, pass); | ||
|
||
while (WiFi.status() != WL_CONNECTED) { | ||
delay(500); | ||
Serial.print("."); | ||
} | ||
|
||
Serial.println("Connected to wifi"); | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////////////////////////////// | ||
void initTime() { | ||
time_t epochTime; | ||
|
||
configTime(0, 0, "pool.ntp.org", "time.nist.gov"); | ||
|
||
while (true) { | ||
epochTime = time(NULL); | ||
|
||
if (epochTime == 0) { | ||
Serial.println("Fetching NTP epoch time failed! Waiting 2 seconds to retry."); | ||
delay(2000); | ||
} else { | ||
Serial.print("Fetched NTP epoch time is: "); | ||
Serial.println(epochTime); | ||
break; | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think the library should be renamed to "AzureIoTHub" as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've agreed to rename this repo to
AzureIoTHub
.