You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
724 B
Python

4 years ago
"""
This modul implements a simple serial connection to the ZS-040 and will echo out to the console
any messages it receives. This board is a Bluetooth SPP (Serial Port Protocol) module.
When powered on the device will broadcast as BT-05 by default. Default passwords are usually 1234 or 0000.
"""
from machine import Pin, UART
from utime import sleep_ms
BT_STATE_PIN = Pin(5, Pin.IN)
uart = UART(2, baudrate=38400, tx=17, rx=16, bits=8, stop=1, parity=None)
while True:
if BT_STATE_PIN.value():
if uart.any():
data = uart.read(1)
print(data.decode('utf8'))
else:
print("No data. Sleeping")
else:
print("No Bluetooth device paired.")
sleep_ms(500)