#include "HX711.h" #include #include #include "max6675.h" #include #include #include #include #include #include String AP = "ssidhere"; // CHANGE ME String PASS = "passhere"; SoftwareSerial esp8266(19,18); int countTrueCommand; int countTimeCommand; boolean found = false; String API = "keyhere"; String HOST = "api.thingspeak.com"; String PORT = "80"; String field = "field1"; void setup() { // start debug serial Serial.begin(9600); // start HW serial for ESP8266 (change baud depending on firmware) esp8266.begin(115200); sendCommand("AT",5,"OK"); sendCommand("AT+CWMODE=1",5,"OK"); sendCommand("AT+CWJAP=\""+ AP +"\",\""+ PASS +"\"",20,"OK"); } void loop() { // make a string for assembling the data to log: String dataString = "12,13,14,15"; String getData = "GET/update?api_key="+ API +"&"+ field +"="+String(dataString); sendCommand("AT+CIPMUX=1",5,"OK"); sendCommand("AT+CIPSTART=0,\"TCP\",\""+ HOST +"\","+ PORT,15,"OK"); sendCommand("AT+CIPSEND=0," +String(dataString.length()+4),4,">"); esp8266.println(getData);delay(1500);countTrueCommand++; sendCommand("AT+CIPCLOSE=0",5,"OK"); } void sendCommand(String command, int maxTime, char readReplay[]) { Serial.print(countTrueCommand); Serial.print(". at command => "); Serial.print(command); Serial.print(" "); while(countTimeCommand < (maxTime*1)) { esp8266.println(command);//at+cipsend if(esp8266.find(readReplay))//ok { found = true; break; } countTimeCommand++; } if(found == true) { Serial.println("OYI"); countTrueCommand++; countTimeCommand = 0; } if(found == false) { Serial.println("Fail"); countTrueCommand = 0; countTimeCommand = 0; } found = false; }