Comments: SX1509 I/O Expander Breakout Hookup Guide

Pages

Looking for answers to technical questions?

We welcome your comments and suggestions below. However, if you are looking for solutions to technical questions please see our Technical Assistance page.

  • Has anyone used an SX1509 pin with a Neopixel?

    Preferably the FastLED library.

  • Is there a device tree example anyone can provide that defines the sx1509 with the gpio-matrix-keypad driver? I am having a problem where the matrix keypad driver in linux will not start as it cannot map an IRQ with the sx1509 pinctrl driver. Any help would be much appreciated.

  • Hello, the advice below for porting SparkFun to raspberry pi seems to be incomplete, or perhaps it has become more involved with the latest version of the SparkFun library. For starters, there are 'byte' types sprinkled throughout the .cpp file and both header files, Wire.h must be replaced with wiringPi.h, remove references to Arduino.h, and a few other obvious steps. But beyond that, I am still seeing a bunch of compile errors. For instance, RPI is missing the constrain() function, and the references to Wire object need to be replaced with equivalent operations for wiringPi (I assume). Not sure if this is the extent of what I need to work through, or if this is just the tip of the iceberg. Am I missing something? has anyone ported the SparkFun library to raspberry pi lately?

  • Hi there! I am using 3 of those boards to drive 36 LEDs in my Arduino Fibbonacci clock project. Used 5x shift registers 74HC595 before, but got those for the PWM ability, and I am loving them! I wrote the code, everything works. There is just one thing that bothers me. When powering up, Arduino connects with those boards and lights up all the LEDs with full power. I would really like to avoid it. I have checked the library files for that, cannot find it. If you guys could point me to the line in SparkFunSX1509.cpp that does it so I can // it out, or how to disable that somehow. Would appreciate any help, thanks in advance!! Pat

  • To use it with the particle photon what I have to do with the code and connecting ?

  • "VCC1 and VCC2 Jumpers

    SJ1 and SJ2 on the back-side of the board connect VCC2 and VCC1, respectively, to the 3V3 voltage supply input. So, if you’re delivering 3.3V to the board, each of the I/O banks will operate at 3.3V."

    I believe you mean SJ2 and SJ3 on the back-side of the board connect VCC1 and VCC2 respectively.

    Thanks,

    Jeffery

  • Steps how to use Sparkfun SX1509 C++ Library on raspberry pi

    you might be facing compilation errors when compiling SX1509 C++ library. Below are the few errors which i faced when compiling and steps to fix them.

    Prerequisites

    • Install wiringPi on raspberry Pi

    • Download the Sparkfun library from github

    ** To compile **

    • g++ -c sx1509_registers.h SparkFunSX1509.h SparkFunSX1509.cpp -std=gnu++11 -lwiringPi -lpthread

    ERRORS

    sx1509_registers.h:142:1: error: ‘uint8_t’ does not name a type uint8_t REG_I_ON[16] = {REG_I_ON_0, REG_I_ON_1, REG_I_ON_2, REG_I_ON_3, ^ sx1509_registers.h:147:1: error: ‘byte’ does not name a type byte REG_T_ON[16] = {REG_T_ON_0, REG_T_ON_1, REG_T_ON_2, REG_T_ON_3, ^

    * Open the file sx1509_registers.h and replace "byte" with "unsigned char"
    * and execute the command above.
    * It should compile successfully and generate an object file "SparkFunSX1509.o" for you.
    

    **Generate an archive library using "SparkFunSX1509.o" **

    • ar rvs SparkFunSX1509.a SparkFunSX1509.o

    ** Compile the demo file available in the ** github

    * g++ main.cpp -o demo SparkFunSX1509.a -lwiringPi -lpthread -std=gnu++11
    

    Demo executable is generated now successfully. Now you can run it on raspberry pi and explore more capabilities of SX1509 I/O Expander Breakout board

  • Not clear on how to utilize and make calls if I'm using two or more SX1509 boards.

    Could someone provide a initialization and pin io example when using two or more boards?

    Is it as straightforward as: ...

    const byte SX1509_ADDRESS1 = 0x3E; 
    const byte SX1509_ADDRESS2 = 0x3F; 
    SX1509 io1,io2; 
    if (!io1.begin(SX1509_ADDRESS1))
        {
        while (1)
        ;
        }
    if (!io2.begin(SX1509_ADDRESS2))
        {
        while (1)
        ;
        }
    

    ... etc

    • Great question. I'm eager to hear the answer as well. Anyone?

    • It should be as simple as specifying the object:

      SX1509 io1, io2;
      io1.pinMode(SX1509_LED_PIN, OUTPUT);
      

      Would reference the first created object.

      No reason you can't call them whatever you want, so this should work, too:

      SX1509 demo1;
      demo1.pinMode(SX1509_LED_PIN, OUTPUT);
      

  • the fritzing diagram for the io test is wrong, button is shown connected to pin 0, but the code says 7

  • I have had success with the SX1509 interfacing to my Raspberry Pi 2 Model B running Raspbian GNU/Linux 9 (stretch) using cmake (sudo apt-get install cmake) with the type of CMakeLists.txt file found at https://github.com/hoppler/SparkFun-SX1509. I have not had to make the "byte" to "unsigned char" changes that Sasi described in the post above to avoid compiler errors. (I use the command cmake . (cmake <space> <dot>) once to set up the compile environment and make to compile the executable.)

    From https://github.com/sparkfun/SparkFun_SX1509_Arduino_Library I adapted the Arduino program keypadInterrupt.ino to implement 4x7 and 8x8 button switch systems using WiringPi interrupt handling. My wires connecting from switches to the SX1509 are longer than they probably should be, so I had to include some code to do some additional debouncing work beyond what the SX1509 library code provides.


If you've found a bug or have other constructive feedback for our tutorial authors, please send us your feedback!