Temp Humidity ESP8266 Difficulty

G'day!
I am using an UNO and a Temperature / Humidity project.
The issue is that it works perfectly on one PC through the serial monitor, but the same UNO rig throws a CIPSEND error when connected via USB to another PC.

I am not sure why it would work perfectly when connected via USB to PC-A but Not PC-B
It's the exact same Arduino device and sketch only on a different PC.

This appears to be the faulting line.....

  **String atSendCmd = "AT+CIPSEND="**

Here is the sketch.

//This File Works Perfectly on November 28, 2018 (With DHT11) (Not DHT22)
// This Sketch is ONLY for DHT11 (BLUE)

#include"dht.h"                      // Including library for dht
#include<Timer.h>
Timer t;
#include <SoftwareSerial.h>
SoftwareSerial Serial1(2, 3);


#define dht_dpin 12 
#define heart 13
dht DHT;


const char *workaround="OK";
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()
{
 Serial1.begin(57600);
 Serial.begin(57600);
 Serial.println("Connecting Wifi....");
 
 connect_wifi("AT",1000);
 connect_wifi("AT+CWMODE=1",1000);
 connect_wifi("AT+CIPSTA=\"192.168.000.58\",\"192.168.000.002\",\"255.255.255.000\"",10000);
  connect_wifi("AT+CWQAP",1000);  
 connect_wifi("AT+RST",5000);
  connect_wifi("AT+CWJAP=\"Gulfstream\",\"potatohead\"",10000);
 Serial.println("Wifi Connected"); 
 pinMode(heart, OUTPUT);
 delay(2000);
 t.oscillate(heart, 1000, LOW);
 t.every(300000, send2server);  // 50000 = 1 minute
}

void loop()
{

  DHT.read11(dht_dpin);
  humi=DHT.humidity;
  tem=DHT.temperature;
  delay(2000);
  t.update();
}

void send2server()
{
  char tempStr[8];
  char humidStr[8];
  char idStr[8];  
  temConv=(tem*1.8)+32;
  temConv=temConv-5.6; //Correction for DHT11 #1
  humiConv=humi+3.5; // Correction for DHT11 #1
  
  dtostrf(temConv, 5, 3, tempStr);
  dtostrf(humiConv, 5, 3, humidStr);
  
  sprintf(postUrl, "temphumid/temphumid.cfm?humidity=%s&temperature=%s&ID=TH-2",humidStr,tempStr,idStr);
     httpGet("192.168.0.103", postUrl, 80);
  }


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

    connect_wifi(atSendCmd,3000);
  connect_wifi(atHttpGetCmd,3000);
}

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("OK"))

      i=8;
    }
    delay(t);
    if(i>5)
    break;
    i++;
  }
  if(i==8)
  {
   Serial.println("OK");

  }
  else
  {
   Serial.println("Error");

  }
}

did you try the most beloved action of all and any modern electronic devices?

I mean re-booting. re-booting your PC-B, unpower / power your ESP ....

post the serial output too.

best regards Stefan

Using the same, or different USB cable?

Yes. Tried that.
So in other words, this error should not have occurred then?

Same cable.
It's that short blue cable that comes with all UNO's that has a USB-A end on one end and a "Printer" connector" ?? on the other end.

Is it one of those UNO boards with the ESP8266 onboard?

If I had to hazard a guess I would say that PC-B was struggling to supply enough current via its USB port. However I could be toally off the mark here. Any other USB peripherals connected to PC-B? Can you wittle down the number of connected peripherals and does it make a difference, or perhaps supply external power?

1 Like

Measure the 5V while plugged into each PC.

1 Like

This could be the issue.
I will try it and thanks.
Will report back the results.

You nailed it.
I simply added a power supply to the UNO and VIOLA!

It started working.
Thanks and kudos.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.