Étape 1: SPI OLED + DS18B20
>> source sur GitHub
Matériel
- Écran OLED SPI (aliexpress)
- Capteur de température ([aliexpress)
Écran OLED de câblage
| OLED | Pico | | ---- |------| | GND | A5 | | VCC | A7 | | SCL | B5 | | SDA | B6 | | RST | B7 | | D/C | A8 |
Capteur de température DS18B20 câblage
| DS18B20 | Pico | | ------- |------|| GND | GND | | OUT | A6 | | VCC | VDD |
Initialiser l’écran OLED
var spi = new SPI(); spi.setup({mosi: B6, sck:B5}); // OLED driver and graphic library var g = require("SSD1306").connectSPI(spi, A8, B7, function() { // display is connected... // do something });
Initialiser le capteur de température DS18B20
// Analog pin A6 to read temperature from Dallas DS18B20 sensor // temp sensor is powered by pins VDD and GND of pico var ow = new OneWire(A6); var tempSensor = require("DS18B20").connect(ow);
Lire la température
var temperature = tempSensor.getTemp(); console.log("Temp is "+temperature);