Home CodeEspruino Espruino Pico and DHT22 example

Espruino Pico and DHT22 example

by shedboy71

In this example we use the DHT22 (or AM2302) humidity/temperature sensor and the Arduino UNO board to read data and print it out to the serial monitor.

The DHT22 is better than the DHT11 because it has a wider range of measurement, 0 to 100% for humidity and -40°C to +125°C for temperature. Also it has a digital output that provides greater data accuracy.


The AM2302 is a wired version of the DHT22, in a large plastic body, so they are the same device. Connect the red 3.3V power, the yellow wire to your data input pin and the black wire to ground.



This is the pin connections

Device Pin – AM2302 colour Espruino Pico
1 (Vcc) – Red wire 3.3
2 (S)  – Yellow wire B3
3 (GND) – Black wire GND


pico and am2302_schem


This example simply logs out temperature and humidity to the console every second

[codesyntax lang=”javascript”]

setInterval(function() {
  var dht = require("DHT22").connect(B3);
  dht.read(function (a){
    console.log("Temperature is "+a.temp.toString());
    console.log("Humidity is "+a.rh.toString());
}, 1000);



AM2302 DHT22 temperature and humidity sensor for arduino


You may also like