0
$\begingroup$

I am trying to set up a Bluetooth communication between two pi pico devices using HC05s. I am trying to make the two HC05s connect and I read that you need to set up Master/Slave configurations using AT commands. I currently have only connected one HC05 to pico and that HC05 is blinking once every two seconds (How it's supposed to for AT commands I believe). TX is connected to GP1 and RX to GP0.

I also tried running the code with 9600 and 38400 baud rates. None seem to work. When I type AT I expected to see the following output: AT reading data 'AT' response: OK

But I only received AT

Here is the code that I am using (From the internet):

from machine import UART, Pin 
from time import sleep

import uos

id = 0
rx = Pin(1)
tx = Pin(0)
baudrate=38400 # default is 9600


uart = UART(0,baudrate=baudrate, tx=tx, rx=rx)

print("PicoTerm")
print(uos.uname())
print("type 'quit' to exit, or help for commands")

command = "AT"
while True and command !='quit':
    
    command = input("PicoTerm>")
    
    if command != 'quit':
        uart.write(command)
        print(command)
        sleep(0.1)
        response = bytes()
            
        if uart.any() > 0:
            response = uart.readline()
            print("reading data")
            print(response)
            print("check")
        # output = "".join(["'",str(command),"'","response:",str(response.decode('utf-8'))])
        try:
            print(str(response.decode('utf-8')))
        except:
            print("weird response")
        
    elif command == 'quit':
        print("-"*50)
        print('Bye.')

The output that I get is this:

PicoTerm
(sysname='rp2', nodename='rp2', release='1.19.1', version='v1.19.1 on 2022-06-18 (GNU 11.2.0 MinSizeRel)', machine='Raspberry Pi Pico with RP2040')
type 'quit' to exit, or help for commands
PicoTerm>AT    

and the output after my input is just whatever I say back. AT

$\endgroup$
7
  • $\begingroup$ Welcome to Robotics, kak_taki. You seem to be asking how to set up Master/Slave configurations using AT commands, but you haven't given us any information about the commands you're using. You seem to be saying the output after my input is just whatever I say back, but that's also what your code is set to do: print(command). Please edit your question to clarify if this code is running on one or both devices, what commands you're sending to each, the status of your HC05 STATE pin (which indicates a connection), how everything is wired, how you changed the baud rate, etc. $\endgroup$
    – Chuck
    Commented Nov 28, 2022 at 20:18
  • $\begingroup$ Thank you so much for the input. I edited the post. I would like to change the state of HC05 and get the Bluetooth address of one HC05 (make is a slave) and use another HC05 to connect to the previous HC05 using the Bluetooth address that I already have. To get the addresses I was planning on using AT commands. Like I get the address of one HC05 and make it a slave, and using that address I will connect it to another HC05 by making it a master and looking to connect to that Bluetooth address and therefore pairing two HC05s $\endgroup$
    – kak_taki
    Commented Nov 28, 2022 at 22:24
  • $\begingroup$ Right off, looks like your RX/TX pins are swapped. Try switching them and putting it back to the 9600 baud setting. $\endgroup$
    – Chuck
    Commented Nov 29, 2022 at 0:21
  • $\begingroup$ Thank you for noticing. I did not realize that I was following the wrong diagram. I switched the wires and changed the baud rate but still this is what I am getting PicoTerm (sysname='rp2', nodename='rp2', release='1.19.1', version='v1.19.1 on 2022-06-18 (GNU 11.2.0 MinSizeRel)', machine='Raspberry Pi Pico with RP2040') type 'quit' to exit, or help for commands PicoTerm>AT AT reading data b'\x00' check PicoTerm>AT AT PicoTerm>AT AT $\endgroup$
    – kak_taki
    Commented Nov 29, 2022 at 1:36
  • $\begingroup$ Looks like there is at least SOME response now, b'\x00' is new, right? Do you have a link to the datasheet? I don't know what sequence you're supposed to send it. Also, for troubleshooting purposes, once you think you've got a module setup as a master, try connecting to it with your phone or some other known-working Bluetooth device. Then you're at least not trying to troubleshoot two devices at the same time. Once you can connect and see the default pairing PIN then you can try to work on the other unit. $\endgroup$
    – Chuck
    Commented Nov 29, 2022 at 3:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.