AS5600 with an ESP32 DevKit V1

12-bit contactless magnetic rotary encoder that reads absolute shaft angle from a diametric magnet over I2C, analog, or PWM.

AS5600, 12-bit contactless magnetic rotary encoder that reads absolute shaft angle from a diametric magnet over I2C, analog, or PWM.
In short

On an ESP32 DevKit V1 the AS5600 module runs from 3V3 with SDA on GPIO21 and SCL on GPIO22, the core's default I2C pins. Its address is fixed at 0x36, so the ESP32's second I2C controller is the way to read a second encoder.

Wiring the AS5600 to the ESP32 DevKit V1

Pin by pin.

AS5600ESP32 DevKit V1
VCC3V3
GNDGND
SCLGPIO22 (D22)
SDAGPIO21 (D21)

What to know on the ESP32 DevKit V1

  • The AS5600 cannot change its I2C address, but the ESP32 has two I2C controllers. Put a second sensor on Wire1 with two pins of your choice through the GPIO matrix, avoiding the input-only GPIO34 to GPIO39 for SDA and SCL.ams AS5600 datasheet v1-06, p. 10; Espressif ESP32 Series Datasheet v5.3, p. 4; Espressif ESP32 Series Datasheet v5.3, p. 61
  • The OUT pin can also give the angle as an analog voltage, 0 to 100 % of VDD. On the ESP32 read it on an ADC1 pin such as GPIO33, since ADC2 pins stop reading while Wi-Fi runs.ams AS5600 datasheet v1-06, pp. 7, 19; Espressif ESP32 Series Datasheet v5.3, p. 14; ESP-IDF Programming Guide, ADC Oneshot Mode Driver
  • Powered from 3V3, the module's pull-ups hold SDA and SCL at 3.3 V, within the ESP32's VDD + 0.3 V input limit, and the chip's 6.5 mA always-on draw is a small load on the 3V3 rail.Espressif ESP32 Series Datasheet v5.3, p. 52; ams AS5600 datasheet v1-06, p. 5

AS5600 code for the ESP32 DevKit V1

Compiled for esp32:esp32:esp32 on 2026-10-30.

Libraries: robtillaart/AS5600
// AS5600 on ESP32 DevKit V1: wiring and a free simulation at https://www.tinkered.ai/components/as5600/esp32
#include <Wire.h>
#include "AS5600.h"

AS5600 as5600;   // I2C, address 0x36

void setup() {
  Serial.begin(9600);
  Wire.begin();
  as5600.begin();                       // DIR managed in hardware (tied to GND)
  Serial.println(as5600.isConnected() ? "AS5600 connected" : "AS5600 NOT found");
  Serial.print("Magnet: ");
  Serial.println(as5600.magnetDetected() ? "detected" : "none");
}

void loop() {
  float deg = as5600.readAngle() * AS5600_RAW_TO_DEGREES;  // 0..360
  Serial.print("Angle: ");
  Serial.print(deg, 1);
  Serial.println(" deg");
  delay(200);
}

AS5600 on the ESP32 DevKit V1: questions

Can I read two AS5600 sensors with one ESP32?

Yes, on two buses. Both answer only at 0x36 (ams datasheet, p. 10), so give the second one Wire1 on its own pair of GPIOs; the ESP32 has two I2C controllers (ESP32 datasheet, p. 4).

Should I read the AS5600 over I2C or analog on the ESP32?

I2C gives the full 12-bit angle with no ADC error and is what the page's sketch uses. The analog OUT option needs an ADC1 pin on the ESP32 and inherits its ADC's nonlinearity (ESP32 datasheet, p. 43).

Keep going

For AI assistants

This guide as plain Markdown. /components/as5600/esp32.md

What will you build with it?