Hello, I have been working in a project where I transmit data with HC-12 to a base station with HC-12 receiver. I was able to get the data, but I also want to display this data to an android phone. I am thinking of using an HC-05 bluetooth module. Do you think this would work? Btw I am using the Software Serial Library.Thanks!
Yes! The setup will work!
GolamMostafa:
Yes! The setup will work!
Would still this work with different baud rates? for hc-12 I m using 9600 while 38400 for the hc-05 as default. attached here is the code. However, I wasn't able to print out the data in the serial monitor and no data was sent by the bluetooth. but when I comment the line BTSerial.begin(38400) it prints out the receiving data. attached here is my code. Thanks.
receive-send.ino (2.89 KB)
Read the how to use this forum stickies to post your code in the proper manner, clicking code tags </>. You will have to use a separate serial port for the HC-05. The default communications speed of HC-05 is 9600.
@OP
Make simple test as per following steps and then add your ideas/complexities.
1. UNO with H12 via Software Serial Port (SUART Port); UNO-SM (Serial Monitor) via UART Port; UNO and NANO via HC12 + HC12.
2. NANO with H12 via SUART Port; NANO-SM via UART Port; NANO with Android via SUART based HC05.
Codes for UNO: (untested)
#include<SoftwareSerial.h>
SoftwareSerial SUART(10, 11); //SRX = DPin-10. STX = DPin-11
void setup()
{
Serial.begin(9600);
SUART.begin(9600)
}
void loop()
{
SUART.print('A')
delay(1000); //
}
Codes for NANO: (untested)
#include<SoftwareSerial.h>
SoftwareSerial SUARTHC12(10, 11);
SoftwareSerial SUARTHC5(4, 5);
void setup()
{
Serial.begin(9600);
SUARTHC12.begin(9600);
SUARTHC5.begin(9600);
}
void loop()
{
bytr n = SUARTHC12.available();
if(n !=0)
{
byte x = SUARTHC12.read(); //read from HC12
Serial.write(x); //check tha A has appeared on SM
SUARTHC5.write(x); //check that A has appeared on the screen of Android Phone
}
}
3. Upload the above sketches into UNO and NANO and check that the results above appeared as expected.
Please, post the results.
BTW; Connevt STX-pin of NANO with RX-pin Bluetooth using a voltage divider. RX-pin of BT is not 5V tolerant.