flyte/mqtt-io

Sensor status keeps switching

msantic opened this issue · 2 comments

Hi, could someone help me with this. I'm testing window switch sensor (open/close position) for my alarm central. I can't figure out why when I open the window mqtt keep switching the values True/False/True/False when physically windows remains open? Here is what I get (gif attached)

mqtt alarm2

My config.yml for that sensor looks like this:

digital_inputs:
  - name: north_window
    module: rpi
    pin: 18
    inverted: yes
    retain: yes

Hardware

  • Platform: Raspberry Pi
  • Connected hardware: switch contact sensors

System:

  • OS: [e.g. Raspbian]

Thank you

How did you connect your sensor electrically? Do you have an external pull-up / pull-down resistor in circuit?
If not, that's your problem. Your input pin isn't in a well-defined state when the window is open, and noise is picked up.
Add pullup: true or pulldown: true (choose one depending on your electrical circuit) to enable internal pull-up / pull-down resistor.

@ondras12345 you are savior! I don't have external pull-up/down resistor even though I know I should. I did some basic testing and haven't seen any difference so I simplifed wiring. Maybe wires are not long enough to generate noise or/and are quality ones (they are specifically for sensors). I'm not an expert in electronics so just lucky guess.

Adding pulldown: true did the trick!

Now config looks like this and works like charm

  - name: north_window
    module: rpi
    pin: 24
    inverted: yes
    retain: yes
    pulldown: true

Thank you very much for your help