Help on reading a value from PCF8575

Hi all, I am using arduino uno and PCF8575 I2C board expander to read and print the values of 4 Ultrasonic sensors and 4 IR sensors. Pin connection reference and code(Cannot give all lines of code, but hope u understand the assigning of inputs and outputs) given below. The examples I referred is all using Wire library, and its must for communication, and they are using push buttons and led's. In my case, I am using Sensors to read and print the input and output. After I connected all pins from the sensors to the board, it wont read any values from the sensors. Individually, All sensors works fine. But I am getting 0 when I connected all sensors to the I2C board. I don't know how to configure it.
I would be glad if someone help me on this.

PCF8575(I2C) Description
GND Connected in Common GND
VDD
P00 Not Connected
P01 Connected to IR1
P02 Connected to Echo pin in US1
P03 Connected to Trigger pin in US1
P04 Not Connected
P05 Connected to Echo pin in US2
P06 Connected to Trigger pin in US2
P07 Connected to IR2
GND Connected in Common GND
VDD
P10 Connected to IR3
P11 Connected to Echo pin in US3
P12 Connected to Trigger pin in US3
P13 Not Connected
P14 Connected to Echo pin in US4
P15 Connected to Trigger pin in US4
P16 Connected to IR4
P17 Not Connected
INT Not Connected
SCL A5
SDA A4
VCC Connected From Battery/Arduino(5V)
GND Connected in Common GND

======================================

#include "PCF8575.h"

// Set i2c address
PCF8575 pcf8575(0x20);

void setup() {

  Serial.begin(9600);
  Serial.println("Started");



  pcf8575.pinMode(P0,INPUT);
  pcf8575.pinMode(P1,INPUT);
  pcf8575.pinMode(P2,INPUT);
  pcf8575.pinMode(P3,OUTPUT);
  pcf8575.pinMode(P4,INPUT);
  pcf8575.pinMode(P5,INPUT);
  pcf8575.pinMode(P6,OUTPUT);
  pcf8575.pinMode(P7,INPUT); 
  pcf8575.pinMode(P8,INPUT);
  pcf8575.pinMode(P9,INPUT);
  pcf8575.pinMode(P10,OUTPUT);
  pcf8575.pinMode(P11,INPUT);
  pcf8575.pinMode(P12,INPUT);
  pcf8575.pinMode(P13,OUTPUT);
  pcf8575.pinMode(P14,INPUT);
  pcf8575.pinMode(P15,INPUT);

  pcf8575.begin();

}`

Why not ?

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

1 Like

You can not use ultrasonic sensors on the expander. The NewPing library takes direct pin numbers, not pins on the expansion board.

If you wanted to do that, you would have to re-write the entire library to change all port access calls to calls to the port expander.

2 Likes

Posting an annotated schematic of how you have it wired will save all of us a lot of time. Without the code and schematic the best we can do is guess. blh64 caught a major bobo for you. Change your code and schematic to reflect that change and we can go from there.

Thanks for your reply.

I think I got the answer from @blh64 . So I have to find the alternative source. Anyway Thanks for your help.

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