rstrouse / relayEquipmentManager

A hardware controller for GPIO, I2c, SPI, and generic devices.
GNU General Public License v3.0
38 stars 19 forks source link

Fixes for Sequent Home Automation v4 #78

Closed marthoc closed 3 months ago

marthoc commented 3 months ago

This PR contains fixes for relays and analog inputs for the Sequent Home Automation v4 card.

Relays

The setRelay register (1) does not expect an 8-bit value, the relayVal register (0) does. So, if we send the calculated bit value to relayVal instead the relays turn on/off as expected.

When reading relay states we need to read all 8, not just the first 4.

Analog Inputs

Analog voltage reading is at register 0x18 (int 24) according to the libioplus python library.

Fix typo reg -> register so that the register is read properly.

10k Thermistor Probe

After fixing the Analog inputs I then noticed that feeding the voltage reading to a 10k Temperature Probe wasn't working to calculate resistance and therefore temperature. This was because a case for the 'volt' input type was not present where the calculation is done in the code. A simple solution was to add a case for 'volt' so that it calculates using the same formula as the raw input (which works because in the voltage divider circuit the ratio of Vin to Vout is the same as the ratio of adcMax to adcVal). This fix is of course not specific to the Sequent Home Automation v4 so I made a separate commit for it.