1

I have a simple problem here. I use an ESP8266 WiFi module and an Arduino Uno r3.

What I want is to receive a serial message from the ESP8266 on the Arduino Uno.

Note: I set the upload speed of the ESP8266 to 9600.

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.write("hello friend");
  delay(2000);
}

Arduino Uno:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); //rx, tx

void setup() {
  Serial.begin(9600);
  mySerial.begin(9600);
}

String message = "";
boolean check = false;

void loop() {
  Serial.println(mySerial.available());
  mySerial.println("hindi nagagana");
  while (mySerial.available() > 0) {
    Serial.println(mySerial.readString());
    check = true;
  }

  if (check == true) {
    Serial.println(message);
  }

  delay(200);
}

Or any idea on how to control the Arduino Uno via the internet, such as a simple LED blink?

I used Firebase for databases an I plan to use ReactJs for webApp/Native App (nodeJs).

2
  • 1
    you print the empty String message forever once something is received on mySerial Commented Jul 3, 2022 at 13:17
  • Are you sure you have tx connected to rx and vice versa? You could use the serial monitor to test each half in isolation. Commented Jul 6, 2022 at 18:29

1 Answer 1

-1

i think you should change Serial.write() to Serial.print() because Serial.write() is for send data as bytes or series of bytes and Serial.print() send as human-readable text.
Reference:
Serial.write()
https://www.arduino.cc/reference/en/language/functions/communication/serial/write/
Serial.print()
https://www.arduino.cc/reference/en/language/functions/communication/serial/print/
esp 8266 code:

void setup()
{
 Serial.begin(9600);
}
void loop(){
    Serial.print("hello friend");
    delay(2000);
 
 }
3
  • Hi thank you for answering my question it really help but the thing is , its not working T_T is there any library or board installation do i need to install?? Im ran out of google stuff on the internet Commented Jul 3, 2022 at 16:03
  • write and print are same for string Commented Jul 3, 2022 at 17:43
  • Can you add your wiring diagram into question? Commented Jul 4, 2022 at 12:51

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.