Page 1 of 1

HC-05 and Pi

Posted: Fri Oct 05, 2018 10:10 pm
by tony1812
Hi, A year ago, I was able to get the Pi communicate with an arduino wirelessly through HC-05. But I totally forget how I did it.

I got into AT mode set the AT+ROLE = 1(master), but the pi won't detect it. However if I set AT+ROLE =0(slave) the pi detects it immediately. Shouldn't the HC-05 be set to master in order for the pi to communicate? Could it be something wrong with the HC-05? Thanks.

Re: HC-05 and Pi

Posted: Fri Oct 05, 2018 10:39 pm
by Andyroo
Going by this https://www.itead.cc/wiki/Serial_Port_B ... e)_:_HC-05 you need to change PIO11 so it’s low in master mode.
How to set the mode to server (master):

1. Connect PIO11 to high level.
2. Power on, module into command state.
3. Using baud rate 38400, sent the “AT+ROLE=1\r\n” to module, with “OK\r\n” means setting successes.
4. Connect the PIO11 to low level, repower the module, the module work as server (master).
I would ask if it matters? Thought the master / slave roll was primarily for pairing rather than functionality.

Note slave mode is default for this chip.

Re: HC-05 and Pi

Posted: Fri Oct 05, 2018 10:42 pm
by Douglas6
The master/slave relationship (or should it be 'parent/worker'? No, it should not) in serial communications only refers to connecting. The slave waits for a connection, the master initiates a connection. After that, the two are peers; either device can read or write. Bluetooth pairing is another topic altogether.

You' ll find it much easier to designate the HC-05 as a slave, and start the connection on the Pi-side. Your use-case may vary.

Re: HC-05 and Pi

Posted: Fri Oct 05, 2018 11:04 pm
by tony1812
Thank you all for the quick replies. :)
I don't recall I had to play with the PIO11 last time. Under AT+UART mine is 38400,1,0 should it be 38400,0,0? Also on the rx line of the JC-05. do I need a voltage divider? Some tutorial say yes but yet many don't and I don't recall I use it in the last time either.

Re: HC-05 and Pi

Posted: Fri Oct 05, 2018 11:12 pm
by Andyroo
tony1812 wrote:
Fri Oct 05, 2018 11:04 pm
Thank you all for the quick replies. :)
I don't recall I had to play with the PIO11 last time. Under AT+UART mine is 38400,1,0 should it be 38400,0,0?
Yes or no :lol: The default is one quoting the above pdf:
Default Baud rate: 38400, Data bits:8, Stop bit:1,Parity:No parity, Data control: has
BUT the AT+UART can set it to zero stop bits.

Re: HC-05 and Pi

Posted: Fri Oct 05, 2018 11:23 pm
by Douglas6
tony1812 wrote:
Fri Oct 05, 2018 11:04 pm
Also on the rx line of the JC-05. do I need a voltage divider? Some tutorial say yes but yet many don't and I don't recall I use it in the last time either.
Are you connecting an HC-05 to the Raspberry Pi? I think it depends on the carrier board. I seem to recall I got away without one, but I could be wrong, or lucky.
Better to have it and not need it. Or is it a 3v3 Arduino? Same applies.

Reason I ask is because you don't need an HC-05 on the Pi-side, you can use the built-in Bluetooth chip or a dongle, and rfcomm.

I've always used the factory settings on my HC-05s.

Re: HC-05 and Pi

Posted: Sat Oct 06, 2018 11:18 am
by danjperron
I do have some HC05/HC06 bluetooth device connected to my Raspberry Pi.

I'm using rfcomm to link them

/usr/bin/rfcomm bind /dev/rfcomm1 00:12:06:20:94:53

Please check rfcomm

Re: HC-05 and Pi

Posted: Sat Oct 20, 2018 6:21 am
by atulkatti
maybe a naive question......can i connect my sensor to HC-05 and then pair it with Pi 3B+so that i can wirellessly send sensor data to Pi and fromt here i can send that data to cloud via wifi or ethernet

Re: HC-05 and Pi

Posted: Sat Oct 20, 2018 12:32 pm
by Douglas6
Depending on the sensor, yes.

Re: HC-05 and Pi

Posted: Sun Oct 21, 2018 6:41 am
by atulkatti
hi could you please elaborate. i have a ADXL345 accelerometer and DTH sensor. Can i connect each of these to HC-05 and send data to pi via BLE ?

Re: HC-05 and Pi

Posted: Sun Oct 21, 2018 11:45 am
by Douglas6
Not directly, no. The HC-05 is a serial device. The sensors you mention have I2C or one-wire interfaces. So you would also need a microcontroller, say a small Arduino type, wirh a UART.

And the HC-05 uses classic Bluetooth, not BLE. You could use an HM-10 for BLE.

Re: HC-05 and Pi

Posted: Sun Oct 21, 2018 12:02 pm
by atulkatti
Thanks