serial / WiFi conflict (arduino IDE)

bencoman
Posts: 2
Joined: Sun Jun 25, 2017 5:13 pm

serial / WiFi conflict (arduino IDE)

Postby bencoman » Sun Jun 25, 2017 7:11 pm

greetings and salutations,

I've been using Sparkfun's ESP32 Thing few a couple of weeks with the arduino IDE set up per Sparkfun's Hookup Guide. I am now trialing WiFi and found some poor interaction between it and the Serial Port/Serial Monitor. The following code I evolved from the Hookup Guide "Arduino Example: WiFi" works fine as long as the Serial Monitor is not connected. With the correctPassword there are a few slow flashes, followed by fast flashing indicating its connected to the access point and the hotspot shows "espressif" connected. With an incorrectPassword, it slow blinks forever - until I go Tools > Serial Monitor at which the blinking stops (with the occasional exception confounding things). Pushing the Thing's reset button does nothing until the Monitor is closed.

Code: Select all

#include "WiFi.h"
#include "esp_log.h"

const char * networkName = "BTC";
const char * networkPswd = "correctPassword";
const int LED_PIN = 5;
int ledState = 0;

void setup() 
{
  //Serial.begin(115200);
  //Serial.print("ESP32 SDK: ");
  //Serial.println(ESP.getSdkVersion());
  //esp_log_level_set("*", ESP_LOG_VERBOSE);
  pinMode(LED_PIN, OUTPUT);
  connectToWiFi(networkName, networkPswd);  
}

void connectToWiFi(const char * ssid, const char * pwd) 
{
  WiFi.begin(ssid, pwd);
  while (WiFi.status() != WL_CONNECTED) 
  { // SLOW flash while connecting.
    digitalWrite(LED_PIN, ledState);
    ledState = (ledState + 1) % 2; // Flip ledState
    delay(1000);
    //Serial.print("!");
  }
}

void loop() // FAST flash once connected. 
{   // FAST flash when connected. 
    digitalWrite(LED_PIN, ledState);
    ledState = (ledState + 1) % 2; // Flip ledState
    delay(100);
}
After closing the Monitor and then pushing the Thing's reset button it resumes blinking slowly as it should.

Uncommenting the four Serial lines and the esp_log_level_set is not detrimental. The slow blinking continues to work properly while the Monitor is closed, and again stops immediately the Monitor is connected, which then shows...

ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
ets Jun 8 2016 00:22:57
rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0x00
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0008,len:8
load:0x3fff0010,len:160
load:0x40078000,len:10632
load:0x40080000,len:252
entry 0x40080034
ESP32 SDK: v2.0-rc1-803-g1e0710f1
I (222) wifi: wifi firmware version: 6c86a1c
I (223) wifi: config NVS flash: enabled
I (223) wifi: config nano formating: disabled
I (232) wifi: Init dynamic tx buffer num: 32
I (232) wifi: Init dynamic rx buffer num: 64
I (233) wifi: wifi driver task: 3ffcf538, prio:23, stack:4096
I (235) wifi: Init static rx buffer num: 10
I (239) wifi: Init dynamic rx buffer num: 0
I (242) wifi: Init rx ampdu len mblock:7
I (246) wifi: Init lldesc rx ampdu entry mblock:4
I (251) wifi: wifi power manager task: 0x3ffd4900 prio: 21 stack: 2560
I (258) wifi: wifi timer task: 3ffd5980, prio:22, stack:3584
I (287) wifi⸮⸮

Its always the same output up to "wifi timer task" and thereafter varies a lot including unprintable characters that don't copy, so I've attached a few snapshots for reference..
1.png
1.png (8.59 KiB) Viewed 5726 times
2.png
2.png (12.55 KiB) Viewed 5726 times
3.png
3.png (19.08 KiB) Viewed 5726 times
Upping the serial monitor to 250,000 baud, seems to often allow more information to be logged (but not always, maybe 2 in 3) ...
I (242) wifi: wifi timer task: 3ffd5978, prio:22, stack:3584
I (266) wifi: mode : sta (24:0a:c4:05:b1:40)
I (388) wifi: n:6 0, o:1 0, ap:255 255, sta:6 0, prof:1
I (1045) wifi: state: init -> auth (b0)
I (1049) wifi: state: auth -> assoc (0)
I (1101) wifi: state: assoc -> run (10)
!!!!!!!!!!!!Gr eiainErr oe0pnce Itrutwttmoto P0)
Rgse up
C :04012 P x0003 A x811 A x31
2 :00000 A x0005 A x0000 A x30c7
6 :00007 A x0000 A x0000 9 x0005
A0 x0002 A1 x0002 A2 xffffffff A x30d8
1 :00000 A5 0ff000 SR x0000 ECAS x0000
XVDR:00000 LE x40d LN x4010 LON xffffff
akrc: x08a2:xffcf00 x11bc0032 x08f9035 x0f2fc:3ffcf3 x0f30:xffcf40 x0f3:0xffcf4 x0fd94030 x0ff16x35
CUhle.

And about 1 in 5 times (at 250,000) it worked perfectly (i.e. properly slow blinking)...
I (268) wifi: mode : sta (24:0a:c4:05:b1:40)
I (390) wifi: n:6 0, o:1 0, ap:255 255, sta:6 0, prof:1
I (1047) wifi: state: init -> auth (b0)
I (1050) wifi: state: auth -> assoc (0)
I (1102) wifi: state: assoc -> run (10)
!!!!!!!!!!!!I (5075) wifi: state: run -> auth (3a0)
I (5075) wifi: n:6 0, o:6 0, ap:255 255, sta:6 0, prof:1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

and...
I (245) wifi: wifi timer task: 3ffd5978, prio:22, stack:3584
I (270) wifi: mode : sta (24:0a:c4:05:b1:40)
I (391) wifi: n:6 0, o:1 0, ap:255 255, sta:6 0, prof:1
I (1048) wifi: state: init -> auth (b0)
I (1053) wifi: state: auth -> assoc (0)
I (1106) wifi: state: assoc -> run (10)
!!!!I (5075) wifi: state: run -> auth (3a0)
I (5075) wifi: n:6 0, o:6 0, ap:255 255, sta:6 0, prof:1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


I'm on Windows 10 using Arduino IDE 1.8.3.
I have a charged 500mAh LiPo battery connected to the Thing to hopefully guard against high WiFi current draw issues I read about.
Last edited by bencoman on Mon Jun 26, 2017 3:15 am, edited 1 time in total.

ESP_Sprite
Posts: 9016
Joined: Thu Nov 26, 2015 4:08 am

Re: serial / WiFi conflict (arduino IDE)

Postby ESP_Sprite » Sun Jun 25, 2017 11:41 pm

I'm afraid that the error you see still is pretty indicative of a power supply that cannot source enough current... do you happen to have something like a lab PSU or a more powerful battery to test that?

bencoman
Posts: 2
Joined: Sun Jun 25, 2017 5:13 pm

Re: serial / WiFi conflict (arduino IDE)

Postby bencoman » Mon Jun 26, 2017 4:40 am

After hooking up a shoebox sized 5A power supply to the 3.3V, J1-5 pin...
https://cdn.sparkfun.com/assets/learn_t ... ematic.pdf
the behaviour remains the same.

amoghjain
Posts: 16
Joined: Mon Nov 30, 2020 9:04 am

Re: serial / WiFi conflict (arduino IDE)

Postby amoghjain » Sun Dec 27, 2020 3:06 am

hey,

were you able to find the root-cause of random "null" in serial monitor. I am experiencing the same thing, just dont know why. Every now and then, serial monitor starts giving inconsistent/unexplanable prints.

I have soddered ESP32 on a breakout board from SEEEDStudio.

Who is online

Users browsing this forum: No registered users and 127 guests