Hello,
I have been trying to figure this out for many hours, so I think it is time to ask for help. I am transferring a ESP32-WROOM-32 code over to a ESP32-C3 dev board. I cannot get the U8g2 library to work, I tested the old SSD1306Wire.h library, and it does work but I would prefer not to rewrite my 1500 line code that is dialed in for U8g2 - which is great for my needs. I am using GPIO Pins 19 for SCL and 18 for SDA, (the C3 allows you to assign SPI pins to most GPIO's) which tested and worked with SSD1306Wire.h
One thought that I have not been able to test yet is addressing, with SSD1306Wire.h I was able to use the default address of 0x3c, which worked but I do not know where I can enter this address in U8g2. That said, I have never needed to address this display when used with a WROOM and U8g2 before.
My other thought is the SPI bitbanging error listed below from the last compile, it is a common error that I got on the wroom as well, it worked anyways on the wroom but I was using the default SPI pins on the wroom and I am not using the defaults on the C3, I did test this by swapping to the C3 default pins and altering the definitions accordingly - but without success.
Applicable code:
#include <Wire.h>
#include <U8g2lib.h>
#include "IRremote.h"
#define DATA_PIN 10
#define IR_RECEIVE_PIN 3
#define LED_BUILTIN 8
#ifdef U8X8_HAVE_HW_SPI
#endif
#ifdef U8X8_HAVE_HW_I2C
#endif
unsigned long lastExecutedMillis = 0;
unsigned long key_value = 0;
uint32_t id = 0;
CRGB leds[58];
U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /*clock*/ 18, /*data*/ 19, /* reset=*/ U8X8_PIN_NONE);
void setup() {
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
SPI.begin( /*18, 4, 19*/ );
digitalWrite(LED_BUILTIN, HIGH);
u8g2.begin();
C3 compile errors:
In file included from C:\Users\User\Documents\Arduino\libraries\IRremote\src/IRremote.h:10,
from C:\Users\User\Documents\Arduino\EMDR\Lightbar4.1_58_TEST_C3\Lightbar4.1_58_TEST_C3.ino:85:
C:\Users\User\Documents\Arduino\libraries\IRremote\src/IRremote.hpp:209:2: warning: #warning For ESP32, RP2040 and particle boards SEND_PWM_BY_TIMER is enabled by default. If this is not intended, deactivate the line over this error message in file IRremote.hpp. [-Wcpp]
#warning For ESP32, RP2040 and particle boards SEND_PWM_BY_TIMER is enabled by default. If this is not intended, deactivate the line over this error message in file IRremote.hpp.
^~~~~~~
In file included from C:\Users\User\Documents\Arduino\libraries\IRremote\src/IRremote.h:10,
from C:\Users\User\Documents\Arduino\EMDR\Lightbar4.1_58_TEST_C3\Lightbar4.1_58_TEST_C3.ino:85:
C:\Users\User\Documents\Arduino\libraries\IRremote\src/IRremote.hpp:271:2: warning: #warning INFO: No definition for LED_BUILTIN found -> default LED feedback is disabled. [-Wcpp]
#warning INFO: No definition for LED_BUILTIN found -> default LED feedback is disabled.
^~~~~~~
In file included from C:\Users\User\Documents\Arduino\libraries\FastLED\src/FastLED.h:67,
from C:\Users\User\Documents\Arduino\EMDR\Lightbar4.1_58_TEST_C3\Lightbar4.1_58_TEST_C3.ino:81:
C:\Users\User\Documents\Arduino\libraries\FastLED\src/fastspi.h:145:23: note: #pragma message: No hardware SPI pins defined. All SPI access will default to bitbanged output
# pragma message "No hardware SPI pins defined. All SPI access will default to bitbanged output"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sketch uses 251166 bytes (19%) of program storage space. Maximum is 1310720 bytes.
Global variables use 12404 bytes (3%) of dynamic memory, leaving 315276 bytes for local variables. Maximum is 327680 bytes.
C:\Users\User\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\3.1.0/esptool.exe --chip esp32c3 --port COM7 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0xe000 C:\Users\User\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2/tools/partitions/boot_app0.bin 0x0 C:\Users\User\AppData\Local\Temp\arduino_build_650310/Lightbar4.1_58_TEST_C3.ino.bootloader.bin 0x10000 C:\Users\User\AppData\Local\Temp\arduino_build_650310/Lightbar4.1_58_TEST_C3.ino.bin 0x8000 C:\Users\User\AppData\Local\Temp\arduino_build_650310/Lightbar4.1_58_TEST_C3.ino.partitions.bin
esptool.py v3.1
Serial port COM7
Connecting....
Chip is unknown ESP32-C3 (revision 3)
Features: Wi-Fi
Crystal is 40MHz
MAC: a0:76:4e:5a:53:80
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00000000 to 0x00003fff...
Flash will be erased from 0x00010000 to 0x0004dfff...
Flash will be erased from 0x00008000 to 0x00008fff...
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 528.5 kbit/s)...
Hash of data verified.
Flash params set to 0x022f
Compressed 12528 bytes to 8981...
Writing at 0x00000000... (100 %)
Wrote 12528 bytes (8981 compressed) at 0x00000000 in 0.4 seconds (effective 268.7 kbit/s)...
Hash of data verified.
Compressed 253392 bytes to 144894...
Writing at 0x00010000... (11 %)
Writing at 0x000172c1... (22 %)
Writing at 0x00020195... (33 %)
Writing at 0x00026094... (44 %)
Writing at 0x0002da30... (55 %)
Writing at 0x00033a99... (66 %)
Writing at 0x00039ba4... (77 %)
Writing at 0x00041b5a... (88 %)
Writing at 0x000487a4... (100 %)
Wrote 253392 bytes (144894 compressed) at 0x00010000 in 4.3 seconds (effective 469.1 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 128...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.1 seconds (effective 372.7 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
All thoughts or suggestions are welcome. Thanks, Bodhi