Twig
Posts: 3
Joined: Fri Aug 05, 2022 7:11 pm

Multiple 7-Segment Displays

Fri Aug 05, 2022 7:21 pm

I am a beginner to the i2c area and am looking for some advice for my project.

I would like to plug four 4-digit 7-Segment i2c displays into my Pico and control each one separately. These are the displays I have: https://thepihut.com/products/grove-4-digit-display. However, each of these displays will have the same i2c address; so from what I understand of i2c, they will not all work on the same i2c pin out of the box.

Therefore, an i2c multiplexer is needed! But how will I code the displays with the multiplexer, as I am using the following module to control the display: https://github.com/mcauser/micropython-tm1637? I am unsure of which address to change for each display in order to have them all plugged in at the same time and be able to control them separately. The display works individually with the code linked above, but not separately due to the displays having the same i2c address.

The i2c multiplexer I have is this one: https://thepihut.com/products/adafruit- ... ultiplexer

Thank you for any help with this in advance!

User avatar
rpdom
Posts: 20380
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Multiple 7-Segment Displays

Fri Aug 05, 2022 8:42 pm

The Pico has two hardware i2c buses, so you could drive two displays, one of each bus.

You can also use the PIOs to add more software i2c buses. There's an example of code to do that in the RP2040 Datasheet and in the pico-examples.
Unreadable squiggle

fivdi
Posts: 562
Joined: Sun Sep 23, 2012 8:09 pm

Re: Multiple 7-Segment Displays

Fri Aug 05, 2022 8:47 pm

Have you read this: https://learn.adafruit.com/adafruit-tca ... t?view=all
I would expect it to explain what needs to be done.
https://github.com/fivdi

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 31363
Joined: Sat Jul 30, 2011 7:41 pm

Re: Multiple 7-Segment Displays

Sat Aug 06, 2022 6:28 am

Twig wrote:
Fri Aug 05, 2022 7:21 pm
I am a beginner to the i2c area and am looking for some advice for my project.

I would like to plug four 4-digit 7-Segment i2c displays into my Pico and control each one separately. These are the displays I have: https://thepihut.com/products/grove-4-digit-display. However, each of these displays will have the same i2c address; so from what I understand of i2c, they will not all work on the same i2c pin out of the box.

Therefore, an i2c multiplexer is needed! But how will I code the displays with the multiplexer, as I am using the following module to control the display: https://github.com/mcauser/micropython-tm1637? I am unsure of which address to change for each display in order to have them all plugged in at the same time and be able to control them separately. The display works individually with the code linked above, but not separately due to the displays having the same i2c address.

The i2c multiplexer I have is this one: https://thepihut.com/products/adafruit- ... ultiplexer

Thank you for any help with this in advance!
Depending on the driver chip involved there may be some links on the PCB of the Led panel that enable you to change the i2c address?
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.

ame
Posts: 5408
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Multiple 7-Segment Displays

Sat Aug 06, 2022 8:17 am

That is not an i2c display. Discuss.
Hmm. What can I put here?

Twig
Posts: 3
Joined: Fri Aug 05, 2022 7:11 pm

Re: Multiple 7-Segment Displays

Sat Aug 06, 2022 8:32 am

Thank you for sharing the Adafruit links. There are no pins to change the board's address :(
So I am going to use the i2c expander with it: what areas of the code I linked do I need to change?
ame wrote:
Sat Aug 06, 2022 8:17 am
That is not an i2c display. Discuss.
Really? It uses the TM1637 chip...

Thanks!

ame
Posts: 5408
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Multiple 7-Segment Displays

Sat Aug 06, 2022 8:57 am

Twig wrote:
Sat Aug 06, 2022 8:32 am
ame wrote:
Sat Aug 06, 2022 8:17 am
That is not an i2c display. Discuss.
Really? It uses the TM1637 chip...

Thanks!
Really.
Hmm. What can I put here?

ghp
Posts: 2558
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany

Re: Multiple 7-Segment Displays

Sat Aug 06, 2022 8:57 am

There is a micropython library which is bitbanging GPIO.
https://github.com/mcauser/micropython-tm1637
You could use separate GPIO pins SCK, DIO for each display, needing 8 in total. If you tweak the library, then one DIO and 4 SCK would be possible.

The datasheet says: "The communication is not equal to I2C protocol totally because there is no slave address."

Multiple display, here a sample for two

Code: Select all

tm0 = tm1637.TM1637(clk=Pin(16), dio=Pin(17))
tm1 = tm1637.TM1637(clk=Pin(18), dio=Pin(19))

Twig
Posts: 3
Joined: Fri Aug 05, 2022 7:11 pm

Re: Multiple 7-Segment Displays

Sat Aug 06, 2022 9:49 am

ghp wrote:
Sat Aug 06, 2022 8:57 am
There is a micropython library which is bitbanging GPIO.
https://github.com/mcauser/micropython-tm1637
You could use separate GPIO pins SCK, DIO for each display, needing 8 in total. If you tweak the library, then one DIO and 4 SCK would be possible.

The datasheet says: "The communication is not equal to I2C protocol totally because there is no slave address."

Multiple display, here a sample for two

Code: Select all

tm0 = tm1637.TM1637(clk=Pin(16), dio=Pin(17))
tm1 = tm1637.TM1637(clk=Pin(18), dio=Pin(19))
Thank you, what part of the code in the module do I need to change so that I can use 1 DIO pin (I would like to conserve as many pins as I can on the Pico)?

ame
Posts: 5408
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Multiple 7-Segment Displays

Sat Aug 06, 2022 10:23 am

Twig wrote:
Sat Aug 06, 2022 9:49 am
ghp wrote:
Sat Aug 06, 2022 8:57 am
There is a micropython library which is bitbanging GPIO.
https://github.com/mcauser/micropython-tm1637
You could use separate GPIO pins SCK, DIO for each display, needing 8 in total. If you tweak the library, then one DIO and 4 SCK would be possible.

The datasheet says: "The communication is not equal to I2C protocol totally because there is no slave address."

Multiple display, here a sample for two

Code: Select all

tm0 = tm1637.TM1637(clk=Pin(16), dio=Pin(17))
tm1 = tm1637.TM1637(clk=Pin(18), dio=Pin(19))
Thank you, what part of the code in the module do I need to change so that I can use 1 DIO pin (I would like to conserve as many pins as I can on the Pico)?
You need one DIO pin connected to all modules, and four CLK pins, one to each module.
Hmm. What can I put here?

Return to “Interfacing (DSI, CSI, I2C, etc.)”