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

Commit

Permalink
Merge pull request #97 from Azure/update_12_3_19
Browse files Browse the repository at this point in the history
manual upload of new lib
  • Loading branch information
jbobotek authored Dec 11, 2019
2 parents 576b018 + 4c1bc55 commit 6780d8b
Show file tree
Hide file tree
Showing 113 changed files with 38,993 additions and 9,248 deletions.
31 changes: 11 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
language: generic
env:
global:
- IDE_VERSION=1.6.12
- IDE_VERSION=1.8.10
matrix:
- BOARD="arduino:samd:arduino_zero_edbg"
- BOARD="arduino:samd:mkr1000"
- BOARD="esp8266:esp8266:huzzah:FlashSize=4M3M,CpuFrequency=80"
- BOARD="esp8266:esp8266:thing"
- BOARD="esp32:esp32:huzzah"
before_install:
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16
- sleep 3
Expand All @@ -18,36 +17,28 @@ before_install:
- tar xf arduino-$IDE_VERSION-linux64.tar.xz
- mv arduino-$IDE_VERSION $HOME/arduino-ide
- export PATH=$PATH:$HOME/arduino-ide
- if [[ "$BOARD" =~ "arduino:samd:" ]]; then
arduino --install-boards arduino:samd;
arduino --install-library WiFi101;
arduino --install-library WiFi101;
arduino --install-library RTCZero;
arduino --install-library NTPClient;
fi
- if [[ "$BOARD" =~ "esp8266:esp8266:" ]]; then
arduino --pref "boardsmanager.additional.urls=http://arduino.esp8266.com/stable/package_esp8266com_index.json" --install-boards esp8266:esp8266;
arduino --pref "boardsmanager.additional.urls=" --save-prefs;
arduino --install-library NTPClient;
fi
- if [[ "$BOARD" =~ "esp32:esp32:" ]]; then
arduino --pref "boardsmanager.additional.urls=https://dl.espressif.com/dl/package_esp32_index.json" --install-boards esp32:esp32;
arduino --pref "boardsmanager.additional.urls=" --save-prefs;
arduino --install-library NTPClient;
fi

- findAndReplace() { sed -i'' -e"s|$1|$2|g" "$3"; }
- buildExampleSketch() {
EXAMPLE_SKETCH=$PWD/examples/$1/$1.ino;

if [[ "$BOARD" =~ "esp8266:esp8266:" ]]; then
findAndReplace WiFi101 ESP8266WiFi $EXAMPLE_SKETCH;
findAndReplace WiFiSSLClient WiFiClientSecure $EXAMPLE_SKETCH;
findAndReplace WiFiUdp WiFiUdp $EXAMPLE_SKETCH;
fi

cat $EXAMPLE_SKETCH;
EXAMPLE_SKETCH=$PWD/examples/iothub_ll_telemetry_sample/telemetry_sample.c.ino;

arduino --verbose-build --verify --board $BOARD $EXAMPLE_SKETCH;
}
install:
- arduino --install-library "AzureIoTUtility"
- arduino --install-library "AzureIoTSocket_WiFi"
- arduino --install-library "AzureIoTProtocol_MQTT"
- arduino --install-library "AzureIoTProtocol_HTTP"
- ln -s $PWD $HOME/Arduino/libraries/.
script:
- buildExampleSketch simplesample_http
- buildExampleSketch telemetry_sample.c
133 changes: 131 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,132 @@
# Azure IoT Currently Does Not Support Arduino.
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

Please refer to the [Espressif Azure IoT GitHub repository](https://github.com/espressif/esp-azure) to use the ESP32 or ESP8266 directly with Azure IoT.
#### Azure IoT Hub Library source files


# AzureIoTHub - Azure IoT Hub library for Arduino

This is the location of the Arduino-specific source files for the

[AzureIoTHub Arduino published library](https://github.com/Azure/azure-iot-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 several Arduino compatible boards with Azure IoT Hub. Please submit any contribution directly to [azure-iot-sdks](https://github.com/Azure/azure-iot-sdks).

Currently supported hardware:

- 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)

- ESP32 based boards with [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32)

- Adafruit [HUZZAH32](https://www.adafruit.com/product/3405)

## Prerequisites

You should have the following ready before beginning with any board:

- [Setup your IoT hub](https://github.com/Azure/azure-iot-device-ecosystem/blob/master/setup_iothub.md)

- [Provision your device and get its credentials](https://github.com/Azure/azure-iot-device-ecosystem/blob/master/setup_iothub.md#create-new-device-in-the-iot-hub-device-identity-registry)

- [Arduino IDE](https://www.arduino.cc/en/Main/Software)

- Install the Azure IoT C SDK libraries by one of two options:
1. Generate the Libraries by executing the [`make_sdk.cmd`](https://github.com/Azure/azure-iot-pal-arduino/blob/master/build_all/make_sdk.cmd) script within the `build_all` folder, with args as follows:
- The folder you want to copy the libraries into as arg 1, and the board you are using (`esp8266` or `esp32`) as arg 2

2. Install the following libraries through the Arduino IDE Library Manager:
- `AzureIoTHub`, `AzureIoTUtility`, `AzureIoTProtocol_MQTT`, `AzureIoTSocket_WiFi`, and, optionally, `AzureIoTSocket_Ethernet2` if you are using the `esp32` with an ethernet shield/daughterboard.

# Simple Sample Instructions

## 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.5.2 or later

- Select your ESP8266 board from Tools > Board menu after installation

2. Open the `iothub_ll_telemetry_sample` example from the Arduino IDE File->Examples->AzureIoTHub menu.

3. Update Wifi SSID/Password in `iot_configs.h`

- 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 `iot_configs.h`

5. Navigate to where your esp8266 board package is located, typically in `C:\Users\<your username>\AppData\Local\Arduino15\packages` on Windows and `~/.arduino15/packages/` on Linux

- Locate the board's Arduino.h (`hardware/esp8266/<board package version>/cores/esp8266/` and comment out the line containing `#define round(x)`, around line 137.

- Locate the board's `platform.txt` and add the defines `-DDONT_USE_UPLOADTOBLOB` `-DUSE_BALTIMORE_CERT` on line 73 (`build.extra_flags=`)

- Note1: Please change the CERT define to the appropriate cert define if not using the global portal.azure.com server, defines for which are laid out in [`certs.c`](https://github.com/Azure/azure-iot-sdk-c/blob/master/certs/certs.c)

- Note2: Due to RAM limits, you must select just one CERT define.

6. Navigate to the AzureIoTUtility library location, typically `C:\Users\<your username>\Documents\Arduino\libraries\AzureIoTUtility\src` on Windows, and `~/Arduino/libraries/AzureIoTUtility/src` on Linux.
- Once there, ensure that `tlsio_mbedtls.c` either is NOT in the `adapters` folder or IS defined/commented out, as this file will produce compile errors when building for esp8266.

7. Run the sample.

8. Access the [SparkFun Get Started](https://azure.microsoft.com/en-us/documentation/samples/iot-hub-c-thingdev-getstartedkit/) tutorial to learn more about Microsoft Sparkfun Dev Kit.

9. Access the [Huzzah Get Started](https://azure.microsoft.com/en-us/documentation/samples/iot-hub-c-huzzah-getstartedkit/) tutorial to learn more about Microsoft Huzzah Dev Kit.

## ESP32

##### Sparkfun ESP32 Thing, Adafruit ESP32 Feather, or generic ESP32 board

1. Install esp32 board support into your Arduino IDE.

- Start Arduino and open Preferences window.

- Enter `https://dl.espressif.com/dl/package_esp32_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 esp32 platform 1.0.2 or later

- Select your ESP32 board from Tools > Board menu after installation

2. Open the `iothub_ll_telemetry_sample` example from the Arduino IDE File->Examples->AzureIoTHub menu.

3. Update Wifi SSID/Password in `iot_configs.h`

- 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 `iot_configs.h`

5. Navigate to where your esp32 board package is located, typically in `C:\Users\<your username>\AppData\Local\Arduino15\packages` on Windows and `~/.arduino15/packages/` on Linux

- Locate the board's `platform.txt` and add the define `-DDONT_USE_UPLOADTOBLOB` on line 53 (`build.extra_flags=`)

6. Navigate to the AzureIoTUtility library location, typically `C:\Users\<your username>\Documents\Arduino\libraries\AzureIoTUtility\src` on Windows, and `~/Arduino/libraries/AzureIoTUtility/src` on Linux
- Once there, ensure that `tlsio_mbedtls.c` is in the `adapters` folder.

7. Run the sample.

8. Access the [SparkFun Get Started](https://azure.microsoft.com/en-us/documentation/samples/iot-hub-c-thingdev-getstartedkit/) tutorial to learn more about Microsoft Sparkfun Dev Kit.

9. Access the [Huzzah Get Started](https://azure.microsoft.com/en-us/documentation/samples/iot-hub-c-huzzah-getstartedkit/) tutorial to learn more about Microsoft Huzzah Dev Kit.

## License

See [LICENSE](LICENSE) file.


[azure-certifiedforiot]: http://azure.com/certifiedforiot

[Microsoft-Azure-Certified-Badge]: images/Microsoft-Azure-Certified-150x150.png (Microsoft Azure Certified)

Complete information for contributing to the Azure IoT Arduino libraries

can be found [here](https://github.com/Azure/azure-iot-pal-arduino).
26 changes: 26 additions & 0 deletions examples/iothub_ll_telemetry_sample/iot_configs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#ifndef IOT_CONFIGS_H
#define IOT_CONFIGS_H

/**
* WiFi setup
*/
#define IOT_CONFIG_WIFI_SSID "your-wifi-name"
#define IOT_CONFIG_WIFI_PASSWORD "your-wifi-pwd"

/**
* Find under Microsoft Azure IoT Suite -> DEVICES -> <your device> -> Device Details and Authentication Keys
* String containing Hostname, Device Id & Device Key in the format:
* "HostName=<host_name>;DeviceId=<device_id>;SharedAccessKey=<device_key>"
*/
#define DEVICE_CONNECTION_STRING "your-iothub-DEVICE-connection-string"

// The protocol you wish to use should be uncommented
//
#define SAMPLE_MQTT
//#define SAMPLE_MQTT_OVER_WEBSOCKETS
//#define SAMPLE_HTTP

#endif /* IOT_CONFIGS_H */
11 changes: 11 additions & 0 deletions examples/iothub_ll_telemetry_sample/sample_init.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#ifndef SAMPLE_INIT_H
#define SAMPLE_INIT_H
#if defined(ARDUINO_ARCH_ESP8266)
#define sample_init esp8266_sample_init
void esp8266_sample_init(const char* ssid, const char* password);
#endif

#endif // SAMPLE_INIT_H
Loading

0 comments on commit 6780d8b

Please sign in to comment.