I've got a weird issue, probably something I'm missing but have no clue what.

Got some simple float sensors connected to D2 - D5 on a Nano. Need internal pull-up to eliminate a floating value. Wrote this little sketch to test things:

pinMode(2, INPUT_PULLUP);
int sensorVal = digitalRead(2);

pinMode(3, INPUT_PULLUP);
int sensorVal = digitalRead(3);

There's one sensor connected reading HIGH and one reading LOW. This works as expected (displays 1010101010...).

Now I've got this connected to my Raspberry Pi via Bluetooth (BT shield connected to RX/TX) and using Firmata to communicate with the Nano. Code (C#):

_arduino.pinMode(2, PinMode.PULLUP);
PinState result2 = _arduino.digitalRead(2);

_arduino.pinMode(3, PinMode.PULLUP);
PinState result3 = _arduino.digitalRead(3);

Debug.WriteLine($"Result pin 2: {result2} and pin 3: {result3}");

This always gives me two pinstates of LOW, even though I'm absolutely sure it should be reading HIGH as my test sketch is outputting the correct value. This driving me nuts. The Firmata sketch I've got loaded on the Arduino is this one: https://github.com/jsiegmund/submerged/blob/master/src/Arduino%20Sketches/SubmergedCabinetModule/SubmergedCabinetModule.ino. Also tried the latest available version from the firmata repo, doesn't solve the issue. As I've got the BlueTooth shield connected to RX/TX (and wasn't able to change that) I cannot use the serial monitor to provide more debug info. Should anyone know how to change that, would also be appreciated.

Btw for other things, Firmata is working just fine. So the communication itself shouldn't be the issue I think.

  • Are you sure pinNumber is 2 when you are calling _arduino.digitalRead(pinNumber) ? and you do have a semicolon at the end of that line right ? Jul 26 '16 at 22:20
  • Absolutely sure and yes it's there :) I'll see whether I can create a very simple test app which does the same to rule out interference of other code.
    – Jasper
    Jul 27 '16 at 5:40

Never mind, I found out what the problem is. The Firmata SDK (Remote Wiring) for Windows just completely ignores the PULLUP pin mode. There are PR (https://github.com/ms-iot/remote-wiring/pull/102) which fixes this, now it's working just fine.

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.