NANO to ESP8266 serial fail

Hi people,
I have some program on Arduino NANO with sensors and buttons, display etc.
I need to send some data from that sensors to ESP8266 over serial. There I want to send them to NodeRED.

I tried that code on my test breadboard and I have some difficulties with data transmission.
Arduino and ESP are connected according to this scheme.

For test purposes, I am using one dht11. To generate some test data to serial output.

#include <dht.h>

dht Sensor;
String Str_Payload ;

#define DHT11_PIN 7

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

void loop()
{
  int chk = Sensor.read11(DHT11_PIN);
  
  String Temp = (String)Sensor.temperature ;
  String Hum = (String)Sensor.humidity ; 
  int DataCounter = 2;
  Str_Payload = "";
  Str_Payload += DataCounter;
  Str_Payload += " " + Temp;
  Str_Payload += " " + Hum;
  Str_Payload += " "; 
  Str_Payload += "\n";    
  Serial.print(Str_Payload);
  
  delay(1000);
}

This is my test code from ESP.

#include<SoftwareSerial.h>
#include <PubSubClient.h>
#include <stdio.h>
//Included SoftwareSerial Library
//Started SoftwareSerial at RX and TX pin of ESP8266
SoftwareSerial s(3, 1);
String InputString;
char Input [20];
int DataCount = 0;
float Temp = 0 ;
float Hum = 0 ;
void setup() {
  //Serial S Begin at 9600 Baud
  s.begin(9600);
}

void loop() {
  while (s.available()) {
    InputString =  s.readString();
    InputString.toCharArray(Input, InputString.length());
    s.print(" Received by ESP:");
    s.print(InputString);
    s.println();

    int n = sscanf(Input, "%d:f:f", &DataCount, &Temp, &Hum);

    s.print("Count = " );
    s.print(DataCount);
    s.print(" Temperature =" );
    s.print(Temp);
    s.print("Humidity = " );
    s.print(Hum);
    s.println();
  }

}

There I want to parse incoming String to individual float values. (Will be maybe 10)
And send separate value via publish(const char* topic, const char* payload);
from <PubSubClient.h> library

But if i put serial monitor also to ESP TX pin… (TTDI232) I receiving some wrong chars.

Please who know why it happening and how to solve this task better.
Especially to make it work.

You need a 3.3V power supply for the ESP8266-01.

http://www.martyncurrey.com/arduino-to-esp8266-serial-commincation/

I use breadboard power supply with 3.3 on one side for ESP and 5 V on the second side for Arduino. (NANO) This picture is only for the explanation of connection.

|500x375

why do you use SoftwareSerial on hw Serial pins?

@Stybyk, please do not cross-post. Threads merged.

[quote author=Coding Badly link=msg=3688690 date=1523607872] @Stybyk, please do not cross-post. Threads merged.

[/quote]

I had bad gw eror while posting first one. I want delete duplicate one when i found it. But it is not possible. Could you please delete duplicate post, instead merge ? Thank you.

SoftwareSerial s(3, 1);

As Juraj already asked. Why do you use a hardware serial pin for software serial.
Leo…

I don´t know... Because I found it somewhere like example. I delete software serial.. and now it receive correct string. But now i don´t know how to parse it. :confused: