Stap 1: SPI OLED + DS18B20
>> Bron op GitHub
Hardware
- SPI OLED-display (aliexpress)
- Temperatuursensor ([aliexpress)
OLED-display met bedrading
| OLED | Pico | | ---- |------| | GND | A5 | | VCC | A7 | | SCL | B5 | | SDA | B6 | | RST | B7 | | D/C | A8 |
Bedrading DS18B20 temperatuursensor
| DS18B20 | Pico | | ------- |------|| GND | GND | | OUT | A6 | | VCC | VDD |
Initialiseren van OLED-display
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 });
Initialiseren van de DS18B20 temperatuursensor
// 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);
Lees de temperatuur
var temperature = tempSensor.getTemp(); console.log("Temp is "+temperature);