Temp Humidity Sketch returns ERROR - not sure why

Hello,
I have this sketch on an Arduino UNO R3 using an ESP8266-01
The problem is that each command sent to the ESP8266-01 returns an ERROR.
I hope I’ve provided adequate information.
Here is the code

#include <DHT.h>
#include <DHT_U.h>


#include<Timer.h>
Timer t;
#include <SoftwareSerial.h>
SoftwareSerial Serial1(2, 3);

#define DHTPIN 12
#define heart 13
#define DHTTYPE DHT22   // DHT 22  (AM2302)
DHT dht(DHTPIN, DHTTYPE);

const char *workaround = "OK";
const char *api_key="ABCDEFGHIJKLMNOP";     // Enter your Write API key from ThingSpeak
static char postUrl[150];
float humi;
float tem;
//int tem,humi;
float temConv;
float humiConv;
void httpGet(String ip, String path, int port=80);

void setup()
{
 delay(2000);
 Serial1.begin(115200);
 Serial.begin(115200);
 Serial.println("Connecting Wifi....");


 connect_wifi("AT",1000);
 connect_wifi("AT+CWMODE=1",1000);
 connect_wifi("AT+CIPSTA=\"192.168.003.57\",\"192.168.003.001\",\"255.255.255.000\"",10000);
 connect_wifi("AT+CWQAP",1000);  
 connect_wifi("AT+RST",5000);
 connect_wifi("AT+CWJAP=\"MyWirelessSSL\",\"Password\"",10000);

 
 Serial.println("Wifi Connected"); 
 pinMode(heart, OUTPUT);
 delay(2000);
 t.oscillate(heart, 1000, LOW);
 t.every(150000, send2server);
}

void loop()
{

    humi = dht.readHumidity();
    tem = dht.readTemperature();
  delay(2000);
  t.update();
}

void send2server()
{
  char tempStr[8];
  char humidStr[8];
  temConv=(tem*1.8)+32;
   humiConv=humi+1;
   
  dtostrf(temConv, 5, 3, tempStr);
  dtostrf(humiConv, 5, 3, humidStr);
  sprintf(postUrl, "update?api_key=%s&field1=%s&field2=%s",api_key,humidStr,tempStr);
  httpGet("api.thingspeak.com", postUrl, 80);
}



void httpGet(String ip, String path, int port)
{
  int resp;
  String atHttpGetCmd = "GET /"+path+" HTTP/1.0\r\n\r\n";
 //String atHttpGetCmd = "GET /"+path+"\r\n\r\n";  
  //AT+CIPSTART="TCP","192.168.20.200",80
  String atTcpPortConnectCmd = "AT+CIPSTART=\"TCP\",\""+ip+"\","+port+"";
  connect_wifi(atTcpPortConnectCmd,1000);
  int len = atHttpGetCmd.length();
  String atSendCmd = "AT+CIPSEND=";
  atSendCmd+=len;
  connect_wifi(atSendCmd,1000);
  connect_wifi(atHttpGetCmd,1000);
}

void connect_wifi(String cmd, int t)
{
  int temp=0,i=0;
  while(1)
  {
    Serial.println(cmd);
    Serial1.println(cmd); 
    while(Serial1.available())
    {
           if(Serial1.find((char*)workaround))

      i=8;
    }
    delay(t);
    if(i>5)
    break;
    i++;
  }
  if(i==8)
  {
   Serial.println("OK");
  }
  else
  {
   Serial.println("Error");
         //lcd.setCursor(0,1);
      //lcd.print("Error");
  }
}

And here is the result in the Serial Monitor

Connecting Wifi....
AT
AT
AT
AT
AT
AT
AT
Error
AT+CWMODE=1
AT+CWMODE=1
AT+CWMODE=1
AT+CWMODE=1
AT+CWMODE=1
AT+CWMODE=1
AT+CWMODE=1
Error
AT+CIPSTA="192.168.003.57","192.168.003.001","255.255.255.000"
AT+CIPSTA="192.168.003.57","192.168.003.001","255.255.255.000"
AT+CIPSTA="192.168.003.57","192.168.003.001","255.255.255.000"
AT+CIPSTA="192.168.003.57","192.168.003.001","255.255.255.000"
AT+CIPSTA="192.168.003.57","192.168.003.001","255.255.255.000"
AT+CIPSTA="192.168.003.57","192.168.003.001","255.255.255.000"
AT+CIPSTA="192.168.003.57","192.168.003.001","255.255.255.000"
Error
AT+CWQAP
AT+CWQAP
AT+CWQAP
AT+CWQAP
AT+CWQAP
AT+CWQAP
AT+CWQAP
Error
AT+RST
AT+RST
AT+RST
AT+RST
AT+RST
AT+RST
AT+RST
Error
AT+CWJAP="MyWirelessSSL","Password"
AT+CWJAP="MyWirelessSSL","Password"
AT+CWJAP="MyWirelessSSL","Password"
AT+CWJAP="MyWirelessSSL","Password"
AT+CWJAP="MyWirelessSSL","Password"
AT+CWJAP="MyWirelessSSL","Password"
AT+CWJAP="MyWirelessSSL","Password"
Error
Wifi Connected
AT+CIPSTART="TCP","api.thingspeak.com",80
AT+CIPSTART="TCP","api.thingspeak.com",80
AT+CIPSTART="TCP","api.thingspeak.com",80
AT+CIPSTART="TCP","api.thingspeak.com",80
AT+CIPSTART="TCP","api.thingspeak.com",80
AT+CIPSTART="TCP","api.thingspeak.com",80
AT+CIPSTART="TCP","api.thingspeak.com",80
Error
AT+CIPSEND=77
AT+CIPSEND=77
AT+CIPSEND=77
AT+CIPSEND=77
AT+CIPSEND=77
AT+CIPSEND=77
AT+CIPSEND=77
Error
GET /update?api_key=ABCDEFGHIJKLMNOP&field1=30.300&field2=80.420 HTTP/1.0


GET /update?api_key=ABCDEFGHIJKLMNOP&field1=30.300&field2=80.420 HTTP/1.0


GET /update?api_key=ABCDEFGHIJKLMNOP&field1=30.300&field2=80.420 HTTP/1.0


GET /update?api_key=ABCDEFGHIJKLMNOP&field1=30.300&field2=80.420 HTTP/1.0


GET /update?api_key=ABCDEFGHIJKLMNOP&field1=30.300&field2=80.420 HTTP/1.0


GET /update?api_key=ABCDEFGHIJKLMNOP&field1=30.300&field2=80.420 HTTP/1.0


GET /update?api_key=ABCDEFGHIJKLMNOP&field1=30.300&field2=80.420 HTTP/1.0


Error

And what does the bolded line do? The "+" sign I believe is concatenation? How would this be spoken in plain English? Is it..... "variable atSendCmd PLUS "equal sign" and the variable LEN at the end?

String atSendCmd = "AT+CIPSEND=";

atSendCmd+=len;

connect_wifi(atSendCmd,1000);

What statements could I add at various points in this Sketch to display the values of various variables to check to see that they are being sent correctly?

Assuming this is the problem with the sketch.

At one point in the past, the error was caused by this line....

if(Serial1.find((char*)workaround))

because the word workaround had quotes around it.

That's not the case now.

So it's a mystery. maybe updates in the Arduino IDE itself changed and are causing the problem?

Not exactly sure what I'm doing, but I'm suspicious of Software Serial.

Trying to figure out ways to test that part of the sketch

This part.....

void connect_wifi(String cmd, int t)
{
  int temp=0,i=0;
  while(1)
  {
    Serial.println(cmd);
    Serial1.println(cmd);
    while(Serial1.available())
    {
           if(Serial1.find((char*)workaround))

      i=8;
    }
    delay(t);
    if(i>5)
    break;
    i++;
  }
  if(i==8)
  {
   Serial.println("OK");
  }
  else
  {
   Serial.println("Error");
         //lcd.setCursor(0,1);
      //lcd.print("Error");
  }
}

After a few attempts at looking at the data in the Serial buffer it appears that the function Serial1.Available() is returning ZERO.

That would probably do it.

More investigation tomorrow

For anyone who comes along this path later.....

I stumbled upon something in my toils and tribulations with this that you might want to be aware of.

IF....the DHT Sensor is bad or incorrectly connected, you might get ERRORS like I show above.

Today I changed what I assumed to be a perfectly good working DHT11 with another and suddenly it started working again. So it seems that at least with the sketch I'm using, a malfunctioning or improperly connecdted DHT Sensor could cause the problem I described in the OP

As a follow up…

This is confirmed. I tested my ESP8266-01 in a separate Test Rig to confirm it was responding properly to AT commands.

Note that I have several of these Temp & Humidity setups going. Some are DHT22 and others are DHT11.

With the DHT22 rig…
It was ONLY after replacing the DHT22 with another one that it started working.

Apparently if your DHT22 OR DHT11 sensor is not responding properly, it can cause the entire process to fail.

With that in mind, I would suggest you have a number of spare sensors on hand.

This was particularly frustrating because I assumed it was a problem with the code and spent days and many hours trying to deduce the problem with the code when all along it was the SENSOR.

In addition to the above, I found that while one ESP8266-01 worked with this sketch at 115200 baud, another needed 57600 baud.

So if you can't get it to work at one baud rate, try another.

You "should" be able to determine the baud rate of a given ESP8266 using the AT Commands. I think.

But overall, THIS sketch seems to work best at 57600 baud.

At baud rates above that, it seem to start throwing errors.