CHEERSNetworkClimate & health

Home / Resources / Weather station

CHEERS technical resources · WindChaser

Source code for wind_bearer_software.sensor_func.as5600

WindChaser technical documentation: Source code for wind_bearer_software.sensor_func.as5600. Original instructions, component references and source limitations.

Original documentation: Min Tai Yap and Julian Walker · © 2025. Migrated to CHEERS on 3 December 2026. This is working documentation; unresolved source gaps remain visible.

Software source reference
"""
Contains a helper function for reading data from the AS5600 sensor.

Authors: Min Tai Yap
"""


import smbus2
import time
import asyncio


[docs] async def as5600_read(bus): """ Reads the raw wind direction angle from the AS5600 sensor. By default, the IC2 address of the AS5600 sensor in use is 0x36. :param bus: An smbus2.SMBus object to communicate on the I2C bus :returns: The raw wind direction read from the AS5600 sensor upon successful reading, otherwise -1 """ # AS5600 I2C address AS5600_address = 0x36 # Register addresses of AS5600 rah = 0x0C # raw angle high ral = 0x0D # raw angle low try: # Read raw angle data from the sensor raw_angle_high = bus.read_byte_data(AS5600_address, rah) raw_angle_low = bus.read_byte_data(AS5600_address, ral) # Combine high and low bytes to get the 12-bit raw angle raw_angle = (raw_angle_high << 8) | raw_angle_low # Convert raw angle to degrees (0-360) angle_degrees = (raw_angle / 4096) * 360 except Exception as e: print(f"I2C device of AS5600 not found: {e}") angle_degrees = -1 return angle_degrees