This Arduino based temperature sensor measures the temperature via the DS18B20 integrated digital temperature sensor and makes it available via bluetooth. The temperature reading is then transmitted via the Arduino’s serial port (pin 0 and pin 1) to the bluetooth module. An assembled sensor is shown in figure 1 and the system block digram in figure 2, both below.
Figure 1: Bluetooth Temperature Sensor, Battery Powered
The DS18B20 digital temperature sensor is a three pin integrated sensor that provides its readings digitally via a one-wire interface. It has an accuracy of ±0.5°C in the measurement range -10°C to +85°C (14°F to +185°F) making it ideal for hobbyist and some industrial applications. The Arduino community already has libraries to interface with this sensor making it easier to integrate this sensor into projects.
Figure 2: Sensor Block Diagram
The bluetooth module acts as a transparent link and simply relays what is sent to its serial port to a paired bluetooth receiver.Default settings:
- Default pairing code: 1234
- Default baudrate: 9600
The bluetooth receiver can be a pc, laptop, table, smartphone, etc and the readings displayed via a standard bluetooth terminal app.
Figure 3: Example Bluetooth Receiver Software (Android App)
Arduino Code:
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
void setup(void)
{
// start serial port
Serial.begin(9600);
// Start up the library
sensors.begin();
}
void loop(void)
{
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.print("Temperature is: ");
Serial.print(sensors.getTempCByIndex(0));
Serial.println(" degrees Celsius ");
delay(1000);
}