I am currently undertaking a project where I am attempting to build a bluetooth thermometer using an arduino. I have the temperature sensor working and returning temperature readings via a usb connection to the serial monitor in the Arduino IDE using the following code.
#include <OneWire.h>
#include <DallasTemperature.h>
#include "Timer.h"
Timer t;
// Data wire is plugged into pin 10 on the Arduino
#define ONE_WIRE_BUS 10
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer = { 0x28, 0x94, 0xE2, 0xDF, 0x02, 0x00, 0x00, 0xFE };
void setup(void)
{
// start serial port
Serial.begin(9600);
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(insideThermometer, 10);
int tickEvent = t.every(3000,doTempReading);
}
void loop()
{
t.update();
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
Serial.print("Error getting temperature");
} else {
Serial.print("C: ");
Serial.print(tempC);
}
}
void doTempReading()
{
delay(2000);
Serial.print("Getting temperatures...\n\r");
sensors.requestTemperatures();
Serial.print("Inside temperature is: ");
printTemperature(insideThermometer);
Serial.print("\n\r");
}
I now want to try and transmit the readings via a bluetooth connection using the HC 05 module to a raspberry pi which will record the data.
I have done a lot of research and tried several different techniques and can't understand how to go about it.
What mode does the HC 05 need to be in? (Command AT/slave/data/etc.) How should it be wired (I have found several different methods using various resistors and capacitors and unsure which to follow). How should I pair it with the Raspberry pi?
Thanks in advance for any help.