LM35 sensor, can't see data on chart | ESP8266 Wi-Fi Module | 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
LM35 sensor, can't see data on chart
No permission to create posts
April 17, 2017
7:32 pm
Avatar
Khorne666
New Member
Members
Forum Posts: 1
Member Since:
April 17, 2017
sp_UserOfflineSmall Offline

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.

April 17, 2017
9:34 pm
Avatar
Vinod

MathWorks
Members
Forum Posts: 202
Member Since:
May 1, 2016
sp_UserOfflineSmall Offline

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?

April 18, 2017
5:02 am
Avatar
steelbullets
New Member
Members
Forum Posts: 3
Member Since:
April 18, 2017
sp_UserOfflineSmall Offline

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:
18 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

MiguelWap, JamesdinnA, ScottTug, ThomasApesy, RicardoVeque, AlbertRop

Administrators: Hans: 387, lee: 457