I wanted to make a simple, small device, with a single ethernet port just to acquire an IP address & display it on a small screen.
This would serve as an easy-to-use network-debugging device & teaching tool.
I had thought the Portenta Breakout board with the Portenta H7 might work, considering the ethernet port.
ethernet
This is the segment I used to initialize the ethernet device & acquire an IP address via DHCP:
#include<SPI.h>#include<Ethernet.h>// Unique MAC address for your device
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
voidsetup(){
Serial.begin(9600);
// Attempt to get an IP address via DHCPif (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// Handle failure (e.g., stop execution or try static IP)while (1);
}
// Print the assigned IP address
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
}
voidloop(){
// Maintain the DHCP lease (essential for long-running projects)
Ethernet.maintain();
delay(1000);
Serial.print(".");
}
It worked the first try, fortunately.
display
I tried to connect my LCD display to the display pins.
Since I had the display's "Reset" pin to the breakout-board's "D2N" pin, I tried compiling the following line
LiquidCrystal lcd(D2N, 0, 0, 0, 0, 0);
And I saw the following compilation error:
error: 'D2N' was not declared inthis scope
D2N is not defined. Why would it be labeled that?
Maybe it's defined in some library somewhere...
arduino-cli lib search portenta\ breakout
I installed the "Arduino_PortentaBreakout" library, however, I still saw the same message:
error: 'D2N' was not declared inthis scope
What's the point of the library? I look at the header file, and see the following segment:
No comments yet. Be the first!