Introduction: OLED + Temperature Sensor on Espruino (JavaScript on MCU)

Picture of OLED + Temperature Sensor on Espruino (JavaScript on MCU)

Two short examples of reading temperature by DS18B20 or DHT22 sensor and show it on OLED display (4-wire SPI) or (2-wire I2C).

Everything is wired directly with breadboard wires to the Espruino Pico board.

No external power supply needed.
Just Plugin to USB Port or power by USB battery pack.

Step 1: SPI OLED + DS18B20

>> source on GitHub

Hardware

Wiring OLED display

| OLED | Pico |  
| ---- |------| 
| GND | A5 |
| VCC | A7 |
| SCL | B5 |
| SDA | B6 |
| RST | B7 |
| D/C | A8 |

Wiring DS18B20 temperature sensor

| DS18B20 | Pico | 
| ------- |------|
| GND | GND |
| OUT | A6 |
| VCC | VDD |

Initialize 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
});

Initialize DS18B20 temperature sensor

// 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);

Read temperature

var temperature = tempSensor.getTemp(); 
console.log("Temp is "+temperature);

Step 2: ​I2C OLED + DHT22

>> source on GitHub

Hardware

Wiring OLED display

| OLED | Pico |  
| ---- |------|
| GND | A5 |
| VCC | A7 |
| SDL | B6 |
| SDA | B7 |

Wiring DHT22 temperature sensor

| DHT22   | Pico |  
| ------- |------|
| 1: VCC | VDD |
| 2: DATA | A8 |
| 3: N/C | N/C |
| 4: GND | GND |

> N/C = not connected

Initialize OLED display

I2C1.setup({scl:B6,sda:B7}); 
// OLED driver and graphic library
var g = require("SSD1306").connect(I2C1, function() {
// display is connected...
// do something
});

Initialize DHT22 temperature sensor

// 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);

Read temperature

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());
});

Comments

About This Instructable

2,939views

29favorites

License:

More by JorgenVikingGod:Blinky MakerBeam Cube (holocron)WiFi RFID ReaderOLED + Temperature Sensor on Espruino (JavaScript on MCU)
Add instructable to: