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");
}
}