Difference between revisions of "Raspberry Pi: Sense Hat"
Line 53: | Line 53: | ||
temp = sense.get_temperature_from_humidity() | temp = sense.get_temperature_from_humidity() | ||
print("Temperature from pressure humidity: %s C" % temp) | print("Temperature from pressure humidity: %s C" % temp) | ||
==== Using the Gyroscope ==== | |||
The <code>get_gyroscope()</code> function returns a dictionary object with the pitch, roll, yaw measured in degrees. The raw output function <code>get_gyroscope_raw()</code> returns a dictionary object with the x, y, z axis representing the rotational intensity of the axis in radians per second. | |||
These three rotation axis can determine the exect headed direction in the three-dimensional space. The three axis are used like in the image below. | |||
[[File:Orientation.png|400px]] | |||
gyroscope = sense.get_gyroscope() degrees | |||
print("p: {pitch}, r: {roll}, y: {yaw}".format(**gyroscope)) | |||
# Returned dictionary object | |||
{ | |||
"pitch": Float, | |||
"roll": Float, | |||
"yaw": Float | |||
} | |||
gyroscope_raw = sense.get_gyroscope_raw() radians per second | |||
print("x: {x}, y: {y}, z: {z}".format(**gyroscope_raw)) | |||
# Returned dictionary object | |||
{ | |||
"x": Float, | |||
"y": Float, | |||
"z": Float | |||
} | |||
== Used Hardware == | == Used Hardware == |
Revision as of 08:10, 12 October 2020
Summary
This documentation deals with the Raspberry Sense Hat.
Requirements
- Hardware: Raspberry Pi
- Operating system: Rasbian
- Interpreter: Python or Python3
- Packages: sense-hat
Description
This add-on board has a is packed with three sensor chips as wall as a 8 by 8 RGB Led matrix and a joystick. The Sensors are a barometer, a hygrometer and an IMU (Inertial Measurement Unit). The barometer measures the air pressure and the temperature. The hygrometer measures the humidity and the temperature as well. The used IMU holds a gyroscope, an accelerometer and a magnetometer for an accurate determination of rotation, movement and detection of magnetic fields.
Package Installation
sudo apt-get install sense-hat
Python Programming
The Sense Hat is mainly used via python programming. The developers also developed a sense hat programming simulation program on trinket.io where you are able to test your code without owning the Sense Hat.
The Project comes with two main libraries the sense_emu which is needed when using the Emulator and the sense_hat for the device. For detailed information about the library use the documentation.
Importing the Libary
# emulator libary from sense_emu import SenseHat sense = SenseHat()
# sensehat libary from sense_hat import SenseHat sense = SenseHat()
Using the barometer
The barometer delivers two functions the get_pressure()
and the get_temperature_from_pressure()
.Both of them return a float value of the corresponding unit.
pressure = sense.get_pressure() print("Pressure: %s Millibars" % pressure)
temp = sense.get_temperature_from_pressure() print("Temperature from pressure sensor: %s C" % temp)
Using the hygrometer
The hygrometer delivers also two functions the get_humidity()
and the get_temperature_from_humidity()
, Both of them return a float value of the corresponding unit.
humidity = sense.get_humidity() print("Humidity: %s %%" % humidity)
temp = sense.get_temperature_from_humidity() print("Temperature from pressure humidity: %s C" % temp)
Using the Gyroscope
The get_gyroscope()
function returns a dictionary object with the pitch, roll, yaw measured in degrees. The raw output function get_gyroscope_raw()
returns a dictionary object with the x, y, z axis representing the rotational intensity of the axis in radians per second.
These three rotation axis can determine the exect headed direction in the three-dimensional space. The three axis are used like in the image below.
gyroscope = sense.get_gyroscope() degrees print("p: {pitch}, r: {roll}, y: {yaw}".format(**gyroscope))
# Returned dictionary object { "pitch": Float, "roll": Float, "yaw": Float }
gyroscope_raw = sense.get_gyroscope_raw() radians per second print("x: {x}, y: {y}, z: {z}".format(**gyroscope_raw))
# Returned dictionary object { "x": Float, "y": Float, "z": Float }