Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1 from stefangordon/master
Browse files Browse the repository at this point in the history
Update AzureIoT Library with support for more boards
  • Loading branch information
sandeepmistry committed Apr 5, 2016
2 parents 7998856 + e0136d6 commit 2f2a227
Show file tree
Hide file tree
Showing 109 changed files with 5,614 additions and 1,369 deletions.
57 changes: 51 additions & 6 deletions README.md
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.
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

Expand Down
75 changes: 75 additions & 0 deletions examples/esp8266/command_center/command_center.ino
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;
}
}
}

Loading

0 comments on commit 2f2a227

Please sign in to comment.