• Hi everyone, I'm trying to read a HC-SR501 with my nodeMCU but I struggle a bit :(

    Wiring :

    VCC to vin (5V)
    OUT to A0
    GDN to GDN

    I tried :

    setWatch(function() {
      console.log("Movement detected");
    }, NodeMCU.A0, {repeat:true, edge:"rising"});

    Never got any detection

    I tried

    setInterval( () =>{
       console.log( analogRead(NodeMCU.A0) );
      // print 0.00097751710 all the time

    I swapped the sensor for a water level sensor and console.log( analogRead(NodeMCU.A0) ); and the water level is detected normally.

    Did I miss something ?

    Thank you a lot for your help :)

  • HC-SR501 datasheet describes output as "TTL output: 3.3V, 0V" so try a D pin like NodeMCU.D1

  • Hi MaBe,

    Thanks for the heads-up :)

    I'm gonna try this.

  • Issue resolved :)

    I tried a digital pin without any success :(

    I tried an other HC-SR501 and it worked. So my sensor was definitely broken.

    here the code that's working :

    setWatch(function() {
      console.log("Movement detected at : ", Math.floor(Date.now() / 1000) );
    }, NodeMCU.D6, {repeat:true, edge:"rising"});
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

HC-SR501 ( motion sensor )on nodeMCU, is my sensor broken ?

Posted by Avatar for Antoine @Antoine