I cant send data to thinkspeak using ESP8266 | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

6   +   5   =  

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
I cant send data to thinkspeak using ESP8266
No permission to create posts
June 4, 2020
4:08 am
Avatar
kingsIV
New Member
Members
Forum Posts: 1
Member Since:
June 4, 2020
sp_UserOfflineSmall Offline

hi im currently doing some project by using the ESP8266, but the problem is i cant retrieve the data even i already put the Write API key and stay connected to the host. Here is my coding :

String ssid = "Simulator Wifi"; // SSID to connect to
String password = ""; // Our virtual wifi has no password (so dont do your banking stuff on this network)
String host = "api.thingspeak.com"; // Open Weather Map API
const int httpPort = 80;
String uri = "/update?api_key=N7JZJG0FAIY9QGKU&field1=";

int setupESP8266(void) {
// Start our ESP8266 Serial Communication
Serial.begin(115200); // Serial connection over USB to computer
Serial.println("AT"); // Serial connection on Tx / Rx port to ESP8266
delay(10); // Wait a little for the ESP to respond
if (!Serial.find("OK")) return 1;

// Connect to 123D Circuits Simulator Wifi
Serial.println("AT+CWJAP=\"" + ssid + "\",\"" + password + "\"");
delay(10); // Wait a little for the ESP to respond
if (!Serial.find("OK")) return 2;

// Open TCP connection to the host:
Serial.println("AT+CIPSTART=\"TCP\",\"" + host + "\"," + httpPort);
delay(50); // Wait a little for the ESP to respond
if (!Serial.find("OK")) return 3;

return 0;
}

void anydata(void) {

int sensor = map(analogRead(gas_pin),0,1000,0,100);

// Construct our HTTP call
String httpPacket = "GET " + uri + String(sensor) + " HTTP/1.1
Host: " + host + "

";
int length = httpPacket.length();

// Send our message length
Serial.print("AT+CIPSEND=");
Serial.println(length);
delay(10); // Wait a little for the ESP to respond if (!Serial.find(">")) return -1;

// Send our http request
Serial.print(httpPacket);
delay(10); // Wait a little for the ESP to respond
if (!Serial.find("SEND OK
")) return;

}

June 8, 2020
11:43 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 861
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

you can program the ESP8266 to connect to the network directly instead of using the AT commands. Have a look at the exampels in the ThingSpeak documentation or the ones in the TingSpeak library. If you program your esp with the arduino IDE, you can use the ThingSpeak library.
https://github.com/mathworks/thingspeak-arduino

FYI, MATLAB answers is the preferred location for ThingSpeak Community support.

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
24 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

briskpanda, Dejw0089, Yassine Ben Salah, anis, 43994554AKS, suda

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457