tony1812
Posts: 354
Joined: Sat Jul 15, 2017 12:40 pm
Location: Boston MA.

HC-05 and Pi

Fri Oct 05, 2018 10:10 pm

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.

Andyroo
Posts: 4177
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: HC-05 and Pi

Fri Oct 05, 2018 10:39 pm

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.
Need Pi spray - these things are breeding in my house...

User avatar
Douglas6
Posts: 4739
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: HC-05 and Pi

Fri Oct 05, 2018 10:42 pm

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.

tony1812
Posts: 354
Joined: Sat Jul 15, 2017 12:40 pm
Location: Boston MA.

Re: HC-05 and Pi

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? 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.
Last edited by tony1812 on Fri Oct 05, 2018 11:13 pm, edited 1 time in total.

Andyroo
Posts: 4177
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: HC-05 and Pi

Fri Oct 05, 2018 11:12 pm

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.
Need Pi spray - these things are breeding in my house...

User avatar
Douglas6
Posts: 4739
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: HC-05 and Pi

Fri Oct 05, 2018 11:23 pm

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.

danjperron
Posts: 3391
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: HC-05 and Pi

Sat Oct 06, 2018 11:18 am

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

atulkatti
Posts: 37
Joined: Sat Oct 20, 2018 3:18 am

Re: HC-05 and Pi

Sat Oct 20, 2018 6:21 am

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

User avatar
Douglas6
Posts: 4739
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: HC-05 and Pi

Sat Oct 20, 2018 12:32 pm

Depending on the sensor, yes.

atulkatti
Posts: 37
Joined: Sat Oct 20, 2018 3:18 am

Re: HC-05 and Pi

Sun Oct 21, 2018 6:41 am

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 ?

User avatar
Douglas6
Posts: 4739
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: HC-05 and Pi

Sun Oct 21, 2018 11:45 am

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.

atulkatti
Posts: 37
Joined: Sat Oct 20, 2018 3:18 am

Re: HC-05 and Pi

Sun Oct 21, 2018 12:02 pm

Thanks

Return to “Beginners”