Angled top view of the pre-soldered AS5600 rotary encoder board

AS5600 Pre-Soldered Magnetic Rotary Encoder Module | ShillehTek Product Manual

ArduinoESP32Raspberry PiPicomanual-product-10645386002719
$5.99 USD Only 2 left · Order by 3pm ET, ships today

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

Sensor
AS5600 Hall-effect encoder
Resolution
12-bit · 4096 steps per turn
Interface
I2C, address 0x36
Supply
3.3 V (3.0 – 3.6 V)
Extra Output
Analog or PWM on OUT
Magnet
Diametric, 0.5 – 3 mm gap

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.

AS5600 magnetic rotary encoder module pinout diagram showing VCC, OUT, GND, DIR, SCL, SDA and GPO pins

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
3.3 V only: Do not connect VCC to 5V. This board is configured for 3.3 V operation, where the chip's limit is 4.0 V, so 5 V on VCC can damage it.
Converter: LV goes to 3.3V, HV to 5V and GND to GND. The sensor's SDA and SCL go on the LV side, and A4 and A5 go on the matching HV pins.

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
Direct wiring: The ESP32 uses 3.3 V logic, so no level converter is needed. Power the module from the 3V3 pin, never from VIN or 5V.

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
Enable I2C: Run sudo raspi-config, open Interface Options and turn on I2C. Then i2cdetect -y 1 should show the sensor as 36.

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
Magnet check: The example prints a warning at start-up if the magnet is missing, too weak or too strong. Adjust the gap until the warnings stop.

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_angle.ino
// 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

as5600_angle.py
#!/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_pico.py
# 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)

Frequently Asked Questions

What kind of magnet do I need, and how far away should it be?
A diametrically magnetized one: its north and south poles sit on opposite halves of the round face, not on the two flat faces. A 6 mm disc is the size the chip's datasheet uses as its reference. Center it over the chip and keep the gap small. The chip is specified for roughly 0.5 to 3 mm, and 1 to 2 mm works well. An ordinary axially magnetized magnet will not give a usable angle.
Why does the example say no magnet detected?
The status register reports three things: magnet detected, magnet too weak and magnet too strong. Not detected or too weak means the magnet is too far away, off-center or the wrong type (axial instead of diametric), so move it closer and re-center it. Too strong means it is too close, so add a little gap. Restart the example after each change, because it checks the magnet only once at start-up.
Why is my angle jumping around or counting backward?
A floating DIR pin is the usual cause of unstable readings, so always tie DIR to GND or VCC. With DIR on GND the value increases when the magnet turns clockwise, seen from above the chip. With DIR on VCC it increases the other way. Jitter of a step or two is normal. Larger noise usually means the magnet is off-center or too far away.
Can I use it with a 5 V Arduino?
Yes, with two precautions. Power the module from the Arduino's 3.3V pin, and put a bidirectional logic level converter on SDA and SCL, as shown in the Arduino tab. Do not feed 5 V into VCC, because this board is configured for 3.3 V.
Can I connect two AS5600 sensors to one microcontroller?
Not on the same I2C bus, because the address is fixed at 0x36 and cannot be changed. Use a second I2C bus (the ESP32 and Pico both have two), put the sensors behind an I2C multiplexer such as the TCA9548A, or read one of them through its analog OUT pin.
How do I count full turns?
The AS5600 reports the position within one turn (0 to 4095) and keeps no turn counter. Track turns in your code: when the value jumps from near 4095 to near 0, add one turn, and when it jumps the other way, subtract one. Read the sensor often enough that the shaft moves less than half a turn between readings.
What are the OUT and GPO pins for?
By default OUT repeats the angle as an analog voltage between 0 V and VCC, and the chip's configuration register can switch it to PWM. That is handy when you only have an analog input free. GPO is the chip's programming-option pin and stays unconnected in normal use. Some boards of this style pull GPO low through a resistor, and connecting GPO to VCC is the commonly reported fix if OUT stays flat. Avoid the chip's BURN commands unless you mean it, because they store settings permanently.

Related Tutorials

Datasheets & downloads

Reference documents for the AS5600 Pre-Soldered Magnetic Rotary Encoder Module. This manual covers wiring and code; the documents below carry the full electrical specifications.