GSM connection to thingSpeak NULL values | ThingSpeak API | Forum

The ThingSpeak community site has been upgraded to a new site. This site is currently in read-only mode. You can ask questions or post and read discussions on the new site.
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
GSM connection to thingSpeak NULL values
No permission to create posts
March 6, 2014
5:06 am
Avatar
Stonker

Silver
Members
Forum Posts: 5
Member Since:
January 20, 2014
sp_UserOfflineSmall Offline

Hi, I am struggling to connect to thingSpeak using a GSM connection.

My problem is that I am posting NULL values to my thingSpeak channel (temperature sensor)

I have tested the code for a string value; that works fine. Just the value for the reading is not going up to thingSpeak.

Here is the Loop() and SendData() section of the sketch:
Any pointers would be greatly appreciated, thank you.

//

void loop()
{
// read the analog sensor:
int sReading = analogRead(A0); // postingInterval))
{
sendData("field1="+sensorReading); //<==========
}

// store the state of the connection for next time through
// the loop:
lastConnected = client.connected();
}

/*
This method makes a HTTP connection to the server.
*/
void sendData(String thisData)
{
// if there's a successful connection:
if (client.connect(server, 80))
{
Serial.println("connecting...");
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: ");
client.print(APIKEY);
client.print("\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(thisData.length());
client.print("\n\n");
client.print("Temp Sensor: ");
client.print(thisData);
}
else
{
// if you couldn't make a connection:
Serial.println("connection failed");
Serial.println();
Serial.println("disconnecting.");
client.stop();
}
// note the time that the connection was made or attempted
lastConnectionTime = millis();
}

//

Forum Timezone: America/New_York

Most Users Ever Online: 166

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

Advantagetreeexperts, laundrydaddyuk, techhhelp5, ken, tran, huldacormier

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457