Can't send data to ESP8266 via arduino

I have an ESP8266-01 and I want to send sensor data from Arduino to ESP8266 via serial communication but the data I receive is not correct, I tried changing baud rates but no luck, here is the code

Code for ESP8266:

#include <SoftwareSerial.h>

void setup() {
// put your setup code here, to run once:


void loop() {
// put your main code here, to run repeatedly:
while(Serial.available()) {

Code for Arduino

#include <SoftwareSerial.h>

SoftwareSerial esp(1, 0);
String str;
void setup(){

void loop() {
// put your main code here, to run repeatedly:
str = String("Hi there");
esp.println("hi there");


Here is the serial monitor:

Serial monitor showing numbers instead of "hi there":
The wiring connections are correct.

You cannot use pins 0 and 1 for software serial on arduino since that is where the hardware serial is.

Please follow the advice given in the link below when posting code. Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

On Arduino-Unos software-serial works only reliable up to 19200 baud.
38400 is a bit fast for software-serial.
And you have to use other pins than IO-pin 0 and 1 because these are the pins that were used by serial (the standard serial interface which is connected to your USB-cable)

You should post code by using code-tags
There is an automatic function for doing this in the Arduino-IDE
just three steps

  1. press Ctrl-T for autoformatting your code
  2. do a rightclick with the mouse and choose "copy for forum"
  3. paste clipboard into write-window of a posting

best regards Stefan

Have you checked the return type of I think it's probably a 'byte'. So you're reading exactly one byte, then print 'yes', read a byte again, etc. In the meantime, your Arduino is probably experiencing timing issues since it can't keep up with printing and reading soft-serial at the same time.

Anyway, as always when people try to knit together an Arduino and an ESP board, my question is: what limitation on the ESP8266 do you think you have that justifies keeping an Arduino in the system as well? Not sure what kind of Arduino you're using, but often people even use a Nano, UNO or something else that's completely overpowered by the ESP (even the old 8266!) without realizing they're bogged down by the complexity of having an inferior microcontroller in the circuit for no good reason at all.

Have you taken into account that most Arduinos work at 5V whilst the ES8266 works at 3.3V ?

In addition, do the two systems have a common GND connection ?

Many people struggle with trying to link the ESP8266-01 to an Arduino.

Is the Arduino doing something which can not be done on a Node MCU or Wemos D1 esp8266 development board. They have USB connectors and can run with the Arduino IDE. They are not expensive.

The ESP32 development board is another good choice to replace the Arduino/8266-01 combination.