All sorted. I removed all my libraries and started a fresh and the issue has resolved itself. Definitely to do with some sort of library conflict as mentioned by @mfalkvidd
sentur
@sentur
Best posts made by sentur
-
RE: Error verifying DhtTemperatureAndHumiditySensor Script wont compile
Latest posts made by sentur
-
RE: My SHT21 and ds18b20 sensor
Looks great!
Would love to see the schematic and 3D print file for the enclosure.
@Blom Would you be able to share them?
-
Raspberry Pi Zero WH as gateway?
Has anyone successfully setup the new Raspberry Pi Zero WH as a my sensors gateway? And using the NRF24 radio.
This is the new board with pre soldered headers.
https://thepihut.com/products/raspberry-pi-zero-wh-with-pre-soldered-header
-
RE: 💬 Building a Raspberry Pi Gateway
Anyone tried using the new Pi Zero WH as a Raspberry Pi Gateway. Presumably by MQTT and using NRF24 radio?
@alowhum Have you been able to setup a gateway with your Raspberry Pi Zero?
-
RE: Error verifying DhtTemperatureAndHumiditySensor Script wont compile
All sorted. I removed all my libraries and started a fresh and the issue has resolved itself. Definitely to do with some sort of library conflict as mentioned by @mfalkvidd
-
RE: Error verifying DhtTemperatureAndHumiditySensor Script wont compile
Sure here's the sketch that wont compile.
/** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * REVISION HISTORY * Version 1.0: Henrik EKblad * Version 1.1 - 2016-07-20: Converted to MySensors v2.0 and added various improvements - Torben Woltjen (mozzbozz) * * DESCRIPTION * This sketch provides an example of how to implement a humidity/temperature * sensor using a DHT11/DHT-22. * * For more information, please visit: * http://www.mysensors.org/build/humidity * */ // Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 //#define MY_RS485 #include <SPI.h> #include <MySensors.h> #include <DHT.h> // Set this to the pin you connected the DHT's data pin to #define DHT_DATA_PIN 3 // Set this offset if the sensor has a permanent small offset to the real temperatures #define SENSOR_TEMP_OFFSET 0 // Sleep time between sensor updates (in milliseconds) // Must be >1000ms for DHT22 and >2000ms for DHT11 static const uint64_t UPDATE_INTERVAL = 60000; // Force sending an update of the temperature after n sensor reads, so a controller showing the // timestamp of the last update doesn't show something like 3 hours in the unlikely case, that // the value didn't change since; // i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms] static const uint8_t FORCE_UPDATE_N_READS = 10; #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 float lastTemp; float lastHum; uint8_t nNoUpdatesTemp; uint8_t nNoUpdatesHum; bool metric = true; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); DHT dht; void presentation() { // Send the sketch version information to the gateway sendSketchInfo("TemperatureAndHumidity", "1.1"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); metric = getControllerConfig().isMetric; } void setup() { dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) { Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!"); } // Sleep for the time of the minimum sampling period to give the sensor time to power up // (otherwise, timeout errors might occure for the first reading) sleep(dht.getMinimumSamplingPeriod()); } void loop() { // Force reading sensor, so it works also after sleep() dht.readSensor(true); // Get temperature from DHT library float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT!"); } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) { // Only send temperature if it changed since the last measurement or if we didn't send an update for n times lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } // Reset no updates counter nNoUpdatesTemp = 0; temperature += SENSOR_TEMP_OFFSET; send(msgTemp.set(temperature, 1)); #ifdef MY_DEBUG Serial.print("T: "); Serial.println(temperature); #endif } else { // Increase no update counter if the temperature stayed the same nNoUpdatesTemp++; } // Get humidity from DHT library float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) { // Only send humidity if it changed since the last measurement or if we didn't send an update for n times lastHum = humidity; // Reset no updates counter nNoUpdatesHum = 0; send(msgHum.set(humidity, 1)); #ifdef MY_DEBUG Serial.print("H: "); Serial.println(humidity); #endif } else { // Increase no update counter if the humidity stayed the same nNoUpdatesHum++; } // Sleep for a while to save energy sleep(UPDATE_INTERVAL); }```
-
Error verifying DhtTemperatureAndHumiditySensor Script wont compile
I'm trying to setup a mysensor with DHT22 sensor. Following the DhtTemperatureAndHumiditySensor.io script on the website and additional example scripts on Github.
However the code wont verify / compile without an error saying it's missing DHT::Class().
I'm using the Arduino IDE 1.8.5, the MySensors library installed through IDE, MySensors Library 2.1.1.
I'm trying to verify the code to finall upload to an Arduino Pro Mini at 8mhz using an FTDI programmer over USB. But I don't think that should matter.
Here's the error:
DhtTemperatureAndHumiditySensor:73: error: no matching function for call to 'DHT::DHT()' DHT dht; ^ /Users/enwhat/Desktop/DhtTemperatureAndHumiditySensor/DhtTemperatureAndHumiditySensor.ino:73:5: note: candidates are: In file included from /Users/enwhat/Desktop/DhtTemperatureAndHumiditySensor/DhtTemperatureAndHumiditySensor.ino:44:0: /Volumes/Data/Users/enwhat/Documents/Arduino/libraries/DHT-sensor-library-master/DHT.h:40:4: note: DHT::DHT(uint8_t, uint8_t, uint8_t) DHT(uint8_t pin, uint8_t type, uint8_t count=6); ^ /Volumes/Data/Users/enwhat/Documents/Arduino/libraries/DHT-sensor-library-master/DHT.h:40:4: note: candidate expects 3 arguments, 0 provided /Volumes/Data/Users/enwhat/Documents/Arduino/libraries/DHT-sensor-library-master/DHT.h:38:7: note: constexpr DHT::DHT(const DHT&) class DHT { ^ /Volumes/Data/Users/enwhat/Documents/Arduino/libraries/DHT-sensor-library-master/DHT.h:38:7: note: candidate expects 1 argument, 0 provided /Volumes/Data/Users/enwhat/Documents/Arduino/libraries/DHT-sensor-library-master/DHT.h:38:7: note: constexpr DHT::DHT(DHT&&) /Volumes/Data/Users/enwhat/Documents/Arduino/libraries/DHT-sensor-library-master/DHT.h:38:7: note: candidate expects 1 argument, 0 provided /Users/enwhat/Desktop/DhtTemperatureAndHumiditySensor/DhtTemperatureAndHumiditySensor.ino: In function 'void setup()': DhtTemperatureAndHumiditySensor:91: error: 'class DHT' has no member named 'setup' dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor ^ DhtTemperatureAndHumiditySensor:92: error: 'class DHT' has no member named 'getMinimumSamplingPeriod' if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) { ^ DhtTemperatureAndHumiditySensor:97: error: 'class DHT' has no member named 'getMinimumSamplingPeriod' sleep(dht.getMinimumSamplingPeriod()); ^ /Users/enwhat/Desktop/DhtTemperatureAndHumiditySensor/DhtTemperatureAndHumiditySensor.ino: In function 'void loop()': DhtTemperatureAndHumiditySensor:104: error: 'class DHT' has no member named 'readSensor' dht.readSensor(true); ^ DhtTemperatureAndHumiditySensor:107: error: 'class DHT' has no member named 'getTemperature' float temperature = dht.getTemperature(); ^ DhtTemperatureAndHumiditySensor:114: error: 'class DHT' has no member named 'toFahrenheit' temperature = dht.toFahrenheit(temperature); ^ DhtTemperatureAndHumiditySensor:131: error: 'class DHT' has no member named 'getHumidity' float humidity = dht.getHumidity(); ^ exit status 1 no matching function for call to 'DHT::DHT()' This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.
Note: there's an additional DHTtester.io script in File>Examples> that I can compile / verify without any errors. It appears to reference a DHT library without any issues.
Here's the full DHTtester script:
// Example testing sketch for various DHT humidity/temperature sensors // Written by ladyada, public domain #include "DHT.h" #define DHTPIN 2 // what digital pin we're connected to // Uncomment whatever type you're using! //#define DHTTYPE DHT11 // DHT 11 #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 //#define DHTTYPE DHT21 // DHT 21 (AM2301) // Connect pin 1 (on the left) of the sensor to +5V // NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1 // to 3.3V instead of 5V! // Connect pin 2 of the sensor to whatever your DHTPIN is // Connect pin 4 (on the right) of the sensor to GROUND // Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor // Initialize DHT sensor. // Note that older versions of this library took an optional third parameter to // tweak the timings for faster processors. This parameter is no longer needed // as the current DHT reading algorithm adjusts itself to work on faster procs. DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(9600); Serial.println("DHTxx test!"); dht.begin(); } void loop() { // Wait a few seconds between measurements. delay(2000); // Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) float h = dht.readHumidity(); // Read temperature as Celsius (the default) float t = dht.readTemperature(); // Read temperature as Fahrenheit (isFahrenheit = true) float f = dht.readTemperature(true); // Check if any reads failed and exit early (to try again). if (isnan(h) || isnan(t) || isnan(f)) { Serial.println("Failed to read from DHT sensor!"); return; } // Compute heat index in Fahrenheit (the default) float hif = dht.computeHeatIndex(f, h); // Compute heat index in Celsius (isFahreheit = false) float hic = dht.computeHeatIndex(t, h, false); Serial.print("Humidity: "); Serial.print(h); Serial.print(" %\t"); Serial.print("Temperature: "); Serial.print(t); Serial.print(" *C "); Serial.print(f); Serial.print(" *F\t"); Serial.print("Heat index: "); Serial.print(hic); Serial.print(" *C "); Serial.print(hif); Serial.println(" *F"); }