PCF8574 with ULN2003 as relay driver. :How to ensure initial state is OFF?

I need to have only one current sensor, for the relay dedicated to heating system.

Firstly i used a couple PCF8574 (relays) + PCF8591 (ACS712) over I2C.
Since i got in trouble with PCF8574 and relays, i replaced all this by a slave I2C arduino pro mini.

It is more accurate for driving the ACS712 over I2C.
8 bits ADC PCF8591 => 10 bits ADC arduino

Also, sensing 220V AC 50 Hz current needs multiple access to ACS712, to get min/max values.
The arduino pro mini handle this.
The main arduino sends an order ("start read ACS712") and asks for value one second later.

An arduino pro mini could handle up to 4 ACS712 with analog inputs (4 = 6 - SCL & SDA).

In my case, the use of an arduino pro mini offers much more possibilities, compared to combining basic integrated circuits.

Wiring is also easier.

PCF8591 (ACS712) over I2C.

ADS1015 could also be an option as well for addressable ADC over I2C

how do you use the acs712? do you attach it to the AC line?
I could incorporate this into my project.

I did a search, I if I understand it correctly, you wire the acs712 in series with the load?
so if I wire it in series with the relay, once relay switched is closed, it can start measuring the load current right? For AC measurement, does it give you RMS value?

Yes . effectively you connect it in series with the load. Google the datasheet, there are example schematics there.

doughboy:
For AC measurement, does it give you RMS value?

No, just the instant value.
ACS712 output is 0-5 V.
Output signal is a sine wave centered on 2,5 V.
You have to read it multiple times to get min / max values.

So how often do you sample the waveform bricoleau to get accurate results? Twice the mains frequency?

ok, I suppose you can estimate the RMS if you find the max and multiply by .707?

I think those KillaWatt power monitors detects the 0 crossing point of the AC then I think based on freq, you can calculate when the peak will occur.

I sample the waveform as fast as possible, since the arduino pro mini has nothing else to do.

Just a loop, during a least 1/50 s = 20 ms

 v = analogRead(pin);
  if (v < mini)  mini = v;
  if (v > maxi) maxi = v;

The arduino can get around 30 or 40 analogRead() on each wave (1/50 s).
That's quite enough to catch min & max, even on one single wave.

I just consider value = max - min, as i just need to know if the aquarium heater is idle or not.

Refer to datasheet to calculate current value from ACS712 output.

ok, that makes sense then that you use the arduino.

I did some more search and the most common usage is to sample 250x over 100ms (6 cycles on 60hz, 5 cycles on 50hz) and get the sum of square of each sample then divide by 250 then take sq root, etc. so literally calculating the rms.

I also just realized after reading that if I get a 5amp module, it can handle only 3.5amp rms current, as 5amp would be peak current.

don't you control the outlet on/off to the heater via a temp sensor reading.

I'm incorporating the current sensor to my aquarium controller to monitor total power consumption.

I'm incorporating the current sensor to my aquarium controller to monitor total power consumption.

I am currently in the PCB design stage of something similar: Remotely controlled -via RS485 link -of 6 Mains relays while also measuring the load current (of four out of 6) and sending back the measurement via the same link.
I am using four ACS712 and one ADS1015 all controlled by an Arduino Micro

Have you considered solid state relays ? (no contact arcing due to zero crossing circuit )

No i havent thought of solid state relays. They dont offer isolation though from mains. Right?

Watcher:
No i havent thought of solid state relays. They dont offer isolation though from mains. Right?

Isolation would appear to be their primary purpose.

DEFINE isolation.

By definition, ISOLATION means NO DIRECT ELECTRICAL CONNECTION.

Thus, an isolation transformer is a primary coil coupled to a secondary coil through a magnetic core ( usually 1:1 ratio) . The ONLY thing they have in common is a magnetic field.
(in plain english that means a multimeter reads NO continuity between the two coils)
Both conventional relays and solid state relays have isolation between the control signal path and the mains. The difference is that the control signal path of a conventional relay is a COIL, whereas the control signal path of a solid state relay is an opto coupler, a zero crossing circuit and a SOLID STATE Triac separated by a 5000 V ISOLATION barrier.. (read the opto datasheet under HV isolation rating). When the contacts of a conventional relay open under power , the electrons jump the gap of the separating contacts initiating a plasma arc (ionization of air) which can reach temperatures that can cause contact surface melting and pitting. The arcing stops when the distance between the contacts exceeds the dielectric breakdown distance for the voltage being switched. (30,000V / per cm) . A solid state relay has NO ARCING because it is switched at the zero-crossing point.
If you answer "YES" to the following questions you should be using solid state relays:
1- Do you want to AVOID arcing ?
2- Do you WANT isolation ?

1- Do you want to AVOID arcing ?
2- Do you WANT isolation ?

The answer to both questions is obviously YES.

Isolation is defined as in galvanic isolation and since there is only optical coupling between the two circuits, then I the requirement is met! Guess I have never seriously considered them as opposed to conventional relays.

Could you recommend one for 20A AC 230V/50Hz ?

EDIT: Just found this on ebay :http://www.ebay.co.uk/itm/1-pcs-New-Solid-State-Relay-SSR-40DA-40A-3-32VDC-/141238330912

It sure is bulkier than a conventional relay. I d have trouble squeezing 6 of them in a 10x10 cm DIN rail mounted box, let alone PCB mounting!

Google "25A solid state relay ebay"
or
"40A solid state relay ebay"
See what happens when you don't include the word "ebay"
( FYI: Make sure SSR says AC NOT DC . They make both)
CRYDOM is a popular brand.

Watcher:
It sure is bulkier than a conventional relay. I d have trouble squeezing 6 of them in a 10x10 cm DIN rail mounted box, let alone PCB mounting!

They do not mount on a PCB.

I really don't have to tell you that you need a bigger box. I doubt they are much bigger than a conventional relay of similar(ly conservative) rating, and no larger when such a relay is mounted on a DIN rail.

Actually, they should mount on a grounded heatsink.

Yes, the one you linked is fine but here is a the same one.

You saw this , right ?

Same problem here

Finally I replaced PCF8574 & co by a single arduino pro mini working as a slave TWI device to drive my relay board.

Maybe overkill, but still cheap, easier to wire, and allows any custom drive (initial values, secure minimum time between switches, ...).

How much experience do you have with electronics ?
You are a "kludger". Instead of starting with a blank sheet of paper and listing your design criteria and then selecting the appropriate components and then designing the box based on the physical and electrical characteristics of the components, you looked around your garage for some piecd of junk and said to yourself "Let's see, I want to control AC devices so what I want is a smsrt power strip so why don't I use a power strip ?". If you strar from scratch with 6 SSRs , your first task is designing the heat sink. If you look, you might find a 1.5" x15" 18" strip of finned heatsink material The aluminum base is 1/8th " to 3/8th" thick with the fins running lengthwise . The fin height can be anything from 1/2" to 3/4" tall. The width has to match the heatsink dimensions. You drill and tap the base plate mounting holes fof the SSRs. If the base is at least 1/2" thick you can drill and tap the cover mounting holes on the sides.
Here is something similar . This heat sink is 3.93 x 2.00 x 0.90 inches and is of course too small but gives you an idea what I was talking about. This company appears to specialize in the kind of heat sink I am talking about. You can see a long strip in the photo. The label for the long strip says 6pk/12pk , which appears to imply the long strip comes in two sizes, one for 6 SSRs (what you need) and another for 12 SSRs.

I haven't found any yet but here is a different style of SSR heatsink.
SSR HEATSINK

Here is a 40A SSR mounted on a heatsink for about $10

I don't know what kind of outlets you need (US or foriegn,) but if you are in the USA, the single outlets are such that the power strip box would have to be much wider than a normal power strip because the outlets would have to mount across the strip. (side to side)

single outlet

On the other hand using pull-down resistors at the output of PCF8574 instead, is not an option since the PCF8574 would then be unable to drive the outputs high due its the low driving current capabilities.

Are you sure about this ? Did you try 20k and 10k pullups//pulldowns ?

I also just realized after reading that if I get a 5amp module, it can handle only 3.5amp rms current, as 5amp would be peak current

I seriously doubt that. The value the product is marketed as is almost always the rms current , not the peak (which is SQR(2) +rms) If it's an AC module, marketed as 5A, that's the rms rating, almost for certain.

From Sparkfun page

The ACS712 current sensor measures up to 5A of DC or AC current.

I can't find anything to prove it but I don't think hall effect current sensors sens instantaneous current because they are based on magnetic fields which are the result of rms current.