AS5600 Magnetic Position Encoder

SKU: SW2001-1
AS5600 magnetic position encoder module with pin header strip and round magnet
AS5600 module top view, VCC OUT GND and DIR SCL SDA GPO pin labels, 22.9 x 22.5 mm

AS5600 Magnetic Position Encoder

SKU: SW2001-1
Default
Regular price $8.99
/
  • Free shipping on all orders over $100
  • Secure payments
  • Low stock - 1 item left
  • Inventory on the way

Add $100.00 more for free shipping

Tax included. Shipping calculated at checkout.

You'll also need

The AS5600 magnetic position encoder module is a 12-bit sensor that measures the angle of a magnet turning above it, without touching it.

It reports 4096 positions per turn over I2C, and also as an analog voltage or a PWM signal. It suits knobs, dials and motor shafts, and works with Arduino, ESP32, Raspberry Pi Pico and other boards.

Chip
AS5600
Resolution
12-bit (4096 per turn)
Interface
I2C, address 0x36
Outputs
I2C, analog, PWM

Why choose it

  • No contact, no wear — the chip senses the magnet through air, so nothing rubs against the shaft.
  • Absolute angle — it reports the angle straight away at power-up, 0 to 4095 for one full turn.
  • Three ways to read it — I2C (address 0x36), an analog output, or a PWM output.

Specifications

Sensor
Sensor chip AS5600 (ams OSRAM) magnetic rotary position sensor
Resolution 12-bit (4096 positions per turn, 0.088° per step)
System accuracy (INL) ±1° (best-line fit, no zero programming)
Sampling rate 150 µs
Magnetic field at the chip 30 to 90 mT
Interface
I2C address 0x36 (7-bit, fixed)
I2C clock Up to 1 MHz
Analog output (OUT) Ratiometric, 0 to 100% of the supply voltage (default) or 10 to 90%
PWM output frequency 115, 230, 460 or 920 Hz (selectable)
Direction (DIR) GND: angle increases clockwise. VCC: increases counter-clockwise
Power
Chip supply, 3.3 V mode 3.0 to 3.6 V
Chip supply, 5 V mode 4.5 to 5.5 V
Supply current (typical) 6.5 mA
Physical
Module size 22.9 × 22.5 mm (from the product photo)
Weight 2.55 g with pins (from the product photo)
Operating temperature (chip) −40 °C to +125 °C

Compatibility

Platform Works Notes
Arduino UNO / Nano (5 V) ✓ Yes I2C on A4 (SDA) and A5 (SCL). The Tutorial below uses the UNO.
ESP32 / ESP8266 (3.3 V) ✓ Yes Power from 3V3. The Tutorial below uses an ESP32 with GPIO21 and GPIO22.
Raspberry Pi (Linux) ✓ Yes Any I2C bus works. The address is 0x36 and the registers are listed in the datasheet.
Software ✓ Yes Arduino IDE (Wire library) or MicroPython (machine.I2C). No extra library is needed for the Tutorial examples.

In the box

Included
  • 1 × AS5600 magnetic position encoder module
  • 1 × pin header strip
  • 1 × round magnet

Applications

  • A digital knob or dial that replaces a potentiometer
  • Shaft angle feedback for a motor or servo
  • Joint angle in a robot arm or gimbal

Tutorial

What you'll build: Read the angle of a turning magnet, in degrees, from 0 to 360, and print it on your computer twice a second. About 20 minutes.

Choose your board

Board Logic voltage Pins used Language Best for
Arduino UNO 5 V A4, A5 C++ (Arduino IDE) First-timers
ESP32 3.3 V GPIO21, GPIO22 C++ (Arduino IDE) Adding Wi-Fi or Bluetooth later

New to this? Start with the Arduino UNO.

How it works

The chip measures the direction of the magnetic field of a small magnet that sits just above it. When the magnet turns, the field turns with it, and the chip reports the angle as a number from 0 to 4095 (one full turn). Your board asks for that number over I2C.

  • GND is the return path for the current. Every GND in your wiring must be joined.
  • I2C (SDA + SCL) uses two wires: SDA carries the data and SCL is the clock. The AS5600 always answers at address 0x36.
  • DIR tells the chip which way is "up". Tied to GND, the angle increases when the magnet turns clockwise.

Place the magnet (all boards):

  1. Fix the module flat, with the chip facing the magnet.
  2. Put the round magnet on the end of a turning shaft or knob so that it spins around its own centre.
  3. Hold it about 0.5 to 3 mm from the chip, with the centre of the magnet directly over the centre of the chip. Do not let the magnet touch the module.
Arduino UNO Tutorial

You need: Arduino UNO R3, USB cable, 5 jumper wires.

Arduino UNO5 V logic5VA4 / SDAA5 / SCLGNDAS5600 moduleVCCSDASCLGNDDIROUT (not used)GPO (not used)5 VSDASCLGNDDIR to GND

■ Power ■ GND ■ SDA (data) ■ SCL (clock)

# Arduino UNO pin Module pin Wire Notes
1 5V VCC Red Power.
2 A4 (SDA) SDA Blue I2C data.
3 A5 (SCL) SCL Yellow I2C clock.
4 GND GND Black Return path for the current.
5 GND (same wire as above) DIR Black Fixes the direction: the angle increases clockwise when DIR is tied to GND.

Watch out: The UNO works at 5 V. The AS5600 chip has its own 3.3 V / 5 V supply modes, so check the supply note in Good to know before you connect VCC.

1
Install the Arduino IDE
Download and install the Arduino IDE, then plug the UNO into your computer with a USB data cable and choose Tools → Board → Arduino UNO and the correct port. If no port appears, try another cable and install the USB driver for your board.
2
Wire it up
Unplug the USB cable first. Join the five wires from the table above (OUT and GPO stay empty), then plug the USB cable in again. Check the pin labels printed on your board.
3
Check the I2C address
Upload the scanner below and open Tools → Serial Monitor at 115200 baud.
▸ Example 1 — I2C scanner
#include <Wire.h>

void setup()
{
  Wire.begin();
 
  Serial.begin(115200);
  Serial.println("\nI2C Scanner");
}
 
 
void loop()
{
  byte error, address;
  int nDevices;
 
  Serial.println("Scanning...");
 
  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Wire.endTransmission to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
 
    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");
 
      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknown error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");
 
  delay(5000);           // wait 5 seconds for next scan
}

✓ Check: The Serial Monitor shows I2C device found at address 0x36 ! and then done.

4
Place the magnet
Follow the magnet steps in How it works above, then upload the angle sketch below.
▸ Example 2 — read the angle
// Wiring: VCC->5V, GND->GND, SDA->A4, SCL->A5, DIR->GND
#include <Wire.h>

const uint8_t AS5600_ADDR = 0x36;   // fixed I2C address of the AS5600
const uint8_t REG_STATUS = 0x0B;    // magnet status
const uint8_t REG_RAW_ANGLE = 0x0C; // 12-bit angle, high byte first

bool readRegisters(uint8_t reg, uint8_t *buf, uint8_t len) {
  Wire.beginTransmission(AS5600_ADDR);
  Wire.write(reg);
  if (Wire.endTransmission(false) != 0) return false;           // no reply
  if ((int)Wire.requestFrom((int)AS5600_ADDR, (int)len) != (int)len) return false;
  for (uint8_t i = 0; i < len; i++) buf[i] = Wire.read();
  return true;
}

void setup() {
  Serial.begin(115200);              // you can change this
  Wire.begin();                      // A4 = SDA, A5 = SCL on the UNO
  uint8_t status;
  if (!readRegisters(REG_STATUS, &status, 1)) {
    Serial.println("AS5600 not found - check wiring");
    while (true) delay(1000);        // stop here
  }
  Serial.println("OK - epartners.co.nz test");
}

void loop() {
  uint8_t status;
  uint8_t data[2];
  if (readRegisters(REG_STATUS, &status, 1) && readRegisters(REG_RAW_ANGLE, data, 2)) {
    uint16_t raw = ((data[0] & 0x0F) << 8) | data[1];   // 0..4095
    float degrees = raw * 360.0 / 4096.0;
    Serial.print("Angle: ");
    Serial.print(degrees, 1);
    Serial.print(" deg (raw ");
    Serial.print(raw);
    Serial.print(") - ");
    if (status & 0x08) Serial.println("magnet too strong");      // MH bit
    else if (status & 0x10) Serial.println("magnet too weak");   // ML bit
    else if (status & 0x20) Serial.println("magnet OK");         // MD bit
    else Serial.println("no magnet detected");
  }
  delay(500);                        // you can change this
}

✓ Check: Serial Monitor (115200 baud) prints OK - epartners.co.nz test once, then a new line every half second, for example Angle: 123.4 deg (raw 1403) - magnet OK. Turn the magnet and the angle changes.

ESP32 Tutorial

You need: ESP32 DevKitC (ESP32-WROOM-32) board, USB cable, 5 jumper wires.

ESP32 DevKitC3.3 V logic3V3GPIO21 / SDAGPIO22 / SCLGNDAS5600 moduleVCCSDASCLGNDDIROUT (not used)GPO (not used)3.3 VSDASCLGNDDIR to GND

■ Power ■ GND ■ SDA (data) ■ SCL (clock)

# ESP32 pin Module pin Wire Notes
1 3V3 VCC Red Power. 3.3 V only.
2 GPIO21 (SDA) SDA Blue Default I2C data pin.
3 GPIO22 (SCL) SCL Yellow Default I2C clock pin.
4 GND GND Black Return path for the current.
5 GND (same wire as above) DIR Black Fixes the direction: the angle increases clockwise when DIR is tied to GND.

Watch out: ESP32 pins are 3.3 V only. Power the module from 3V3, never from 5V, and do not feed a 5 V signal into any GPIO.

1
Add the ESP32 boards to the Arduino IDE
Install the Arduino IDE. In File → Preferences, paste https://espressif.github.io/arduino-esp32/package_esp32_index.json into Additional boards manager URLs. Then open Tools → Board → Boards Manager, search for esp32 by Espressif Systems and click Install (official guide).
2
Select the board and port
Choose Tools → Board → esp32 → ESP32 Dev Module and the correct port. If no port appears, use a data USB cable and install the USB driver for your board.
3
Wire it up
Unplug the USB cable first. Join the five wires from the table above. Check the pin labels printed on your board.
4
Check the I2C address
Upload the scanner below (use the default pins above) and open the Serial Monitor at 115200 baud. If the upload fails, set Tools → Upload Speed to 115200 and upload again.
▸ Example 1 — I2C scanner
#include <Wire.h>

void setup()
{
  Wire.begin();
 
  Serial.begin(115200);
  Serial.println("\nI2C Scanner");
}
 
 
void loop()
{
  byte error, address;
  int nDevices;
 
  Serial.println("Scanning...");
 
  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Wire.endTransmission to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
 
    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");
 
      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknown error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");
 
  delay(5000);           // wait 5 seconds for next scan
}

✓ Check: The Serial Monitor shows I2C device found at address 0x36 ! and then done.

5
Place the magnet and upload the angle sketch
Follow the magnet steps in How it works above, then upload this sketch.
▸ Example 2 — read the angle
// Wiring: VCC->3V3, GND->GND, SDA->GPIO21, SCL->GPIO22, DIR->GND
#include <Wire.h>

const uint8_t AS5600_ADDR = 0x36;   // fixed I2C address of the AS5600
const uint8_t REG_STATUS = 0x0B;    // magnet status
const uint8_t REG_RAW_ANGLE = 0x0C; // 12-bit angle, high byte first

bool readRegisters(uint8_t reg, uint8_t *buf, uint8_t len) {
  Wire.beginTransmission(AS5600_ADDR);
  Wire.write(reg);
  if (Wire.endTransmission(false) != 0) return false;           // no reply
  if ((int)Wire.requestFrom((int)AS5600_ADDR, (int)len) != (int)len) return false;
  for (uint8_t i = 0; i < len; i++) buf[i] = Wire.read();
  return true;
}

void setup() {
  Serial.begin(115200);              // you can change this
  Wire.begin(21, 22);                // SDA = GPIO21, SCL = GPIO22
  uint8_t status;
  if (!readRegisters(REG_STATUS, &status, 1)) {
    Serial.println("AS5600 not found - check wiring");
    while (true) delay(1000);        // stop here
  }
  Serial.println("OK - epartners.co.nz test");
}

void loop() {
  uint8_t status;
  uint8_t data[2];
  if (readRegisters(REG_STATUS, &status, 1) && readRegisters(REG_RAW_ANGLE, data, 2)) {
    uint16_t raw = ((data[0] & 0x0F) << 8) | data[1];   // 0..4095
    float degrees = raw * 360.0 / 4096.0;
    Serial.print("Angle: ");
    Serial.print(degrees, 1);
    Serial.print(" deg (raw ");
    Serial.print(raw);
    Serial.print(") - ");
    if (status & 0x08) Serial.println("magnet too strong");      // MH bit
    else if (status & 0x10) Serial.println("magnet too weak");   // ML bit
    else if (status & 0x20) Serial.println("magnet OK");         // MD bit
    else Serial.println("no magnet detected");
  }
  delay(500);                        // you can change this
}

✓ Check: Serial Monitor (115200 baud) prints OK - epartners.co.nz test once, then a new line every half second, for example Angle: 123.4 deg (raw 1403) - magnet OK.

Troubleshooting

Board Problem Likely cause Fix
All Scanner finds no device SDA and SCL swapped, a loose wire, or the module is not powered Re-check the pin table, press every wire in firmly and keep the wires under about 20 cm. The address must be 0x36.
All Says "magnet too weak" or "no magnet detected" Magnet too far away, off-centre, or not over the chip Move the magnet closer, centred over the chip, with a gap of roughly 0.5 to 3 mm.
All Says "magnet too strong" Magnet too close to the chip Increase the gap a little until the message changes to "magnet OK".
All Angle barely changes when you turn the magnet Magnet is not diametrically magnetised or is not centred on the turning axis Turn the magnet around its own centre with the chip directly over that centre point.
All Angle jumps from about 359 to 0 This is normal The reading wraps around once per turn.
Arduino UNO No port in the Tools menu Charge-only USB cable, or USB driver missing Use a data USB cable and install the USB driver for your board.
ESP32 Stuck on "Connecting..." Board not in upload mode Hold the BOOT button until uploading starts.
ESP32 Upload fails or stops part-way Upload speed too high for the USB cable or USB chip Tools → Upload Speed → 115200, then upload again.

Try next: Make a digital knob that shows the angle on an OLED display, or try the AS5600 library by Rob Tillaart (GitHub) for helpers such as angle in degrees and magnet checks.

Spotted a problem in this tutorial? Email support@epartners.co.nz and we'll check it and update the tutorial.

Good to know
  • Keep the magnet centred over the chip and keep iron or other magnets away from it, because stray fields change the reading.
  • Power: the chip runs from 3.0 to 3.6 V (3.3 V mode) or 4.5 to 5.5 V (5 V mode). Use 3.3 V with the ESP32 and Pico, and 5 V with the Arduino UNO.
  • Leave the GPO pin unconnected. The chip can store its zero position and settings permanently, but the zero position can be written only 3 times and the settings only once, so you do not need to do this to use the module.

Video guide

Datasheet

Key figures from the manufacturer's datasheet for the AS5600, the magnetic angle sensor chip on this module.

AS5600 magnetic rotary position sensor chip
Resolution 12-bit (4096 positions per turn)
System INL (best-line fit) ±1°
RMS noise (1 sigma) 0.015° to 0.043°, depending on the slow-filter setting
Sampling rate 150 µs
Power-up time 10 ms
Supply, 3.3 V mode 3.0 to 3.6 V (VDD5V and VDD3V3 tied together)
Supply, 5 V mode 4.5 to 5.5 V on VDD5V
Supply current (NOM mode, typical) 6.5 mA
I2C address and clock 0x36 (7-bit), up to 1 MHz
PWM output frequency 115, 230, 460 or 920 Hz
Magnetic field Bz at the chip 30 to 90 mT
Operating temperature −40 °C to +125 °C
Package SOIC-8

Download the AS5600 datasheet (PDF)

▸ Preview the datasheet

If the preview does not load on your device, use the download link above.

Source: ams OSRAM, AS5600 datasheet, revision v1-06 (2018-06-20).

Resources

FAQ

▸ What kind of magnet do I need?

You need a round magnet that is magnetised across its diameter, so that one half is north and the other half is south. Sensor guides describe the chip as reading the orientation of a nearby diametric magnet, and the module comes with a round magnet in the product photo. Keep the magnet centred over the chip and about 0.5 to 3 mm away.

▸ Can I change the I2C address?

No. The AS5600 always answers at address 0x36. To use more than one on the same board, put each on its own I2C bus or use an I2C multiplexer.

▸ Does it count full turns?

No. The chip reports the angle inside one turn as a number from 0 to 4095. If your project turns more than once, count the wrap-arounds in your code.

▸ Can I use the OUT pin instead of I2C?

Yes. By default the OUT pin gives an analog voltage from 0 to 100% of the supply that follows the angle, so you can read it with an analog input.

Technical question about this part? Email support@epartners.co.nz with your board and wiring, and we'll help you get it working.

Shipping: $5.99 urban, $9.99 rural. Free shipping on orders of $100 or more.

Order by 10:30am (NZT), Monday to Friday, and we dispatch the same day. Orders placed after 10:30am, on weekends or on public holidays are dispatched the next business day.

Delivery usually takes 1–2 business days after dispatch (2–3 for rural addresses). See our Shipping Policy for full details.

This site is protected by hCaptcha and the hCaptcha Privacy Policy and Terms of Service apply.

More from Various Sensors
Recently viewed