0

I am able to connect to thingspeak but now able to upload the data. here are my set of commands:

AT+CIPMUX=0 OK AT+CIPSTART="TCP","184.106.153.149", 80 OK Linked AT+CIPSTATUS STATUS:3 +CIPSTATUS:0,"TCP","184.106.153.149",80,0 OK AT+CIPSEND=45 > GET /update?api_key=DXDPC4MLXMXFB5TT&field1=60 busy s... SEND OK OK 

and after some time unlink

I am giving these commands using arudino serial monitor. Please help, I have searched a many blogs, youtube videos.

0

2 Answers 2

0

You have a malformed HTTP request. You only have half of the first line.

A valid HTTP request would look more like this:

GET /update?api_key=DXDPC4MLXMXFB5TT&field1=60 HTTP/1.1 Host: api.thingspeak.com Content-length: 0 Connection: close <blank line> 

Just sending "GET : ain't gonna work. For a start, the server won't know what protocol you're speaking (HTTP/1.1), nor what website it's supposed to direct the request to (Host: api.thingspeak.com). Also, the final extra blank line is required to finish the request.

1
  • Comments are not for extended discussion; this conversation has been moved to chat. Commented Jan 4, 2018 at 11:13
0

I got it working. Yo!

#include <SoftwareSerial.h> #include <stdlib.h> // LED int ledPin = 13; // LM35 analog input int lm35Pin = 0; float my_value = 22; // replace with your channel's thingspeak API key String apiKey = "9PJEF1EP8ZMVY5JA"; // connect 10 to TX of Serial USB // connect 11 to RX of serial USB SoftwareSerial ser(10, 11); // RX, TX // this runs once void setup() { // initialize the digital pin as an output. pinMode(ledPin, OUTPUT); // enable debug serial Serial.begin(9600); // enable software serial ser.begin(9600); // reset ESP8266 ser.println("AT+RST"); } // the loop void loop() { // blink LED on board digitalWrite(ledPin, HIGH); delay(200); digitalWrite(ledPin, LOW); // read the value from LM35. // read 10 values for averaging. // convert to temp: // temp value is in 0-1023 range // LM35 outputs 10mV/degree C. ie, 1 Volt => 100 degrees C // So Temp = (avg_val/1023)*5 Volts * 100 degrees/Volt my_value++; float temp = my_value; // convert to string char buf[16]; String strTemp = dtostrf(temp, 4, 1, buf); Serial.println(strTemp); // TCP connection String cmd = "AT+CIPSTART=\"TCP\",\""; cmd += "184.106.153.149"; // api.thingspeak.com cmd += "\",80"; ser.println(cmd); if(ser.find("Error")){ Serial.println("AT+CIPSTART error"); return; } // prepare GET string String getStr = "GET /update?api_key="; getStr += apiKey; getStr +="&field1="; getStr += String(strTemp); getStr +="&field2="; getStr += String(strTemp); getStr += "\r\n\r\n"; // send data length cmd = "AT+CIPSEND="; cmd += String(getStr.length()); ser.println(cmd); Serial.println(cmd); if(ser.find(">")){ ser.print(getStr); Serial.println(getStr); } else{ ser.println("AT+CIPCLOSE"); // alert user Serial.println("AT+CIPCLOSE"); } // thingspeak needs 15 sec delay between updates ser.println("AT+RST"); delay(30000); } 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.