Wireless Temperature Sensor

Wireless Temperature Sensor


This is a quick and easy Wireless Temperature Sensor. One Espruino reads the temperature from a DS18B20 temperature sensor and transmits it over the NRF wireless module every 10 seconds, and another Espruino receives it and draws it on an LCD display.

You'll Need

Wiring Up

Board 1 (transmitter)

  • Follow the wiring instructions for wiring up the NRF24L01+ wireless module
  • Connect up the DS18B20 Temperature sensor as follows:
Sensor Wire Espruino 4.7k Resistor
Black GND
Red 3.3v 1st wire
White A1 2nd wire

Board 2 (receiver)


Connect to the transmitting Espruino, copy and paste this into the right-hand window, then click the Send to Espruino button.

SPI1.setup({sck:A5, miso:A6, mosi:A7});
var nrf = require("NRF24L01P").connect( SPI1, B0, B1 );
var ow = new OneWire(A1);
var sensor = require("DS18B20").connect(ow);
function onInit() {
  nrf.init([0,0,0,0,2], [0,0,0,0,1]);
setInterval(function() {
  var temperature = sensor.getTemp();
}, 10000);

Now, connect to the second (receiving) Espruino, and copy and paste this in:

SPI1.setup({sck:A5, miso:A6, mosi:A7});
var nrf = require("NRF24L01P").connect( SPI1, B0, B1 );
SPI3.setup({ baud: 1000000, sck:B3, mosi:B5 });
var g;
function onInit() {
  nrf.init([0,0,0,0,1], [0,0,0,0,2]);
  // We set up the LCD here because it needs to initialise at power on
  g = require("PCD8544").connect(SPI3,B6,B7,B8);

// Draw temperature onto the LCD
function showTemperature(temp) {

// Keep checking to see if we have any new data...
dataLine = "";
setInterval(function() {
  while (nrf.getDataPipe() !== undefined) {
    var data = nrf.getData();
    for (var i in data) {
      var ch = data[i];
      if (ch===0 && dataLine!=="") {
        // if we got a 0 (end of string), show what we got
        dataLine = "";
      } else if (ch!==0) {
        dataLine += String.fromCharCode(ch);
}, 50);


About 10 seconds later the display should update with the temperature received from the sender...

And that's it! A wireless temperature sensor. This could be extended with the code from the Heater Controller to make a wireless themostat, a history graph could be drawn, more than one wireless temperature sensor could be used or data could be logged onto an SD card...

This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.