Your solution started out as bearable (5V at 100mA) but ended up completely unacceptable at 500 mA. You say that your "wall wart" is rated at 300 mA. When you supply a voltage using a linear regulator the current in is the same as the current out - the regulator drops the difference in voltage. So here if you draw 500 mA at 5V you must supply 500 mA at 12V or 24V. The transformer will be overloaded in either case.
If the ratings are as you say then a potentially acceptable solution is to use a switching regulator (SR) operating from 24V in. \$5V \times 500 mA = 2.5 W\$.
\$24V \times 5 W =~ 210 mA\$. If the SR is 80% efficient (easily achieved) that rises to 260 mA. As that is liable to be an occasional requirement the total current at 24V will probably be acceptable with a 300 mA supply - depending on how many solenoids you wish to maintain on.
If you switch only one solenoid on at once the current drain with N activated is \$20 \times N + 20 mA\$. The surge current is essentially immaterial.
If you wanted more than 3 or 4 solenoids then current drain at 5V may need to be limited.
e.g.
- 10 solenoids at 20 mA = \$200 mA\$
- Balance = \$300mA-200mA = 100 mA\$
- Available current at 5V at 80 % efficient = \$ 100 mA \times \frac{24}{5} \times 0.8 = 384 mA\$, say \$400 mA\$.
Note that when a switching regulator is used, using a higher input voltage will result in less input current drain. Hence it is better here to use the full 24V supply.
Note also that if the transformer is a genuine 24 VAC then the rectified DC will be about \$24 VAC \times 1.414 - 1.5V - \$ "a bit" \$~= 30 VDC \$
Because:
\$VDC_{peak} = VAC_{RMS} \times \sqrt{2} ~= VAC \times 1.414 ~= 34 V\$.
A full bridge rectifier will drop about 1.5V.
34 VDC is peak voltage and available DC will be slightly lower - depends on load. There will be "a bit" of ripple and wiring loss and transformer droop and ...
At 80% efficiency this gives a 24VAC to 5V DC current boost of \$ \frac{30}{5} \times 0.8 = 4.8:1 \$
e.g.
- for 48 mA at 5V you need 10 mA at 30V.
- for 480 mA at 5V you need 100 mA at 30V.
So you about get 10 solenoids plus almost 500 mA at 5V DC :-)
One solution of many:
There are many SR IC's and designs. Here a simple buck regulator will suffice.
You can buy commercial units or "roll your own". There are many modern ICs but if cost is at a premium you could look at ye olde MC34063. About the cheapest switching regulator IC available and able to handle essentially any topology. It would handle this task with no external semiconductors and a minimum of other components.
MC34063. $US0.62 from Digikey in 1's. I pay about 10 cents each in 10,000 qauntity in China (about half Digikey's price).
Figure 8 in the datasheet referenced below happens to be a "perfect match" to your requirement. Here 25 VDC in, 5V at 500 mA out. 83% efficient.
3 x R, 3 x C, diode, inductor. It would work without alteration at 30 VDC in.
Datasheet - http://focus.ti.com/lit/ds/symlink/mc33063a.pdf
Prices - http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=296-17766-5-ND
Figure 8 in the LM34063 datasheet shows ALL component values except for the inductor design (inductance only is given). We can spec the inductor for you from Digikey (see below) or wherever and/or help you design it. Basically it's a 200 uH inducor designed for general power switching use with a saturation current of say 750 mA or more. Things like resonant frequency, resistance etc matter BUT are liable to be fine in any part that meets the basic spec. OR you can wind your own for very little on eg a Micrometals core. Design software on their site.
From Digikey $US0.62/1. In stock. Bourns (ie good).
Price:
http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=SDR1005-221KLCT-ND
Datasheet:
http://www.bourns.com/data/global/pdfs/SDR1005.pdf
Slightly better spec
The Raspberry Pi is generally powered from a 5V wall-wart type of DC power supply. The secondary is galvanically isolated from the mains voltage for reasons of personal safety (a fault will not expose the end user to the mains voltage).
The DC return of your bridge rectifier circuit is most certainly not isolated from the mains. The Raspberry Pi ground is 'floating' with respect to the bridge rectifier ground - there is no galvanic connection between them, hence your voltage measurement.
If you were to connect the DC return of the bridge rectifier circuit to the Raspberry Pi ground, you bypass the galvanic isolation that the DC power supply gives you. This means your Raspberry PI is now mains-referenced, and any fault could potentially expose you you to lethal voltages. I wouldn't do this.
A further complication comes if you also hook up an earth-referenced return to the Raspberry Pi, like a connection to a PC, with the mains-reference return connected. When you mix a mains-referenced return like your rectifier circuit with earth, things are going to explode (you essentially short out your bridge through the earthed return, which is often a flimsy wire that gets really hot and melts/catches fire while blowing up everything connected to it). Another reason not to do this.
You would be much better off with a small line frequency transformer to (1) step down the mains voltage to a lower level ahead of your resistive attenuator, and (2) provide galvanic isolation from the mains. Put your bridge and attenuator in the secondary of the transformer. With this, you can safely connect the low voltage isolated rectifier return to the Raspberry Pi return.
(You also must include a fuse in the line to isolate the rectifier circuit from the mains if there is a severe fault like a transformer fault or a short circuit.)
Best Answer
First thing to do is find out if you have black (ground) wire available.
If you do, then make sure you have other colors right by operating thermostat and measuring voltage between other wires and ground. Standard pinout is G-fan, W-heat, Y-AC. The voltage should appear on the wire when corresponding function activated.
If you don't have ground (which is usually the case) then measure between red (24VAC) and G/W/Y. In this case the output is reversed - you should see some voltage when function is not active, and 0 when it is activated.
How exactly you use them depends on the availability of ground wire and location of you wiretap. If you placing this near the furnace you might be able to bring ground out of it, so the second case becomes the first. If this is not possible you'd have to disconnect red wire from furnace and supply your own DC (e.g. +5V) to it. (normally I'd recommend connecting it to GND, but if thermostat uses solid-state relays it might not work)
The best way to convert AC into I/O is by using optocouplers connected between G/W/Y and black wires. See here or here for examples. Or, even better, use AC optocoupler like H11AA1M, HCPL3700 to simplify circuit a lot.
If you had to disconnect red and supply your own DC then you can connect return wires from thermostat to I/O, with some resistors in series and pull-downs. However I would recommend using optocouplers on inputs anyway, to isolate your controller from whatever currents might lurk in your wiring.
Please, take the standard precautions when working on mains-powered appliances.