I have a RC-board with an OLED display to transmit data over nRF24 with an Nano every that works fine. (Pull-up resistors are soldered)
Using the same board with a Nano R4 and adjusted code shows a weired behaviour:
Uploading works, but the board hangs. Unplugging the board and powering from a walladapter lets the board work partially: LED blinks, the frame is displayed, string and loopcounter are not.
When I Insert
u8g2.setDrawColor(1);
u8g2.setCursor(4,32);
u8g2.print("***");
u8g2.print(loopcounter);
in setup, nothing is displayed any more, but the LED still blinks, loop is not blocked.
My code: (modified Blink example, transmitter code has >1000 lines)
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
#include <U8g2lib.h>
// give it a name:
int led = LED_BUILTIN;
uint8_t loopcounter = 13; // dummy
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
void setup()
{
Serial.begin(9600);
pinMode(led, OUTPUT);
u8g2.begin();
u8g2.drawFrame(4,4,40,10);
u8g2.sendBuffer();
}
void loop()
{
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
u8g2.setCursor(4,32);
u8g2.print(loopcounter++);
delay(1000); // wait for a second
}
Error message:
Opening DFU capable USB device...
Device ID 2341:0074
Run-Time device DFU version 0101
Claiming USB DFU (Run-Time) Interface...
Setting Alternate Interface zero...
Determining device status...
DFU state(0) = appIDLE, status(0) = No error condition is present
Device really in Run-Time Mode, send DFU detach request...
Device will detach and reattach...
Opening DFU USB Device...
Claiming USB DFU Interface...
Setting Alternate Interface #0 ...
Determining device status...
DFU state(2) = dfuIDLE, status(0) = No error condition is present
DFU mode device DFU version 0101
Device returned transfer size 64
Copying data from PC to DFU device
Download [=========================] 100% 53684 bytes
Download done.
DFU state(7) = dfuMANIFEST, status(0) = No error condition is present
DFU state(2) = dfuIDLE, status(0) = No error condition is present
Done!
processing.app.SerialException: Error opening serial port '/dev/cu.usbmodem2101'.
at processing.app.Serial.<init>(Serial.java:154)
at processing.app.Serial.<init>(Serial.java:82)
at processing.app.SerialMonitor$2.<init>(SerialMonitor.java:132)
at processing.app.SerialMonitor.open(SerialMonitor.java:132)
at processing.app.AbstractMonitor.resume(AbstractMonitor.java:132)
at processing.app.Editor.resumeOrCloseSerialMonitor(Editor.java:2158)
at processing.app.Editor.access$1300(Editor.java:116)
at processing.app.Editor$UploadHandler.run(Editor.java:2115)
at java.lang.Thread.run(Thread.java:748)
Caused by: jssc.SerialPortException: Port name - /dev/cu.usbmodem2101; Method name - openPort(); Exception type - Port not found.
at jssc.SerialPort.openPort(SerialPort.java:167)
at processing.app.Serial.<init>(Serial.java:143)
... 8 more
Error opening serial port '/dev/cu.usbmodem2101'.
Calling the serial monitor shows:
Board at /dev/cu.usbmodem2101 is not available
Controlling the port in terminal at the same time with
ls /dev/cu*
shows an open port:
/dev/cu.usbmodem2101
macos 14, u8g2 version 2.35.50
What is going wrong?