Smegheid / water_heater

Running solar water heater system with a busted panel sensor from a raspberry pi
0 stars 0 forks source link

Drop voltage dividers to 3.3V #4

Open Smegheid opened 2 years ago

Smegheid commented 2 years ago

The ADC hat we're using (see the readme) is really handy in that it has a little breadboard area that made setting up the voltage dividers quite simple and self-contained. However, the hat only provides a +5V rail for the supply side of the divider.

This is a fail as the A/D converters on the hat have an input range of 0-2.5V. With the 10k fixed resistor on top and the 10k thermistor below, this means that the 2.5V limit is reached when the thermistor hits 10k, which is only 25C. As it stands, the system can't read temperatures lower than this; not a problem here in summer, but possibly a train wreck in winter.

Before I calmed down, I was thrashing around a bit and had considered adding a little cheap 2.5V regulator board that's cheap on ebay. With 3 pins, I could probably fit these on another breadboard area and then feed the 2.5V output over to the point that taps off the existing 5V rail.

However, a far cheaper "good enough" solution would be to simply tap off the pi's existing +3.3V supply. This is available on pin 1 of the GPIO connector and I already have jumper leads with female connectors on hand. Going to 3.3V would require desoldering the existing run from the hat's 5V rail, soldering a lead cut to length to the same point on the breadboard and the plugging that in to pin 1. The leads are known to fit inside the case (using them for the GPIO relay control) so once the lid's on, it'll be fine.

I did the math when I first realised this and I believe this will allow the system to read down to 3C or so. That's plenty for these parts; if it ever gets that cold here, then we've got bigger problems going on as a species/planet.

Once the hardware is in place, the software needs to use the new voltage when doing its conversion from A/D voltage to resistance. Though malice of forethought, this is a constant in the control script's volt_to_resistance() function instead of something rolled into another value from "optimisation", so this should be trivial to get working.

Dunno if it's worth measuring what the 3.3V rail actually supplies. It's not like my ancient fluke can be considered calibrated in any way...