Is it possible to set the Arduino Nano 33 IoT to AP mode using Simulink

6 vues (au cours des 30 derniers jours)
Michal
Michal le 7 Mar 2025
I am trying to program an Arduino Nano 33 IoT using Simulink and establish Wi-Fi Direct communication. However, all the examples I have found so far require cloud connectivity, which I would like to avoid.
I want to implement the following Arduino IDE code in Simulink instead:
#include <WiFiNINA.h>
#include <WiFiUdp.h>
const char* apSSID = "Arduino_Nano_AP"; // Wi-Fi network name
const char* apPassword = "12345678"; // Wi-Fi password
WiFiUDP Udp;
unsigned int localPort = 8888;
void setup() {
Serial.begin(115200);
WiFi.beginAP(apSSID, apPassword);
Serial.println("Access Point started");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
Udp.begin(localPort);
}
void loop() {
char packetBuffer[255]; // Buffer to store incoming messages
int packetSize = Udp.parsePacket();
if (packetSize) {
int len = Udp.read(packetBuffer, 255);
if (len > 0) packetBuffer[len] = 0; // Null-terminate string
Serial.print("Received Message: ");
Serial.println(packetBuffer); // Print message as text
}
}

Réponses (1)

Aravind
Aravind le 11 Mar 2025
Since Simulink does not natively support Access Point (AP) configuration for the Arduino Nano 33 IoT, you can achieve this functionality by creating a Custom Device Driver Block.
A device driver block is a specialized form of the “MATLAB System” block that generates custom C/C++ device driver code for deployment to an Arduino hardware board. These blocks provide easy access to hardware board features, such as communication protocols or hardware libraries, that are not available in the Simulink Support Package for Arduino Hardware.
Using this approach, you can create a custom block to enable AP mode on the Arduino Nano 33 IoT board. Through this block you can implement the necessary code and functionality, allowing you to use it in a Simulink model to deploy on the Arduino hardware.
For more information on creating custom device driver blocks, refer to the following resources:
  1. Documentation for custom device driver blocks: https://www.mathworks.com/help/simulink/device-driver-blocks-arduino.html
  2. Strucure of device driver block: https://www.mathworks.com/help/simulink/supportpkg/arduino_ug/introduction-to-device-drivers-and-system-objects.html
  3. Tutorial on creating a custom device driver block: https://www.mathworks.com/help/simulink/supportpkg/arduino_ug/create-custom-blocks-for-arduino-support-package.html
  4. A blog post that gives details on creating driver blocks for Arduino and other targets: https://blogs.mathworks.com/simulink/2013/04/12/creating-driver-blocks-for-arduino-lego-and-other-targets/
I hope this resolves your query!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by