I'm working in project involving Arduino, Bluetooth and Android. My Arduino hardware will collect data from sensors and send them to an Android tablet via Bluetooth. My application on Android seems to work well when I tested it with BlueChat; it successfully receives data from BlueChat. Following is my code for my Arduino hardware. I'm quite sure I initiate HC-05 correctly. Can anyone look at my code and suggest whether it works if my idea is to collect reading from a temperature sensor at Analog pin 0, then transmit them to Digital pin 11, which is the Tx pin on Arduino connecting to Rx pin of Hc-05?
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);
int tempPin=0;
void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
}
void loop()
{
float reading = analogRead(tempPin); // reading on tempPin
float voltage = reading*5.0/1024.0; // the resolution of a pin is 10 bit,
float tempC = voltage/0.01; // 10mV = 1 Celcius
mySerial.write(tempC);
delay(3000);
}
I should mention that I power my Arduino Uno externally by an 9V battery.