From e20dcc19ac396eca76a4651543845aff7d8e3805 Mon Sep 17 00:00:00 2001 From: Khawaja Usman Riaz Sehgal Date: Thu, 6 May 2021 13:51:12 +0500 Subject: [PATCH 1/3] added support for arduino nano 33 iot board --- .../base-libraries/AzureIoTHub/README.md | 34 +++++++++++++++++++ .../src/scripts/automate_board_config.py | 32 ++++++++++------- 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/build_all/base-libraries/AzureIoTHub/README.md b/build_all/base-libraries/AzureIoTHub/README.md index 1db40ac..a4e3e6e 100644 --- a/build_all/base-libraries/AzureIoTHub/README.md +++ b/build_all/base-libraries/AzureIoTHub/README.md @@ -128,6 +128,40 @@ You should have the following ready before beginning with any board: 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. + +## ARDUINO NANO 33 IOT + +##### ARDUINO NANO 33 IOT board + +1. Install Arduino Nano33 IoT board support into your Arduino IDE. + + - Open Boards Manager from Tools > Board menu and install arduino nano 33 iot platform 1.8.11 or later + + - Select your Arduino Nano 33 IoT 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. Configure board library using the automation script and `python3`. If you choose this method you can skip step 6. + - Clone or download this repo: `git clone https://github.com/Azure/azure-iot-pal-arduino.git` , navigate to the downloaded sub-folder: `cd azure-iot-pal-arduino/build_all/base-libraries/AzureIoTHub/src/scripts` , and check that the script `automate_board_config.py` exists in this location. If this folder or script cannot be located, download the script [directly](https://raw.githubusercontent.com/Azure/azure-iot-pal-arduino/master/build_all/base-libraries/AzureIoTHub/src/scripts/automate_board_config.py). + - Run the script E.x.: `python3 automate_board_config.py` and select appropriate options. + - Note: if you update or reinstall your board library in Arduino you will need to run this script again. + +6. Navigate to where your esp32 board package is located, typically in `C:\Users\\AppData\Local\Arduino15\packages` on Windows and `~/.arduino15/packages/` on Linux + + - Navigate deeper in to `hardware/samd//` where the `platform.txt` file lives. + + - Copy the [`platform.local.txt`](https://github.com/Azure/azure-iot-arduino/blob/master/examples/iothub_ll_telemetry_sample/esp32/platform.local.txt) file from the `samd` folder in the sample into the same folder as the `platform.txt`. + + - Alternatively, or for later versions of the Board Package, add the define `-DDONT_USE_UPLOADTOBLOB` to `build.extra_flags=` in `platform.txt` or a `platform.local.txt` that you create. + +7. Run the sample. + ## License See [LICENSE](LICENSE) file. diff --git a/build_all/base-libraries/AzureIoTHub/src/scripts/automate_board_config.py b/build_all/base-libraries/AzureIoTHub/src/scripts/automate_board_config.py index 92b7ba6..59e992c 100644 --- a/build_all/base-libraries/AzureIoTHub/src/scripts/automate_board_config.py +++ b/build_all/base-libraries/AzureIoTHub/src/scripts/automate_board_config.py @@ -7,6 +7,7 @@ ESP8266_PACKAGE_PATH = Path("packages/esp8266/hardware/esp8266/") ESP32_PACKAGE_PATH = Path("packages/esp32/hardware/esp32/") +NANO33_PACKAGE_PATH = Path("packages/arduino/hardware/samd/") ARDUINO_PACKAGES_PATH = None # Determined by user opts or platform @@ -78,9 +79,9 @@ def usage(): Prints script's opt usage ''' print( - "automate_board_config.py usage:\n" - " -h or --help: Print usage text\n" - " -p or --packages_path: Set custom path for Arduino packages path") + "automate_board_config.py usage:\n" + " -h or --help: Print usage text\n" + " -p or --packages_path: Set custom path for Arduino packages path") sys.exit() @@ -89,9 +90,9 @@ def parse_opts(): Prints script's command line options ''' options, _ = getopt.gnu_getopt( - sys.argv[1:], - 'hp:', - ['help', 'packages_path']) + sys.argv[1:], + 'hp:', + ['help', 'packages_path']) for opt, arg in options: if opt in ('-h', '--help'): @@ -109,7 +110,7 @@ def main(): " for the repo https://github.com/Azure/azure-iot-arduino" \ "\nPlease refer to the license agreement there." \ "\nThis script will update all installed versions of board" \ - " libraries for ESP8266 and/or ESP32." \ + " libraries for ESP8266 and/or ESP32 and/or NANO33" \ "\nDo you wish to proceed? Please answer Y or N:" \ " " @@ -126,9 +127,10 @@ def main(): print("Ensure your response is a Y or N") board_prompt = \ - "Would you like to update your ESP8266 or ESP32 board files?\n" \ + "Would you like to update your ESP8266,ESP32 or NANO33 board files?\n" \ "For ESP8266 please respond: 8266\n" \ "For ESP32 please respond: 32\n" \ + "For NANO33 please respond: 33\n" \ "Which board files would you like to update:" \ " " @@ -145,8 +147,12 @@ def main(): board_to_update = '32' PACKAGE_PATH = ESP32_PACKAGE_PATH break + elif response == '33': + board_to_update = '33' + PACKAGE_PATH = NANO33_PACKAGE_PATH + break else: - print("Ensure your response is either 8226 or 32") + print("Ensure your response is either 8226,32 or 33") global ARDUINO_PACKAGES_PATH if ARDUINO_PACKAGES_PATH is None: @@ -156,7 +162,7 @@ def main(): ARDUINO_PACKAGES_PATH = Path(Path.home() / ".arduino15") elif sys.platform == "win32": ARDUINO_PACKAGES_PATH = Path( - Path.home() / "AppData/Local/Arduino15") + Path.home() / "AppData/Local/Arduino15") else: print(f"Error: no valid board path condition for platform:" f" {sys.platform}") @@ -225,9 +231,11 @@ def main(): " -DUSE_BALTIMORE_CERT" elif PACKAGE_PATH == ESP32_PACKAGE_PATH: append_str = " -DDONT_USE_UPLOADTOBLOB" + elif PACKAGE_PATH == NANO33_PACKAGE_PATH: + append_str = " -DDONT_USE_UPLOADTOBLOB" get_update = update_line_file( - platform_txt_file, "build.extra_flags=", - str_append=append_str) + platform_txt_file, "build.extra_flags=", + str_append=append_str) print(f"Updated: {get_update} for {platform_txt_file}") else: print(f"Could not find {platform_txt_file}") From dde943addedced27167fbc0d39115e6b18ea9922 Mon Sep 17 00:00:00 2001 From: Khawaja Usman Riaz Sehgal Date: Thu, 6 May 2021 15:37:32 +0500 Subject: [PATCH 2/3] updated Readme for Arduino Nano 33 ioT --- build_all/base-libraries/AzureIoTHub/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build_all/base-libraries/AzureIoTHub/README.md b/build_all/base-libraries/AzureIoTHub/README.md index a4e3e6e..d533718 100644 --- a/build_all/base-libraries/AzureIoTHub/README.md +++ b/build_all/base-libraries/AzureIoTHub/README.md @@ -152,11 +152,11 @@ You should have the following ready before beginning with any board: - Run the script E.x.: `python3 automate_board_config.py` and select appropriate options. - Note: if you update or reinstall your board library in Arduino you will need to run this script again. -6. Navigate to where your esp32 board package is located, typically in `C:\Users\\AppData\Local\Arduino15\packages` on Windows and `~/.arduino15/packages/` on Linux +6. Navigate to where your arduino nano 33 iot board package is located, typically in `C:\Users\\AppData\Local\Arduino15\packages` on Windows and `~/.arduino15/packages/` on Linux - Navigate deeper in to `hardware/samd//` where the `platform.txt` file lives. - - Copy the [`platform.local.txt`](https://github.com/Azure/azure-iot-arduino/blob/master/examples/iothub_ll_telemetry_sample/esp32/platform.local.txt) file from the `samd` folder in the sample into the same folder as the `platform.txt`. + - Copy the [`platform.local.txt`](https://github.com/Azure/azure-iot-arduino/blob/master/examples/iothub_ll_telemetry_sample/ArduinoNano33iot/platform.local.txt) file from the `samd` folder in the sample into the same folder as the `platform.txt`. - Alternatively, or for later versions of the Board Package, add the define `-DDONT_USE_UPLOADTOBLOB` to `build.extra_flags=` in `platform.txt` or a `platform.local.txt` that you create. From 6babf290daeaa8c5bb450c568aa225ba2c32c1dc Mon Sep 17 00:00:00 2001 From: Khawaja Usman Riaz Sehgal Date: Thu, 6 May 2021 15:38:11 +0500 Subject: [PATCH 3/3] updated Readme for Arduino Nano 33 ioT --- build_all/base-libraries/AzureIoTHub/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_all/base-libraries/AzureIoTHub/README.md b/build_all/base-libraries/AzureIoTHub/README.md index d533718..9b19be5 100644 --- a/build_all/base-libraries/AzureIoTHub/README.md +++ b/build_all/base-libraries/AzureIoTHub/README.md @@ -156,7 +156,7 @@ You should have the following ready before beginning with any board: - Navigate deeper in to `hardware/samd//` where the `platform.txt` file lives. - - Copy the [`platform.local.txt`](https://github.com/Azure/azure-iot-arduino/blob/master/examples/iothub_ll_telemetry_sample/ArduinoNano33iot/platform.local.txt) file from the `samd` folder in the sample into the same folder as the `platform.txt`. + - Copy the [`platform.local.txt`](https://github.com/Azure/azure-iot-arduino/blob/master/examples/iothub_ll_telemetry_sample/ArduinoNano33iot/platform.local.txt) file from the `ArduinoNano33iot` folder in the sample into the same folder as the `platform.txt`. - Alternatively, or for later versions of the Board Package, add the define `-DDONT_USE_UPLOADTOBLOB` to `build.extra_flags=` in `platform.txt` or a `platform.local.txt` that you create.