Arduino Ethernet Shield using DHT11 Sensor & ThingSpeak problem | Arduino | 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
Arduino Ethernet Shield using DHT11 Sensor & ThingSpeak problem
No permission to create posts
October 12, 2018
9:11 pm
Avatar
Adrian257
New Member
Members
Forum Posts: 2
Member Since:
October 12, 2018
sp_UserOfflineSmall Offline

Hello Everyone ! I started my project with Arduino and Temperature/Humidity sensor DHT11. I want values from sens to display on ThingSpeak Charts.

Project Components:

Arduino Uno Rev3

Ethernet Shield

DHT 11

There is my code:
**********************************************************************************************************************************************************************
#include "ThingSpeak.h"
#include
#include
byte mac[] = { 0xFJ, 0x3C, 0xDA, 0xB7, 0xC1, 0x05}; //not importatnt for you
EthernetClient client;

#include

#include "DHT.h"

#define DHTPIN 12

#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

unsigned long myChannelNumber = MyChanellNumber; //not importatnt for you
const char * myWriteAPIKey = "MyApiKey"; //not importatnt for you

void setup() {
Serial.begin(9600);
dht.begin();
Ethernet.begin(mac);
ThingSpeak.begin(client);
}

void loop() {
float t = dht.readTemperature();
float h = dht.readHumidity();

Serial.println("======================================");
Serial.println("Weather condictions");
Serial.print("Temperature= ");
Serial.print(t);
Serial.println(" C");
Serial.print("Humidity= ");
Serial.print(h);
Serial.println(" %");
Serial.println();

ThingSpeak.writeField(myChannelNumber, 1, t, myWriteAPIKey);
ThingSpeak.writeField(myChannelNumber, 2, h, myWriteAPIKey);
delay(20000);
}
**********************************************************************************************************************************************************************

Problem is with values. Serial Monitor and ThingSpeaks Field 1 Chart show me NaN (Not a Number) value. Ethernet connection was good and ThingSpeak will show any other value but not humidity and Temperature.

I tried everything:

1. I checked out my connection. Countless times ! No problem.

2. Try this code without Ethernet & ThingSpeak functions, only with DHT11 and Serial Monitor ,it worked without problem (showing values)!

3. I tried -> float t = dht.readTemperature();
String temp = String(t);
ThingSpeak.writeField(myChannelNumber, 1, temp, myWriteAPIKey);

String doesn´t worked !

4. I was reading forums with similar issues. And nothing for me.

I will be grateful for any answer. Thanks.

October 13, 2018
1:34 pm
Avatar
Hans
Natick, MA

Admin
Forum Posts: 404
Member Since:
January 18, 2011
sp_UserOfflineSmall Offline

Try using setField. You are writing twice to a channel. You want to setField twice and write once. That will solve your NaN issue.

October 13, 2018
2:51 pm
Avatar
Adrian257
New Member
Members
Forum Posts: 2
Member Since:
October 12, 2018
sp_UserOfflineSmall Offline

Yes there were a problem. Thanks a lot. That helped

Forum Timezone: America/New_York

Most Users Ever Online: 114

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

Williampes, esmeraldagx11, lilacs16, loriexo60, ThomasHut, WernerDernnida

Administrators: Hans: 387, lee: 457