Sonoff Wifi Switch, GPIO14 and interrupts



  • The Sonoff has a 'spare' GPIO number 14.
    I hooked this up to a Hall Effect Water Meter and tried to count the pulses.
    The Arduino sketch I wrote works fine on the NODEMCU but doesn't record interrupts on the Sonoff.
    For the NODEMCU the board was set as NodeMCU 0.9, for the Sonoff I set it as Generic ESP8266
    I'm open to ideas as to why I'm not getting interrupts.
    Awaiting your valuable insight



  • can you post some code? interrupts work fine with my sonoff:

    attachInterrupt(PIN_PIR_SENSOR, ISR_PIRPinHasChanged, CHANGE);
    [...]
    void ISR_PIRPinHasChanged(){
      int currentPinStatus = digitalRead(PIN_PIR_SENSOR);
      if(currentPinStatus == LOW){
        Serial.println("ISR fired, pin LOW");
      }
      else{
        Serial.println("ISR fired, pin HIGH");
        ToggleRelay();
      }
    }
    
    ISR fired, pin LOW
    ISR fired, pin HIGH
    toggling relay to OFF
    switching off
    sending status to controller
    ISR fired, pin LOW
    ISR fired, pin HIGH
    toggling relay to ON
    switching on
    sending status to controller
    ISR fired, pin LOW
    ISR fired, pin HIGH
    toggling relay to OFF
    switching off
    

Log in to reply
 

Suggested Topics

  • 87
  • 9
  • 7
  • 3
  • 1
  • 8

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts