schreibfaul1 / ESP32-MiniWebRadio

Internetradio with ESP32, I2S DAC and SPI TFT Display with Touchpad
https://www.youtube.com/watch?v=6QbPee2583o
329 stars 82 forks source link

V3 standard build using WifiMulti fails to connect to Wifi reporting "Wifi credentials are not correct": Diagnosed as Auth Expire endless loop #374

Closed RobinMosedale closed 7 months ago

RobinMosedale commented 7 months ago

Schreibfaul ,

Thank you for your efforts and responses so far:

It's a lengthy battle, and I'm still losing.

Having started with a standard no PSRAM, A VS1053, and an ILI9341 with MMC resistors, and stumbled serially with each of those impediments in turn.

That took several weeks of discovery that VS1053 was no longer supported, the experimentation with SD card direct connection, and the need to transition to a DAC So the current configuration is:- ESP32S3N16R8 ILI9341 PCM5102 MMC on ILI8341 has no resistors.

I'm struggling. As discussed before my only motive is to receive BBC playlist streaming. A basic functionality of ESP32N16r8/ILI9341+touch+PCM5102 with BBC URL's embedded would be sufficient, as your colleague's kitchen basic radio. SD Playlists, BT, IR control are all good, but not necessary If you could point me to build to that I'd be more than grateful The first thing to note is: Startup page showing only half image 20240321_141526 1

Main Issue: WiFi Credentials are not correct: 20240321_141543 1

In addition, Message seems to be different colour to that in main.ccp

The access point is unobtainable, and not registering in any form on my router. I can't see whether it is indeed entering the access point code in the Wifi connect part of main.cpp

The Wifi is 2.4Ghz (Indeed initial attempts were made with 5.2GHz until it was discovered that the S3 can't operate on the frequency The WiFi capability has been checked with a simple standalone Wifi connect on both hotspots. SSID and Passwords checked. They have no unusual characters, one is a 4character SSID no spaces, no none alphanumeric. One has a space. Attempted in proximity to Hotspots, less than 30cms adjacent. Attached is Common.h

`// created: 10.Feb.2022 // updated: 08.Feb 2024

pragma once

pragma GCC optimize("Os") // optimize for code size

define _SSID "Xxxx" // Your WiFi credentials here

define _PW "xxxxxxxxxxx" // Or in textfile on SD-card

define DECODER 1 // (1)MAX98357A PCM5102A CS4344... (2)AC101, (3)ES8388, (4)WM8978

define TFT_CONTROLLER 0 // (0)ILI9341, (1)HX8347D, (2)ILI9486a, (3)ILI9486b, (4)ILI9488, (5)ST7796, (6)ST7796RPI

define DISPLAY_INVERSION 0 // (0) off (1) on

define TFT_ROTATION 3 // 1 or 3 (landscape)

define TFT_FREQUENCY 40000000 // 80000000, 40000000, 27000000, 20000000, 10000000

define TP_VERSION 0 // (0)ILI9341, (1)ILI9341RPI, (2)HX8347D, (3)ILI9486, (4)ILI9488, (5)ST7796, (3)ST7796RPI

define TP_ROTATION 3 // 1 or 3 (landscape)

define TP_H_MIRROR 0 // (0) default, (1) mirror up <-> down

define TP_V_MIRROR 0 // (0) default, (1) mittor left <-> right

define AUDIOTASK_CORE 0 // 0 or 1

define AUDIOTASK_PRIO 2 // 0 ... 24 Priority of the Task (0...configMAX_PRIORITIES -1)

define I2S_COMM_FMT 0 // (0) MAX98357A PCM5102A CS4344, (1) LSBJ (Least Significant Bit Justified format) PT8211

define SDMMC_FREQUENCY 20000000 // 80000000, 40000000, 27000000, 20000000, 10000000 not every SD Card will run at 80MHz

define FTP_USERNAME "esp32" // user and pw in FTP Client

define FTP_PASSWORD "esp32"

define CONN_TIMEOUT 5000 // unencrypted connection timeout in ms (http://...)

define CONN_TIMEOUT_SSL 5000 // encrypted connection timeout in ms (https://...)

define BT_SINK_NAME "MiniWebRadio" // ESP32 only

/**/

include

include

include

include

include

include

include

include

include

include

include

include

include

include "index.h"

include "index.js.h"

include "accesspoint.h"

include "websrv.h"

include "rtime.h"

include "IR.h"

include "tft.h"

include "ESP32FtpServer.h"

include "AC101.h"

include "ES8388.h"

include "WM8978.h"

include "DLNAClient.h"

include "KCX_BT_Emitter.h"

ifdef CONFIG_IDF_TARGET_ESP32

// Digital I/O used
    #define TFT_CS           22
    #define TFT_DC           21
    #define TFT_BL           32  // at -1 the brightness menu is not displayed
    #define TP_IRQ           39  // VN
    #define TP_CS             5
    #define SD_MMC_D0         2  // cannot be changed
    #define SD_MMC_CLK       14  // cannot be changed
    #define SD_MMC_CMD       15  // cannot be changed
    #define IR_PIN           35  // IR Receiver (if available)
    #define TFT_MOSI         23  // TFT and TP (VSPI)
    #define TFT_MISO         19  // TFT and TP (VSPI)
    #define TFT_SCK          18  // TFT and TP (VSPI)

    #define I2S_DOUT         25
    #define I2S_BCLK         27
    #define I2S_LRC          26
    #define I2S_MCLK          0  // mostly not used

    #define I2C_DATA         -1  // some DACs are controlled via I2C
    #define I2C_CLK          -1
    #define SD_DETECT        -1  // some pins on special boards: Lyra, Olimex, A1S ...
    #define HP_DETECT        -1
    #define AMP_ENABLED      -1

    #define BT_EMITTER_RX    33  // TX pin - KCX Bluetooth Transmitter (-1 if not available)
    #define BT_EMITTER_TX    36  // RX pin - KCX Bluetooth Transmitter (-1 if not available)
    #define BT_EMITTER_LINK  34  // high if connected                  (-1 if not available)
    #define BT_EMITTER_MODE  13  // high transmit - low receive        (-1 if not available)

endif

ifdef CONFIG_IDF_TARGET_ESP32S3

// Digital I/O used
    #define TFT_CS            8
    #define TFT_DC           12
    #define TFT_BL           10 // at -1 the brightness menu is not displayed
    #define TP_IRQ           39
    #define TP_CS            15
    #define SD_MMC_D0        11
    #define SD_MMC_CLK       13
    #define SD_MMC_CMD       14
    #define IR_PIN            4  // IR Receiver (if available)
    #define TFT_MOSI         18  // TFT and TP (FSPI)
    #define TFT_MISO          2  // TFT and TP (FSPI)
    #define TFT_SCK          17  // TFT and TP (FSPI)

    #define I2S_DOUT          9
    #define I2S_BCLK          3
    #define I2S_LRC           1
    #define I2S_MCLK          0

    #define I2C_DATA         -1  // some DACs are controlled via I2C
    #define I2C_CLK          -1
    #define SD_DETECT        -1  // some pins on special boards: Lyra, Olimex, A1S ...
    #define HP_DETECT        -1
    #define AMP_ENABLED      -1

    #define BT_EMITTER_RX    45  // TX pin - KCX Bluetooth Transmitter (-1 if not available)
    #define BT_EMITTER_TX    38  // RX pin - KCX Bluetooth Transmitter (-1 if not available)
    #define BT_EMITTER_LINK  19  // high if connected                  (-1 if not available)
    #define BT_EMITTER_MODE  20  // high transmit - low receive        (-1 if not available)

endif

/**/ // output on serial terminal

define ANSI_ESC_BLACK "\033[30m"

define ANSI_ESC_RED "\033[31m"

define ANSI_ESC_GREEN "\033[32m"

define ANSI_ESC_YELLOW "\033[33m"

define ANSI_ESC_BLUE "\033[34m"

define ANSI_ESC_MAGENTA "\033[35m"

define ANSI_ESC_CYAN "\033[36m"

define ANSI_ESC_WHITE "\033[37m"

define ANSI_ESC_RESET "\033[0m"

define ANSI_ESC_BROWN "\033[38;5;130m"

define ANSI_ESC_ORANGE "\033[38;5;214m"

define SerialPrintfln(...) {xSemaphoreTake(mutex_rtc, portMAX_DELAY); \

                        Serial.printf("%s ", rtc.gettime_s()); \
                        Serial.printf(__VA_ARGS__); \
                        Serial.printf("\033[0m"); \
                        Serial.println(""); \
                        xSemaphoreGive(mutex_rtc);}

/**/

// //prototypes (main.cpp) boolean defaultsettings(); boolean saveStationsToNVS(); boolean saveDefaultIRbuttonsToNVS(); void saveIRbuttonsToNVS(); void loadIRbuttonsFromNVS(); void updateSettings(); void urldecode(char str); const char SD_stringifyDirContent(String path); void setTFTbrightness(uint8_t duty); void showHeadlineVolume(); void showHeadlineTime(bool complete = true); void showHeadlineItem(uint8_t idx); void showFooterIPaddr(); void showFooterStaNr(); void showFooterRSSI(boolean show = false); void fall_asleep(); void wake_up(); void setRTC(const char TZString); void vector_clear_and_shrink(vector<char>& vec); boolean copySDtoFFat(const char path); void updateSleepTime(boolean noDecrement = false); void showVolumeBar(); void showBrightnessBar(); void showFooter(); void display_info(const char str, int32_t xPos, int32_t yPos, uint16_t color, uint16_t margin_l, uint16_t margin_r, uint16_t winWidth, uint16_t winHeight); void showStreamTitle(const char streamTitle); void showVUmeter(); void updateVUmeter(); void showLogoAndStationName(); void showStationName(String sn); void showStationLogo(String ln); void showFileLogo(uint8_t state); void showFileName(const char fname); void showFileNumber(); void showStationsList(uint16_t staListNr); void display_time(boolean showall = false); void display_alarmDays(uint8_t ad, boolean showall = false); void display_alarmtime(int8_t xy = 0, int8_t ud = 0, boolean showall = false); void display_sleeptime(int8_t ud = 0); boolean drawImage(const char path, uint16_t posX, uint16_t posY, uint16_t maxWidth = 0, uint16_t maxHeigth = 0); bool SD_listDir(const char path, boolean audioFilesOnly, boolean withoutDirs); boolean isAudio(File file); boolean isAudio(const char path); boolean isPlaylist(File file); bool connectToWiFi(); void openAccessPoint(); const char byte_to_binary(int8_t x); uint32_t simpleHash(const char str); void trim(char s); bool startsWith(const char base, const char str); bool endsWith(const char base, const char str); int32_t indexOf(const char base, const char str, int32_t startIndex); int32_t lastIndexOf(const char haystack, const char needle); boolean strCompare(char str1, char str2); boolean strCompare(const char str1, char str2); char x_ps_malloc(uint16_t len); char x_ps_calloc(uint16_t len, uint8_t size); char x_ps_strdup(const char str); int16_t strlenUTF8(const char str); int32_t map_l(int32_t x, int32_t in_min, int32_t in_max, int32_t out_min, int32_t out_max); void SerialPrintflnCut(const char item, const char color, const char str); const char scaleImage(const char path); void xchgShuffle(uint16_t n); void setVolume(uint8_t vol); inline uint8_t getvolume(); uint8_t downvolume(); uint8_t upvolume(); void setStation(uint16_t sta); void nextStation(); void prevStation(); void StationsItems(); void setStationViaURL(const char url); void changeBtn_pressed(uint8_t btnNr); void changeBtn_released(uint8_t btnNr); void savefile(const char fileName, uint32_t contentLength); String setI2STone(); void SD_playFile(const char path, uint32_t resumeFilePos = 0, bool showFN = true); void SD_playFolder(const char folderPath, bool showFN); bool SD_rename(const char src, const char dest); bool SD_newFolder(const char folderPathName); bool SD_delete(const char itemPath); void processPlaylist(boolean first = false); void changeState(int32_t state); void connecttohost(const char host); void connecttoFS(const char filename, uint32_t resumeFilePos = 0); void stopSong(); void IRAM_ATTR headphoneDetect(); void showDlnaItemsList(uint16_t itemListNr, const char parentName);

//prototypes (audiotask.cpp) void audioInit(); void audioTaskDelete(); void audioSetVolume(uint8_t vol); uint8_t audioGetVolume(); uint32_t audioGetBitRate(); boolean audioConnecttohost(const char host, const char user = "", const char pwd = ""); boolean audioConnecttoFS(const char filename, uint32_t resumeFilePos = 0); uint32_t audioStopSong(); void audioSetTone(int8_t param0, int8_t param1, int8_t param2, int8_t param3 = 0); uint32_t audioInbuffFilled(); uint32_t audioInbuffFree(); uint32_t audioInbuffSize(); boolean audioIsRunning(); uint32_t audioGetStackHighWatermark(); uint32_t audioGetCodec(); boolean audioPauseResume(); void audioConnectionTimeout(uint32_t timeout_ms, uint32_t timeout_ms_ssl); uint32_t audioGetFileSize(); uint32_t audioGetFilePosition(); uint16_t audioGetVUlevel(); ` It can be seen that: SDMMC_FREQUENCY 20000000 : there are no longer mount failures

define CONN_TIMEOUT 5000 // unencrypted connection timeout in ms (http://...)

define CONN_TIMEOUT_SSL 5000

Connection time outs have been increased to 5 seconds

Failure occurs whether connected via USB or directly powered via 5 volts

I am unable to obtain any serial output from pio device monitor --baud 115200 or any other baud. The USB becomes unavailable when 5v power is applied to the PCM and ILI, the esp32 is merely attached to ground. No idea why. It is not advisable to power everything via USB as the 5V ESp32 PIN is input only

Note: -D CORE_DEBUG_LEVEL=5 Clean build

The touch screen responds to pen in upper quadrant, resulting in display buttons in lower quarter, but doesn't respond thereafter. 20240321_141604 1

Main issue is difficulty in a:-

  1. Wifi logon
  2. No serial output

I cannot therefore diagnose any message via serial terminal Attached is pio.ini

`; PlatformIO Project Configuration File

[common] build_flags = -D TFT_FONT=1 ; (0) GARAMOND, (1) TFT_TIMES_NEW_ROMAN, (2) TFT_FREE_SERIF_ITALIC, (3) TFT_ARIAL, (4) Z300 -D NTP_Pool_1='"europe.pool.ntp.org"' ;note the double quotes -D NTP_Pool_2='"pool.ntp.org"' -D NTP_Pool_3='"time-a-g.nist.gov"' -D CORE_DEBUG_LEVEL=5 ; 0 None, 1 Error, 2 Warn, 3 Info, 4 Debug, 5 Verbose -D CONFIG_ARDUHAL_LOG_COLORS=1 -D ARDUINO_RUNNING_CORE=1 ; Arduino Runs On Core (setup, loop) -D ARDUINO_EVENT_RUNNING_CORE=0 ; Events Run On Core -D BOARD_HAS_PSRAM=1 -Wall -Wextra ;__-

[esp32] ;board_build.partitions = boards/miniwebradio4MB.csv ; 4MB Flash board_build.partitions = boards/miniwebradio8MB.csv ; 8MB Flash ;board_build.partitions = boards/miniwebradio16MB.csv ; 16MB Flash

;board = ESP32-Dev-4MB            ; 4MB Flash
board = ESP32-Dev-8MB            ; 8MB Flash
;board = ESP32-Dev-16MB           ;16MB Flash

;__-

[esp32s3] ;board_build.partitions = boards/miniwebradio4MB.csv ; 4MB Flash ;board_build.partitions = boards/miniwebradio8MB.csv ; 8MB Flash board_build.partitions = boards/miniwebradio16MB.csv ; 16MB Flash

;board = ESP-S3-12K-4MB           ;  4 MB Flash, 8MB quad PSRAM
;board = ESP-S3-12K-8MB           ;  8 MB Flash, 8MB quad PSRAM
;board = ESP-S3-12K-16MB          ; 16 MB Flash, 8MB quad PSRAM
;board = ESP32-S3-DevKitC-1-N8R2  ;  8 MB Flash, 2MB quad PSRAM
;board = ESP32-S3-DevKitC-1-N8R8  ;  8 MB Flash, 8MB octo PSRAM
board = ESP32-S3-DevKitC-1-N16R8 ; 16 MB Flash, 8MB octo PSRAM

;__-

[env]

extra_scripts = pre:env-extra.py

platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF5 platform_packages = platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git platformio/framework-arduinoespressif32-libs @ https://github.com/espressif/esp32-arduino-libs.git#idf-v5.1.3 framework = arduino

build_flags = ${common.build_flags} monitor_speed = 115200 monitor_filters = esp32_exception_decoder upload_speed = 115200 ; 921600, 512000, 460800, 256000, 115200

lib_deps = https://github.com/schreibfaul1/ESP32-audioI2S.git https://github.com/schreibfaul1/ESP32-KCX-BT-EMITTER.git https://github.com/schreibfaul1/ESP32-DLNA-Client.git https://github.com/schreibfaul1/ESP32-IR-Remote-Control.git

;__- [env:esp32] board = ${esp32.board} board_build.partitions = ${esp32.board_build.partitions} ;__- [env:esp32s3] board = ${esp32s3.board} board_build.partitions = ${esp32s3.board_build.partitions} ;__- [env:esp32_ota] board = ${esp32.board} board_build.partitions = ${esp32.board_build.partitions} upload_protocol = espota ;update code over WiFi upload_port = "MiniWebRadio.local" ;__- [env:esp32s3_ota] board = ${esp32s3.board} board_build.partitions = ${esp32s3.board_build.partitions} upload_protocol = espota ;update code over WiFi upload_port = "MiniWebRadio.local"

`

Arne65 commented 7 months ago

Hello, I have the following setting for ILI 9341

define TFT_ROTATION 3

define TP_VERSION 1

define TP_ROTATION 1

This is how the touch works

BBrz commented 7 months ago

@RobinMosedale I have the same hardware config as you. It connects to Wi-Fi (2.4GHz) and works ok, but I cannot acces it from the browser (laptop or phone). I've used the wire connections from here: https://github.com/schreibfaul1/ESP32-MiniWebRadio/issues/338

RobinMosedale commented 7 months ago

Thank you Arne65. I did manage to get it to log on twice and obtained the operation window and did something to touch. No more, so I'm not getting to the operational page any more

RobinMosedale commented 7 months ago

IBBrz, The connections are now automatically generated by setting the processor, esp32N16R8, PCM5012 and ILI9341 (correct variant). They are nearly identical to your (MMC slightly different, but MMC seems fine).

What puzzles me is why the USB becomes unrecognizable when running, but fine in Burn/Boot mode. If I could get terminal output, I'd be able to see what's going on or inserting some serial messages

schreibfaul1 commented 7 months ago

If this happens: image this is often a contact problem with the SD_MMC. Please check the wiring again, especially the solder joints. And if these resistors exist,
image it is better to bridge them

hevet commented 7 months ago

@schreibfaul1 It's the same for me, and I have an adapter soldered directly to the pins. I loaded version 2 and the logo is displayed correctly. The terminal displays this error: [ 1164][E][tft.cpp:3782] decode_mcu(): pjpeg_decode_mcu() failed with status 29

schreibfaul1 commented 7 months ago

thank you, I was able to reproduce this, the MiniWebRadioV3.jpg image for the small displays is defective. I have replaced it. Please unpack the content_on_SD_card.zip and overwrite the file in SD_MMC /common/s

RobinMosedale commented 7 months ago

Thank you Shreibfaul1,

Welcome screen now fixed. Therefore the MMC card has been reading successfully and not a contributor to any of the faults.

Double checked Router and Wifi settings, and all 2.4GHz, well within range. Default access point 30cm adjacent. Two successful logons last night, and obtained operational screen, with an IP of 192.168.1.212. Dunno where the 192.168.4.1 displayed comes from, not accessible and not identifiable on my network. Even with the 192.168.1.212 shown, unable to log on to the ESP32 webserver at that address. Credentials wrong still displayed. 4 access points on the SD card.

Connection time increased to

define CONN_TIMEOUT 8000 // unencrypted connection timeout in ms (http://...)

define CONN_TIMEOUT_SSL 8000 // encrypted connection timeout in ms (https://...)

although I suspect that these having nothing to do with initial logon Still no serial terminal activity 20240322_125107 1 20240322_125118 1

schreibfaul1 commented 7 months ago

Please replace the main.cpp with the example from Espressif. https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/examples/WiFiMulti/WiFiMulti.ino Does this work?

RobinMosedale commented 7 months ago

Esp32ExceptionDecoder: disabling, firmware at D:\ESP32-MiniWebRadio.pio\build\esp32s3\firmware.elf does not exist, rebuild the project? --- Terminal on COM19 | 115200 8-N-1 --- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time --- More details at https://bit.ly/pio-monitor-filters --- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H Disconnected (ClearCommError failed (PermissionError(13, 'The device does not recognize the command.', None, 22))) Reconnecting to COM19 Please build project in debug configuration to get more details about an exception. See https://docs.platformio.org/page/projectconf/build_configurations.html

Esp32ExceptionDecoder: disabling, firmware at D:\ESP32-MiniWebRadio.pio\build\esp32s3\firmware.elf does not exist, rebuild the project? Connected! [ 210][I][esp32-hal-psram.c:92] psramInit(): PSRAM enab[ 4243][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 5369][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 6394][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 7418][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 8186][E][WiFiMulti.cpp:311] run(): [WIFI] Connecting Failed (6). [ 8195][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 202 - AUTH_FAIL [ 13983][I][WiFiMulti.cpp:133] run(): [WIFI] scan done [ 13990][I][WiFiMulti.cpp:138] run(): [WIFI] 5 networks found [ 13996][I][WiFiMulti.cpp:262] run(): [WIFI] Connecting BSSID: D8:0D:17:EF:41:B6 SSID: Roise_4 Channel: 1 (-78) [ 15091][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 16115][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 17139][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 18265][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 19050][E][WiFiMulti.cpp:307] run(): [WIFI] Connecting Failed. [ 19290][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 20059][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 202 - AUTH_FAIL [ 25847][I][WiFiMulti.cpp:133] run(): [WIFI] scan done [ 25853][I][WiFiMulti.cpp:138] run(): [WIFI] 5 networks found [ 25860][I][WiFiMulti.cpp:262] run(): [WIFI] Connecting BSSID: 00:0F:94:D5:A2:14 SSID: Rose Channel: 9 (-83) [ 26966][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 27990][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 29014][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 30038][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 30914][E][WiFiMulti.cpp:307] run(): [WIFI] Connecting Failed. [ 31062][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 31923][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 202 - AUTH_FAIL [ 37711][I][WiFiMulti.cpp:133] run(): [WIFI] scan done [ 37717][I][WiFiMulti.cpp:138] run(): [WIFI] 5 networks found [ 37724][E][WiFiMulti.cpp:316] run(): [WIFI] no matching wifi found! [ 41520][I][WiFiMulti.cpp:133] run(): [WIFI] scan done [ 41526][I][WiFiMulti.cpp:138] run(): [WIFI] 5 networks found [ 41532][I][WiFiMulti.cpp:262] run(): [WIFI] Connecting BSSID: 60:E3:27:EB:85:0C SSID: TP-LINK_EB850C Channel: 1 (-40) [ 42645][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 43771][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 44796][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 45821][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 46587][E][WiFiMulti.cpp:307] run(): [WIFI] Connecting Failed. [ 46946][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 47596][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 202 - AUTH_FAIL [ 53385][I][WiFiMulti.cpp:133] run(): [WIFI] scan done [ 53391][I][WiFiMulti.cpp:138] run(): [WIFI] 6 networks found [ 53397][I][WiFiMulti.cpp:262] run(): [WIFI] Connecting BSSID: 00:0F:94:D5:A2:14 SSID: Rose Channel: 9 (-82) [ 54513][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 55536][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 58142][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 201 - NO_AP_FOUND [ 58495][E][WiFiMulti.cpp:303] run(): [WIFI] Connecting Failed AP not found. [ 59223][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 59505][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 202 - AUTH_FAIL [ 65294][I][WiFiMulti.cpp:133] run(): [WIFI] scan done [ 65300][I][WiFiMulti.cpp:138] run(): [WIFI] 5 networks found [ 65306][I][WiFiMulti.cpp:262] run(): [WIFI] Connecting BSSID: D8:0D:17:EF:41:B6 SSID: Roise_4 Channel: 1 (-83) [ 66396][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 67522][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 68547][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 69673][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 70361][E][WiFiMulti.cpp:307] run(): [WIFI] Connecting Failed. [ 70697][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 71370][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 202 - AUTH_FAIL [ 77159][I][WiFiMulti.cpp:133] run(): [WIFI] scan done [ 77165][I][WiFiMulti.cpp:138] run(): [WIFI] 6 networks found [ 77171][E][WiFiMulti.cpp:316] run(): [WIFI] no matching wifi found! [ 80967][I][WiFiMulti.cpp:133] run(): [WIFI] scan done [ 80973][I][WiFiMulti.cpp:138] run(): [WIFI] 6 networks found [ 80979][I][WiFiMulti.cpp:262] run(): [WIFI] Connecting BSSID: 60:E3:27:EB:85:0C SSID: TP-LINK_EB850C Channel: 1 (-39) [ 82071][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 83096][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 84119][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 85245][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 86034][E][WiFiMulti.cpp:307] run(): [WIFI] Connecting Failed. [ 86270][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE

See issue below:

https://github.com/espressif/arduino-esp32/issues/8142

I'll revert to the simplest Arduino build, which has been successful and report back

RobinMosedale commented 7 months ago

`/* Wi-Fi STA Connect and Disconnect Example

This example code is in the Public Domain (or CC0 licensed, at your option.)

Unless required by applicable law or agreed to in writing, this software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

*/

include

const char ssid = "TP-LINK_EB850C"; const char password = "xxxxxxx";

int btnGPIO = 0; int btnState = false;

void setup() { Serial.begin(115200); delay(10);

// Set GPIO0 Boot button as input
pinMode(btnGPIO, INPUT);

// We start by connecting to a WiFi network
// To debug, please enable Core Debug Level to Verbose

Serial.println();
Serial.print("[WiFi] Connecting to ");
Serial.println(ssid);

WiFi.begin(ssid, password);

// Auto reconnect is set true as default // To set auto connect off, use the following function // WiFi.setAutoReconnect(false);

// Will try for about 10 seconds (20x 500ms)
int tryDelay = 500;
int numberOfTries = 20;

// Wait for the WiFi event
while (true) {

    switch(WiFi.status()) {
      case WL_NO_SSID_AVAIL:
        Serial.println("[WiFi] SSID not found");
        break;
      case WL_CONNECT_FAILED:
        Serial.print("[WiFi] Failed - WiFi not connected! Reason: ");
        return;
        break;
      case WL_CONNECTION_LOST:
        Serial.println("[WiFi] Connection was lost");
        break;
      case WL_SCAN_COMPLETED:
        Serial.println("[WiFi] Scan is completed");
        break;
      case WL_DISCONNECTED:
        Serial.println("[WiFi] WiFi is disconnected");
        break;
      case WL_CONNECTED:
        Serial.println("[WiFi] WiFi is connected!");
        Serial.print("[WiFi] IP address: ");
        Serial.println(WiFi.localIP());
        return;
        break;
      default:
        Serial.print("[WiFi] WiFi Status: ");
        Serial.println(WiFi.status());
        break;
    }
    delay(tryDelay);

    if(numberOfTries <= 0){
      Serial.print("[WiFi] Failed to connect to WiFi!");
      // Use disconnect function to force stop trying to connect
      WiFi.disconnect();
      return;
    } else {
      numberOfTries--;
    }
}

}

void loop() { // Read the button state btnState = digitalRead(btnGPIO);

if (btnState == LOW) {
  // Disconnect from WiFi
  Serial.println("[WiFi] Disconnecting from WiFi!");
  // This function will disconnect and turn off the WiFi (NVS WiFi data is kept)
  if(WiFi.disconnect(true, false)){
    Serial.println("[WiFi] Disconnected from WiFi!");
  }
  delay(1000);
}

} `

[WiFi] Connecting to TP-LINK_EB850C [WiFi] WiFi is disconnected [WiFi] WiFi is connected! [WiFi] IP address: 192.168.1.212

All peripherals disconnected, ILI9341, PCM5012

RobinMosedale commented 7 months ago

Bare Esp32N16R8. No peripherals Rerun your example main with the same result.

ELF file SHA256: d4978be755caf041

Rebooting... ESP-ROM:esp32s3-20210327 Build:Mar 27 2021 rst:0xc (RTC_SW_CPU_RST),boot:0xb (SPI_FAST_FLASH_BOOT) Saved PC:0x40376d71 => 0x40376d71: esp_restart_noos at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/port/soc/esp32s3/system_internal.c:158 (discriminator 1) SPIWP:0xee mode:DIO, clock div:1 load:0x3fce3818,len:0x508 load:0x403c9700,len:0x4 => 0x403c9700: ?? ??:0 load:0x403c9704,len:0xad0 => 0x403c9704: ?? ??:0 load:0x403cc700,len:0x29d8 => 0x403cc700: ?? ??:0 entry 0x403c9880 => 0x403c9880: ?? ??:0 [ 209][I][esp32-hal-psram.c:92] psramInit(): PSRAM enabled [ 248][I][WiFiMulti.cpp:89] addAP(): [WIFI][APlistAdd] add SSID: TP-LINK_EB850C [ 256][I][WiFiMulti.cpp:89] addAP(): [WIFI][APlistAdd] add SSID: Roise_4 [ 264][I][WiFiMulti.cpp:89] addAP(): [WIFI][APlistAdd] add SSID: Rose [ 2908][I][WiFiMulti.cpp:133] run(): [WIFI] scan done [ 2914][I][WiFiMulti.cpp:138] run(): [WIFI] 4 networks found [ 2920][I][WiFiMulti.cpp:262] run(): [WIFI] Connecting BSSID: 60:E3:27:EB:85:0C SSID: TP-LINK_EB850C Channel: 1 (-45) [ 4020][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 5044][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 6068][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 7092][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 7970][E][WiFiMulti.cpp:311] run(): [WIFI] Connecting Failed (6). [ 7980][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 202 - AUTH_FAIL [ 13768][I][WiFiMulti.cpp:133] run(): [WIFI] scan done [ 13774][I][WiFiMulti.cpp:138] run(): [WIFI] 5 networks found [ 13781][I][WiFiMulti.cpp:262] run(): [WIFI] Connecting BSSID: D8:0D:17:EF:41:B6 SSID: Roise_4 Channel: 1 (-63) [ 14834][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 15858][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 16882][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 17906][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 18829][E][WiFiMulti.cpp:307] run(): [WIFI] Connecting Failed. [ 18930][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 19839][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 202 - AUTH_FAIL [ 25627][I][WiFiMulti.cpp:133] run(): [WIFI] scan done [ 25633][I][WiFiMulti.cpp:138] run(): [WIFI] 5 networks found [ 25639][I][WiFiMulti.cpp:262] run(): [WIFI] Connecting BSSID: 00:0F:94:D5:A2:14 SSID: Rose Channel: 9 (-87) [ 26772][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 27795][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 30396][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 201 - NO_AP_FOUND [ 30689][E][WiFiMulti.cpp:303] run(): [WIFI] Connecting Failed AP not found. [ 31482][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 31699][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 202 - AUTH_FAIL [ 37288][I][WiFiMulti.cpp:133] run(): [WIFI] scan done [ 37294][I][WiFiMulti.cpp:138] run(): [WIFI] 4 networks found [ 37301][E][WiFiMulti.cpp:316] run(): [WIFI] no matching wifi found! [ 40896][I][WiFiMulti.cpp:133] run(): [WIFI] scan done [ 40902][I][WiFiMulti.cpp:138] run(): [WIFI] 4 networks found [ 40908][I][WiFiMulti.cpp:262] run(): [WIFI] Connecting BSSID: 60:E3:27:EB:85:0C SSID: TP-LINK_EB850C Channel: 1 (-41) [ 42012][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 43036][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 44060][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 45084][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 45959][E][WiFiMulti.cpp:307] run(): [WIFI] Connecting Failed. [ 46108][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 2 - AUTH_EXPIRE [ 46969][W][WiFiGeneric.cpp:1081] _eventCallback(): Reason: 202 - AUTH_FAIL

There must be some fault in multiwifi

Suggest a simple wifi logon in main.cpp and I'll try it

RobinMosedale commented 7 months ago

Looks as though we need a station close before retrying

RobinMosedale commented 7 months ago

Re-emphasising issue with WifiMulti, fails to connect:

I have extensively checked the hardware under suspicion of it having a weak wifi receiver on another thread.

I have run tests back to back.

They are under Arduino builds as they are simple

The first is a simple WiFi.begin, with a time to connect: The chip connects consistently in 500ms

The test is repeated employing the WiFiMulti.run() and it never connects

This seems fairly convincing evidence that on the same hardware, running in the same environment, within the same timeframe, one works, but the other fails. Does this suggest something odd with WiFiMulti?

If you would like further test runs or evidence to isolate please let me know This is the simple wiFi.begin() programme

`#include

const char ssid = "TP-LINK_EB850C"; const char password = "blanked_out";

int btnGPIO = 0; int btnState = false; unsigned long startTime; unsigned long elapsedTime;

void setup() { Serial.begin(115200); delay(10);

// Set GPIO0 Boot button as input pinMode(btnGPIO, INPUT);

// We start by connecting to a WiFi network // To debug, please enable Core Debug Level to Verbose

Serial.println(); Serial.print("[WiFi] Connecting to "); Serial.println(ssid);

WiFi.begin(ssid, password); // Auto reconnect is set true as default // To set auto connect off, use the following function // WiFi.setAutoReconnect(false); startTime=millis(); // Will try for about 10 seconds (20x 500ms) int tryDelay = 500; int numberOfTries = 20;

// Wait for the WiFi event while (true) {

switch(WiFi.status()) {
  case WL_NO_SSID_AVAIL:
    Serial.println("[WiFi] SSID not found");
    break;
  case WL_CONNECT_FAILED:
    Serial.print("[WiFi] Failed - WiFi not connected! Reason: ");
    return;
    break;
  case WL_CONNECTION_LOST:
    Serial.println("[WiFi] Connection was lost");
    break;
  case WL_SCAN_COMPLETED:
    Serial.println("[WiFi] Scan is completed");
    break;
  case WL_DISCONNECTED:
    Serial.println("[WiFi] WiFi is disconnected");
    break;
  case WL_CONNECTED:
    Serial.print("Time to connect - ms: ");
    elapsedTime=millis()-startTime;
    Serial.println(elapsedTime);
    Serial.println("[WiFi] WiFi is connected!");
    Serial.print("[WiFi] IP address: ");
    Serial.println(WiFi.localIP());
    return;
    break;
  default:
    Serial.print("[WiFi] WiFi Status: ");
    Serial.println(WiFi.status());
    break;
}
delay(tryDelay);

if(numberOfTries <= 0){
  Serial.print("[WiFi] Failed to connect to WiFi!");
  // Use disconnect function to force stop trying to connect
  WiFi.disconnect();
  return;
} else {
  numberOfTries--;
}

} }

void loop() { // Read the button state btnState = digitalRead(btnGPIO);

if (btnState == LOW) { // Disconnect from WiFi Serial.println("[WiFi] Disconnecting from WiFi!"); // This function will disconnect and turn off the WiFi (NVS WiFi data is kept) if(WiFi.disconnect(true, false)){ Serial.println("[WiFi] Disconnected from WiFi!"); } delay(1000); } }`

This is the output:

[WiFi] Connecting to TP-LINK_EB850C [WiFi] WiFi is disconnected Time to connect - ms: 500 [WiFi] WiFi is connected! [WiFi] IP address: 192.168.1.212

This is the WiFiMulti programme:

`/*

include

include

WiFiMulti wifiMulti;

// WiFi connect timeout per AP. Increase when connecting takes longer. const uint32_t connectTimeoutMs = 10000;

void setup(){ Serial.begin(115200); delay(10); WiFi.mode(WIFI_STA);

// Add list of wifi networks wifiMulti.addAP("ESP32_NAT_Router", "Blanked_out"); wifiMulti.addAP("TP-LINK_EB850C", "Blanked_out"); wifiMulti.addAP("Rosem", "Blanked_out"); wifiMulti.addAP("Roie_4", "Blanked_out"); wifiMulti.addAP("Rose", "Blanked_out"); wifiMulti.addAP("Rosem", "Blanked_out"); wifiMulti.addAP("Rosie_3", "Blanked_out");

// WiFi.scanNetworks will return the number of networks found int n = WiFi.scanNetworks(); Serial.println("scan done"); if (n == 0) { Serial.println("no networks found"); } else { Serial.print(n); Serial.println(" networks found"); for (int i = 0; i < n; ++i) { // Print SSID and RSSI for each network found Serial.print(i + 1); Serial.print(": "); Serial.print(WiFi.SSID(i)); Serial.print(" ("); Serial.print(WiFi.RSSI(i)); Serial.print(")"); Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*"); delay(10); } }

// Connect to Wi-Fi using wifiMulti (connects to the SSID with strongest connection) Serial.println("Connecting Wifi..."); if(wifiMulti.run() == WL_CONNECTED) { Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); } }

void loop(){ //if the connection to the stongest hotstop is lost, it will connect to the next network on the list if (wifiMulti.run(connectTimeoutMs) == WL_CONNECTED) { Serial.print("WiFi connected: "); Serial.print(WiFi.SSID()); Serial.print(" "); Serial.println(WiFi.RSSI()); } else { Serial.println("WiFi not connected!"); } delay(1000); }`

This is the output (truncated......................) WiFi not connected! WiFi not connected! WiFi not connected! WiFi not connected! WiFi not connected! WiFi not connected! WiFi not connected! WiFi not connected! WiFi not connected! WiFi not connected! WiFi not connected!

RobinMosedale commented 7 months ago

Lastly, I'll attempt to replace the ESP32N16R8 with another. However, originals are hard to find in the Uk, most being a close clone When achieved, I'll repeat. A search of GITHUb throws up several references to WiFiMulti failingin a loop

RobinMosedale commented 7 months ago

20240328_201443 1 Wolle,

I am very pleased to let you know, that my +Replacement ESP32N32R8 Devkitc-1 arrived this afternoon. The issues with AUTH Failure is due to a poor antenna on the original. Similarly failure to raise an AP is likely to be the pooor antenna too.

I noticed that the original ESP32 would connect if I held a finger against the antenna, and disconnect when finger removed.

The salutary tale is that the market is flooded with poor quality ESP32 clones. On close inspect, it could be distinguished with the Boot and Reset buttons not in the published position. I managed to find a genuine Espressif DevkitC-1ESP32N32R8, but not cheap at ~£23 On rewiring with my new DevkitC-1 Esp32N32R8, the radio connects quickly with a decent bit rate. In addition it is worth reminding people that a decent power supply helps with WiFi Connection. I swapped mine for a decent 3Amp supply.

All I need to do now is:- a) Figure out which setting is appropriate for the TFT "20:13:49 Touchpoint not valid x=12, y=10 20:13:51 Touchpoint not valid x=14, y=13 20:13:53 Touchpoint not valid x=46, y=55 20:13:53 Touchpoint not valid x=14, y=25"

b) Insert the BBC Radio stations in the list.

I'm more than grateful for not only your efforts but also your patience.