You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which all looks perfectly fine. If, however, we declare an object of type SimpleDHT11 without a pin, the sketch fails to compile.
Here is a minimal sketch to show it.
#include <SimpleDHT.h>
int pinDHT11 = 14;
SimpleDHT11 dht11(); // fails, error: request for member 'read2' in 'dht11', which is of non-class type 'SimpleDHT11()'
//SimpleDHT11 dht11(-1); //works fine
void setup() {
Serial.begin(115200);
}
void loop(){
float temperature = 0;
float humidity = 0;
int err = dht11.read2( pinDHT11, &temperature, &humidity, NULL);
Serial.println(humidity);
delay(1200);
}
If we pass in a dummy pin number, such as -1, the code compiles and works. I pass in the pin number to the read/read2 function which are all overloaded to include, or not include, the pin.
Because of the design of my application, I wish to be able to specify the pin on each call to read, so my plan was to not specify a pin in the constructor call. I have no problem passing in a dummy value, but I am trying to understand why it does not work without.
This is happening on a Wemos D1 (ESP8266), Arduino IDE 2.0.3
The text was updated successfully, but these errors were encountered:
SimpleDH11 defines two public constructors:
and they are implemented like this:
Which all looks perfectly fine. If, however, we declare an object of type SimpleDHT11 without a pin, the sketch fails to compile.
Here is a minimal sketch to show it.
If we pass in a dummy pin number, such as -1, the code compiles and works. I pass in the pin number to the read/read2 function which are all overloaded to include, or not include, the pin.
Because of the design of my application, I wish to be able to specify the pin on each call to read, so my plan was to not specify a pin in the constructor call. I have no problem passing in a dummy value, but I am trying to understand why it does not work without.
This is happening on a Wemos D1 (ESP8266), Arduino IDE 2.0.3
The text was updated successfully, but these errors were encountered: