vitotai / BrewManiacEsp8266

BrewManiac on ESP8266. Only ESP8266 needed.
155 stars 71 forks source link

LevelSensor "normal-open" #40

Open EroshKA opened 5 years ago

EroshKA commented 5 years ago

I want to use a normally open level sensor in my system. Can I change the code to work with such a sensor?

vitotai commented 5 years ago

The code to check "fullness" of water is at

https://github.com/vitotai/BrewManiacEsp8266/blob/37abaa4f665191833882669f77456036f338f21d/src/pins.h#L224

The default code is supposed to work with "Normal Open". If the wort/water level is not high enough to trigger the level sensor, the level sensor is "Open" and the signal should be "High". When the sensor is "triggered", it should be "closed" and short the PIN to GROUND, which results in "LOW" state of the PIN.

If you get opposite result, change the code to

return (_portvalue & LevelSensorIOExpPin) !=0;

EroshKA commented 5 years ago

it worked so well for me

if EnableLevelSensor

// close/connected/ground: not full // open/disconnected/V+: full

if SensorNormalCloseOnNotFull

if LevelSensorOnIoExpander

bool isWaterLevelFull(void){ // _portvalue is read for button every loop cycle return (_portvalue & LevelSensorIOExpPin) !=1; }

else

bool isWaterLevelFull(void){ return digitalRead(LevelSensorPin) != 1; }

endif

else

if LevelSensorOnIoExpander

bool isWaterLevelFull(void){ // _portvalue is read for button every loop cycle return (_portvalue & LevelSensorIOExpPin) !=1; }

else

bool isWaterLevelFull(void){ return digitalRead(LevelSensorPin) == 1; }

endif

endif //#if SensorNormalCloseOnNotFull

endif // EnableLevelSensor

Thanks you