Home Statistiscs

Index

  1. Index
  2. MCP23017 I2C Digital I/O
  3. Home Statistics
  4. SW

MCP23017 I2C Digital I/O

MCP23017.png

Here is the full Datasheet of the MCP23017 family.

Home Statistics

Cistern feeding time

This time is measured on the valve which opens, when cistern level is very low. The valve itself have a high magnetic field on the opposite side of the pipe ports. A small magnetic switch or read contact is installed. One side of the switch is connected to ground and the other one to the GPA0 port of the MCP23017. The internal pull up resistor must be switched on. The state of the switch at start up of the programm is stored with date and time. The state of the switch is read out every second and if it had changed, the new state is stored with date and time.
valve.png valve_sensor1.png valve_sensor2.png home.png
Valve Switch

Warm water heat pump time

This time is measured ...
The detection and storage is done equal as described above.

Solar pump time

This time is measured ...
The detection and storage is done equal as described above.

Cistern level

The cistern level shall be measured in 4 % steps by using 5 bit in grey code with the following table:
0 % 4 % 8 %12 %16 %20 %24 %28 %32 %36 %40 % 44 %48 %52 %56 %60 %64 %68 %72 %76 %80 %84 % 88 %92 %96 %100 %
Bit 0 0110011001110 0110011001100
Bit 1 0011111100011 1100001111110
Bit 2 0000111111000 1111000000111
Bit 3 0000001111111 1111111100000
Bit 4 0000000000000 1111111111111
Hex 0001030206070F0E0C0D090B0A 1E1F1D1C18191B1A1213171614

For measuring the water level a closed pipe or rod is used which is mounted in the cistern by hanging on a spring. The pipe or rod must have a density higher than water. The following picture and formulas show the dependency between water level x and change of the spring length.
sketch1.png Formula4CisternLevel.png FFeder: Force on the spring [N]
l: lengthen because of force of the spring [m]
k1: Spring constant [N/m]
d: diameter of pipe or rode [m]
m: mass of the pipe or rode [kg]
g: acceleration of gravity, 9.81 [m/s2]
x: hight of water [m]
s: gab between bottom of cistern and actual pipe position, 0 if x = 0 [m]
ρ: density of water [kg/m3]
lmax: maximum lenghten of spring, s shall be almost 0 [m]

The measurement is done by adding a metal stripe with at least a length of smax below the spring. smax is calculated with the above shown formula and the maximum level in the cistern. This plate is connected to ground and isolated on one surface on the places where the table above has zeros. 5 contacts which can slide over this surface are connected to the MCP23017 port A bit 0..4.
plate.png
Here are the values of my cistern and sensor:
k1 = N/m
d = m
m = kg
xmax = m

SW

The SW for reading the values is running in the background program "TS_HomeServer" on my Raspberry Pi 2. This program is running as daemon and provides a task system with different cycle times and a init part. This daemon is described here.
All own written SW is stored in the files OwnI2C.cc and OwnI2C.h and is divided in different classes.

Class ComI2C

This class summarises all function needed for the I2C communication using the "wiringPI" library.

home.png