PCF8574 easy port naming

Hi, I'm working on a arduino controled vivarium.

All me electrical equipment is connected to 2 PCF8574's breakoutboards.

I have 1 PCF8574 (0x21) build in me exo-terra dual top and me TL lamp is connected to P0 and the halogen lamp is connected to P1.
the other PCF8574 (0x22) is used to control heater1, heater2, fogger.

Now i want to control in an easy way me electronic devices.

Someone any idea?

Kind regards

Koen

You need to send the signal of the PCF8574 to a mosfet to control something serious like heater as these PCF8574 do not deliver any serious power.

If 220V (Belgium) is involved use opto couplers and broad lines and wider spacing on your prints.

I use the sainsmart 2 relay module to switch the 220V but found out that the relay module sinks 50 mA and the maximum PCF8574 output current is 25mA.
So 1ste PCF8574 is blow up. I will mod the 2 relay module so the current is limited to 20 mA (changing R1 and R4)

Koen

Hi,

I found me error why the PCF8574 is dead.

I used A2 and A3 as digital outputs A2 high (+5V) and A3 low (GND) to deliver the 5V to the I2C boards and de relay module but the current was to high. .

Now I'm using an external 12V to 5V power regulator connected to Vin
Below you can found me test code that i already have
The Timelord lib will be used to calculated the sunrise and sunset time
the Time and TimeAlarms lib will be used to schedule timed actions (recalculate everyday the sunset/rise time turn on/off the light and set max temp and humidity
...

//#include <TimeLord.h>
//#include <Time.h>
//#include <TimeAlarms.h>
#include <Wire.h>
//#include <DS1307RTC.h>
//#include <SoftPWM.h>
//#include <Adafruit_MCP23017.h>
//#include <Adafruit_RGBLCDShield.h>

// Pin definitions
  
  const byte  
  I2C_SDA_PIN = A4, 
  I2C_SCL_PIN = A5;

//exo-terra dual top parameters  
  #define DUALTOP_ADDR 0x21  //PCF8574 Halogen on B0, TL on B1
  byte dualtop_byte; 
  boolean TL, Halogen;
  
// Set pin modes
  
void setup()
{
  Wire.begin();
  Serial.begin(9600);
}
void update_dualtop()  // calcualte byte that is send to the PCF8574 in the dualtop
{
  if (TL == true)
  {
    dualtop_byte = 255 - 0x02;
  }
  if (Halogen == true)
  { 
    dualtop_byte = 255 - 0x01;
  }
  if (Halogen == true && TL == true)
  {
    dualtop_byte = 255 - 0x03;
  }

  if (Halogen == false && TL == false)
  {
    dualtop_byte = 255 - 0x00;
  }
  //else dualtop_byte = 0x00;
  Wire.beginTransmission(DUALTOP_ADDR);  
  Wire.write(dualtop_byte);
  Wire.endTransmission();
  
}

void loop ()
{
  
  Serial.println("TL");
  TL = true;
  Halogen = false;
  update_dualtop();
  Serial.println(dualtop_byte,BIN);
  delay (1000);
  Serial.println("Halogen");
  TL = false;
  Halogen = true;
  update_dualtop();
  Serial.println(dualtop_byte,BIN);
  delay (1000);
  Serial.println("Halogen + TL");
  TL = true;
  Halogen = true;
  update_dualtop();
  Serial.println(dualtop_byte,BIN);
  delay (1000);
  Serial.println("off");
  TL = false;
  Halogen = false;
  update_dualtop();
  Serial.println(dualtop_byte,BIN);
  delay (1000);
}

Kind regards

Koen