HumiditySensor code does not compile
-
Hi everyone,
I tried to compile the code for the HumiditySensor but it does not work. I downloaded the latest Arduino-master from Github, added all libraries but when I compile the code of the HumiditySensor, I get this answer:
HumiditySensor.cpp.o: In function
loop': /Users//Desktop/Desktop/HumiditySensor.ino:38: undefined reference toDHT::getTemperature()'
/Users//Desktop/Desktop/HumiditySensor.ino:51: undefined reference toDHT::getHumidity()' HumiditySensor.cpp.o: In functionsetup':
/Users//Desktop/Desktop/HumiditySensor.ino:22: undefined reference to `DHT::setup(unsigned char, DHT::DHT_MODEL_t)'I tried other sensors (for example distance) and they compile and work.
I'm using a Mac, any other things of relevance?Thanks a lot,
Philipp -
Hi everyone,
I tried to compile the code for the HumiditySensor but it does not work. I downloaded the latest Arduino-master from Github, added all libraries but when I compile the code of the HumiditySensor, I get this answer:
HumiditySensor.cpp.o: In function
loop': /Users//Desktop/Desktop/HumiditySensor.ino:38: undefined reference toDHT::getTemperature()'
/Users//Desktop/Desktop/HumiditySensor.ino:51: undefined reference toDHT::getHumidity()' HumiditySensor.cpp.o: In functionsetup':
/Users//Desktop/Desktop/HumiditySensor.ino:22: undefined reference to `DHT::setup(unsigned char, DHT::DHT_MODEL_t)'I tried other sensors (for example distance) and they compile and work.
I'm using a Mac, any other things of relevance?Thanks a lot,
Philippcompliles fine for me... Arduino Version 1.6.3; my sensors version 1.4 (latest release)
you have the DHT library in your arduino library folder:

Code:
#include <SPI.h> #include <MySensor.h> #include <DHT.h> #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define HUMIDITY_SENSOR_DIGITAL_PIN 3 unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) MySensor gw; DHT dht; float lastTemp; float lastHum; boolean metric = true; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); void setup() { gw.begin(); dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); // Send the Sketch Version Information to the Gateway gw.sendSketchInfo("Humidity", "1.0"); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_HUM, S_HUM); gw.present(CHILD_ID_TEMP, S_TEMP); metric = gw.getConfig().isMetric; } void loop() { delay(dht.getMinimumSamplingPeriod()); float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT"); } else if (temperature != lastTemp) { lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } gw.send(msgTemp.set(temperature, 1)); Serial.print("T: "); Serial.println(temperature); } float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum) { lastHum = humidity; gw.send(msgHum.set(humidity, 1)); Serial.print("H: "); Serial.println(humidity); } gw.sleep(SLEEP_TIME); //sleep a bit } -
@BulldogLowell I just reinstalled arduino and now it is working... thank you for testing and telling me!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login