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).
1 Answer 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);
}
-
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 internetArt Lisboa– Art Lisboa2022年07月03日 16:03:45 +00:00Commented Jul 3, 2022 at 16:03
-
write
andprint
are same for string2022年07月03日 17:43:27 +00:00Commented Jul 3, 2022 at 17:43 -
Can you add your wiring diagram into question?Metronomy31– Metronomy312022年07月04日 12:51:53 +00:00Commented Jul 4, 2022 at 12:51
message
forever once something is received on mySerial