5% OFF Over $19, Code: Elephant5; 10% OFF Over $59, Code: Elephant10

Raspberry Pi GPIO shield with-PCF8591 AD-DA for Raspberry Pi

Regular price $12.99

Shipping calculated at checkout.


There's no AD/DA function on the Raspberry Pi GPIO interface, this may trouble you in the Pi development. However, it won't be a problem anymore. The RPI GPIO-PCF8591 Shield allows you to add high-precision AD/DA functions to the Raspberry Pi.

The PCF8591 features four-8-bit analog to digital converters and a single 8-bit digital to analog converter.This will operate through the I2C interface on the Raspberry Pi.

Connection Diagram 

Plug it directly into Raspberry Pi to start your works as shown in below figure.

KS0213 (8).jpg

Shipping List

  • Raspberry Pi GPIO-PCF8519 Shield x1
  • M2.5 nut x4
  • M2.5* 10 Copper Pillar x4
  • M2.5* 20MM Round Head Screw x4

Sample Code

DA(Digital to Analog) Source Code:
#include <wiringPi.h>
#include <pcf8591.h>
#include <stdio.h>

#define Address 0x48
#define BASE 64          //DA Output
#define A0 BASE+0
#define A1 BASE+1
#define A2 BASE+2
#define A3 BASE+3

int main(void)
    unsigned char value;
	pcf8591Setup(BASE,Address);    //configuration pcf8591	

               analogWrite(BASE,value);      //write the value output on AOUT interface
               printf("AOUT:%d\n",value);     //print that value

AD(Analog to Digital) Source Code:
#include <wiringPi.h>
#include <pcf8591.h>
#include <stdio.h>

#define Address 0x48         //pcf8591 address 
#define BASE 64
#define A0 BASE+0           //A0 input
#define A1 BASE+1           //A1 input
#define A2 BASE+2           //A2 input
#define A3 BASE+3           //A3 input
int main(void)
    unsigned char value;
	pcf8591Setup(BASE,Address);        //configurationpcf8591
               value=analogRead(A0);     // read A0 value          
               printf("A0:%d\n",value);  // print A0 value

Program Writing

1.Install Wiringpi Library
Wiring Pi is a library. WiringPi supports analog reading and writing, and while there is no native analog hardware on a Pi by default, modules are provided so other A/D and D/A devices can be implemented relatively easily.
We will provide a Wiringpi installation package or click on this URL: https://projects.drogon.net/raspberry-pi/wiringpi/download-and-install/
(it should open in a new page) to download the latest version. This will download a .tar file with a name like wiringPi-b0a60c3.tar. Then copy the file and put it into the raspberry pi file as shown in below figure:


Type in this command to unzip the source code and install:

  • tar xfz wiringPi-98bcb20.tar.gz
  • cd wiringPi-98bcb20
  • ./build

Note that the actual file name will be different (may not be 98bcb20) – you will have to check the name and adjust accordingly.
Here is the interface after installing WiringPi as shown in below figure.


2.Enable I2C Utility
The I2C bus allows multiple devices to be connected to your Raspberry Pi. Before using I2C it needs to be configured.
Run this command: sudo raspi-config and follow the prompts to install I2C. Now complete the following steps:

  • Select “9 Advanced Options”
  • Select “A6 I2C”

The screen will ask if you want the ARM I2C interface to be enabled :

  • Select “Yes”
  • Select “Ok”
  • Select “Finish” to return to the command line

When you next reboot the I2C module will be loaded.


Copy the file pcf8591 provided by us and put it into your pi directory through winSCP. Next, type this command: cd pcf8591 to go inside the pcf8591 folder. Then type this command: make to make an executable file. This means this is the file we run to launch the program.
Finally type this: sudo ./TTP229 to launch the program.


DA source code makes AOUT interface output 0-5V voltage; the pi will prints digital value among 0-255 on the terminal after reading out voltage set by AD source code.


  • PDF File:


  • Installation Package Download:


  • Source Code Download: