g33rt
February 2, 2023, 10:55pm
#1
Hi,
I would like to build a ESP32 NTP time server that I found on GitHub.
The original build on GitHub is for an Olimex ESP32-Gateway development board.
However I like to use the Wireless-Tag WT32-ETH01 board instead.
So I downloaded the code from github and open it with Platformio.
I made changes in platformio.ini
[env:wt32-eth01]
platform = espressif32
board = wt32-eth01
framework = arduino
monitor_speed = 115200
And if I build the code I see this message:
Compiling .pio\build\wt32-eth01\lib333\Ethernet\ETH.cpp.o
src/GPS.cpp: In function 'uint8_t* s2ck(uint8_t*, int)':
src/GPS.cpp:202:11: warning: address of local variable 'result' returned [-Wreturn-local-addr]
uint8_t result[length + 4];
^~~~~~
src/main.cpp:5:10: fatal error: Adafruit_SSD1306.h: No such file or directory
**************************************************************************
* Looking for Adafruit_SSD1306.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:Adafruit_SSD1306.h"
* Web > https://registry.platformio.org/search?q=header:Adafruit_SSD1306.h
*
**************************************************************************
#include <Adafruit_SSD1306.h>
^~~~~~~~~~~~~~~~~~~~
compilation terminated.
Compiling .pio\build\wt32-eth01\lib5ae\Wire\Wire.cpp.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\Esp.cpp.o
*** [.pio\build\wt32-eth01\src\main.cpp.o] Error 1
C:/Users/Geert/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.cpp: In member function 'bool TwoWire::initPins(int, int)':
C:/Users/Geert/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.cpp:74:26: error: 'SDA' was not declared in this scope
sdaPin = SDA; //use Default Pin
^~~
C:/Users/Geert/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.cpp:95:26: error: 'SCL' was not declared in this scope
sclPin = SCL; // use Default pin
^~~
*** [.pio\build\wt32-eth01\lib5ae\Wire\Wire.cpp.o] Error 1
========================== [FAILED] Took 3.78 seconds ==========================
Can someone help me a bit I’m new to this all.
Are we talking GitHub - DennisSc/PPS-ntp-server: ESP32 NTP Server using GPS reference clock ? This code expects you to have a SSD1306 OLED display just so it can write some status messages. If you don’t need that just remove that code.
g33rt
February 3, 2023, 5:00pm
#3
Yes it’s GitHub - DennisSc/PPS-ntp-server: ESP32 NTP Server using GPS reference clock I have forgotten to add this info.
So this is an issue SSD1306 SDA and SCL pins are not assigned ?
I would like to use that SSD1306 OLED display if possible.
Well if you want to use it then you need to add the library like PlatformIO told you in the error message.
So you just add to your platformio.ini
lib_deps =
adafruit/Adafruit SSD1306@^2.5.7
adafruit/Adafruit GFX Library@^1.11.5
g33rt
February 3, 2023, 5:03pm
#5
The only thing I have changed in platformio.ini is:
[env:esp32-gateway]
platform = espressif32
board = esp32-gateway
framework = arduino
monitor_speed = 115200
to
[env:wt32-eth01]
platform = espressif32
board = wt32-eth01
framework = arduino
monitor_speed = 115200
g33rt
February 3, 2023, 5:10pm
#6
Okay I have added
lib_deps =
adafruit/Adafruit SSD1306@^2.5.7
adafruit/Adafruit GFX Library@^1.11.5
to platformio.io and now I got a bunch of other errors:
Compiling .pio\build\wt32-eth01\libb95\Adafruit BusIO\Adafruit_SPIDevice.cpp.o
C:/Users/Geert/.platformio/packages/framework-arduinoespressif32/libraries/SPI/src/SPI.cpp: In member function 'void SPIClass::begin(int8_t, int8_t, int8_t, int8_t)':
C:/Users/Geert/.platformio/packages/framework-arduinoespressif32/libraries/SPI/src/SPI.cpp:97:37: error: 'SCK' was not declared in this scope
_sck = (_spi_num == VSPI) ? SCK : 14;
^~~
C:/Users/Geert/.platformio/packages/framework-arduinoespressif32/libraries/SPI/src/SPI.cpp:98:38: error: 'MISO' was not declared in this scope
_miso = (_spi_num == VSPI) ? MISO : 12;
^~~~
C:/Users/Geert/.platformio/packages/framework-arduinoespressif32/libraries/SPI/src/SPI.cpp:99:38: error: 'MOSI' was not declared in this scope
_mosi = (_spi_num == VSPI) ? MOSI : 13;
^~~~
C:/Users/Geert/.platformio/packages/framework-arduinoespressif32/libraries/SPI/src/SPI.cpp:100:36: error: 'SS' was not declared in this scope
_ss = (_spi_num == VSPI) ? SS : 15;
^~
C:/Users/Geert/.platformio/packages/framework-arduinoespressif32/libraries/SPI/src/SPI.cpp:100:36: note: suggested alternative: 'PS'
_ss = (_spi_num == VSPI) ? SS : 15;
^~
PS
Compiling .pio\build\wt32-eth01\lib8b5\Adafruit GFX Library\Adafruit_GFX.cpp.o
Compiling .pio\build\wt32-eth01\lib8b5\Adafruit GFX Library\Adafruit_GrayOLED.cpp.o
Compiling .pio\build\wt32-eth01\lib8b5\Adafruit GFX Library\Adafruit_SPITFT.cpp.o
Compiling .pio\build\wt32-eth01\lib8b5\Adafruit GFX Library\glcdfont.c.o
Compiling .pio\build\wt32-eth01\liba39\Adafruit SSD1306\Adafruit_SSD1306.cpp.o
Compiling .pio\build\wt32-eth01\libab6\microTime\DateStrings.cpp.o
C:/Users/Geert/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.cpp: In member function 'bool TwoWire::initPins(int, int)':
C:/Users/Geert/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.cpp:74:26: error: 'SDA' was not declared in this scope
sdaPin = SDA; //use Default Pin
^~~
C:/Users/Geert/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.cpp:95:26: error: 'SCL' was not declared in this scope
sclPin = SCL; // use Default pin
^~~
Compiling .pio\build\wt32-eth01\libab6\microTime\microTime.cpp.o
*** [.pio\build\wt32-eth01\lib925\SPI\SPI.cpp.o] Error 1
*** [.pio\build\wt32-eth01\lib5ae\Wire\Wire.cpp.o] Error 1
src/GPS.cpp: In function 'uint8_t* s2ck(uint8_t*, int)':
src/GPS.cpp:202:11: warning: address of local variable 'result' returned [-Wreturn-local-addr]
uint8_t result[length + 4];
^~~~~~
src/main.cpp:42:1: error: 'SSD1306' does not name a type
SSD1306 display(0x3C, SDApin, SCLpin); // Addr, SDA, SCL
^~~~~~~
src/main.cpp: In function 'void writeLCD(uint8_t, String)':
src/main.cpp:65:3: error: 'display' was not declared in this scope
display.setColor(BLACK);
^~~~~~~
src/main.cpp:65:3: note: suggested alternative: 'delay'
display.setColor(BLACK);
^~~~~~~
delay
src/main.cpp: In function 'void setup()':
src/main.cpp:307:5: error: 'display' was not declared in this scope
display.init();
^~~~~~~
src/main.cpp:307:5: note: suggested alternative: 'delay'
display.init();
^~~~~~~
delay
*** [.pio\build\wt32-eth01\src\main.cpp.o] Error 1
========================= [FAILED] Took 11.40 seconds =========================
That doesn’t seem right, the wt32-eth01
has no default SPI pins defined in its pins_arduino.h header? That was already fixed in https://github.com/espressif/arduino-esp32/pull/7237 and got in the 2.0.6 realease which PlatformIO should be using in its latest release.
A quick way to update is to open a CLI and execute
pio pkg update -g -p espressif32
Retry compilation thereafter.
g33rt
February 3, 2023, 6:15pm
#8
That command did some downloading things:
PS E:\Platformio projects\PPS-ntp-server-master> pio pkg update -g -p espressif32
Platform Manager: Updating espressif32 @ 5.1.1
Platform Manager: Removing espressif32 @ 5.1.1
Platform Manager: espressif32@5.1.1 has been removed!
Platform Manager: Installing platformio/espressif32 @ 6.0.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Platform Manager: espressif32@6.0.0 has been installed!
Tool Manager: Installing espressif/toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: toolchain-xtensa-esp32@8.4.0+2021r2-patch5 has been installed!
Tool Manager: Installing platformio/tool-esptoolpy @ ~1.40400.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: tool-esptoolpy@1.40400.0 has been installed!
Tool Manager: tool-esptoolpy@1.40400.0 is already up-to-date
Tool Manager: tool-mkfatfs@2.0.1 is already up-to-date
Tool Manager: tool-mklittlefs@1.203.210628 is already up-to-date
Tool Manager: tool-mkspiffs@2.230.0 is already up-to-date
Tool Manager: toolchain-xtensa-esp32@8.4.0+2021r2-patch5 is already up-to-date
PS E:\Platformio projects\PPS-ntp-server-master>
g33rt
February 3, 2023, 6:16pm
#9
When I build it gives this result:
Processing wt32-eth01 (platform: espressif32; board: wt32-eth01; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/wt32-eth01.html
PLATFORM: Espressif 32 (6.0.0) > Wireless-Tag WT32-ETH01 Ethernet Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
- framework-arduinoespressif32 @ 3.20006.221224 (2.0.6)
- tool-esptoolpy @ 1.40400.0 (4.4.0)
- toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 37 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Adafruit SSD1306 @ 2.5.7
| |-- Adafruit GFX Library @ 1.11.5
| | |-- Adafruit BusIO @ 1.14.1
| | | |-- Wire @ 2.0.0
| | | |-- SPI @ 2.0.0
| | |-- Wire @ 2.0.0
| | |-- SPI @ 2.0.0
| |-- Adafruit BusIO @ 1.14.1
| | |-- Wire @ 2.0.0
| | |-- SPI @ 2.0.0
| |-- Wire @ 2.0.0
| |-- SPI @ 2.0.0
|-- Adafruit GFX Library @ 1.11.5
| |-- Adafruit BusIO @ 1.14.1
| | |-- Wire @ 2.0.0
| | |-- SPI @ 2.0.0
| |-- Wire @ 2.0.0
| |-- SPI @ 2.0.0
|-- Time @ 1.5
|-- Ethernet @ 2.0.0
| |-- WiFi @ 2.0.0
|-- WiFi @ 2.0.0
|-- Wire @ 2.0.0
Building in release mode
Compiling .pio\build\wt32-eth01\src\main.cpp.o
Archiving .pio\build\wt32-eth01\lib8b5\libAdafruit GFX Library.a
src/main.cpp:42:1: error: 'SSD1306' does not name a type
SSD1306 display(0x3C, SDApin, SCLpin); // Addr, SDA, SCL
^~~~~~~
src/main.cpp: In function 'void writeLCD(uint8_t, String)':
src/main.cpp:65:3: error: 'display' was not declared in this scope
display.setColor(BLACK);
^~~~~~~
src/main.cpp:65:3: note: suggested alternative: 'delay'
display.setColor(BLACK);
^~~~~~~
delay
src/main.cpp: In function 'void setup()':
src/main.cpp:307:5: error: 'display' was not declared in this scope
display.init();
^~~~~~~
src/main.cpp:307:5: note: suggested alternative: 'delay'
display.init();
^~~~~~~
delay
Archiving .pio\build\wt32-eth01\liba39\libAdafruit SSD1306.a
Archiving .pio\build\wt32-eth01\libab6\libmicroTime.a
Archiving .pio\build\wt32-eth01\libf11\libWiFi.a
Compiling .pio\build\wt32-eth01\lib333\Ethernet\ETH.cpp.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\Esp.cpp.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\FirmwareMSC.cpp.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\FunctionalInterrupt.cpp.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\HWCDC.cpp.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\HardwareSerial.cpp.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\IPAddress.cpp.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\IPv6Address.cpp.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\MD5Builder.cpp.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\Print.cpp.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\Stream.cpp.o
*** [.pio\build\wt32-eth01\src\main.cpp.o] Error 1
===================================================== [FAILED] Took 4.47 seconds =====================================================
My bad, although it does use the SSD1306 display, it doesn’t actually use the Adafruit SSD1306 library for it, something highly uncommon. Remove the old lib_deps
expression and write instead
lib_deps =
thingpulse/ESP8266 and ESP32 OLED driver for SSD1306 displays@^4.3.0
Also in src/GPS.cpp
, comment out the creation of the two hardware serials. They’re automatically created by Arduino-ESP32 now.
//HardwareSerial Serial1(1);
//HardwareSerial Serial2(2);
g33rt
February 3, 2023, 7:09pm
#12
maxgerhardt:
My bad, although it does use the SSD1306 display, it doesn’t actually use the Adafruit SSD1306 library for it, something highly uncommon. Remove the old lib_deps
expression and write instead
lib_deps =
thingpulse/ESP8266 and ESP32 OLED driver for SSD1306 displays@^4.3.0
After I change this I receive other message:
Error: Invalid value: '115200\n\nlib_deps =\nthingpulse/ESP8266 and ESP32 OLED driver for SSD1306 displays@^4.3.0' is not a valid integer. for option
monitor_speed in section [env:wt32-eth01]
You have a bad indentation in the platformio.ini
. Does it 100% look like this?
g33rt
February 3, 2023, 7:14pm
#14
maxgerhardt:
Also in src/GPS.cpp
, comment out the creation of the two hardware serials. They’re automatically created by Arduino-ESP32 now.
//HardwareSerial Serial1(1);
//HardwareSerial Serial2(2);
On GPS.cpp I have comment out like you requested:
//HardwareSerial Serial1(1);
//HardwareSerial Serial2(2);
g33rt
February 3, 2023, 7:17pm
#15
I see the error now:
[env:wt32-eth01]
platform = espressif32
board = wt32-eth01
framework = arduino
monitor_speed = 115200
lib_deps =
thingpulse/ESP8266 and ESP32 OLED driver for SSD1306 displays@^4.3.0
I remover the spaces before the lib_deps
g33rt
February 3, 2023, 7:20pm
#16
At main.cpp I have these include:
#include <Arduino.h>
#include <Wire.h>
#include <ETH.h>
#include <WifiUDP.h>
#include <Adafruit_SSD1306.h>
#include <microTime.h>
#include "microTimeLib.h"
#include "DateTime.h"
When I build I see this:
Processing wt32-eth01 (platform: espressif32; board: wt32-eth01; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/wt32-eth01.html
PLATFORM: Espressif 32 (6.0.0) > Wireless-Tag WT32-ETH01 Ethernet Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
- framework-arduinoespressif32 @ 3.20006.221224 (2.0.6)
- tool-esptoolpy @ 1.40400.0 (4.4.0)
- toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 35 compatible libraries
Scanning dependencies...
Dependency Graph
|-- ESP8266 and ESP32 OLED driver for SSD1306 displays @ 4.3.0
|-- Time @ 1.5
|-- Ethernet @ 2.0.0
| |-- WiFi @ 2.0.0
|-- WiFi @ 2.0.0
|-- Wire @ 2.0.0
Building in release mode
Compiling .pio\build\wt32-eth01\src\main.cpp.o
src/main.cpp:5:10: fatal error: Adafruit_SSD1306.h: No such file or directory
**************************************************************************
* Looking for Adafruit_SSD1306.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:Adafruit_SSD1306.h"
* Web > https://registry.platformio.org/search?q=header:Adafruit_SSD1306.h
*
**************************************************************************
#include <Adafruit_SSD1306.h>
^~~~~~~~~~~~~~~~~~~~
compilation terminated.
Compiling .pio\build\wt32-eth01\FrameworkArduino\esp32-hal-i2c-slave.c.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\esp32-hal-i2c.c.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\esp32-hal-ledc.c.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\esp32-hal-matrix.c.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\esp32-hal-misc.c.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\esp32-hal-psram.c.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\esp32-hal-rgb-led.c.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\esp32-hal-rmt.c.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\esp32-hal-sigmadelta.c.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\esp32-hal-spi.c.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\esp32-hal-time.c.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\esp32-hal-timer.c.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\esp32-hal-tinyusb.c.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\esp32-hal-touch.c.o
Compiling .pio\build\wt32-eth01\FrameworkArduino\esp32-hal-uart.c.o
*** [.pio\build\wt32-eth01\src\main.cpp.o] Error 1
===================================================== [FAILED] Took 3.54 seconds =====================================================
Revert this back to the original #include <SSD1306.h>
now that the correct library is used.
g33rt
February 3, 2023, 8:07pm
#18
Yes it compiles !
only this yellow messgae:
Compiling .pio\build\wt32-eth01\libf11\WiFi\WiFiServer.cpp.o
Compiling .pio\build\wt32-eth01\libf11\WiFi\WiFiUdp.cpp.o
src/GPS.cpp: In function 'uint8_t* s2ck(uint8_t*, int)':
src/GPS.cpp:202:11: warning: address of local variable 'result' returned [-Wreturn-local-addr]
uint8_t result[length + 4];
^~~~~~
Compiling .pio\build\wt32-eth01\lib333\Ethernet\ETH.cpp.o
Archiving .pio\build\wt32-eth01\lib5ae\libWire.a
is this negligible?
g33rt:
is this negligible?
The warning indeed hints a bug in this function, you should never just return the memory of a local variable since it gets destructed when the function is exited. However, the functino s2ck
is never used in the program, just s2ckv0
which has no such problems. So it can be ignored or better, the function can be just deleted.
g33rt
February 4, 2023, 5:02pm
#20
maxgerhardt:
The warning indeed hints a bug in this function, you should never just return the memory of a local variable since it gets destructed when the function is exited. However, the functino s2ck
is never used in the program, just s2ckv0
which has no such problems. So it can be ignored or better, the function can be just deleted.
Okay, however I don’t know how to delete this fuction so I ignore it for now.
I’m struggling getting the OLED display to work, I even test the OLED on another ESP32 project which use SSD1306 and it works just fine.
Don’t know what I’m doing wrong here but I only need 3 pins to define.
SDA (OLED)
SCL (OLED)
Switch (rocking switch) connecting pin >?< with high/low; toggles between serialConfig/NTPserver mode
So I’m looking into the WT32-EHT01 IO pin description and found out that the first 6 pins does not count up to all 20 pins.