I'm trying to use a HC-06 Bluetooth module with an UNO to send a number on my phone to set a target temperature on the UNO whilst also monitoring the temperature measured by the UNO. I have encountered problems receiving the data from my phone.
I have used some code (below) to strip the communications back to basic, but I still can't receive any data, however the sending of the data from the serial port to the phone works fine. I'm using a Serial Bluetooth app on my phone at the moment. I have also got a 3.3-->5V logic level shifter which both the Tx and Rx lines go through to make them the correct level.
I have tried using different pins for the Bluetooth software serial, and also tried using the hardware serial (with different code) but no success. I've also tried using different pins on the bi-directional logic level shifter.
Any insight into why it isn't working would be greatly appreciated, thanks
#include <SoftwareSerial.h>
#define rxPin 2 // define SoftwareSerial rx data pin
#define txPin 3 // define SoftwareSerial tx data pin
SoftwareSerial blueTooth(rxPin, txPin); // create instance of SoftwareSerial
void setup()
{
Serial.begin(9600); // Start hardware Serial
blueTooth.begin(9600); // Start SoftwareSerial
}
void loop()
{
char c;
if (Serial.available())
{
c = Serial.read();
Serial.print(c); // Write the character to the Serial Monitor
blueTooth.write (c); // Write the character to Bluetooth
}
if (blueTooth.available())
{
c = blueTooth.read();
Serial.print(c); // Write the character to the Serial Monitor
blueTooth.write (c); // Write the character to Bluetooth
}
}
I should also point out this code isn't mine, but from Neil Kenyon's blog