I'm trying to use an esp8266 that I bought quite a lot time ago. I configured correctly and stablish requests. But I don't know why when I'm using the pins of the arduino and using SoftwareSerial the message that I recive isn't readable.
I searched which esp-01 version do I have and I think is the 01S, cause the board is black (i found that here: https://aruneworld.com/embedded/esp8266/esp8266-boards/). But i don't understand what do you mean with pull up.
when loading code into flash memory or executing code from flash microcontrollers have to have certain pins in specified states HIGH or LOW, e.g. the ESP-01
the states can be achieved by the programmer hardware/software setting them or using pullup resistors connected to VCC or pulldown resistors connected to GND
here is some code to test the UNO and ESP-01 communications
ESP-01 code characters received on U0RXD are echoed back on U0TXD
// ESP-01 blink LED and read characters from serial U0RXD and echo back to U0TXD
void setup() {
Serial.begin(9600);
delay(1000);
Serial.println();
Serial.println("\n\nESP-01 blinking LED and read characters from serial U0RXD and echo back to U0TXD ");
Serial.print("LED blinking pin ");
Serial.println(LED_BUILTIN);
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
// read serial U0RXD and echo it back to U0TXD
while (Serial.available() > 0) {
char ch = Serial.read();
Serial.write(ch);
}
}
and the UNO (note SoftwareSerial will not work as the code may transmit and receive at the same time)
// UNO - ESP-01 AltSoftSerial test - ESP-01 loopsback - character transmitted to it are echoed back
// requires program ESP-01_Serial_loopback loaded in to ESP-01 and serial connections (see below)
#include <AltSoftSerial.h>
// load program ESP-01_Serial_loopback in to ESP-01
// ESP-01 U0TXD to UNO RX pin 8
// ESP-01 U0RXD to UNO TX pin 9
// ESP-01 GPIO0 and GPIO2 need to have pull-up resistors connected to ensure the module starts up correctly
// The ESP-01S has 12K resistors on the board for GPIO0, RST and CH_PD
AltSoftSerial espSerial;
void setup() {
Serial.begin(115200);
Serial.println("AltSoftSerial test");
//Begin serial communication with Arduino and SIM800L
espSerial.begin(9600);
Serial.println("ESP-01 serial intialized");
Serial.println("load ESP-01_Serial_loopback in to ESP-01");
Serial.println("ESP-01 U0TXD to UNO RX pin 8");
Serial.println("ESP-01 U0RXD to UNO TX pin 9");
}
void loop() {
if (Serial.available()) {
char command = Serial.read();
//Serial.println(command);
espSerial.print(command);
}
while (espSerial.available()) {
char reponse = espSerial.read();
Serial.print(reponse);
}
}
note the UNO <> ESP-01 baudrate is 9600 - at higher rate, e.g. 115200, some characters can get corrupted
UNO serial monitor output
ESP-01 blinking LED and read characters from serial U0RXD and echo back to U0TXD
LED blinking pin 2
UNO test 1
UNO test2 1234567890
UNO test3 abcdefghijklmnopqrstuvwxyz