I'm working on a project that will monitor the temperature of a refrigerator. Ideally, we are hoping to do this wireless via RF to a Raspberry PI to collect the data. If anyone has completed this project already, would you mind sharing your lessons learned.


I use a DS18B20 sensor rigged up to a ESP8266 (Arduino Wifi compatible board). Then I hooked up the ESP8266 to the Wifi and called web services to upload the temperature data to an endpoint (IFTTT) that loads it in a Google spreadsheet. I have also done this on a production system (with more sophisticated hardware and a C# back-end) that was used to monitor the temperature of fruit in a refrigeration unit and it also was online, rather than using RF.

Here is a Fritzing diagram describing how the temperature sensor is hooked up:

OneWire setup Arduino

And my code (simply) is like below. You can check out the sub project as well but that has other stuff in it like hosting it's own web site and displaying on a Nokia 5110 screen.

#include <OneWire.h> 

int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2

//Temperature chip i/o
OneWire ds(DS18S20_Pin); // on digital pin 2

void setup(void) {

void loop(void) {
 float temperature = getTemp();

 delay(100); //just here to slow down the output so it is easier to read


float getTemp(){
 //returns the temperature from one DS18S20 in DEG Celsius

 byte data[12];
 byte addr[8];

 if ( !ds.search(addr)) {
   //no more sensors on chain, reset search
   return -1000;

 if ( OneWire::crc8( addr, 7) != addr[7]) {
   Serial.println("CRC is not valid!");
   return -1000;

 if ( addr[0] != 0x10 && addr[0] != 0x28) {
   Serial.print("Device is not recognized");
   return -1000;

 ds.write(0x44,1); // start conversion, with parasite power on at the end

 byte present = ds.reset();
 ds.write(0xBE); // Read Scratchpad

 for (int i = 0; i < 9; i++) { // we need 9 bytes
  data[i] = ds.read();


 byte MSB = data[1];
 byte LSB = data[0];

 float tempRead = ((MSB << 8) | LSB); //using two's compliment
 float TemperatureSum = tempRead / 16;

 return TemperatureSum;

What you could do is set up your PI as a little WiFi server for the devices to connect to and then let them send the data to the Pi for collection, and the Pi can upload it somewhere else.

The problem with RF is it's going to be line of sight, and very unreliable. WiFi would be a way better way to go in my opinion. Or better yet if you just need one sensor wire the sensor straight to the Pi and upload via WiFi.

Lessons learned:

  1. This kind of data is heavy. You better be able to store a LOT of information
  2. Perhaps work with averages over some shorter time rather than a single value. I use an average over 5 minutes, so if my sensor is initialising, I don't trust the -1000Âșc that it sends me. Averages are better anyway, especially if you are going to be raising alarms and get people up late at night.
  3. Do what you need for the project. Over engineering and hard policy decisions will ultimately hurt you (e.g. we MUST use RF, or we MUST use Arduino's / ESP8266 boards) because if you can't adapt to the problem, you'll try hacking too much and end up with a mess.
  4. Tackle one problem at a time. Get the sensor data, then work on comms, etc. etc.
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.