Close

Testing the Bluetooth

A project log for The Squid! Open robotics control module.

The Squid! Open robotics control module. Bluetooth, I2C or Serial interfaced for easy Human to Machine or Machine to Machine interface.

dennisDennis 05/28/2018 at 15:210 Comments

Connecting a PIC to a Bluetooth module opens up a lot of possibilities for robotics. Here is the test setup for Squid. In an earlier post, I was using a 4Mhz crystal I switched to a 20Mhz for the PICs clock. In the image below, I’m using a JY-MCU Bluetooth module the HC-5 version. The Bluetooth module is connected to the PICs USART pins with two 10k ohm resistors to divide the PICs TX voltage from 5 volt to 2.5 volt. A safe level for the Bluetooth module while still a high enough voltage to be a logic level 1.

In “int main” I added the following two lines of code to test the Bluetooth connection.

Usart_write(“b”);

_delay_ms(1000);

This will transmit a “b” every second, and since the interrupt is enabled, any characters sent to the Squid will mirror back to the computer that is connected through Bluetooth to the PIC.

Next, we need to “pair” the Bluetooth to a computer. Power up the test setup, and on the computer, go to the Bluetooth devices. Highlight HC-05 and click “pair”.

Enter the passcode for the Bluetooth module in this case “1234” and click “NEXT”.

And we are connected.

Next, we need to find our COM port. Open Bluetooth devices and click “Bluetooth Settings” and “COM ports”. There will be two COM ports--an incoming and an outgoing.

I’m using Putty as a terminal, so the next step is to open Putty and click the serial radio button, enter the outgoing com port and BUAD rate (speed). 

If Putty fails to connect, try opening Putty and connecting to the incoming Com port then close Putty, open Putty again, and then try connecting to the outgoing COM port. I ran into this problem…I’m not sure why, but it worked.

Once connected, the below screen should appear. A “b” is being received every second, and every key I press is being mirrored back…SUCCESS!!!

Discussions