-->
Page 1 of 1

ESP-01 doesn't send any data over serial with wifi connected

PostPosted: Sat Mar 06, 2021 12:08 pm
by vra
how are you?. I'm using an ESP-01 with platformIO wich is programmed using esptool.py to run an example of a web server that I found in a book called "NodeMCU ESP8266 Communication Methods and Protocols: programming with arduino IDE". The code is the following:

Code: Select all#include <Arduino.h>
#include <ESP8266WebServer.h>
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>

const char *wifiName = "XXX";
const char *wifiPassword = "YYYY";

ESP8266WebServer server(80);

int ledPin = 1;

void handleRoot()
{
    //digitalWrite(ledPin,LOW);
    server.send(200,"text/plain","hello from esp8266");
    delay(1000);
    //digitalWrite(ledPin,HIGH);
}

void setup() {
// put your setup code here, to run once:
    Serial.begin(115200);
    delay(5000);
    //pinMode(ledPin,OUTPUT);
    Serial.print("Conectando");
    WiFi.begin(wifiName,wifiPassword);
    while (WiFi.status() != WL_CONNECTED)
    {
    /* code */
        delay(500);
        Serial.print(".");
    }
    Serial.println("");
    Serial.println("Conectado por WIFI");
    Serial.println("Dirección IP: ");
    Serial.println(WiFi.localIP());
    server.on("/", handleRoot);
    server.begin();
    Serial.println("Servidor HTTP iniciado");
}

void loop() {
// put your main code here, to run repeatedly:
   server.handleClient();
}


the problem that I have here is that if the wifi connections is initiated then the board doesn't send any data over serial but if the wifi connection is not initiated then the data is sent normally. As you noted I've commented the writing to the "ledPin" since it is the same pin where is TX but even by doing that the ESP-01 doesn't send the data over serial with wifi enabled.

I think the wifi is somehow disabling the serial port but I don't know for sure.

Can anyone help me with this?.

Thanks in advance for the help.

Re: ESP-01 doesn't send any data over serial with wifi conne

PostPosted: Tue Mar 09, 2021 5:30 am
by QuickFix
You aren't sending anything over serial in the handleRoot()-event. :idea:

Code: Select allvoid handleRoot()
{
    server.send(200,"text/plain","hello from esp8266");
    Serial.print("Hello sent"); // Or something similar
    delay(1000);
}

Re: ESP-01 doesn't send any data over serial with wifi conne

PostPosted: Tue Mar 09, 2021 6:13 am
by vra
Hi, I didn't but I will. Anyway, as you can see The code is sending data over serial while the wifi connection and there server are being configured and none of that data are being sent.

Re: ESP-01 doesn't send any data over serial with wifi conne

PostPosted: Wed Mar 10, 2021 9:13 am
by vra
Apparently some of my cables we're doing bad contacts, last night I was able to see some data on the monitor, is that or the ESP-01 is damaged because the web page loads.