9 Replies Latest reply on May 24, 2016 5:44 PM by Intel Corporation

    Having trouble reading digital input using Sparkfun GPIO breakout board


      I'm very new to this (I've messed around with Arduinos a little bit) and I just started using my Edison and I am currently trying to get it working with an infrared sensor (TSOP38238), after struggling for quite a while I realized my problem was simply with any kind of digital input. As mentioned in the title I'm using the Sparkfun GPIO breakout board (SparkFun Block for Intel® Edison - GPIO - DEV-13038 - SparkFun Electronics), so all IO is level shifted to 3.3V. I decided to really simplify things, I had the 3.3 VCC connected to a 10k Ohm resistor and a jumper I could remove connecting it to ground, and a line between the resistor and the jumper going to GP44 on the GPIO board (See image below). In theory when the jumper is removed the pin should read high, and when the jumper is added it should read low. I created a very simple C++ program to just set the pin as input and read it 4 times per second, printing the response. What I saw happening was that when I started the program with no jumper it was reading high, and as soon as I added the jumper it would drop low. However, once I took the jumper out it would stay low for about 5 seconds before going high again. When I hooked up my multimeter I could see as soon as I took the jumper out the voltage was only around 1.2V for that 5 seconds (hence reading low) and would then go back to the 3.3. It is acting like there is a very large capacitor it is charging. And sure enough, when I replaced the 10k Ohm resistor with a 330 Ohm resistor it now registers the change almost instantly (faster than I can notice at least). Worrying that it was something in my code I connected to my device using the serial port, insured that GP44 was in input mode and read the values from "/sys/kernel/debug/gpio_debug/gpio44/current_value" and I was still seeing the same behavior. Is 0.33 mA not enough current to drive the input of this board? Again I'm very new to this so I don't fully understand how the internal pull up resistor may be effecting this, the pullmode is currently the default "pullup" and pullstrength is the default "50k", is this something I should change? The final application I plan on making will be battery powered so I would like to minimize power consumption where possible.


      And for those curious my C++ code is simply:

      #include "mraa.hpp"
      int main() {
        mraa_gpio_context pin31 = mraa_gpio_init(31);
        mraa_gpio_dir(pin31, MRAA_GPIO_IN);
        int in;
        for (;;) {
          printf("switch %d \n",in);
        return mraa::SUCCESS;