Created
December 21, 2021 16:30
-
-
Save HourGlss/c2a16ea967572234ae9625890e9ec9ea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import serial | |
ser = serial.Serial ("COM4", 115200) | |
ser.write("AT\r\n".encode('ascii')) | |
response = ser.readline() | |
# print(response) | |
ser.write("AT+ADDRESS=4\r\n".encode('ascii')) | |
response = ser.readline() | |
# print(response) | |
while True: | |
data = None | |
response = ser.readline() | |
# print(response) | |
try: | |
data = response.decode().replace("\r\n","") | |
except: | |
continue | |
if data is not None: | |
# print(data) | |
if "+RCV" in data: | |
addr, length, actual_data, rssi, sig_noise_ratio = data.split(',') | |
# print(f"addr {addr}") | |
# print(f"length {length}") | |
print(f"acc data {actual_data}") | |
# print(f"rssi {rssi}") | |
# print(f"from field {sig_noise_ratio}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment