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