Overview
The AS5600 is a contactless magnetic rotary position sensor. A Hall-effect chip reads the direction of a small magnet's field and turns it into a 12-bit angle: 4096 steps per turn, about 0.088° each. Fix a diametrically magnetized magnet to the end of a shaft, hold it a millimeter or two above the chip, and you get the absolute angle with no brushes, contacts or optical disk to wear out or get dirty.
This pre-soldered module has two header strips: VCC, OUT and GND on one side, and DIR, SCL, SDA and GPO on the other. The angle is read over I2C at the fixed address 0x36, and the OUT pin repeats it as an analog voltage or PWM signal. The board is set up for 3.3 V power and 3.3 V logic, so it connects directly to an ESP32, Raspberry Pi or Pico. A 5 V Arduino powers it from its 3.3V pin and uses a level converter on the I2C lines.
Typical uses are closed-loop feedback on stepper and gimbal motors, endless knobs and dials, robot joint angles, wind vanes, and replacing worn potentiometers. This manual covers the pinout, wiring for Arduino, ESP32, Raspberry Pi and Pico, working code for each, and answers on magnets, direction and the usual "no magnet detected" problems.
At a Glance
Specifications
| Parameter | Value |
| Sensor IC | ams AS5600 contactless Hall-effect position sensor |
| Resolution | 12-bit: 4096 positions per turn (0.088° per step) |
| Measuring range | 0 – 360°, absolute (no homing needed) |
| Interface | I2C, fixed address 0x36, up to 1 MHz |
| OUT pin | Analog voltage (ratiometric to VCC) or PWM |
| Supply and logic | 3.3 V (3.0 – 3.6 V) as built. Not for 5 V. |
| Supply current | About 6.5 mA in normal mode |
| Direction (DIR) | GND: clockwise counts up · VCC: reversed |
| Magnet | Diametrically magnetized, centered, 0.5 – 3 mm above the chip |
| Temperature | -40 to +125 °C (chip rating) |
| Board size | About 23 × 23 mm, four mounting holes |
| Headers | 3-pin (VCC, OUT, GND) and 4-pin (DIR, SCL, SDA, GPO) |
Pinout Diagram
The board has two header strips. The 3-pin side carries VCC (3.3 V power), OUT (the angle as an analog voltage or PWM signal) and GND. The 4-pin side carries DIR (rotation direction: tie it to GND or VCC and never leave it floating), SCL and SDA (I2C), and GPO (the chip's programming-option pin, left unconnected in normal use). The AS5600 chip sits in the center of the board, and the magnet goes directly above it.
Wiring Guide
Mount the magnet first: centered over the chip and 1 – 2 mm above it. Every setup below reads the angle over I2C and ties DIR to GND so the value counts up when the magnet turns clockwise. OUT and GPO stay unconnected.
Arduino Uno / Nano Wiring
This module runs on 3.3 V and an Uno or Nano uses 5 V logic, so power it from the 3.3V pin and put a bidirectional logic level converter on SDA and SCL.
| AS5600 Pin | Arduino Uno / Nano |
|---|---|
| VCC | 3.3V pin |
| GND | GND |
| SDA | A4, through the level converter |
| SCL | A5, through the level converter |
| DIR | GND |
ESP32 Wiring
| AS5600 Pin | ESP32 Pin | Notes |
|---|---|---|
| VCC | 3V3 | Power |
| GND | GND | Ground |
| SDA | GPIO 21 | I2C data |
| SCL | GPIO 22 | I2C clock |
| DIR | GND | Direction |
Raspberry Pi Wiring
| AS5600 Pin | Raspberry Pi Pin | Notes |
|---|---|---|
| VCC | 3.3V (Pin 1) | Power |
| GND | GND (Pin 6) | Ground |
| SDA | GPIO 2 (Pin 3) | I2C data |
| SCL | GPIO 3 (Pin 5) | I2C clock |
| DIR | GND (Pin 9) | Direction |
Raspberry Pi Pico Wiring
| AS5600 Pin | Pico Pin | Notes |
|---|---|---|
| VCC | 3V3(OUT) (Pin 36) | Power |
| GND | GND (Pin 38) | Ground |
| SDA | GP4 (Pin 6) | I2C0 data |
| SCL | GP5 (Pin 7) | I2C0 clock |
| DIR | GND (Pin 3) | Direction |
Code Examples
View or download this product's example code on GitHub.
Each example reads the chip's status register once to check the magnet, then prints the raw 12-bit value and the angle in degrees ten times a second. No library is needed on any platform.
Arduino and ESP32 — Read the Angle (No Library)
// AS5600 magnetic encoder - read the angle over I2C (no library needed)
// Uno/Nano: SDA = A4, SCL = A5 through a 3.3 V level converter, VCC = 3.3V
// ESP32: SDA = GPIO 21, SCL = GPIO 22, VCC = 3V3 (direct)
#include <Wire.h>
const uint8_t AS5600_ADDR = 0x36;
const uint8_t REG_STATUS = 0x0B; // bit 5 = magnet detected, bit 4 = too weak, bit 3 = too strong
const uint8_t REG_RAW_ANGLE = 0x0C; // 12-bit raw angle, high byte first
// Reads 1 or 2 bytes starting at reg. Returns -1 if the sensor does not answer.
int readRegister(uint8_t reg, uint8_t count) {
Wire.beginTransmission(AS5600_ADDR);
Wire.write(reg);
if (Wire.endTransmission(false) != 0) return -1;
Wire.requestFrom((int)AS5600_ADDR, (int)count);
if (Wire.available() < count) return -1;
int value = 0;
for (uint8_t i = 0; i < count; i++) {
value = (value << 8) | Wire.read();
}
return value;
}
void setup() {
Serial.begin(115200);
Wire.begin();
delay(100);
int status = readRegister(REG_STATUS, 1);
if (status < 0) {
Serial.println("AS5600 not found - check wiring and 3.3 V power");
while (true) { delay(1000); }
}
if (!(status & 0x20)) Serial.println("No magnet detected - center it over the chip");
if (status & 0x10) Serial.println("Magnet too weak - move it closer");
if (status & 0x08) Serial.println("Magnet too strong - move it away");
}
void loop() {
int raw = readRegister(REG_RAW_ANGLE, 2);
if (raw >= 0) {
raw &= 0x0FFF; // keep the 12 valid bits
float degrees = raw * 360.0 / 4096.0; // 4096 steps per turn
Serial.print("Raw: ");
Serial.print(raw);
Serial.print(" Angle: ");
Serial.print(degrees, 1);
Serial.println(" deg");
}
delay(100);
}
Raspberry Pi — Python
#!/usr/bin/env python3
# AS5600 magnetic encoder on Raspberry Pi (I2C bus 1)
# Install once: sudo apt install python3-smbus2 (enable I2C in raspi-config)
import time
from smbus2 import SMBus
AS5600_ADDR = 0x36
REG_STATUS = 0x0B # bit 5 = magnet detected, bit 4 = too weak, bit 3 = too strong
REG_RAW_ANGLE = 0x0C # two bytes, high byte first
with SMBus(1) as bus:
status = bus.read_byte_data(AS5600_ADDR, REG_STATUS)
if not status & 0x20:
print("No magnet detected - center it over the chip")
if status & 0x10:
print("Magnet too weak - move it closer")
if status & 0x08:
print("Magnet too strong - move it away")
while True:
high, low = bus.read_i2c_block_data(AS5600_ADDR, REG_RAW_ANGLE, 2)
raw = ((high << 8) | low) & 0x0FFF # 12-bit value, 0-4095
degrees = raw * 360.0 / 4096.0
print(f"Raw: {raw:4d} Angle: {degrees:6.1f} deg")
time.sleep(0.1)
Raspberry Pi Pico — MicroPython
# AS5600 magnetic encoder on Raspberry Pi Pico (MicroPython)
# SDA = GP4 (pin 6), SCL = GP5 (pin 7), VCC = 3V3(OUT), DIR = GND
from machine import I2C, Pin
import time
AS5600_ADDR = 0x36
REG_STATUS = 0x0B # bit 5 = magnet detected, bit 4 = too weak, bit 3 = too strong
REG_RAW_ANGLE = 0x0C # two bytes, high byte first
i2c = I2C(0, sda=Pin(4), scl=Pin(5), freq=400000)
print("I2C scan:", [hex(a) for a in i2c.scan()]) # expect 0x36
status = i2c.readfrom_mem(AS5600_ADDR, REG_STATUS, 1)[0]
if not status & 0x20:
print("No magnet detected - center it over the chip")
if status & 0x10:
print("Magnet too weak - move it closer")
if status & 0x08:
print("Magnet too strong - move it away")
while True:
data = i2c.readfrom_mem(AS5600_ADDR, REG_RAW_ANGLE, 2)
raw = ((data[0] << 8) | data[1]) & 0x0FFF # 12-bit value, 0-4095
degrees = raw * 360 / 4096
print("Raw:", raw, " Angle: {:.1f} deg".format(degrees))
time.sleep(0.1)



