Announcement

Collapse
No announcement yet.

Arduino Script Help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Arduino Script Help

    Hey guys,

    I have an ultrasonic sensor in my cistern connected to an Arduino that uploads data to a local MQTT server so that HS can control and monitor the cistern water level and fill when needed as well as other things.

    The major issue I have is that the Ultrasonic sensor that I am using sends out random false reading. I am using a couple filters that makes it much better, but even one really false reading (reporting 198% full when only 75% full) plays havoc on my system. Basically when the cistern if really at 100% it stope the fill cycle, so if I have run out of water a couple times because one false reading shuts everything down.

    Basically I am having issues coming up with the perfect logic. The idea is to compare the previous reported value and only accept a reading that is only 1-2 CM higher or lower. The cistern does not change levels fast and the arduino script reports to the MQTT every 20 seconds, and HS updates the cistern logic every 2 minutes.

    I am currently trying things like this:

    if ( (LastReportedDistance <= distance-2) || (LastReportedDistance >= distance+2 ) ) {


    what do I need to addas this reports true when it should not? It usually reports higher so removing <= check may be all I need, but feel like I should code for the possible time that it reports a negative.

    I have been staring at this for weeks and everything I try breaks something else.
    Kirk

    http://cleverhouseautomation.ca
    http://southcoastwebsitedesign.ca
Working...
X