I write MicroPython code for my Raspberry Pi Pico. I faced the problem with converting bytes to the string. I receive the following data from the GPS module:
b'x07xe8x05x1ft"r,x19x00!0Ex19;x01}xf6Nx10x00jx14x00x00x00x01M_x00
x039x00x03x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00'
It has to be convertible into ascii or unicode, but it doesn’t seem to work.
The data should contain NMEA string and the garbage bytes have to be OA
This is my code:
from machine import Pin, I2C
def main() -> None:
i2c_gps = I2C(0, scl=Pin(21), sda=Pin(20), freq=400000)
print(i2c_gps.scan()[0])
print(i2c_gps.readfrom(32, 50))
if __name__ == "__main__":
main()
The hardware is: Pico W, GNSS
This is the example of how it should actually look like
I tried following the official documentation to decode the I2C package in a proper way, DOCUMENTATION, but i couldn’t find anything to help me with that. All the other resources on the internet are related to either RPI 3 or 4 or to the UART standart. Github didn’t contain the library as well. I’m new to embedded programming, I had electronics classes at my college but nobody taught us to work with I2C or any other protocol. Any help would be much appreciated.
InWamos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.