WiFi code working when compiled in arduino IDE but not when in platformio - lib issues?

Again today, sorry, don’t want to annoy anybody but right after I fixed the first problem I stumbled in the next one.

I did use arduino IDE so far but due to the ESP23 platform I sort of were forced to used platformio too and I am actually happy about it, since it does a lot of things better.

However I was testing this long range/low rate wifi connection of the ESP32 using this as a start
https://github.com/jnogues/ESP32-Long-Range-WiFi
As long as I compile both in arduino IDE and flash them to the LOLIN S2 min (client) and the ESP-32-2432S024 display (master/server) the client connects and send its message.

As soon as I flash the same MASTER code with platformio to the display, the S2 doesn’t find the host and stays disconnected.

As the code is the same I thought there would be differences in the WiFi libs but I am unsure about it,
the arduino IDE takes the libs from here
AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.3\libraries\WiFi

platformio reporting this:

Dependency Graph
|-- WiFi @ 2.0.0

So I grabbed the libs from arduino ide and put them in libs/ of the project
but that didn’t change anything.
How do I know what libs platformio is actually using ?

Compiling .pio\build\esp32dev\lib59c\WiFi\WiFi.cpp.o
Compiling .pio\build\esp32dev\lib59c\WiFi\WiFiAP.cpp.o
Compiling .pio\build\esp32dev\lib59c\WiFi\WiFiClient.cpp.o
Compiling .pio\build\esp32dev\lib59c\WiFi\WiFiGeneric.cpp.o
Compiling .pio\build\esp32dev\lib59c\WiFi\WiFiMulti.cpp.o
Compiling .pio\build\esp32dev\lib59c\WiFi\WiFiSTA.cpp.o
Compiling .pio\build\esp32dev\lib59c\WiFi\WiFiScan.cpp.o
Compiling .pio\build\esp32dev\lib59c\WiFi\WiFiServer.cpp.o
Compiling .pio\build\esp32dev\lib59c\WiFi\WiFiUdp.cpp.o

What else could be the reason?

thanks (also for the patience :wink: )

Arduino-ESP32 2.0.3 is 2 years old at this piont.

Can you cross-verify that if you update your Arduino-ESP32 core in the Arduino IDE to 2.0.14, the code still works? That would eliminate quite a lot of possibilities. (Tools → Boards → Board Manager → ESP32 → Update)

1 Like

I just tried the better way and cloned the client code to platformio now
(just in case it doesn’t work I don’t change my arduino setup by that),
Now I just need to find out how to handle multiple devices/ports/serial monitors in platformio.

What would you like to know?

found already @maxgerhadts comments here

This is just too messy when the devices change the ports again and again (The S2 tends to toggle between port 10 and 4 all the time.),
It tried to compile the display stuff with the S2 mini as board then :-/

Luckily opening a new instance of visual studio works too, but consumes more space on the desktop.

But anyway, the client can’t communicate with the host. Even when they are using the same wifi libs now.

I don’t know what the client script is actually doing, showing nothing in the serial monitor.
Not even the serial prints at the beginning of setup().

No idea how I can encircle the problem now, I could update the arduino IDE now but that comes with the risk that I have two IDEs then which are not going to compile a working code.

You are using an ESP32-S3 with builtin USB (no external UART to Serial chip).
When the ESP reboot after the firmware update finished, the USB connection to your PC got lost for a few seconds. After reconnecting, the COM port might have changed.
I can’t think of any way to change this.

Which client and host are you referring to? Unfortunately, I do not know your project.

It is a S2, but yes I know the port problem, annoying but common.

These two scripts I am trying:

https://github.com/jnogues/ESP32-Long-Range-WiFi

It is about the WiFi LR mode of the ESP32, there is some part in the master code connecting to a router. I kicked that out, because it doesn’t make sense, nor did it prevent the connection to work (when using arduino IDE) plus I changed the IP of the client to a static one.

At least I found out why I didn’t get anything in the serial monitor.

these were off:

monitor_rts = 1
monitor_dtr = 1
Error = 0 , Mode LR OK!
................................

Now to the “funny” thing, I now flashed the HOST to the ESP32 display using arduino IDE,
now the client connects, however the remote IP identification at the host doesn’t work now. for some reason it gets 192.168.4.2 instead of the set 192.168.4.102.

Some missunderstanding in the versions I guess but this isn’t a solution anyway it doesn’t help me.

Unfortunately, I am not familiar with the “advanced” WiFi functions used in this project.

I think the best place for the questions would be to open an issue in the repository. Issues · jnogues/ESP32-Long-Range-WiFi · GitHub

Well yes, that guy doesn’t respond. So I guess I won’t have luck there.

Actually it is just a protocol from espressif. Everything else is just sending/receiving udp packets.
The LR mode is already active,so this shouldn’t be the issue.

I tried the libs from arduino IDE yesterday (at least I think I did) but I am not sure if platformio really uses them if I put them in the projects root/libs.

I have no idea what else could be different in platformio but I guess there are some variables, starting with the Arduino-ESP32 core.

Is there a way to force platformio to use an older one?

Sorry, i did not read correctly your post (Project runs ok when compiled and uploaded via ArduinoIDE and does not work when compiled via PlatformIO).

Well, the repo was updated 6 years ago.
In the meantime lot of changes happened (to the underlying ESP-IDF and arduino framework).

So let’s find out the differences between your ArduinoIDE settings and your platformIO settings.

What’s the platform version you’re using in ArduinoIDE?
For comparison: can you post screenshots from your ArduinoIDE settings and your platformio.ini?

As @maxgerhardt already noticed,

Arduino IDE:
AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.3\libraries\WiFi

Arduino IDE is 1.8.19
Settings …

board=esp32
boardsmanager.additional.urls=https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json,https://github.com/espressif/arduino-esp32/blob/master/package.json,http://arduino.esp8266.com/stable/package_esp8266com_index.json
build.verbose=true
build.warn_data_percentage=75
cache.enable=true
compiler.cache_core=true
compiler.warning_level=all
console=true
console.auto_clear=true
console.error.file=stderr.txt
console.length=500
console.lines=4
console.output.file=stdout.txt
custom_CDCOnBoot=lolin_s2_mini_default
custom_CPUFreq=esp32_240
custom_CrystalFreq=generic_26
custom_DFUOnBoot=lolin_s2_mini_default
custom_DebugLevel=esp32_none
custom_EventsCore=esp32_1
custom_FlashFreq=esp32_80
custom_FlashMode=esp32_dio
custom_FlashSize=esp32_4M
custom_LoopCore=esp32_1
custom_MSCOnBoot=lolin_s2_mini_default
custom_PSRAM=esp32_disabled
custom_PartitionScheme=esp32_default
custom_ResetMethod=generic_nodemcu
custom_UploadSpeed=esp32_921600
custom_baud=d1_mini_clone_921600
custom_cpu=nano_atmega328
custom_dbg=d1_mini_clone_Disabled
custom_eesz=d1_mini_clone_4M2M
custom_exception=d1_mini_clone_disabled
custom_ip=d1_mini_clone_hb6f
custom_led=nodemcuv2_2
custom_lvl=d1_mini_clone_None____
custom_mmu=d1_mini_clone_3232
custom_non32xfer=d1_mini_clone_fast
custom_sdk=generic_nonosdk_190703
custom_ssl=d1_mini_clone_all
custom_stacksmash=d1_mini_clone_disabled
custom_vt=d1_mini_clone_flash
custom_wipe=d1_mini_clone_none
custom_xtal=d1_mini_clone_80
editor.antialias=true
editor.auto_close_braces=true
editor.caret.blink=true
editor.code_folding=false
editor.divider.size=2
editor.external=false
editor.font=Monospaced,plain,16
editor.indent=true
editor.invalid=false
editor.keys.alternative_cut_copy_paste=true
editor.keys.home_and_end_beginning_end_of_doc=false
editor.keys.shift_backspace_is_delete=true
editor.languages.current=
editor.linenumbers=true
editor.save_on_verify=true
editor.tabs.expand=true
editor.tabs.size=2
editor.update_extension=true
editor.window.height.default=600
editor.window.height.min=290
editor.window.width.default=500
editor.window.width.min=400
export.applet.separate_jar_files=false
export.application.fullscreen=false
export.application.platform=true
export.application.stop=true
export.delete_target_folder=true
gui.scale=auto
ide.accessible=false
last.folder=M:\smartdisplay\1-Demo\Demo_Arduino\1_2_Factory_samples_Capacitive_touch\Factory_samples_Capacitive_touch\Factory_samples_Capacitive_touch.ino
last.ide.1.8.16.daterun=1656770426
last.ide.1.8.16.hardwarepath=C:\Program Files (x86)\Arduino\hardware
last.ide.1.8.19.daterun=1705501618
last.ide.1.8.19.hardwarepath=C:\Program Files (x86)\Arduino\hardware
last.ide.1.8.4.daterun=1636472243
last.ide.1.8.4.hardwarepath=C:\Program Files (x86)\Arduino IDE for Microduino-1.8.4-V6.0\hardware
last.ide.1.8.5.daterun=1631359319
last.ide.1.8.5.hardwarepath=C:\Program Files (x86)\Arduino\hardware
last.screen.height=2160
last.screen.width=3840
last.serial.location=1998,537,1749,956
last.sketch.count=1
last.sketch.default.location=-13,-13,3866,2106,1707,6
last.sketch.default.path=C:\Users\theuser\OneDrive\Dokumente\Arduino\wifilr_master\wifilr_master.ino
last.sketch0.location=-13,-13,3866,2106,1707,6
last.sketch0.path=C:\Users\theuser\OneDrive\Dokumente\Arduino\wifilr_master\wifilr_master.ino
last.sketch1.location=39,50,3675,2101,1678,0
last.sketch1.path=C:\Users\theuser\OneDrive\Dokumente\Arduino\LR_WIFI_Client\LR_WIFI_Client.ino
last.sketch2.location=2012,0,1839,2101,1156,0
last.sketch2.path=C:\Users\theuser\OneDrive\Dokumente\Arduino\LR_WIFI_Client\LR_WIFI_Client.ino
last.sketch3.location=464,94,3333,1884,1579,0
last.sketch3.path=C:\Users\theuser\OneDrive\Dokumente\Arduino\HC12_receiver_smartdisplay\HC12_receiver_smartdisplay.ino
last.sketch4.location=-11,-11,3862,2122,1650,6
last.sketch4.path=C:\Users\theuser\OneDrive\Dokumente\Arduino\_graphicstest\_graphicstest.ino
last.sketch5.location=115,837,600,600,327,0
last.sketch5.path=C:\Users\theuser\OneDrive\Dokumente\Arduino\stepper\stepper.ino
last.sketch6.location=-11,-11,3862,2122,1849,6
last.sketch6.path=M:\Arduino\stepper\stepper.ino
last.sketch7.location=-11,-11,3862,2122,1849,6
last.sketch7.path=M:\webserver2.ino\Connect\Connect.ino
last.sketch8.location=-11,-11,3862,2122,1849,6
last.sketch8.path=M:\webserver2.ino\Connect\Connect.ino
platform.auto_file_type_associations=true
preferences.readonly=false
preproc.color_datatype=true
preproc.enhanced_casting=true
preproc.imports.list=java.applet.*,java.awt.Dimension,java.awt.Frame,java.awt.event.MouseEvent,java.awt.event.KeyEvent,java.awt.event.FocusEvent,java.awt.Image,java.io.*,java.net.*,java.text.*,java.util.*,java.util.zip.*,java.util.regex.*
preproc.output_parse_tree=false
preproc.save_build_files=false
preproc.substitute_floats=true
preproc.substitute_unicode=true
preproc.web_colors=true
programmer=arduino:arduinoasisp
proxy.manual.hostname=
proxy.manual.password=
proxy.manual.port=
proxy.manual.type=HTTP
proxy.manual.username=
proxy.pac.url=
proxy.type=auto
recent.sketches=C:\Users\theuser\OneDrive\Dokumente\Arduino\wifilr_master\wifilr_master.ino,C:\Users\theuser\OneDrive\Dokumente\Arduino\LR_WIFI_Client\LR_WIFI_Client.ino
run.display=1
run.options=
run.options.memory=false
run.options.memory.initial=64
run.options.memory.maximum=256
run.present.bgcolor=#666666
run.present.exclusive=false
run.present.stop.color=#cccccc
serial.databits=8
serial.debug_rate=115200
serial.line_ending=1
serial.parity=N
serial.port=COM5
serial.port.file=COM5
serial.port.iserial=null
serial.show_timestamp=true
serial.stopbits=1
sketchbook.path=C:\Users\theuser\OneDrive\Dokumente\Arduino
software=ARDUINO
target_package=esp32
target_platform=esp32
theme.file=
update.check=true
update.id=7804288014357835302
update.last=1705416539618
upload.using=bootloader
upload.verbose=true
upload.verify=true

platformio client (slave)

[env:lolin_s2_mini]
platform = espressif32
board = lolin_s2_mini
framework = arduino
monitor_speed = 115200
monitor_rts = 1
monitor_dtr = 1
monitor_filters = esp32_exception_decoder

platformio host (or master as it is named in the original code)

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
monitor_rts = 1
monitor_dtr = 1
monitor_filters = esp32_exception_decoder

That’s Arduino Framework 2.0.3 which corresponds to espressif32@4.3.0

Change your platformio.ini to

platform = espressif32@4.3.0

and give it a try.

1 Like

for the S2 mini:

Resolving lolin_s2_mini dependencies...
Tool Manager: Installing espressif/toolchain-riscv32-esp @ 8.4.0+2021r2-patch3
UnknownPackageError: Could not find the package with 'espressif/toolchain-riscv32-esp @ 8.4.0+2021r2-patch3' requirements for your system 'windows_amd64'

one more hurdle but fixed with this:

platform_packages =
    toolchain-riscv32-esp @ 8.4.0+2021r2-patch5

now the ports gave up… rebooting time :roll_eyes: edit in a couple of seconds with the result

EDIT: WORKS! Now I hope the old espressif will also work with the display libs on the host.

Thanks for the excellent assistance with this !

As expected the display code doesn’t work with the espressif32@4.3.0
So I am back at step1, except it is clear now it isn’t a platformio issue, cause I updated the arduino IDE and the WiFi test doesn’t work there as well. :frowning: