Page 1 of 1

Sense HAT What is I2C and do I need to enable?

Posted: Mon Oct 09, 2017 11:17 am
by Anne_Carlill
I'm trying to write a troubleshooting document for using the Sense HAT for myself and other people who are using this HAT for the first time. Many, like me, will be starting out so we can do Astro Pi activities with children. While I was getting Sense HAT to work someone, in a forum, said, 'Enable I2C'. You can do this from the main applications menu on the GUI (Graphical User Interface) by choosing, Preferences then Raspberry Pi Configuration then the Interface tab. But is it necessary?

Re: Sense HAT What is I2C and do I need to enable?

Posted: Mon Oct 09, 2017 11:27 am
by scotty101
I2C is definitely required for the SenseHAT to work correctly. I'm not sure whether it is enabled by default on Raspbian but doing this via the "Raspberry Pi Configuration" certainly isn't going to hurt.

I2C is the communication protocol/port used to communicate with the sensors and LEDs on the SenseHAT.

Re: Sense HAT What is I2C and do I need to enable?

Posted: Mon Oct 09, 2017 12:05 pm
by Anne_Carlill
Thanks very much Scotty101 that really helps! Anne

Re: Sense HAT What is I2C and do I need to enable?

Posted: Mon Oct 09, 2017 12:54 pm
by Davespice
In the latest image of Raspbian Stretch I believe it is turned on by default, in which case enabling it in that menu is a red herring.

Re: Sense HAT What is I2C and do I need to enable?

Posted: Tue Oct 10, 2017 10:34 am
by Anne_Carlill
That's good. I'm using Jessie at present but Stretch will be great!

Re: Sense HAT What is I2C and do I need to enable?

Posted: Sat Oct 14, 2017 11:15 pm
by mlepage
As for what is I2C... it's a very simple serial protocol using only two wires. One is a clock (signal voltage goes up and down) and the other is data (up or down during a clock signal to be counted as a 0 or 1 binary digit). E.g. you can use it to communicate to a sensor, or an Arduino microcontroller.

Re: Sense HAT What is I2C and do I need to enable?

Posted: Mon Oct 16, 2017 10:24 am
by Anne_Carlill
Thanks mlepage. That explains it very clearly. Incidentally, for Sense HAT newbies like me, I've now written a guide at http://geekgran.wordpress.com . Scroll down to the Sense HAT - how to get your Sense HAT working post.

Re: Sense HAT What is I2C and do I need to enable?

Posted: Mon Oct 16, 2017 4:20 pm
by bensimmo
I thought it turned its self on when the Sense-hat is fitted to the Pi.
(The EEPROM ID 'tells it to')

So no need to turn it on yourself.

Re: Sense HAT What is I2C and do I need to enable?

Posted: Tue Oct 17, 2017 8:02 am
by Anne_Carlill
Hi Ben,

It seems to only do this if you are using Raspbian Stretch. I've stayed with Jessie for the moment.

Re: Sense HAT What is I2C and do I need to enable?

Posted: Tue Oct 17, 2017 8:21 am
by bensimmo
I've always been on Jessie and only ever use my SenseHATs on them.
(Stick to Jessie as that is what is used on the AstroPi

They'll know in the AstroPi section, but i'm pretty sure I put the hat on and it just works. The dtoverlay is found from the EEPROM (HAT standard ID) and autoload and sets it all up.

I know recently from github there have been a few not seeing the EEPROM, by the looks of it and needing to be forced to work.
HAT problem or Software problem, I don't know. (I think most are good contact with the pins, it's cropped up a lot in the python SenseHat github)

Of course it does no harm checking.


There is a specific image that can be used for the AstroPi competition, Davespice above is the man who know where all that is also cannot remember the link.

Re: Sense HAT What is I2C and do I need to enable?

Posted: Tue Oct 17, 2017 9:46 am
by Anne_Carlill
Yes, Ben Nuttall couldn't understand why I had to do the dtoverlay = rpi-sense bit. Anyway I've summarised all the possible snags, I've had with the Sense HAT, here: https://geekgran.wordpress.com/ in the post Sense HAT - how to get your Sense HAT working. It might help newbies to it, like me.

Re: Sense HAT What is I2C and do I need to enable?

Posted: Tue Oct 17, 2017 11:06 am
by bensimmo
You might want to add this little it
The Astro Pi kits, for this year's challenge, will be using this NOOBS image http://downloads.raspberrypi.org/AstroP ... 017-09-04/ which is based on Jessie. This will give you working push buttons out of the box.
From viewtopic.php?f=104&t=194372&p=1217689#p1217689

That would then be a known good working image for the AstroPi.
I canot tell you what it has (desktop, no desktop etc) as being in a school downloads are restricted :roll:

Re: Sense HAT What is I2C and do I need to enable?

Posted: Tue Oct 17, 2017 11:39 am
by Anne_Carlill
Thanks Ben.

Anne

Re: Sense HAT What is I2C and do I need to enable?

Posted: Tue Oct 24, 2017 5:04 am
by Elfen
Somewhere I read that the Sense Hat has an Amtel Tiny88 Micro controller in it. I maybe wrong but that is what I read and it would answer many questions about IC2. It would make reading the sensors easier to read without tying up resources on the Raspberry Pi. Tying up resources will slow down a Pi.

The IC2 is basically, IN THE SIMPLEST EXPLANATION, a serial port which chips can talk to each other serially on 1 or 2 wires. The R-Pi has them, and strangely enough, the Arduinoes have them. I've seen U-Tube Videos where more than one Arduino is "talking" to several others through IC2, running the wires in parallel from unit to unit..The key here is to write the program so that the Sender send an "ID-Key" which all the others gets but only one accepts and the others ignore. Each Arduino would have its own unique "ID-Key' from which they use to listen or ignore commands.

If we were not talking about the Sense Hat, we could have several R-Pies talk each other in this way and we would not tie up USB Hubs or Ethernet/Wifi Routers (a major plus for complex robotics projects). With the Sense Hat, the R-Pi talks to the Sense Hat using the IC2 and the Sense Hat sends back what the R-Pi wants.

The last installment of Jessie has this on, as I discovered when I built my AstroPi, so there was nothing to configure. Now, for the quick and dirty - in theory and a bit of hacking the Sensor Hat Tiny 88 chip and the Raspbian, you can have the R-Pi talk to several Sense Hats or talk to a Sense Hat and an Arduino or another Raspberry Pi through IC2. But the problem lies in how open that code is and can one flash and reflash the Tiny88 on the Sense Hat or not. I'll leave that dirty work to the hackers... my brain is numb from lack of sleep. I can see how it would work but it would be an elusive dream for me to achieve in this mental state.

But it best to leave it as is and work with it as one needs to use it - gather data from the sensors. It works fine as is with Jessie without putting a configuration flag on.

If you have an Older Jessie, you should update and upgrade with:

Code: Select all

sudo apt-get update
sudo apt-get upgrade
This will insure that your Jessie is up to date with the Sense Hat software configurations and work without setting any configuration files. It would be Plug & Play at this point.

Re: Sense HAT What is I2C and do I need to enable?

Posted: Tue Oct 24, 2017 9:57 am
by bensimmo
Elfen, it is some more details (and a link to the schematics with it on are here https://www.raspberrypi.org/documentati ... sense-hat/
It however doesn't have the AVR part on there yet (still)
I believe though the 3 sensors just run over the standard connection on the I2C bus, not via the Atmel AVR Attiny88 which controls the LEDs and Joystick.
and yes you can modify it if you want.

...One minute
https://www.raspberrypi.org/blog/buy-th ... -in-space/

Re: Sense HAT What is I2C and do I need to enable?

Posted: Tue Oct 24, 2017 8:48 pm
by Elfen
bensimmo wrote:
Tue Oct 24, 2017 9:57 am
I believe though the 3 sensors just run over the standard connection on the I2C bus, not via the Atmel AVR Attiny88 which controls the LEDs and Joystick.
and yes you can modify it if you want.

...One minute
https://www.raspberrypi.org/blog/buy-th ... -in-space/
Interesting to know. I will need to follow up in reading the schematics. I thought the ATTiny88 did all the sensor data reading AND accessing the LED matrix and joystick. If it does not, its OK. So these are "Smart Sensors" and not "Dumb Sensors;" the difference being that Smart Sensors send out formatted data that is picked up in the environment while Dumb Sensors have to be read and what is read is formatted or converted (like resistance to a temperature reading). All that is basic programming but the smart sensor makes it easier to get the data with less code and the dumb sensor needs a subroutine to be read.

The question I have is can I attach to the I2C bus and run in parallel more things to it on top of the Sense Hat? Similar to the Arduino video (there are many others on YouTube): https://www.youtube.com/watch?v=yQ15Hi1E7I4 In theory it should be "Yes," and "It's easy."

BTW, I already have a Sense Hat. Bought two, gave one to a friend so we can work on projects together, and when funds are available, buy another one. :mrgreen: