I bought some of these https://www.amazon.co.uk/gp/product/B09Z2B6LVP/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1 and tried them with this module. However, no matter what I did I kept getting null.
Here's the code I've been using:
const { SSD1306 } = require('ssd1306/i2c');
const {DHT} = require('dht');
const dht = new DHT(15, DHT.DHT11);
const ssd1306 = new SSD1306();
ssd1306.setup(board.i2c(0), {
width: 128,
height: 64
});
const gc = ssd1306.getContext();
function poll () {
gc.clearScreen()
dht.read();
gc.drawText(0, 16, `Temp: ${dht.temperature}`);
gc.drawText(0, 26, `Humidity: ${dht.humidity} %`);
gc.display()
}
setInterval(poll
, 1000)
But the value is always null.
I also tried
but that's also always null.
I thought this could have been bad hardware but then when I tried the same device on Arduino IDE (with all the exact same hardware setup) it worked fine. For the Arduino IDE I used this module and that works fine: DFRobot_DHT11.h https://github.com/DFRobot/DFRobot_DHT11
I bought some of these https://www.amazon.co.uk/gp/product/B09Z2B6LVP/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1 and tried them with this module. However, no matter what I did I kept getting null.
Here's the code I've been using:
But the value is always null.
I also tried
but that's also always null.
I thought this could have been bad hardware but then when I tried the same device on Arduino IDE (with all the exact same hardware setup) it worked fine. For the Arduino IDE I used this module and that works fine: DFRobot_DHT11.h https://github.com/DFRobot/DFRobot_DHT11