Arduino DUE I2c PCF8591

Hello I just got the PCF8591 module:

I connected it to UNO and used library:

and everything is okay.

When i connected it to DUE and run the i2c scanner it finds the module at 0x48.
After i upload the same example sketch I have an error all the time:

the example sketch modified to just analog.write:
 * 	PCF8591 Analog Port Expand
 *  Read all analog pins and write value on analog ouput
 *  by Mischianti Renzo <>
 * PCF8574    ----- Esp32
 * A0         ----- GRD
 * A1         ----- GRD
 * A2         ----- GRD
 * SDA        ----- A4
 * SCL        ----- A5
#include "Arduino.h"
#include "PCF8591.h"
#define PCF8591_I2C_ADDRESS 0x48

PCF8591 pcf8591(PCF8591_I2C_ADDRESS);

void setup()

void loop()



C:\Users\Sebastian\Documents\Arduino\libraries\PCF8591_library\PCF8591.cpp: In member function 'void PCF8591::begin()':
C:\Users\Sebastian\Documents\Arduino\libraries\PCF8591_library\PCF8591.cpp:88:26: error: no matching function for call to 'TwoWire::begin(uint8_t&, uint8_t&)'
   _wire->begin(_sda, _scl);
C:\Users\Sebastian\Documents\Arduino\libraries\PCF8591_library\PCF8591.cpp:88:26: note: candidates are:
In file included from C:\Users\Sebastian\Documents\Arduino\libraries\PCF8591_library\PCF8591.h:31:0,
                 from C:\Users\Sebastian\Documents\Arduino\libraries\PCF8591_library\PCF8591.cpp:28:
C:\Users\Sebastian\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\libraries\Wire\src/Wire.h:38:7: note: void TwoWire::begin()
  void begin();
C:\Users\Sebastian\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\libraries\Wire\src/Wire.h:38:7: note:   candidate expects 0 arguments, 2 provided
C:\Users\Sebastian\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\libraries\Wire\src/Wire.h:39:7: note: void TwoWire::begin(uint8_t)
  void begin(uint8_t);
C:\Users\Sebastian\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\libraries\Wire\src/Wire.h:39:7: note:   candidate expects 1 argument, 2 provided
C:\Users\Sebastian\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\libraries\Wire\src/Wire.h:40:7: note: void TwoWire::begin(int)
  void begin(int);
C:\Users\Sebastian\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\libraries\Wire\src/Wire.h:40:7: note:   candidate expects 1 argument, 2 provided
exit status 1
Błąd kompilacji dla płytki Arduino Due (Programming Port).

I connected the SDA/SCL to PIN SDA1 and SCL1 ( I am using also the i2c screen). But I tried also to disconect the screen and use the 20/21 pins - still nothing helps.
Please help me to get it to work, everything on due is co complicated, wish I have bought mega...

Are you sure the pcf8591 library supports the Arduino Due processor (Atmel SAM3X8E ARM Cortex-M3)?

Here it says it works with al architectures.
I tried to make it work with standard wire library but it won’t work probably I do something wrong.

Tried also this sketch:

#include "Wire.h"
#define PCF8591 (0x48 >> 1) // I2C bus address
void setup()
void loop()
 Wire.beginTransmission(PCF8591); // wake up PCF8591
 Wire.write(0x40); // control byte - turn on DAC (binary 1000000)
 Wire.write(250); // value to send to DAC
 Wire.endTransmission(); // end tranmission


It compiles but no voltage at the output.

Check please. Is seems to me that address should be (0x90 >> 1) or simply 0x48.

Tried both didn't work.
Downloaded all possible libraries and the Adafruit one works at 3.3 Vref.
But still the vmax is like 2.8V but that is just the case of the board. I heard that unsoldering one Resistor makes it work to full values.

So i have to make an op amp with a gain of ~3 to make it 0-10V.

Of course it does not work :slight_smile:
I have connected the PFC to SDA 20 SCL 21
and now LCD to SDA1 SCL1
When I run this sketch:

#include <Adafruit_PCF8591.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display
// Make sure that this is set to the value in volts of VCC
Adafruit_PCF8591 pcf = Adafruit_PCF8591();

void setup() {
  lcd.init();                      // initialize the lcd 
  // Print a message to the LCD.
  lcd.print("Hello, world!");


  Serial.println("# Adafruit PCF8591 demo");
  if (!pcf.begin()) {
    Serial.println("# Adafruit PCF8591 not found!");
    while (1)
  Serial.println("# Adafruit PCF8591 found");

  Serial.println("AIN0, AIN1, AIN2, AIN3");

uint8_t dac_counter = 0;

void loop() {
  // Make a triangle wave on the DAC output


float int_to_volts(uint16_t dac_value, uint8_t bits, float logic_level) {
  return (((float)dac_value / ((1 << bits) - 1)) * logic_level);

The LCD part does not work...

I don’t understand. Does the board work or not?
If it doesn't work, then that's one issue.
If it works, but gives a low voltage, then I already wrote to you about the problems of this board caused by the LED.

It works with Adafruit library.
I know about the LED will try it later.
Now i have a problem because running both LCD and DAC board, the LCD part is not working... For sure it is because of using 2 I2C.

Fixed that:
Changed the cpp file of Liquid Crystal library adding:
extern TwoWire Wire1;
and changing each "Wire" in code for "Wire1" to make it use the second I2c :smiley:
now have to convert it to 0-10V and it's perfect :smiley:

Stop. This is another problem again. It does not belong to the main topic.

Okay so this topic is solved !


1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.