Multiple Leptons on one I2C bus (Raspberry Pi)

816 views
Skip to first unread message

Paul Cernek

unread,
Feb 18, 2016, 2:40:58 PM2/18/16
to Flir Lepton
Hi! We would like to have two Leptons interface with a single Raspberry Pi 2.

We can use the CS pins to alternate reading video from them over SPI.

However, when it comes to sending commands over I2C it seems that we're limited by the fact that the Lepton has only a single possible I2C address (0x2A). Thus it seems that we need to get an I2C multiplexer such as this one.

Before we do, anyone know if there's another (software) way around this?

Thanks!

Kurt Kiefer

unread,
Feb 18, 2016, 2:52:11 PM2/18/16
to Flir Lepton
What about using two different i2c busses? RPi has a second bus (i2c0) used for some internal stuff that can apparently be made to work: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=115709

Paul Cernek

unread,
Mar 3, 2016, 9:00:30 PM3/3/16
to Flir Lepton
Thanks for the suggestion Kurt! We'll try that; if that turns out to cause more problems than its' worth we'll go for a hardware solution.

Paul Cernek

unread,
Mar 3, 2016, 9:50:50 PM3/3/16
to Flir Lepton
Turns out that once I figured out how to do it, it was pretty simple to get /dev/i2c-0 to show up on i2cdetect -y 0 (running on Raspbian 4.1.13-v7+).

According to /boot/overlays/README:

 Note also that i2c, i2c_arm and i2c_vc are aliases for the physical
        interfaces i2c0 and i2c1. Use of the numeric variants is still possible
        but deprecated because the ARM/VC assignments differ between board
        revisions. The same board-specific mapping applies to i2c_baudrate,
        and the other i2c baudrate parameters.

Paul Cernek

unread,
Mar 3, 2016, 10:09:23 PM3/3/16
to Flir Lepton
Sorry about that. Accidentally pressed "Post" and it looks like the only way to "edit" a post is to delete it and repost.

Anyway, based on that README and what others have written around the web, I found the following to be sufficient to enable /dev/i2c-0:
  • Append to /boot/config.txt the following line: dtparam=i2c_vc=on
I had to make the following change in the code to get the Lepton to run on /dev/i2c-0. Note that this changes the Lepton to run exclusively on /dev/i2c-0; eventually I want to be able to run two Leptons, one on each I2C bus.
  1. In LeptonModule/software/raspberrypi_libs/leptonSDKEmb32PUB, make the following change to raspi_I2C.c:
    • In the function DEV_I2C_MasterInit, in the line that says leptonDevice = open("/dev/i2c-1", O_RDWR); change "/dev/i2c-1" to "/dev/i2c-0"
    • You'll need to change this back to i2c-1 if you want to interface with a camera 
    • This is a nasty workaround and should probably be made more flexible in the source code. I'm opening an issue on Github for a better solution.
  2. In your equivalent to LeptonSPI.cpp (which can be found in the directory raspberrypi_video), change the following:
    • Whenever you call LEP_OpenPort, make sure you change the first argument from 1 to 0.
And, of course, make sure that the Lepton's SDA is plugged into the Pi's ID_SD (pin 27), and that the Lepton's SCL is plugged into the Pi's ID_SC (pin 28).

Paul Cernek

unread,
Mar 4, 2016, 12:52:41 AM3/4/16
to Flir Lepton
Issue is currently open on GitHub: https://github.com/groupgets/LeptonModule/issues/23

Paul Cernek

unread,
Mar 13, 2016, 10:03:19 PM3/13/16
to Flir Lepton
Issue closed! :-)

Seren

unread,
Jul 14, 2018, 12:40:52 PM7/14/18
to Flir Lepton
Dear Kurt,

Can you please let me know how to run two leptons on one computer? I checked your previous post here https://groups.google.com/forum/#!topic/flir-lepton/OLyUetrvMow, which says 
uvc_find_device() can take optional arguments of PID and VID. By checking the USB devices, I got sth like this below. The two cameras are only different by the location ID.




Thanks very much!
Reply all
Reply to author
Forward
0 new messages