# Adafruit PCF8591 Basic 4 x ADC + DAC Breakout

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/093/057/medium800/adafruit_products_a_overview_4648_iso_ORIG_2020_07_guide.png?1594429096)

Measuring voltage and adjusting it is what electronics is all about so you won’t get far without friends like the [**PCF8591 ADC+DAC combo**](https://adafruit.com/product/4648).&nbsp; **A** nalog to **D** igital **C** onverters help by measuring an analog voltage and turning it into something a microcontroller like a Metro or Arduino can understand. If you’re using a single board computer like a Raspberry Pi, you might not have any other way to measure a voltage because even though they are well equipped for digital circuits, many boards of that type don’t have any pins that can measure analog voltages.

Adding a PCF8591 to your electronics project will give you not one, not two, but **_four_**  **8-bit analog inputs** that you can use to measure voltages from. If knobs are just the thing to complete your project, just add a PCF8591 and some potentiometers and you’re ready to twist, turn, twiddle and tweak to get things _just right._

![](https://cdn-learn.adafruit.com/assets/assets/000/093/055/medium800/adafruit_products_a_overview_4648_kit_ORIG_2020_07_guide.png?1594429070)

Along with four 8-bit ADC channels, the PCF8591 comes complete with an 8-bit **D** igital to **A** nalog **C** onverter converter as well! Not only can you measure voltages, but now you can _create_ them just as you want them. You can even use the DAC and ADC together to create an input to a circuit and measure the results with the ADC. The possibilities abound!&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/093/067/medium800/adafruit_products_jumper_crop.jpg?1594434017)

_" **Wow!** _ **”** you say, **”_That sounds great, but surely with all that fun in one small package, I can only use one at a time_.”**

Well my friend, I’ve got good news. On the back of each PCF8591 breakout are three jumpers that allow you to set the I2C address, allowing the use of **eight PCF8591s on the same I2C bus!** That’s up to a a whopping **32 channels** of analog measurement and **8 channels** of analog signal generation! If you do decide to go all out with your project, you won’t break the bank because the PCF8591 breakouts are reasonably priced compared to some higher-end ADCs.

![](https://cdn-learn.adafruit.com/assets/assets/000/093/056/medium800/adafruit_products_a_overview_4648_detail_ORIG_2020_07_guide.png?1594429084)

As if 4 ADCs and one DAC in a single package weren’t enough, we’ve made it even easier to use by mounting the PCF8591's chonky SO16 surface mount package onto a breakout with standard 0.1”/2.54mm headers and [SparkFun Qwiic](https://www.sparkfun.com/qwiic) compatible[STEMMA QT](https://learn.adafruit.com/introducing-adafruit-stemma-qt) connectors for the I2C bus, making it simple to integrate with your project. Using the wiring diagrams and example code on the pages that follow, you’ll be able to use our **[Python](https://github.com/adafruit/Adafruit_CircuitPython_PCF8591) and [Arduino](https://github.com/adafruit/Adafruit_PCF8591) libraries** to easily measure as many voltages as you need (as long as that number is 32 or less).

# Adafruit PCF8591 Basic 4 x ADC + DAC Breakout

## Pinouts

![](https://cdn-learn.adafruit.com/assets/assets/000/093/058/medium800/adafruit_products_b_pinouts_4648_top_ORIG_2020_07_guide.png?1594429575)

## **Power Pins**

- **VCC** - this is the power pin. To power the board, give it the same power as the logic level of your microcontroller - e.g. for a 5V microcontroller like Arduino, use 5V
- **GND** - common ground for power and logic

Info: 

## **I2C Logic Pins**

- **SCL** - I2C clock pin, connect to your microcontroller I2C clock line. This pin is 3.3V and 5V compatible, and there's a **10K pullup** on this pin.
- **SDA** - I2C data pin, connect to your microcontroller I2C data line. This pin is 3.3V and 5V compatible, and there's a **10K pullup** on this pin.
- [**STEMMA QT**](https://learn.adafruit.com/introducing-adafruit-stemma-qt) **&nbsp;-** These connectors allow you to connectors to dev boards with&nbsp; **STEMMA QT** connectors or to other things with&nbsp;[various associated accessories](https://www.adafruit.com/?q=JST%20SH%204)  

## **Analog Pins**

- **A0-A3** - **ADC Inputs** , Connect these to the voltage you want to measure
- **Out - DAC Output.** Connect to a circuit to create a voltage

![](https://cdn-learn.adafruit.com/assets/assets/000/093/059/medium800/adafruit_products_b_pinouts4648_quarter_ORIG_2020_07_guide.png?1594429591)

 **Other Pins and Jumpers**

- **OSC - Oscillator input/output.** Outputs the oscillator signal used by the ADC **.** You can use it to &nbsp;supply an external oscillator using the **EXT** jumper
- **EXT Solder Jumper - OSC Switch.** Short to use an external oscillator
- **AD0, AD1, AD2 Jumpers** &nbsp;- **I2C Address jumpers**. Bridging the solder jumpers on the back will allow you to change the I2C address from the default **0x48 (72)** to one between **0x49 (73)** and **0x4F (79).&nbsp;**

Shorting **A0** will add **1** to the address, shorting **A1** will **add 2** , and **A2** will **add 4.** For example

**`0x48 + 1 (A0) + 2 (A1) = 0x48 + 3 = 0x4B`**

or

**` 0x48 + 1 (A0) + 4 (A2) = 0x48 + 5 = 0x4D`**

# Adafruit PCF8591 Basic 4 x ADC + DAC Breakout

## Arduino

Using the PCF8591 with Arduino is a simple matter of wiring up it to your Arduino-compatible microcontroller, installing the [Adafruit PCF8591](https://github.com/adafruit/Adafruit_PCF8591) library we've written, and running the provided example code.

## **I2C Wiring**

Wiring the PCF8591&nbsp; is made simple by using the I2C interface. The default I2C address for the PCF8591 is **0x48** but it can be switched to several up to **0x4F** by shorting the address jumpers. See the&nbsp; **Pinouts** page for details

- Connect **PCF8591** **VCC (red wire)** to&nbsp; **Arduino 5V** &nbsp;if you are running a **5V** board Arduino (Uno, etc.).&nbsp;If your board is **3V,** connect to that instead.
- Connect **PCF8591 GND (black wire)** to&nbsp; **Arduino**  **GND**
- Connect **PCF8591 SCL (yellow wire)** to&nbsp; **Arduino**  **SCL**
- Connect **PCF8591 SDA (blue wire)** to&nbsp; **Arduino**  **SDA**

**For our test program, we expect you'll wire up the ADC / DAC pins as well:**

- Use a jumper wire to connect the **PCF8591's A0** pin to the **Out** pin
- Use another wire to connect PCF8591's&nbsp; **A1 pin to&nbsp;** the Arduino 3.3V pin.
- Connect **PCF8591 A2** pin to **Arduino**  **IORef**
- Connect **PCF8691 A3** to **Arduino GND**

![adafruit_products_PCF8591_Arduino_I2C_STEMMA_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/093/069/medium640/adafruit_products_PCF8591_Arduino_I2C_STEMMA_bb.jpg?1594648648)

![adafruit_products_PCF8591_Arduino_I2C_breadboard_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/093/070/medium640/adafruit_products_PCF8591_Arduino_I2C_breadboard_bb.jpg?1594648674)

## **Library Installation**

You can install the **[Adafruit PCF8591](https://github.com/adafruit/Adafruit_PCF8591) l**ibrary for Arduino using the Library Manager in the Arduino IDE.

![](https://cdn-learn.adafruit.com/assets/assets/000/093/060/medium800/adafruit_products_a_ARDUINO_-_library_manager_menu.png?1594431359)

Click the&nbsp; **Manage Libraries ...** menu item, search for **Adafruit PCF8591** ,&nbsp;and select the&nbsp; **Adafruit PCF8591** &nbsp;library:

![](https://cdn-learn.adafruit.com/assets/assets/000/093/054/medium800/adafruit_products_image.png?1594427364)

Follow the same process for the **Adafruit BusIO** &nbsp;library.

![](https://cdn-learn.adafruit.com/assets/assets/000/093/062/medium800/adafruit_products_aa_ARDUINO-_BusIO_Lib_Manager.png?1594432108)

## **Load Example**

Open up&nbsp; **File -\> Examples -\> Adafruit PCF8591 -\> PCF8591**

After opening the demo file, upload to your Arduino wired up to the sensor. Once you upload the code, you will see the **ADC** &nbsp;values being printed when you open the Serial Monitor ( **Tools-\>Serial Monitor** ) at **115200 baud** , similar to this:

![](https://cdn-learn.adafruit.com/assets/assets/000/093/053/medium800/adafruit_products_image.png?1594426333)

## **Example Code**
https://github.com/adafruit/Adafruit_PCF8591/blob/master/examples/PCF8591/PCF8591.ino

# Adafruit PCF8591 Basic 4 x ADC + DAC Breakout

## Arduino Docs

# Adafruit PCF8591 Basic 4 x ADC + DAC Breakout

## Python & CircuitPython

It's easy to use the **PCF8591** with Python or CircuitPython, and the [Adafruit CircuitPython PCF8591](https://github.com/adafruit/Adafruit_CircuitPython_PCF8591) module. This library allows you to easily write Python code that reads ADC values and set DAC voltages

You can use this sensor with any CircuitPython microcontroller board or with a computer that has GPIO and Python [thanks to Adafruit\_Blinka, our CircuitPython-for-Python compatibility library](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux).

## **CircuitPython Microcontroller Wiring**
Wire up a PCF8591 to your board exactly as shown below. Here's an example of wiring a Feather M4 to the sensor with I2C using a solderless breadboard

- **Board 3V** to **PCF8591**** &nbsp;VIN (red wire)**
- **Board GND** to **PCF8591**** &nbsp;GND (black wire)**
- **Board SCL** to **PCF8591**** &nbsp;SCL (yellow wire)**
- **Board SDA** to **PCF8591**** &nbsp;SDA (blue wire)**
- **PCF8591 A0** to **PCF8591 Out**

![adafruit_products_PCF8591_FeatherM4_I2C_STEMMA_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/093/072/medium640/adafruit_products_PCF8591_FeatherM4_I2C_STEMMA_bb.jpg?1594648835)

![adafruit_products_PCF8591_FeatherM4_I2C_breadboard_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/093/073/medium640/adafruit_products_PCF8591_FeatherM4_I2C_breadboard_bb.jpg?1594648819)

## **Python Computer Wiring**

Since there's _dozens_ of Linux computers/boards you can use, we will show wiring for Raspberry Pi. For other platforms, [please visit the guide for CircuitPython on Linux to see whether your platform is supported](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux).&nbsp;

Here's the Raspberry Pi wired to the sensor using I2C and a solderless breadboard

- **Board 3V** to **PCF8591**** &nbsp;VIN (red wire)**
- **Board GND** to **PCF8591**** &nbsp;GND (black wire)**
- **Board SCL** to **PCF8591**** &nbsp;SCL (yellow wire)**
- **Board SDA** to **PCF8591**** &nbsp;SDA (blue wire)**
- **PCF8591 A0** to **PCF8591 Out**

![adafruit_products_PCF8591_RasPi_I2C_STEMMA_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/093/074/medium640/adafruit_products_PCF8591_RasPi_I2C_STEMMA_bb.jpg?1594648849)

![adafruit_products_PCF8591_RasPi_I2C_breadboard_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/093/075/medium640/adafruit_products_PCF8591_RasPi_I2C_breadboard_bb.jpg?1594648868)

## **CircuitPython Installation of PCF8591 Library**

You'll need to install the [Adafruit CircuitPython PCF8591](https://github.com/adafruit/Adafruit_CircuitPython_PCF8591) library on your CircuitPython board.

First make sure you are running the&nbsp;[latest version of Adafruit CircuitPython](https://learn.adafruit.com/welcome-to-circuitpython/installing-circuitpython)&nbsp;for your board.

Next you'll need to install the necessary libraries&nbsp;to use the hardware--carefully follow the steps to find and install these libraries from&nbsp;[Adafruit's CircuitPython library bundle](https://circuitpython.org/libraries).&nbsp;

Our CircuitPython starter guide has [a great page on how to install the library bundle](https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries).

Before continuing make sure your board's **lib** folder or root filesystem has the **adafruit\_PCF8591.mpy** file **and adafruit\_bus\_device** folder **&nbsp;** copied over.

Next&nbsp;[connect to the board's serial REPL&nbsp;](https://learn.adafruit.com/welcome-to-circuitpython/the-repl)so you are at the CircuitPython&nbsp; **\>\>\>** &nbsp;prompt.

## **Python Installation of PCF8591 Library**

You'll need to install the **Adafruit\_Blinka** library that provides the CircuitPython support in Python. This may also require enabling I2C on your platform and verifying you are running Python 3.

&nbsp;[Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux)!

Once that's done, from your command line run the following command:

`sudo pip3 install adafruit-circuitpython-pcf8591`

If your default Python is version 3 you may need to run 'pip' instead. Just make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!

## **CircuitPython & Python Usage**

To demonstrate the usage of the ADC and DAC we'll initialize it and set the DAC and read the ADC&nbsp; from the board's Python REPL.

Run the following code to import the necessary modules and initialize the I2C connection with the sensor:

```python
import time
import board

import adafruit_pcf8591.pcf8591 as PCF
from adafruit_pcf8591.analog_in import AnalogIn
from adafruit_pcf8591.analog_out import AnalogOut

i2c = board.I2C()
pcf = PCF.PCF8591(i2c)
```

Info: 

Next we will create an `AnalogIn` and `AnalogOut`from the PCF8591 to allow us to set and read voltages the same way as with other CircuitPython boards with built in DACs and ADCs

```python
pcf_in_0 = AnalogIn(pcf, PCF.A0)
pcf_out = AnalogOut(pcf, PCF.OUT)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/093/048/medium800/adafruit_products_image.png?1594424698)

Now that we are all set up, we will use the code below to set the DAC's value and then read the voltage that was set using the ADC. A little math will translate the raw 16-bit (scaled from 8-bit) value to a voltage level.

```python
pcf_out.value = 65535
raw_value = pcf_in_0.value
scaled_value = (raw_value / 65535) * pcf_in_0.reference_voltage
print("Pin 0: %0.2fV" % (scaled_value))
print("")
```

![](https://cdn-learn.adafruit.com/assets/assets/000/093/049/medium800/adafruit_products_image.png?1594424827)

Next we'll repeat the process but this time we'll specify a DAC value that was&nbsp; **half** the previous amount. Note how the voltage level changes as a result

```python
pcf_out.value = 32767
raw_value = pcf_in_0.value
scaled_value = (raw_value / 65535) * pcf_in_0.reference_voltage

print("Pin 0: %0.2fV" % (scaled_value))
```

![](https://cdn-learn.adafruit.com/assets/assets/000/093/050/medium800/adafruit_products_image.png?1594424938)

Finally we'll set the DAC value to zero and use the ADC to verify that the DAC can go all the way down to 0V/GND

```python
pcf_out.value = 0
raw_value = pcf_in_0.value
scaled_value = (raw_value / 65535) * pcf_in_0.reference_voltage

print("Pin 0: %0.2fV" % (scaled_value))
```

![](https://cdn-learn.adafruit.com/assets/assets/000/093/051/medium800/adafruit_products_image.png?1594425432)

## **Example Code**
https://github.com/adafruit/Adafruit_CircuitPython_PCF8591/blob/main/examples/pcf8591_simpletest.py

# Adafruit PCF8591 Basic 4 x ADC + DAC Breakout

## Python Docs

# Adafruit PCF8591 Basic 4 x ADC + DAC Breakout

## Downloads

## **Files**

- [PCF8591 Datasheet](https://www.nxp.com/docs/en/data-sheet/PCF8591.pdf)
- [EagleCAD files on GitHub](https://github.com/adafruit/Adafruit-PCF8591-PCB)
- [Fritzing object in the Adafruit Fritzing Library](https://github.com/adafruit/Fritzing-Library/blob/master/parts/Adafruit%20PCF8591.fzpz)

## **Schematic**

## &nbsp;
![](https://cdn-learn.adafruit.com/assets/assets/000/093/066/medium800/adafruit_products_e_downloads_schematic.png?1594433667)

## **Fab Print**
![](https://cdn-learn.adafruit.com/assets/assets/000/093/065/medium800/adafruit_products_e_downloads_fab.png?1594433646)


## Primary Products

### Adafruit PCF8591 Quad 8-bit ADC + 8-bit DAC - STEMMA QT / Qwiic

[Adafruit PCF8591 Quad 8-bit ADC + 8-bit DAC - STEMMA QT / Qwiic](https://www.adafruit.com/product/4648)
Measuring voltage and adjusting it is what electronics is all about so you won’t get far without friends like the **Adafruit PCF8591 Quad 8-bit ADC + 8-bit DAC combo**.&nbsp;&nbsp; **A** nalog to&nbsp; **D** igital&nbsp; **C** onverters help...

In Stock
[Buy Now](https://www.adafruit.com/product/4648)
[Related Guides to the Product](https://learn.adafruit.com/products/4648/guides)

## Featured Products

### STEMMA QT / Qwiic JST SH 4-pin to Premium Male Headers Cable

[STEMMA QT / Qwiic JST SH 4-pin to Premium Male Headers Cable](https://www.adafruit.com/product/4209)
This 4-wire cable is a little over 150mm / 6" long and fitted with JST-SH female 4-pin connectors on one end and premium Dupont male headers on the other. Compared with the chunkier JST-PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4209)
[Related Guides to the Product](https://learn.adafruit.com/products/4209/guides)
### JST SH 4-pin Cable with Alligator Clips - STEMMA QT / Qwiic

[JST SH 4-pin Cable with Alligator Clips - STEMMA QT / Qwiic](https://www.adafruit.com/product/4398)
This cable will make it super easy to use our plug-and-play STEMMA QT boards with boards like Circuit Playground. On one end you get a Qwiic / STEMMA QT connector (technically known as a JST SH 4-pin plug)&nbsp; into 4 individual wires with grippy alligator clips. We're carrying these to...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4398)
[Related Guides to the Product](https://learn.adafruit.com/products/4398/guides)
### 4-pin JST PH to JST SH Cable - STEMMA to QT / Qwiic

[4-pin JST PH to JST SH Cable - STEMMA to QT / Qwiic](https://www.adafruit.com/product/4424)
Are you a maker in the midst of&nbsp;a [**STEMMA**](https://learn.adafruit.com/introducing-adafruit-stemma-qt/what-is-stemma) dilemma? This 200mm long 4-wire cable is a fantastic chimera-cable fitted with **STEMMA QT / Sparkfun Qwiic JST SH** on one end,...

In Stock
[Buy Now](https://www.adafruit.com/product/4424)
[Related Guides to the Product](https://learn.adafruit.com/products/4424/guides)
### STEMMA QT / Qwiic JST SH 4-pin Cable with Premium Female Sockets

[STEMMA QT / Qwiic JST SH 4-pin Cable with Premium Female Sockets](https://www.adafruit.com/product/4397)
This 4-wire cable is a little over 150mm / 6" long and fitted with JST-SH female 4-pin connectors on one end and premium female headers on the other. Compared with the chunkier JST-PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4397)
[Related Guides to the Product](https://learn.adafruit.com/products/4397/guides)
### STEMMA QT / Qwiic JST SH 4-pin Cable - 100mm Long

[STEMMA QT / Qwiic JST SH 4-pin Cable - 100mm Long](https://www.adafruit.com/product/4210)
This 4-wire cable is a little over 100mm / 4" long and fitted with JST-SH female 4-pin connectors on both ends. Compared with the chunkier JST-PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and remove.

<a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/4210)
[Related Guides to the Product](https://learn.adafruit.com/products/4210/guides)

## Related Guides

- [Analog Knobs on Raspberry Pi 400 with CYBERDECK Hat](https://learn.adafruit.com/analog-knobs-on-raspberrypi-400-with-cyberdeck-hat.md)
- [USB MIDI Host2Host](https://learn.adafruit.com/usb-midi-host2host.md)
- [Adafruit PCM5122 I2S DAC](https://learn.adafruit.com/adafruit-pcm5122-i2s-dac.md)
- [Best Beginner Boards for Teachers](https://learn.adafruit.com/best-beginner-boards-for-teachers.md)
- [CircuitPython Libraries on MicroPython using the Raspberry Pi Pico](https://learn.adafruit.com/circuitpython-libraries-on-micropython-using-the-raspberry-pi-pico.md)
- [Adafruit NeoDriver - I2C to NeoPixel Driver](https://learn.adafruit.com/adafruit-neodriver-i2c-to-neopixel-driver.md)
- [Measuring Parts from Product Photos in FreeCAD](https://learn.adafruit.com/measuring-parts-from-product-photos-in-freecad.md)
- [Adafruit 2.8" and 3.2" Color TFT Touchscreen Breakout v2](https://learn.adafruit.com/adafruit-2-8-and-3-2-color-tft-touchscreen-breakout-v2.md)
- [USB Host to BLE Keyboard Adapter](https://learn.adafruit.com/esp32-s3-usb-to-ble-keyboard-adapter.md)
- [Adafruit Powerboost 1000C](https://learn.adafruit.com/adafruit-powerboost-1000c-load-share-usb-charge-boost.md)
- [Adafruit VCNL4020 Proximity and Light Sensor](https://learn.adafruit.com/adafruit-vcnl4020-proximity-and-light-sensor.md)
- [Raspberry Pi 5 3D Printed Case](https://learn.adafruit.com/pi-5-case.md)
- [Tri-Layer Mini Round Robot Chassis Kit](https://learn.adafruit.com/tri-layer-mini-round-robot-chassis-kit.md)
- [Adafruit Joy Bonnet for Raspberry Pi](https://learn.adafruit.com/adafruit-joy-bonnet-for-raspberry-pi.md)
- [Adafruit CAN Bus BFF](https://learn.adafruit.com/adafruit-can-bus-bff.md)
