0

I've written similar code in python that works as expected.

Using one of these moisture sensors: https://www.amazon.com/dp/B00ZR3B60I

The following code always prints "true"

const rpio = require('rpio'); 
rpio.open(12, rpio.INPUT);
console.log('Pin 12 is currently ' + (rpio.read(12) ? 'true' : 'false'));

Weather the sensor is submerged or not, regardless of the light on sensor (which I assumed was a visual HIGH or LOW) it will always come back true. When I remove the wire from the sensor, it will read false (as expected).

I've tried multiple node libraries all with the same result.

pi@pi-zer00:~ $ cat /etc/debian_version
9.4
pi@pi-zer00:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
pi@pi-zer00:~ $  uname -a
Linux pi-zer00 4.14.52+ #1123 Wed Jun 27 17:05:32 BST 2018 armv6l GNU/Linux
  • Maybe wrong pin number? rpio uses the physical pin number, not the GPIO number. – Edgar Bonet Aug 2 '18 at 10:46
  • I know it's the right pin because when I remove the jumper wire from the sensor, it changes the reading. I've also tried setting the pin using both the phys and GPIO numbers using rpio.init({mapping: 'gpio'}); – J.Milliscone Aug 2 '18 at 14:11
0

The issue was a hardware one. Once I changed the sensor, it worked. Not sure why my last answer was marked worng. It's my question and it's working as expected....

  • You can accept your own answer. :D – OyaMist Aug 2 '18 at 16:27
  • Some moderator deleted my last answer...... – J.Milliscone Aug 2 '18 at 18:41
  • Whoa! That is a bad experience for you. I am sorry this has happened to you. Please forgive us. I am glad your issue is resolved! :D – OyaMist Aug 2 '18 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.