Probing H-RTK GPS
Note
For cabling connection:

Checking GPS stream in Serial
import serial
import time
port_name = '/dev/ttyTHS1'
baud_rates = [9600, 38400, 57600, 115200, 230400, 460800]
print(f"Scanning {port_name}...")
for baud in baud_rates:
print(f"\n--- Testing Baud Rate: {baud} ---")
try:
with serial.Serial(port_name, baud, timeout=2) as ser:
# Clear buffer
ser.reset_input_buffer()
# Read a chunk of data
data = ser.read(100)
if not data:
print("No data received.")
continue
# Check for NMEA (starts with $)
try:
text_data = data.decode('ascii', errors='ignore')
if '$G' in text_data:
print(f"SUCCESS! Found NMEA data at {baud}.")
print(f"Sample: {text_data[:50]}")
break
except:
pass
# Check for UBX (starts with 0xB5 0x62)
if b'\xb5\x62' in data:
print(f"SUCCESS! Found UBX Binary data at {baud}.")
print("This is binary data (not human readable text).")
print(f"Hex sample: {data[:20].hex()}")
break
print(f"Data received but unrecognized (likely wrong baud): {data[:20]}")
except Exception as e:
print(f"Error opening port: {e}")
Checking Magnetometer stream in I2C
import smbus
import time
# Configuration
BUS_NUM = 7 # The bus you found with i2cdetect
DEVICE_ADDR = 0x0E # The address of the IST8310
REG_CNTL1 = 0x0A # Control Register 1
REG_DATA = 0x03 # Starting Data Register (X_Low)
MODE_SINGLE = 0x01 # Value to trigger a single measurement
def read_magnetometer():
try:
bus = smbus.SMBus(BUS_NUM)
print(f"Reading IST8310 on Bus {BUS_NUM}...")
while True:
# 1. Trigger a single measurement
# IST8310 often needs to be "poked" for every reading
bus.write_byte_data(DEVICE_ADDR, REG_CNTL1, MODE_SINGLE)
# 2. Wait for measurement (approx 6ms usually sufficient)
time.sleep(0.02)
# 3. Read 6 bytes of data: X_L, X_H, Y_L, Y_H, Z_L, Z_H
data = bus.read_i2c_block_data(DEVICE_ADDR, REG_DATA, 6)
# 4. Convert 2's Complement (combining Low and High bytes)
x = data[1] * 256 + data[0]
if x >= 32768: x -= 65536
y = data[3] * 256 + data[2]
if y >= 32768: y -= 65536
z = data[5] * 256 + data[4]
if z >= 32768: z -= 65536
# Print raw values (roughly corresponds to microTesla uT)
print(f"Mag Raw: X={x:5d} Y={y:5d} Z={z:5d}")
time.sleep(0.1)
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
read_magnetometer()