This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| en:iot-open:practical:hardware:sut:esp32:iot_1 [2024/03/26 20:10] – [Result validation] pczekalski | en:iot-open:practical:hardware:sut:esp32:iot_1 [2024/03/26 20:21] (current) – [Result validation] pczekalski | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== IOT1: Reading MAC address of the WiFi ===== | ||
| + | Each network IP card is supposed to have a unique MAC address. ESP32 chip has built-in MAC. MAC can be used to identify devices, but note that it is not a " | ||
| + | |||
| + | ===== Prerequisites ===== | ||
| + | To implement this scenario, it is necessary to get familiar with at least one of the following scenarios first: | ||
| + | * [[en: | ||
| + | * [[en: | ||
| + | * [[en: | ||
| + | |||
| + | A WiFi library is already included in the Arduino framework for ESP32, so there is no need to add it to the '' | ||
| + | |||
| + | ===== Suggested Readings and Knowledge Resources ===== | ||
| + | * [[en: | ||
| + | * [[en: | ||
| + | * [[en: | ||
| + | * [[en: | ||
| + | |||
| + | ===== Hands-on Lab Scenario ===== | ||
| + | |||
| + | ==== Task to be implemented ==== | ||
| + | Present a MAC address on the selected display. The steps below present only the reading part, not a display. Handling a display is presented in the EMBx scenarios, as listed above. | ||
| + | |||
| + | ==== Start ==== | ||
| + | Check if you can see a full LCD in your video stream. Book a device and create a dummy Arduino file with '' | ||
| + | |||
| + | |||
| + | ==== Steps ==== | ||
| + | |||
| + | === Step 1 === | ||
| + | Include the WiFi management library in your source code: | ||
| + | <code c> | ||
| + | #include < | ||
| + | </ | ||
| + | The WiFi library automatically initialises a singleton class '' | ||
| + | |||
| + | === Step 2 === | ||
| + | Reading the MAC as a '' | ||
| + | <code c> | ||
| + | WiFi.macAddress(); | ||
| + | </ | ||
| + | |||
| + | ==== Result validation ==== | ||
| + | Using another node should change the MAC read. Book another device and discover its MAC. | ||
| + | |||
| + | ===== FAQ ===== | ||
| + | **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: | ||
| + | <code c> | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | 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, | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | <WRAP noprint> | ||
| + | ===== Project information ===== | ||
| + | {{: | ||
| + | This Intellectual Output was implemented under the Erasmus+ KA2.\\ | ||
| + | Project IOT-OPEN.EU Reloaded – Education-based strengthening of the European universities, | ||
| + | Project number: 2022-1-PL01-KA220-HED-000085090. | ||
| + | |||
| + | **__Erasmus+ Disclaimer__**\\ | ||
| + | This project has been funded with support from the European Commission. \\ | ||
| + | This publication reflects the views of only the author, and the Commission cannot be held responsible for any use that may be made of the information contained therein. | ||
| + | |||
| + | **__Copyright Notice__**\\ | ||
| + | This content was created by the IOT-OPEN.EU Reloaded consortium, 2022, | ||
| + | The content is Copyrighted and distributed under CC BY-NC [[https:// | ||
| + | <figure label> | ||
| + | {{: | ||
| + | </ | ||
| + | |||
| + | </ | ||