This is an old revision of the document!
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 “strong” ID: it can be programmatically changed and easily discovered. In the following scenario, we only present how to read the MAC address. A part regarding displaying on the selected screen is up to the developer. You can refer to the appropriate scenario, as listed below.
To implement this scenario, it is necessary to get familiar with at least one of the following scenarios first:
A WiFi library is already included in the Arduino framework for ESP32, so there is no need to add it to the platformio.ini
explicitly.
Draw “Hello World” in the upper line of the LCD and “Hello IoT” in the lower one.
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 library in your source code:
#include <Adafruit_LiquidCrystal.h>
Declare GPIOs controlling the LCD, according to the hardware reference:
#define LCD_RS 2 #define LCD_ENABLE 1 #define LCD_D4 39 #define LCD_D5 40 #define LCD_D6 41 #define LCD_D7 42
Declare a static instance of the LCD controller class and preconfigure it with appropriate control GPIOs:
static Adafruit_LiquidCrystal lcd(LCD_RS, LCD_ENABLE, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
Initialise class with display area configuration (number of columns, here 16 and rows, here 2):
lcd.begin(16,2);
Implement your algorithm. The most common class methods that will help you are listed below:
.clear()
- clears all content;.setCursor(x,y)
- set cursor, writing will start there;.print(contents)
- prints text in the cursor location; note there are many overloaded functions, accepting various arguments, including numerical.You should be able to see “Hello World” and “Hello IoT” on the LCD now.