Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By john77
#92543 I see all prints outside like
Code: Select allSerial.println("UDP OK");

Now I want to receive a char from a terminal
Code: Select allvoid UART_Get()
{
     char chr;
    if (Serial.available() > 0)
    {
        chr = Serial.read();

        //for debug
        Serial.print(chr);
    }
}

and I put it in a loop
Code: Select allvoid loop()
{
     UART_Get();
}

But I get nothing.
I test the RX pin with a scope and I see incoming signals on the pin.
What can be wrong?
User avatar
By prgvitor
#92546
john77 wrote:I see all prints outside like
Code: Select allSerial.println("UDP OK");

Now I want to receive a char from a terminal
Code: Select allvoid UART_Get()
{
     char chr;
    if (Serial.available() > 0)
    {
        chr = Serial.read();

        //for debug
        Serial.print(chr);
    }
}

and I put it in a loop
Code: Select allvoid loop()
{
     UART_Get();
}

But I get nothing.
I test the RX pin with a scope and I see incoming signals on the pin.
What can be wrong?


Check the baudRate value in "Serial.begin(value);" in "void setup()". The value must be the same as configured with another device. For ESP8266 the values ​​can be 115200 or 78880, try changing the baudRate.

Also check the RX (Arduino) -> TX (Modulo), TX (Arduino) -> RX (Modulo) connections.

You can also concatenate characters into a String:

String dataRec = "";

void UART_Get()
{
char chr;
if (Serial.available() > 0)
{
chr = Serial.read();

dataRec.concat(chr);

Serial.print(dataRec);

}
}