Data not visible on Thingspeak | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

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
Data not visible on Thingspeak
No permission to create posts
July 28, 2020
3:34 pm
Avatar
Anushree
New Member
Members
Forum Posts: 2
Member Since:
July 23, 2020
sp_UserOfflineSmall Offline

Hello,
I tried this simple code to plot data on thingseak. I can see the values on serial monitor but nothing is displayed on thingspeak. Could someone please help me point out what is wrong.
Here is my code:
#ifdef __cplusplus
extern "C" {
#endif

uint8_t temprature_sens_read();

#ifdef __cplusplus
}
#endif

uint8_t temprature_sens_read();
#include
String apiKey = "Z8YA6Z5QTSKMSIN9"; // Enter your Write API key from ThingSpeak
const char *ssid = "xxxx"; // replace with your wifi ssid and wpa2 key
const char *pass = "xxx";
const char* server = "api.thingspeak.com";
WiFiClient client;
//====================================================
// Setup
//====================================================
void setup() {
Serial.begin(115200);
delay(10);
Serial.println("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
}

//====================================================
// Loop
//====================================================
void loop() {
float t =0;
Serial.print("Temperature: ");

t = ((temprature_sens_read()-32)/1.8); //changing temperature parameter to celsius
if (client.connect(server,80)) // "184.106.153.149" or api.thingspeak.com
{

String postStr = apiKey;
postStr +="&field1=";
postStr += String(t);
postStr += "

";

client.print("POST /update HTTP/1.1
");
client.print("Host: api.thingspeak.com
");
client.print("Connection: close
");
client.print("X-THINGSPEAKAPIKEY: "+apiKey+"
");
client.print("Content-Type: application/x-www-form-urlencoded
");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("
");
client.print(postStr);

Serial.print("Temperature:");
Serial.print(t);
Serial.println(" C");

Serial.println("%. Send to Thingspeak.");
}
client.stop();
Serial.println("Waiting...");
delay(10000);
}

August 6, 2020
9:07 am
Avatar
cstapels
Moderator
Members


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

I think you might need another carriage return after the post data.
Is this running on a device? What kind of device are you using?

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

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
29 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:

r0833965, UO266047, edelww50, Gianpaolo Vitali, fernando, phil

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457