The Adafruit PCF8591 is a versatile breakout board featuring the PCF8591 IC, which is a single-chip, single-supply low-power 8-bit CMOS data acquisition device with four analog inputs, one analog output, and a serial I²C-bus interface. This component is commonly used in applications requiring analog-to-digital conversion (ADC) and digital-to-analog conversion (DAC), such as sensor data reading, light intensity measurement, and simple feedback control systems.
Pin Number | Pin Name | Description |
---|---|---|
1 | AIN0 | Analog input channel 0 |
2 | AIN1 | Analog input channel 1 |
3 | AIN2 | Analog input channel 2 |
4 | AIN3 | Analog input channel 3 |
5 | AOUT | Analog output |
6 | AGND | Analog ground |
7 | VREF | Reference voltage for ADC and DAC |
8 | VSS | Power supply ground |
9 | SCL | Serial clock line for I²C |
10 | SDA | Serial data line for I²C |
11 | VDD | Positive power supply |
12 | OS | Output enable for the DAC, active low |
#include <Wire.h>
// PCF8591 default I2C address
const int PCF8591 = 0x48;
void setup() {
Wire.begin(); // Join I2C bus
Serial.begin(9600); // Start serial communication at 9600 baud
}
void loop() {
Wire.beginTransmission(PCF8591); // Start transmission to device
Wire.write(0x04); // Control byte - enable DAC, enable ADC0
Wire.endTransmission(); // End transmission
Wire.requestFrom(PCF8591, 2); // Request 2 bytes from the PCF8591
Wire.read(); // Read first byte (dummy read)
int analogValue = Wire.read(); // Read second byte (ADC0 value)
Serial.println(analogValue); // Print the value to the serial monitor
delay(1000); // Wait for 1 second
}
This example initializes the I²C communication and reads the analog value from channel AIN0 every second, then prints it to the serial monitor.
Q: Can I use this board with a 5V Arduino? A: Yes, the PCF8591 can operate at 5V and is compatible with 5V Arduino boards.
Q: How do I change the I²C address? A: The I²C address can be changed by adjusting the jumpers on the board to one of the eight possible addresses (0x48 to 0x4F).
Q: Can I use differential inputs with this board? A: Yes, the PCF8591 allows for three differential input measurements. Refer to the datasheet for configuring differential inputs.
Q: What is the maximum sampling rate of the ADC? A: The maximum sampling rate depends on the I²C clock frequency but typically is around 100 samples per second.
Remember to always consult the PCF8591 datasheet for detailed information and specifications.