If everything goes well, get_temp returns the temp as a float, otherwise it returns None.The call to get_temp fails sometimes, most likely due to noise picked up by the jumper cables.The last five digits on the second line are the temperature in degrees Celsius.
//#define DHTTYPE DHT11 // DHT 11 #define DHTTYPE DHT22 // DHT 22 (AM2302) //#define DHTTYPE DHT21 // DHT 21 (AM2301) const int TEMPERATURE_INTERVAL = 10; unsigned long last_temperature_sent = 0; const int HUMIDITY_INTERVAL = 10; unsigned long last_humidity_sent = 0; Homie Node temperature Node("temperature", "temperature"); Homie Node humidity Node("humidity", "humidity"); DHT dht(DHTPIN, DHTTYPE); void setup Handler() void get Send Temperature() void get Send Humid() void loop Handler() void setup() void loop() const int PIN_LED = D2; const int PIN_BUTTON = D1; int button OLD=LOW; Homie Node light("light", "light"); bool light On Handler(String message) Homie Node button Node("button", "button"); void loop Handler() void setup() void loop() Infact, the last sketch works for push button and switch.
Does the settings get flashed aswell when you rewrite arduino code to it?
It would be really nice if we could get it to work with ardafruit aswell as mosquitto.
The script starts by loading kernel modules for reading from 1 wire devices.
Next, it searches for a directory in /sys/bus/w1/devices.
For instance if I am brewing beer at my mates house i can threw an esp with dht11 in there, a powersupply and then just log on to ardfruit and plot the temperature. For openhab purposes i would of course use mosquitto and the mqtt binding.