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
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 sayingthe 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 HC05STATE
pin (which indicates a connection), how everything is wired, how you changed the baud rate, etc. $\endgroup$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$