No (serial) communication between Arduino Uno and ESP8266

Hi all,
First post on this forum, don’t be too hard)

Having a problem where I send data (int hour) from my Wemos D1 mini esp,via Serial to my Arduino Uno,
no data gets read… :confused: To clear things up, they are connected by Uno pin1 RX-> ESP pin1 TX and
Uno pin2 TX-> Esp pin2 RX, both set to 9600 baud rate. Both a share a common ground,
and both receive their appropriate power. I have used multiple example snippets from the internet but have not come to a working solution now. I read some people still haven’t figured it out for this combination.
Both ino’s also attached. The reason for 2 boards is a lack of GPIO pins, but won’t use a MCP23016/14 or FCP8574. (for those who noticed, only my 4x4 keypad and Ledstrip work without their library as this is mandatory by my guidelines).
Any help with this would be greatly appreciated :slight_smile:

Esp:

#include <ESP8266WebServer.h>
#include <ArduinoJson.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <WiFiClientSecure.h>
#include <SoftwareSerial.h>
#include <DS3231.h>
#include <Wire.h>
#include <NTPClient.h>
SoftwareSerial ESPserial(9,10); //RX & TX
//absent rtc
DS3231 rtc;
//Btc Api
const char* host = "api.coindesk.com";    
int noDec = 0;
//Network
const char* ssid     = "NoWifi4U_2.4Ghz";
const char* password = "ValentinB00";
WiFiUDP ntpUDP;
const long utcOffsetInSeconds = 0;
NTPClient timeClient(ntpUDP, "be.pool.ntp.org", utcOffsetInSeconds);
WiFiClientSecure client;
//webserver
ESP8266WebServer server(80);
void handle_root() {
  server.send(200, "text/plain", "Hello from the esp32");
  delay(100);
}
int btc;
void setup() {
  Serial.begin(9600);
  ESPserial.begin(9600);
  WiFi.begin(ssid, password);
  while ( WiFi.status() != WL_CONNECTED ) {
    delay ( 500 );
    Serial.print ( "." );
  }
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  server.on("/", handle_root);
  server.begin();
  Serial.println("HTTP server started");
  timeClient.begin();
  Wire.begin();
}
void loop() {
  server.handleClient();  
  bool h12, pm;
  int hour = timeClient.getHours() + 1; // Get the hour
  int minute = timeClient.getMinutes(); // Get the minute
  timeClient.update();
  String newhour;
  String newminute;
  if (hour < 9)
  {
     newhour = '0'+ String(hour);
     Serial.println(newhour);
  }
  else
  {Serial.println(hour);}
  if (minute < 9)
  {
     newminute =  '0'+ String(minute);
     Serial.println(newminute);
  }
  else
  {Serial.println(minute);}
  //Serial.print("connecting to ");
  Serial.println(host);
  WiFiClient client;
  const int httpPort = 80;
  if (!client.connect(host, httpPort)) {
    Serial.println("connection failed");
    return;
  }
  String url = "/v1/bpi/currentprice/USD.json";
  //Serial.print("requesting URL: ");
  //Serial.println(url);
  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "Connection: close\r\n\r\n");

  //Serial.println("request sent");
  String answer;
  while (client.connected()) {
    String line = client.readStringUntil('\r');
    answer += line;
  }
  client.stop();
  String jsonAnswer;
  int jsonIndex;
  for (int i = 0; i < answer.length(); i++) {
    if (answer[i] == '{') {
      jsonIndex = i;
      break;
    }
  }
  jsonAnswer = answer.substring(jsonIndex);
  //Serial.println("JSON answer: ");
  //Serial.println(jsonAnswer);
  jsonAnswer.trim();
  int rateIndex = jsonAnswer.indexOf("rate_float");
  String priceString = jsonAnswer.substring(rateIndex + 12, rateIndex + 18);
  priceString.trim();
  float price = priceString.toFloat();
  Serial.println(priceString);
  char sendBTC[10];
  dtostrf(price, 4, 0, sendBTC);
  sprintf(sendBTC, "%d", (int)price);
  ESPserial.write(1);
  Serial.println();
  delay(10000);
}

My first suggestion is to work in just the serial communication between the ESP and Uno. Get that working by itself before adding in the other complexity.

To clear things up, they are connected by Uno pin1 RX-> ESP pin1 TX and
Uno pin2 TX-> Esp pin2 RX,

SoftwareSerial ESPserial(9,10); //RX & TX

There seems to be a conflict there. Which pins are connected?

Indeed trying to work this out from a fresh sketch. The Esp pin 1 RX corresponds to GPIO9 and Esp pin 2 TX corresponds to GPIO10 looking at this Wemos pinout.

I have made a hardware change to check if the i2c protocol works, loaded the default i2c scanner example onto the ESP and connected ESP SDA (D2 or Gpio4) to UNO SDA (Gpio18) and ESP SCL (D1 or Gpio5) to UNO SCL (Gpio19). Unfortunately, the program does not return any connected i2c devices.. I'm having a thought my esp is damaged but my main code which gets time, and data from an Api works.

I know I should write code myself, but it really is my hardest skill to overcome. Any info that leads to a solution or more problems will be cherished greatly :slight_smile:

(p.s. I could add my schematic if needed)