0

I am trying to set up 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. (Get the Bluetooth address from one HC05 using AT command and connect the other HC05 to the first HC05 given that address). 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

# uos provides information such as the machine name and build version numbers
import uos

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

# create the UART
uart = UART(0,baudrate=baudrate, tx=tx, rx=rx)

print("PicoTerm")
print(uos.uname())
print("type 'quit' to exit, or help for commands")
# Loop
command = "AT"
while True and command !='quit':
    # Write our command prompt
    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.')


I ran the code and typed AT and it just said AT back to me, even though it should have said OK. Also, when I type AT+UART? commands it just says them back as well. Not sure what the issue is

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
kak_taki
  • 19
  • 2
  • 1
    According to the following article, https://www.instructables.com/AT-command-mode-of-HC-05-Bluetooth-module/ HC-05 needs a pin tied high to enter AT mode. While the HC-06 is in AT mode when it is not connected.Are you selecting AT mode? – ukBaz Nov 29 '22 at 06:51
  • Oh, I have not wired anything to the enable pin, that might be the issue. Do you know how I can adjust the code to set the enable pin to high? Sorry I am new to this – kak_taki Nov 29 '22 at 07:54
  • 1
    According to the following article http://helloraspberrypi.blogspot.com/2021/02/raspberry-pi-picomicropython-pair-hc-05.html there is a tiny button on the HC-05 that you need to press & hold while powering on to enter AT mode. There are many different variants of the HC-05 so it is difficult to help without knowing more about your specific module. – ukBaz Nov 29 '22 at 09:46
  • The structure needs some improvement. You MUST properly [**read** and **parse**](https://stackoverflow.com/a/46064206/23118) the response the modem gives back and react to the *Final response code*. – hlovdal Dec 02 '22 at 23:16

0 Answers0