Comments: SX1509 I/O Expander Breakout Hookup Guide
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.
If you've found an issue with this tutorial content, please send us your feedback!
Hi All. In case anyone is still interested, I have ported the code to run in python on a Raspberry Pi. More details are here: https://github.com/ilikecake/SX1509-Python.
Has anyone used an SX1509 pin with a Neopixel?
Preferably the FastLED library.
Hi All, recently I am trying to address multiple I/O expanders as mentioned up to 4 units. But somehow I am unable to configure and read out 0x70 address. The other 3 are well received from the MCU. Is anyone facing the same issue? If so how to overcome this 0x70 address. I will need it all 4 addresses to be used.
Hey there, 1.) I'm interested in using the SX1509 for a 8x8 button matrix. I have read through the datasheet of the SX1509 to understand how the buttons have to be wired up. I understand the simple row/column layout for the 12 button keypad. But in this setup, multiple button pressed (or buttons being held) will cause problems, correct? Can I just make use of those diodes after each button to prevent this?
2.) How to deal with latching buttons? Since they are always "on" … can I wire them up in button matrices and make use of the SX1509s keypad engine as well? Is the interrupt only firing on the buttons state change … ?
Thanks
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, Late reply, but in case anyone is still wondering: I have successfully ported the library to use on the Raspberry Pi. If anyone is interested, you can find my updated code here. Here is a rough outline of what I have done:
There are a lot of 'byte' types in the source, which I replaced with 'unsigned char' types.
There are a few defines that are taken from the Arduino libraries that need to be replaced in 'SparkFunSX1509.h'. If you are using 'wiringPi.h' you do not need to define some of these.
The Arduino function 'constrain' needs to be replaced. I wrote a very simple one as shown below. Note: this function will probably not work as intended for negative constraints, so I need to fix it when I get a chance. I put this in the top of 'SparkFunSX1509.c'
The six I2C read and write functions at the bottom of 'SparkFunSX1509.c' (readByte, readWord, readBytes, writeByte, writeWord, writeBytes) need to be changed to use the wiringPi library. Note that there is an endianness issue with the wiringPi 'WriteReg16' and 'ReadReg16'. I used two 8-bit writes instead.
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 **
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, ^
**Generate an archive library using "SparkFunSX1509.o" **
** Compile the demo file available in the ** github
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
See my top-posted comment. The steps above seem to be insufficient, at least with the current version of SparkFun.
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: ...
... etc
Great question. I'm eager to hear the answer as well. Anyone?
It should be as simple as specifying the object:
Would reference the first created object.
No reason you can't call them whatever you want, so this should work, too:
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.