hans_ober
Posts: 4
Joined: Tue Mar 13, 2018 12:46 pm

Sense HAT LED matrix i2c protocol

Tue Mar 13, 2018 12:52 pm

Is there any documentation on the actual i2c protocol that the AVR MCU on the Sense HAT uses? I couldn't find the firmware of the AVR that drives the LED matrix.
I'm trying to use the SenseHAT with another microcontroller, and with software emulated i2c on the Pi.

User avatar
DougieLawson
Posts: 33813
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Sense HAT LED matrix i2c protocol

Tue Mar 13, 2018 5:40 pm

The SenseHAT code at: https://github.com/RPi-Distro/python-sense-hat doesn't access any I2C devices. The pixels are set up as a 64 pixel RGB565 frame buffer (how that's driven by the RPi is not documented).

There's docs at: https://www.raspberrypi.org/documentati ... /README.md
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5308
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Sense HAT LED matrix i2c protocol

Tue Mar 13, 2018 5:56 pm

The idea is to talk to the device directly rather than through the linux driver.

Firmware source is here:
https://github.com/raspberrypi/rpi-sense

hans_ober
Posts: 4
Joined: Tue Mar 13, 2018 12:46 pm

Re: Sense HAT LED matrix i2c protocol

Wed Mar 14, 2018 5:25 pm

ShiftPlusOne wrote: The idea is to talk to the device directly rather than through the linux driver.

Firmware source is here:
https://github.com/raspberrypi/rpi-sense
DougieLawson wrote: The SenseHAT code at: https://github.com/RPi-Distro/python-sense-hat doesn't access any I2C devices. The pixels are set up as a 64 pixel RGB565 frame buffer (how that's driven by the RPi is not documented).

There's docs at: https://www.raspberrypi.org/documentati ... /README.md
I had a look at the docs on github, and nothing is mentioned about the I2C protocol the AVR uses. The firmware for the AVR isn't posted either.
Without any of this, it will be nearly impossible to use I2C commands to control the AVR (without using the standard driver), right?

EDIT:
https://github.com/raspberrypi/rpi-sens ... ter/main.c didn't seem to have much in it, but https://github.com/raspberrypi/rpi-sens ... pi-sense.S has assembly code. I'll need to have a closer look at it and see if it can be used.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5308
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Sense HAT LED matrix i2c protocol

Wed Mar 14, 2018 7:27 pm

It can definitely be used. The information is off the top of my head, so I can't give you the specifics, but there's really nothing tricky to it.Try i2cget and i2cset to write to the first few registers and the rest should be obvious.

I'm sure I've seen straight C libraries for talking to it, but the first one I found is a C# one: https://github.com/emmellsoft/RPi.Sense ... Support.cs

hans_ober
Posts: 4
Joined: Tue Mar 13, 2018 12:46 pm

Re: Sense HAT LED matrix i2c protocol

Thu Mar 15, 2018 5:24 pm

ShiftPlusOne wrote:
Wed Mar 14, 2018 7:27 pm
It can definitely be used. The information is off the top of my head, so I can't give you the specifics, but there's really nothing tricky to it.Try i2cget and i2cset to write to the first few registers and the rest should be obvious.

I'm sure I've seen straight C libraries for talking to it, but the first one I found is a C# one: https://github.com/emmellsoft/RPi.Sense ... Support.cs
My application is based on Python, so I'll try using a Python i2c library.

hans_ober
Posts: 4
Joined: Tue Mar 13, 2018 12:46 pm

Re: Sense HAT LED matrix i2c protocol

Fri Mar 16, 2018 5:44 am

https://github.com/4eMaLo/SenseHAT-Game-of-Life

I tried this out and it works perfectly!

alphanumeric
Posts: 1535
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Sense HAT LED matrix i2c protocol

Sun Mar 18, 2018 1:30 pm

Pinout and other info here, https://pinout.xyz/pinout/sense_hat# if that helps?

Return to “Astro Pi”

Who is online

Users browsing this forum: No registered users and 2 guests