Étape 2: I2C OLED + DHT22
>> source sur GitHub
Matériel
- Écran OLED I2C ([aliexpress)
- Capteur de température (aliexpress)
Écran OLED de câblage
| OLED | Pico | | ---- |------| | GND | A5 | | VCC | A7 | | SDL | B6 | | SDA | B7 |
Câblage DHT22 sonde de température
| DHT22 | Pico | | ------- |------| | 1: VCC | VDD | | 2: DATA | A8 | | 3: N/C | N/C | | 4: GND | GND | > N/C = not connected
Initialiser l’écran OLED
I2C1.setup({scl:B6,sda:B7}); // OLED driver and graphic library var g = require("SSD1306").connect(I2C1, function() { // display is connected... // do something });
Initialiser le capteur de température DHT22
// Analog pin A8 to read temperature from DHT22 sensor // temp sensor is powered by pins VDD and GND of pico var tempSensor = require("DHT22").connect(A8);
Lire la température
var temperature; var humidity; tempSensor.read(function(dht) { temperature = dht.temp; humidity = dht.rh; console.log("Temp is "+temperature.toString()+" and RH is "+humidity.toString());});