LM35 sensor, can't see data on chart | ESP8266 Wi-Fi Module | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





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

Register Lost password?
sp_Feed sp_TopicIcon
LM35 sensor, can't see data on chart
Avatar
Khorne666
New Member
Forum Posts: 1
sp_UserOfflineSmall Offline
1
April 17, 2017 - 7:32 pm
sp_Permalink sp_Print

Hello everyone, newbie here

I'v started using an ESP8266 12E with an LM35 Temperature sensor, I can read data correctly and show the on my serial monitor, but when I created a new channel on thingspeak and added the API key to my code to show the data, I can't see nothing, Entries value keep incrementing, but I can't see anything on the chart.
Help, Thanks.

Avatar
Vinod

Forum Posts: 183
sp_UserOfflineSmall Offline
2
April 17, 2017 - 9:34 pm
sp_Permalink sp_Print

Have you had a look at this tutorial? Does following this tutorial give you the right results in your ThingSpeak channel? Can you compare your code with what is in the tutorial to figure out what is different in your code that causes it to not work?

Avatar
steelbullets
New Member
Forum Posts: 3
sp_UserOfflineSmall Offline
3
April 18, 2017 - 5:02 am
sp_Permalink sp_Print sp_EditHistory

Even i am having this same problem using a DHT11 Sensor. No matter what I try, My thingspeak channel is not at all recording data sent to it. I am working on a IOT Project for my college. I have tried almost 15-19 tutorials on the internet. Using functions like ThingSpeak.writeField(channel, 1, t, apiKey), ThinkSpeak.setFields() to using POST methods from arduino etc. None Seems to work. I don't know where i am going wrong. However if I type the post method with the api key and field values in the address bar of the browser, the data gets logged into ThinkSpeak. 

Here is my Code: Parts of it, like the network ssid, passwords and API Keys are hidden. I have it in my sketch though.

#include
#include
#include
#include
#define dht_apin 4// Analog Pin sensor is connected to
#define IP "184.106.153.149"

DHT dht(dht_apin, DHT11,15);
const char* apiKey = ""; //Hidden due to privacy
String apiKey1 = ""; //Hidden due to privacy
unsigned long channel =; //Hidden due to privacy
const char* ssid = "//Hidden due to privacy";
const char* password = "//Hidden due to privacy";
const char* server = "api.thingspeak.com";
int h,t;

WiFiClient client;

void setup(){

Serial.begin(115200);
delay(500);//Delay to let system boot
dht.begin();
delay(1000);//Wait before accessing Sensor
WiFi.begin(ssid, password);
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
ThingSpeak.begin(client);

}//end "setup()"

void loop(){
//Start of Program

// DHT.read11(dht_apin);

Serial.print("Current humidity = ");
Serial.print(dht.readHumidity());
h=dht.readHumidity();
Serial.print("% ");
Serial.print("temperature = ");
Serial.print(dht.readTemperature());
t=dht.readTemperature();
Serial.println("C ");
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}

This is creating the Headache i think. Please Look into this part of Code specifically. 

if (client.connect(server,80)) { // "184.106.153.149" or api.thingspeak.com
Serial.print("Temperature: ");
Serial.print(t);
ThingSpeak.setField(1,t);
Serial.print(" degrees Celcius Humidity: ");
Serial.print(h);
ThingSpeak.setField(2,h);
Serial.println("% send to Thingspeak");
String postStr = apiKey;
postStr +="&field1=";
postStr += String(t);
postStr +="&field2=";
postStr += String(h);
postStr += "

";

client.print("POST /update HTTP/1.1
");

client.print("Host: api.thingspeak.com
");

client.print("Connection: close
");

client.print("X-THINGSPEAKAPIKEY: "+apiKey1+"
");

client.print("Content-Type: application/x-www-form-urlencoded
");

client.print("Content-Length: ");
client.print(postStr.length());
client.print("
");

client.print(postStr);

// wait for response
/*while(!!!client.available()) {
delay(10);
}*/

// Read all the lines of the reply from server and print them to Serial
Serial.println("Response: ");
while(client.available()){
String line = client.readStringUntil('
');

Serial.print(line);
}

Serial.println();
Serial.println("closing connection");
//ThingSpeak.writeField(channel, 1, t, apiKey);
//ThingSpeak.writeField(channel, 2, h, apiKey);

// Write the fields that you've set all at once.
//ThingSpeak.writeFields(channel,apiKey);
}
else{
Serial.print("Cannot connect to the internet. Check Mobile Data");
Serial.print("
");
}
client.stop();

Serial.println("Waiting…");
// thingspeak needs minimum 15 sec delay between updates
delay(20000);

//Fastest should be once every two seconds.

}// end loop()

 

Thanking You

Regards

SteelBullets

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
20 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

candacele1

WilliamBer

roxieob18

Metawatch

ozayagw

ubabeutiti

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee