Sense Hat Raspberry Pi Zero

Installation

In order to work correctly, the Sense HAT requires an up-to-date kernel, I2C to be enabled, and a few libraries to get started.

The Sense HAT (B) is specially designed for Raspberry Pi, integrates multi powerful sensors such as gyroscope, accelerometer, magnetometer, barometer, temperature and humidity sensor, etc. It is communicated via I2C interface, and allows to connect more external sensors if you need. Astro Pi resources. This versatile board was designed especially for a space mission. Two Astro Pi units – comprising a Raspberry Pi with Sense HAT in a special case – are currently aboard the International Space Station (ISS), orbiting 408km above the Earth. Astro Pi is an ESA (European Space Agency) project run with the Raspberry Pi. The Sense HAT, which is a fundamental part of the Astro Pi mission, allows your Raspberry Pi to sense the world around it. In this project, you will learn how to control the Sense HAT’s LED matrix and collect sensor data, and you will combine these ideas in a number of small projects. The Sense HAT is an official add-on board that adds a range of motion sensors to Raspberry Pi, including a gyroscope, accelerometer, and magnetometer, along with temperature, pressure, and humidity sensors. It also features an 8×8 LED matrix. From sensehat import SenseHat sense = SenseHat r = 255 g = 255 b = 255 sense. Clear ((r, g, b)) Save and run your code. The LED matrix will then go bright white. The variables r, g, and b represent the colours red, green, and blue. Their values specify how bright each colour should be; each value can be between 0 and 255. In the above code.

  1. Ensure your APT package list is up-to-date:

  2. Next, install the sense-hat package which will ensure the kernel is up-to-date, enable I2C, and install the necessary libraries and programs:

  3. Finally, a reboot may be required if I2C was disabled or the kernel was not up-to-date prior to the install:

Hardware

The schematics can be found here.

Software overview

After installation, example code can be found under /usr/src/sense-hat/examples.

These can be copied to the user's home directory by running cp /usr/src/sense-hat/examples ~/ -a.

The C/C++ examples can be compiled by running make in the appropriate directory.

The RTIMULibDrive11 example comes pre-compiled to help ensure everything works as intended. It can be launched by running RTIMULibDrive11 and closed by pressing Ctrl+c.

Hat

Python sense-hat

sense-hat is the officially supported library for the Sense HAT; it provides access to all of the on-board sensors and the LED matrix.

Complete documentation can be found at pythonhosted.org/sense-hat.

RTIMULib

RTIMULib is a C++ and Python library that makes it easy to use 9-dof and 10-dof IMUs with embedded Linux systems. A pre-calibrated settings file is provided in /etc/RTIMULib.ini, which is also copied and used by sense-hat. The included examples look for RTIMULib.ini in the current working directory, so you may wish to copy the file there to get more accurate data.

Other

LED matrix

The LED matrix is an RGB565 framebuffer with the id 'RPi-Sense FB'. The appropriate device node can be written to as a standard file or mmap-ed. The included 'snake' example shows how to access the framebuffer.

Joystick

The joystick comes up as an input event device named 'Raspberry Pi Sense HAT Joystick', mapped to the arrow keys and Enter. It should be supported by any library which is capable of handling inputs, or directly through the evdev interface. Suitable libraries include SDL, pygame and python-evdev. The included 'snake' example shows how to access the joystick directly.

Calibration

Taken from this forum post.

Install the necessary software and run the calibration program as follows:

You will then see this menu:

Press lowercase m. The following message will then show; press any key to start.

After it starts, you will see something similar to this scrolling up the screen:

Focus on the two lines at the very bottom of the screen, as these are the most recently posted measurements from the program.Now you have to move the Astro Pi around in every possible way you can think of. It helps if you unplug all non-essential cables to avoid clutter.

Try and get a complete circle in each of the pitch, roll and yaw axes. Take care not to accidentally eject the SD card while doing this. Spend a few minutes moving the Astro Pi, and stop when you find that the numbers are not changing anymore.

Now press lowercase s then lowercase x to exit the program. If you run the ls command now, you'll see a new RTIMULib.ini file has been created.

In addition to those steps, you can also do the ellipsoid fit by performing the steps above, but pressing e instead of m.

When you're done, copy the resulting RTIMULib.ini to /etc/ and remove the local copy in ~/.config/sense_hat/:

You are now done.

Updating the AVR firmware

...

EEPROM data

These steps may not work on Raspberry Pi 2 Model B Rev 1.0 and Raspberry Pi 3 Model B boards. The firmware will take control of I2C0, causing the ID pins to be configured as inputs.

  1. Enable I2C0 and I2C1 by adding the following line to /boot/config.txt:

  2. Enter the following command to reboot:

  3. Download and build the flash tool:

Sense Hat Raspberry Pi Zero Gravity

Reading

  1. EEPROM data can be read with the following command:

Raspberry Pi Sound Hat

Writing

Please note that this operation is potentially dangerous, and is not needed for the everyday user. The steps below are provided for debugging purposes only. If an error occurs, the HAT may no longer be automatically detected.

  1. Download EEPROM settings and build the .eep binary:

  2. Disable write protection:

  3. Write the EEPROM data:

  4. Re-enable write protection:

Installation

In order to work correctly, the Sense HAT requires an up-to-date kernel, I2C to be enabled, and a few libraries to get started.

  1. Ensure your APT package list is up-to-date:

  2. Next, install the sense-hat package which will ensure the kernel is up-to-date, enable I2C, and install the necessary libraries and programs:

  3. Finally, a reboot may be required if I2C was disabled or the kernel was not up-to-date prior to the install:

Hardware

The schematics can be found here.

Software overview

After installation, example code can be found under /usr/src/sense-hat/examples.

These can be copied to the user's home directory by running cp /usr/src/sense-hat/examples ~/ -a.

The C/C++ examples can be compiled by running make in the appropriate directory.

The RTIMULibDrive11 example comes pre-compiled to help ensure everything works as intended. It can be launched by running RTIMULibDrive11 and closed by pressing Ctrl+c.

Python sense-hat

sense-hat is the officially supported library for the Sense HAT; it provides access to all of the on-board sensors and the LED matrix.

Raspberry Pi 4 Hats

Complete documentation can be found at pythonhosted.org/sense-hat.

RTIMULib

RTIMULib is a C++ and Python library that makes it easy to use 9-dof and 10-dof IMUs with embedded Linux systems. A pre-calibrated settings file is provided in /etc/RTIMULib.ini, which is also copied and used by sense-hat. The included examples look for RTIMULib.ini in the current working directory, so you may wish to copy the file there to get more accurate data.

Other

LED matrix

The LED matrix is an RGB565 framebuffer with the id 'RPi-Sense FB'. The appropriate device node can be written to as a standard file or mmap-ed. The included 'snake' example shows how to access the framebuffer.

Joystick

The joystick comes up as an input event device named 'Raspberry Pi Sense HAT Joystick', mapped to the arrow keys and Enter. It should be supported by any library which is capable of handling inputs, or directly through the evdev interface. Suitable libraries include SDL, pygame and python-evdev. The included 'snake' example shows how to access the joystick directly.

Calibration

Taken from this forum post.

Install the necessary software and run the calibration program as follows:

You will then see this menu:

Press lowercase m. The following message will then show; press any key to start.

After it starts, you will see something similar to this scrolling up the screen:

Focus on the two lines at the very bottom of the screen, as these are the most recently posted measurements from the program.Now you have to move the Astro Pi around in every possible way you can think of. It helps if you unplug all non-essential cables to avoid clutter.

Try and get a complete circle in each of the pitch, roll and yaw axes. Take care not to accidentally eject the SD card while doing this. Spend a few minutes moving the Astro Pi, and stop when you find that the numbers are not changing anymore.

Now press lowercase s then lowercase x to exit the program. If you run the ls command now, you'll see a new RTIMULib.ini file has been created.

In addition to those steps, you can also do the ellipsoid fit by performing the steps above, but pressing e instead of m.

When you're done, copy the resulting RTIMULib.ini to /etc/ and remove the local copy in ~/.config/sense_hat/:

You are now done.

Updating the AVR firmware

...

EEPROM data

Raspberry Pi Zero W Sense Hat

Sense Hat Raspberry Pi Zero

These steps may not work on Raspberry Pi 2 Model B Rev 1.0 and Raspberry Pi 3 Model B boards. The firmware will take control of I2C0, causing the ID pins to be configured as inputs.

  1. Enable I2C0 and I2C1 by adding the following line to /boot/config.txt:

  2. Enter the following command to reboot:

  3. Download and build the flash tool:

Reading

  1. EEPROM data can be read with the following command:

Raspberry Pi 0 Projects

Writing

Please note that this operation is potentially dangerous, and is not needed for the everyday user. The steps below are provided for debugging purposes only. If an error occurs, the HAT may no longer be automatically detected.

Sense Hat Raspberry Pi Zero Turn

  1. Download EEPROM settings and build the .eep binary:

  2. Disable write protection:

  3. Write the EEPROM data:

  4. Re-enable write protection: