I am trying to upload 1 number to thingspeak.com but the code does not work. It complies and I put in LED switched to know when the program is running, but I cannot get it to work. I am not a great coder so anything help is thanked extremely!!!
#include <SoftwareSerial.h>
#define SSID "WIFI"
#define PASS "1234567"
#define IP "184.106.153.149"
String GET = "GET /update?key=E1USJVGN3QYCCN4H&field1=";
void setup()
{
Serial.begin(9600);
Serial.println("AT");
delay(3000);
if(Serial.find("OK")){
connectWiFi();
}
}
void loop() {
pinMode(13, OUTPUT);
digitalWrite(13, LOW); //turn on led
delay(2000);
digitalWrite(13, HIGH);
int Compton = 9;
String cmd = "AT+CIPSTART="TCP","";
cmd += IP;
cmd += "",80";
Serial.println(cmd);
digitalWrite(13, LOW); //turn off led
delay(2000);
cmd = GET;
cmd += Compton;
cmd += "\r\n";
Serial.print("AT+CIPSEND=");
Serial.println(cmd.length());
if(Serial.find(">")){
Serial.print(cmd);
}else{
Serial.println("AT+CIPCLOSE");
}
;
}
boolean connectWiFi(){
Serial.println("AT+CWMODE=1");
delay(2000);
String cmd="AT+CWJAP="";
cmd+=SSID;
cmd+="","";
cmd+=PASS;
cmd+=""";
Serial.println(cmd);
delay(3000);
if(Serial.find("OK")){
return true;
}else{
return false;
}
;
}
Trial_capstone.ino (1.04 KB)