Arduino NANO 33 Made Easy BLE, Sense and IoT : 11 Steps - yanceythawased
Introduction: Arduino NANO 33 Made Slowly BLE, Sense and IoT
Warm Start
This teacher shows you how to use the free pfodDesignerV3 V3.0.3774+ Android app to create a general purpose Bluetooth Low Zip (BLE) and WiFi connection for Arduino NANO 33 boards without doing any computer programming. There are three (3) Arduino NANO 33 boards, the NANO 33 BLE and NANO 33 BLE Sense, which connect by BLE merely and the NANO 33 IoT which tin can link via BLE or WiFi.
Copulative using pfodApp is the almost flexible agency to tie in via BLE (or WiFi). Come across
Using pfodApp to relate to the NANO 33 BLE (Step 4) and
Using pfodApp to connect to the NANO 33 IoT via BLE (Step 7) and
Using pfodApp to touch base to the NANO 33 IoT via WiFi (Footstep 9) beneath.
Nevertheless mere sketches are besides provided to send user defined statement words via Telnet, for WiFi, or via the free Geographic region nRF UART 2.0 for BLE. Hear
Using the Nordic nRF UART 2.0 app to connect to NANO 33 BLE (Step 5) and
Using the Nordic nRF UART 2.0 app to colligate to the NANO 33 IoT via BLE (Step 8) and
Using a Telnet depot program to tie in to the NANO 33 IoT via WiFi (Abuse 10) below
This tutorial is also available on-line at Arduino NANO 33 Made Easy
Supplies
Arduino NANO 33 -- either BLE surgery Horse sense OR IoT
optionally pfodDesignerV3 and pfodApp
Step 1: Intromission
At that place are a bi of problems with BLE. Insure this page for BLE problems and solutions and there are some BLE trouble shot tips . The learning curved shape is steep and the specification has hundreds of narrow down connect services each of which requires its ain mobile application to join to. This tutorial shows you how to generate Arduino code for a general purpose Nordic UART BLE connection over which you can send and meet a stream of commands and information to a unspecialized purpose BLE UART mobile application. The free pfodDesignerV3 Mechanical man application is accustomed generate the Arduino computer code. The end product is designed to connect to the paid pfodApp Android application program which can display menus, send bidding, log information and prove charts. No more Android programming is required. The Arduino write in code has complete control over what is displayed by pfodApp.
For the NANO 33 IoT you can also connect via WiFi. Again the pfodDesignerV3 generates all the Arduino code and by default is designed to connect to pfodApp with optional 128bit security.
However you do non pauperism to use pfodApp, you can link up to the generated code exploitation the liberal Nordic nRF UART 2.0 surgery a Telnet programs (for the WiFi connection). Sketches are included which provide command words to control the boards.
The free pfodDesigner V3.0.3774+ will generate Arduino code for a comprehensive range of boards and connection types including Serial connections, Bluetooth Low Energy (BLE), WiFi, SMS, Radio set/LoRa, Bluetooth Classic and Ethernet. For examples Arduino cipher for of a wide range of BLE boards see Bluetooth Low Energy (BLE) made spatula-shaped with pfodApp. Here we volition be using a BLE connection for NANO 33 BLE, Sense and IoT and a WiFi connection for the IoT.
All of the NANO 33 boards has extra sensor components that differ between the three (3) boards. The pfodDesignerV3 generates code to read/write the digital outputs and perform analogReads and analogWrites. In the examples under we will turn the board LED off and on and read the voltage at A0 and logarithm and plat it. Once that sketch is running you can add for each one board's specialised sensor libraries and sent their information in place of the analogRead(A0).
pfodDesigner generates needled menus and charts, however you can also program bespoke graphical interfaces in your Arduino cartoon. Above is an example of yellow-bellied terrapin manipulate adjusting a guage. All the inscribe for this control is in your Arduino sketch. No Humanoid computer programing required. See Custom Arduino Controls for more examples.
How pfodApp is optimised for short BLE style messages
Bluetooth Low-altitude Energy (BLE) or Bluetooth V4 is a completely different version of Bluetooth. BLE has been optimised for same contralto power consumption. pfodApp is a general purpose Mechanical man app whose screens, menus, buttons, sliders and plots are completely defined by the device you connect to.
BLE only sends 20 bytes in each message. Luckily the pfod Specification was designed around very small messages. Almost all of pfod's command are fewer then 20 bytes. The usual exception is the first of import menu message which specifies what text, menus, buttons, etc. pfodApp should display to the user, but the size of this message is completely controlled by you and you can use sub-menus to reduce the size of the main menu.
The pfod specification also has a number of features to thin out the message size. Spell the BLE device must respond to every control the pfodApp sends, the response canful be as lanceolate as {} (an empty response). If you need to update the menu the user is viewing in response to a command or due to a ray-call for, you need only direct back the changes in the existing menu, rather and then resending the entire carte. These features keep the almost all messages to to a lesser degree 20 bytes. pfodApp caches menus across re-connections so that the whole menu but needs to be sent once. Thereafter telescoped card updates privy be sent.
Step 2: Creating the Usance Android Menus and Generating the Code
Before looking at for each one of these BLE modules, pfodDesignerV3 will first be secondhand to make up a custom menu to turn a Led on and dispatch and secret plan the voltage read at A0. pfodDesignerV3 can then generate cypher tailored to the particular hardware you select.
You bathroom bound off over this maltreat and arrive dorsum to it later if you like. The part on each module, below, includes the completed code sketch for this example menu generated for that mental faculty and also includes sketches that do non need pfodApp
The free pfodDesignerV3 is accustomed make up the menu and show you an accurate trailer of how the menu will look on your mobile. The pfodDesignerV3 allows you to create menus and sub-menus with buttons and sliders optionally coupled to I/O pins and generate the sketch encrypt for you (see the pfodDesigner example tutorials) but the pfodDesignerV3 does not cover all the features pfodApp supports. See the pfodSpecification.pdf for a complete tilt including data logging and plotting, multi- and single- selections screens, sliders, school tex input, etc.
Create the Custom menu to turn the Arduino Light-emitting diode off and on and Plot A0
Start a new computer menu and select as a target Bluetooth Depleted Energy (BLE) and then take NANO 33 BLE (and Sense). pfodDesignerV3.0.3770+ has support for NANO 33 boards.
Then follow the tutorial Intention a Custom bill of fare to turn the Arduino Led along and off for gradually instructions for creating a Light-emitting diode along/off fare exploitation pfodDesignerV3.
If you don't the like the colours of font sizes or the text, you can easily cut them in pfodDesignerV3 to whatever you want and see a WYSIWYG (What You See Is What You Get) display of the designed menu.
Now we leave add together a Graph button to display the A0 reading. The steps to does this in pfodDesignerV3 are shown in Adding a Graph and Logging Data The AtoD array is 0 to 1023 for 0 to 3.3V
Generating the computer code from pfodDesignerV3 gives the this sketch Nano33BLE_Led_A0.ino
Step 3: NANO 33 BLE / Sense
Both the NANO 33 BLE and the NANO 33 BLE Sense connect via BLE. The NANO 33 BLE as an IMU (Inertial Measurement Unit). The NANO 33 BLE Sense has an IMU and a number of other sensor ICs. Each sensor requires it grade-appropriate library to be installed. Here just the fundamental Digital and Analog I/O will be used, simply you can readily replace the Analog plot data with a detector's information.
Installment support for NANO 33 BLE / Sense
Follow the Getting started with the Arduino NANO 33 BLE instructions to install the NANO 33 room support in the Arduino IDE and load and test with the Blink example. Note of hand: If the board COM port is not found for programming you can double snap the reset push-button to put the board into program mode until it is readjust or power cycled. Also install the ArduinoBLE library from the Arduino IDE library director.
Step 4: Exploitation PfodApp to Connect to the NANO 33 BLE
To connect using the pfodApp, load the Nano33BLE_Led_A0.ino resume and then set up a BLE connector to the NANO 33 BLE (view the pfodAppForAndroidGettingStarted.pdf ) then when you connect you will see the fare you designed above. Clicking in the Led button will toggle the light-emitting diode on/remove. Clicking connected the Voltage Plot button wish show the secret plan of the potential difference on A0. Away default on the plot information is also logged on your mobile for later exercise.
Sending BLE messages thirster then 20 bytes
The BLE message size is modified to 20 bytes, pfodParser V3.32+ includes a pfodBLEBufferedSerial class which buffers the parser.print() and releases them 20 bytes at a time with a detain between each block to allow them to comprise conveyed via BLE. The code generated for the NANO 33 BLE connections includes this BLE buffer (defaults to 1024 byte buffer). The delay betwixt blocks sack adjusted by career pfodBLEBufferedSerial's setBLEBlockSendDelay(Georgia home boy) which should mate the pfodBLESerial's setConnectionInterval(min,max) max treasure. The stay is set by the maxConnectionCount (default 160 => 200mS)
Pace 5: Using the Nordic NRF UART 2.0 App to Connect to NANO 33 BLE
You can also connect to the NANO 33 BLE exploitation the free Nordic nRF UART 2.0 Open the app and click Connect and take the NANO 33 BLE connection. You bequeath get wind the CSV information for the A0 reading organism sent all second.
To control your NANO 33 BLE/Sense from the nRF UART 2.0 you can modify the generated code to remove the pfodParser and add text commands. The modified sketch is Nano33BLE_UART_LED.ino
Nano33BLE_UART_LED.ino adds the SafeString subroutine library via the Depository library Managing director and needs the millisDelay program library installed from How to code Timers and Delays in Arduino
#include "ArduinoBLE.h"
#admit SafeString.h" // set up SafeString library V1.0.3+ via Arduino Library Manager #include "millisDelay.h" // download the millisDelay library from https://www.forward.com.au/pfod/ArduinoProgrammin... // download the pfodParser library from http://World Wide Web.forward.com.au/pfod/pfodParserLibrarie... // pfodParser.zip V3.48+ contains pfodBLEBufferedSerial, pfodParser, pfodSecurity, pfodDelay, pfodSMS and pfodRadio #include "pfodBLEBufferedSerial.h"
The frame-up() sets the Led output and connects the bleBufferedSerial and starts the plot timer.
void setup() {
pinMode(Led_pin, OUTPUT); // end product for 'Led' is initially LOW, digitalWrite(Led_pin, 0); // localize output if (!bleSerial.begin()) { // Serial.println("starting ble failed!"); while (1); } bleBufferedSerial.connect(&bleSerial); plotDataTimer.start(PLOT_DATA_INTERVAL); // get down plot timer } The side by side section defines the commands that will be acknowledged and the delimiters and the command timeout. The timeout will execute the last command if nix else is acceptable with in 0.3sec.
const size_t maxCmdLength = 5; // make SafeStrings at any rate large enough to hold longest cmd
createSafeString(onCmdStr, maxCmdLength, "happening"); createSafeString(offCmdStr, maxCmdLength, "off"); // stimulus must be large sufficiency to hold longest cmd + 1 delimiter createSafeString(input, maxCmdLength + 1); // to read input signal cmd + 1 delimiter createSafeString(token, maxCmdLength + 1); // for parsing, capacity >= input.capacitance() char delimiters[] = " .,\r\n"; // place dot comma CR NL are cmd delimiters millisDelay timeout; unsigned long TIMEOUT_MS = 300; // 0.3sec
The loop() code is very simple. It collects chars from the BLE UART connection and then breaks it to tokens and executes any recognized command. If the command is invalid the message "Commands are on,inactive" is returned.
void loop() {
if (input.read(bleBufferedSerial)) { // read from Serial, returns true if at any rate same character was added to SafeString input timeout.start(TIMEOUT_MS); // restart a 0.3sec timer every time something is take } if (input.nextToken(token, delimiters)) { // process at most one token per loop does not rejoi tokens yearner than input.capacity() if (item == onCmdStr) { digitalWrite(Led_pin, 1); // set output bleBufferedSerial.mark("Light-emitting diode on"); } else if (token == offCmdStr) { digitalWrite(Led_pin, 0); // Set output bleBufferedSerial.print("Led soured"); } else { // not a valid cmd ignore bleBufferedSerial.print("Commands are on,off"); } } if (timeout.justFinished()) { // nothing received for 0.3secs, terminated last chars thusly token will be processed. stimulation += delimiters[0]; // any delimiter will do } // sendData(); // uncomment this to send data all 1sec } Higher up is a sample concealment from Nordic nRF UART 2.0
The 'led' command was non recognised so the message "Commands are happening,off" was returned. The sketch give the axe be easily extended to add your personal command words. Multiple commands can be dispatched on the same line separated by space, dot or comma.
Step 6: NANO 33 IoT
The NANO 33 IoT rear be connect to via either BLE surgery WiFi. The NANO 33 IoT has an IMU and a CryptoAuthentication IC, but no EEPROM. Hither we will setting up a Serial BLE guide to point connection and a Serial WiFi point to point connecter.
Installing support for NANO 33 IoT and Upgrading the Firmware
Early keep abreast the Getting started with the Arduino NANO 33 IoT guide on to establis the board support for the NANO 33 IoT and function the Blink example to test the install. Next put in the WiFiNINA_Generic library and the ArduinoBLE library via the Arduino IDE library manager.
Then load and consort the CheckFirmwareVersion chalk out from File → Examples → WifiNINA_Generic → Tools → CheckFirmwareVersion The WifiNINA_Generic is at the tooshie of the Examples list. Load and hightail it this sketch and check off the Monitor output (using 115200 baud setting)
If you experience a substance like the one below you will penury to update the firmware
WiFiNINA firmware control.
Microcode reading installed: 1.2.3 In vogue firmware version available : 1.3.0 Check event: NOT PASSED - The firmware interpretation on the module do not match the version required by the program library, you May experience issues or failures.
To update the microcode, first laden the Lodge → Examples → WifiNINA_Generic → Tools → FirmwareUpdater sketch. This sketch does non Doctor of Osteopathy the updating. It precisely communicates with the updating tool around.
The Firmware and certificates Updater instructor covers lengthwise the microcode updater tool BUT you mustiness firstly set u the a la mode version of the joyride . Download the latest firmware updater tool from https://github.com/arduino-libraries/WiFi101-FirmwareUpdater-Plugin/releases/latest The version used here was V0.10.10
Create
a tools folder in your sketch block, if it doesn't exist even. It should already exist with the old version of the tool. Blue-pencil the old version i.e. delete the directory ../Arduino/tools/WiFi101 Then unzip the latest WiFi101-Updater-ArduinoIDE-Plugin-0.10.10.nil to the tools directory to get the WiFi101.jar in a directory like .../Arduino/tools/WiFi101/tool/WiFi101.jar Then stop and restart the ArduinoIDE.
Harsh card Tools → WiFi101 / NINA Firmware Updater If there are deuce listings choose the second one.
Coil pile the ports and select the Arduino NANO 33 IoT port and superior the required firmware from the drop down. I.e. NINA 1.3.0 as renowned in the CheckFirmwareVersion output preceding. If NINA 1.3.0 is unlisted try the 'other' Firmware Updater.
Click Update Firmware button and the shape up bar will indicate the progress. When information technology finishes thither will be a Success panel.
Step 7: Using PfodApp to Connect to the NANO 33 IoT Via BLE
The NANO 33 IoT uses a different buffalo chip to the NANO 33 BLE so the pin capabilities take issue. Coarse the pfodDesignerV3 again. Opt Blue-pencil Existing Menu and the Menu 1 and then change the target to Bluetooth Low Energy → NANO 33 IoT via BLE
There volition be a message Ignoring incompatible I/O Pins from the previous Target. The D13 pin on the IoT is different. It does non support PWM.
Click happening Edit Menu and past on the LED is clitoris and then coil down to I/O pin to select the D13 stick.
You can then go back and generate the code again. The vignette is Nano33IoTBLE_Led_A0.ino This resume is the synoptic as Nano33BLE_Led_A0.ino except for comments. The NANO 33 IoT via BLE connection uses the Saami libraries As the NANO 33 BLE and the pfodApp connection is similar (but with a different BLE address)
Step 8: Using the Nordic NRF UART 2.0 App to Connect to the NANO 33 IoT Via BLE
Because the NANO 33 IoT via BLE association uses the synoptic libraries as the NANO 33 BLE, The sketch to connect using the Nordic nRF UART 2.0 app is the indistinguishable, i.e. Nano33BLE_UART_LED.ino as in a higher place in Step 5
Step 9: Using PfodApp to Connect to the NANO 33 IoT Via WiFi
Open the Existing Menu, previously designed in pfodDesignerV3 (above Create the Bespoke menu to turn the Arduino LED connected and off and Diagram A0) and click in Target and then WiFi and then NANO 33 IoT connected via WiFi. Go indorse and Generate Code
The resulting sketch is Nano33IoTWiFi_Led_A0.ino
Edit the top of the sketch to match your WiFi network and select a staticIP indeed that it is user-friendly to touch base to, typically 10.1.1.200 to 10.1.1.254 so as not to interfere with any else existing devices
#define WLAN_SSID "myNetwork" // cannot be longer than 32 characters! #define WLAN_PASS "myPassword" const int portNo = 4989; // What TCP port to listen on for connections. const char staticIP[] = ""; // set this the static Informatics you want, e.g. "10.1.1.200" surgery leave it as "" for DHCP. DHCP is not recommended.
Setting up a WiFi connection on pfodApp (see the pfodAppForAndroidGettingStarted.pdf ) and connecting with pfodApp will show the same menu as above when connecting via NANO 33 BLE above. You can also tally a 128bit shared out private key to secure the connection. See A Simple WiFi/Arduino pfodDevice with 128 bit security and SipHash Secure Challenge and Response for micro-devices and Secret Key Generator for Secure Take exception and Answer
Step 10: Using a Telnet Terminal Broadcast to Connect to the NANO 33 IoT Via WiFi
To connect via a telnet terminal, the changes ready-made are similar to those ready-made for Using the Nordic nRF UART 2.0 app to connect to NANO 33 BLE above. The port number is transformed to 23, the well lie with Telnet larboard act. The resulting sketch is Nano33IoTWiFi_UART_Led.ino
On PC's you seat utilisation TeraTerm to connect. Connecting using Telnet along Mac is bit more involved but still doable. On your Android mobile there are a number of terminal apps much A TCP Telnet Period of time Pro
Connecting using TeraTerm
Starting TeraTerm. Usance the card option Setup → Terminal to tick Local Echo
Then use File → New Connection to open an Telnet connect to the IP you have set. Here I have used 10.1.1.211
TeraTerm sends some initial talks bytes which the Nano33IoTWiFi_UART_Led.ino sketch does non recognised as a command so it responds with the "Commands are on,soured" message. You put up then send the happening and dispatch commands.
Again the sketch tooshie be easily extended to handle other command words. Multiple commands hind end be sent along the same line separated by space, dot or comma.
TeraTerm buffers you typing until you press Enter. Different Telnet programs may send each character as you type it. In that case if you don't type tight adequate the timeout timer leave finish and add a delimiter forcing a token to represent returned. You can fix this by increasing the timeout setting to say 1sec
unsigned long TIMEOUT_MS = 1000; // 1.0sec
Oregon by commenting out the timer altogether.
if (input.read(bleBufferedSerial)) { // read from Sequential, returns true if at to the lowest degree one character was added to SafeString input // timeout.start(TIMEOUT_MS); // off timer start thusly call for to send back delimiter like space or newline } Step 11: Conclusion
This tutorial has shown how you tin can easily set-up Arduino NANO 33 BLE, Sense and IoT to connect via Bluetooth Low Department of Energy (and WiFi for the IoT).
No Android programming is required . pfodApp handles all of that.
No Arduino coding is required . The (free) pfodDesignerV2 generates downright sketches for each of these modules.
While the sketches generated away pfodDesigner are for use with pfodApp, as shown in a higher place you can readily modify them to use a Nordic BLE UART app surgery a telnet program (for WiFi). In the modified sketches two simple commands, on and off, where set-up but the sketches can be easily extended to handle another command words. Multiple commands arse be conveyed on the same line.
Be the First to Share
Recommendations
-
Anything Goes Contest 2022
Source: https://www.instructables.com/Arduino-NANO-33-Made-Easy-BLE-Sense-and-IoT/
Posted by: yanceythawased.blogspot.com

0 Response to "Arduino NANO 33 Made Easy BLE, Sense and IoT : 11 Steps - yanceythawased"
Post a Comment