Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Arduino nano33 iot automated board script support #29

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions build_all/base-libraries/AzureIoTHub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 arduino nano 33 iot board package is located, typically in `C:\Users\<your username>\AppData\Local\Arduino15\packages` on Windows and `~/.arduino15/packages/` on Linux

- Navigate deeper in to `hardware/samd/<board package version>/` 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 `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.

7. Run the sample.

## License

See [LICENSE](LICENSE) file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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()


Expand All @@ -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'):
Expand All @@ -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:" \
" "

Expand All @@ -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:" \
" "

Expand All @@ -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:
Expand All @@ -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}")
Expand Down Expand Up @@ -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}")
Expand Down