This is an old revision of the document!
The STM32WB55 SoC doesn't have a WiFi network controller so our STM laboratory stands have the WiFi module based on ESP32-C3 SoC connected by serial port and controlled with AT commands. In this scenario, you will learn how to use these commands.
To implement this scenario, it is necessary to get familiar with the LCD scenario first:
It is also possible to use other displays if you prefer. Please refer to the appropriate chapter to learn how to do it.
This introductory scenario shows how to use AT commands to control the ESP32-C3 WiFi module connected to the STM laboratory stand. In this scenario, we will use simple AT commands and try to display if their execution finished properly. We will use the LCD to observe the behaviour of the device.
Check if you can see a full LCD in your video stream. Book a device and create a dummy Arduino file with void setup()… and void loop()….
Include the LiquidCrystal library in your source code to control LCD:
#include "LiquidCrystal.h"
We will connect to the ESP32-C3 WiFi module with a hardware serial port. We need to instantiate the object of the HardwareSerial class. The LiquidCrystal object allows us to display data on LCD.
Reading the MAC as a String is as easy as simply calling:
// Pins definition for Hardware Serial #define RxD_PIN PC_0 //STM numbering #define TxD_PIN PC_1 //STM numbering HardwareSerial WiFiSerial(RxD_PIN, TxD_PIN, NC, NC); // LCD class const int rs = PC5, en = PB11, d4 = PB12, d5 = PB13, d6 = PB14, d7 = PB15; LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
Using another node should change the MAC read. Book another device and discover its MAC.
Can I change MAC?: Actually, yes, you can. It is not advised, however, because you may accidentally generate an overlapping address that will collide with another device in the same network. You must first explicitly configure the ESP32 chip to work as an AP (Access Point, Server) or STA (WiFi Client) to do it. Sample stub code (for STA) may look as follows:
#include <WiFi.h> #include <esp_wifi.h> uint8_t newMAC[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xCA, 0xFE}; //Array of bytes with new MAC void setup() { WiFi.mode(WIFI_STA); esp_wifi_set_mac(WIFI_IF_STA, &newMAC[0]); }