AdSense
Friday, July 14, 2017
7 - Raspberry Pi and Sense HAT (IV): colors with 8x8 RGB LED matrix
RASPBERRY PI AND SENSE HAT (IV): 8x8 RGB LED matrix
- Layout for this exercise:
- Sense HAT includes a 8×8 RGB LED matrix that is available to program for displaying different color effects
1 - Scrolling time and date in the RGB LED matrix
- This Python program uses color red (255,0,0) for the time and color blue (0,0,255) for the date:
- Giving execution permissions:
- Running the program:
- The output can be seen in this video:
https://www.dropbox.com/s/6osa24003h11moj/Video%20Jun%2028%2C%2010%2005%2009%20AM.mov?dl=0
2 - Rainbow
- Program for displaying the 7 colors of the rainbow:
- Giving execution permissions:
- Running the Python program:
6 - Raspberry Pi and Sense HAT (III): working with the Magnetometer
RASPBERRY PI AND SENSE HAT(III): WORKING WITH THE MAGNETOMETER
- Layout for this exercise:
1 - Introduction
- A magnetometer is an instrument that measures magnetism, either magnetization of magnetic material like a ferromagnet, or the direction, strength, or the relative change of a magnetic field at a particular location.
- A compass is a simple example of a magnetometer, one that measures the direction of an ambient magnetic field.
https://en.wikipedia.org/wiki/Magnetometer
2 - Magnetic North
- The function get_compass() gets the direction of North from the magnetometer in degrees. On the other hand, the function get_compass_raw() gets the raw XYZ axis magnetometer data:
- Giving execution permissions:
- Running the program:
2 - Sensing a magnet
- The function get_compass_raw() detects the presence of a magnet. For instance when the reading for the Z axis is higher than an established limit, turning the LED matrix with red light (255,0,0) every 0.1 second:
- Giving execution permissions:
- Running the program when a magnet is getting closer vertically to the Sense Hat module:
5 - Raspberry Pi and Sense Hat (II): IMU (Inertial Management Unit) with Accelerometer, Gyroscope and Magnetometer
RASPBERRY PI AND SENSE HAT(II): IMU (INERTIAL MANAGEMENT UNIT) WITH ACCELEROMETER, GYROSCOPE AND MAGNETOMETER
- Layout for this exercise:
1 - Introduction
- The Sense HAT has a movement sensor called an IMU (Inertial Management Unit) which can measure the type of movement it is experiencing:
https://www.raspberrypi.org/learning/astro-pi-guide/sensors/movement.md
- An IMU is an electronic device that measures and reports a body's specific force, angular rate, and sometimes the magnetic field surrounding the body, using a combination of accelerometers and gyroscopes, sometimes also magnetometers.
- An IMU is built basically with 3 sensors in one. The readings for these 3 sensors are combined to have an accurate orientation of the Sense HAT module:
a) gyroscope: measures momentum and rotation.
b) accelerometer: measures acceleration forces and can be used to find the direction of gravity.
c) magnetometer: measures the Earth's own magnetic field, so it's a bit like a compass.
- An IMU sensor is used on all manned and unmanned spacecraft to track movements and maintain an understanding of orientation.
- All objects in space have three axes around which they can rotate. The three axes are:
- Pitch, roll, yaw are terms used in aviation and airplane control to describe the movement around the 3 axes:
a) pitch: like a plane taking off
b) roll: the plane doing a victory roll
c) yaw: steering the plane like a car
- If you know how much rotation has happened on each axis, then you know which way the object is pointing.
- This image shows where these axes are in relation to the Sense HAT:
2 - Programming Raspberry Pi and Sense Hat to determine its orientation
- The next program offers accurate information about the orientation of the Raspberry Pi and Sense Hat module.
- The function set_imu_config(True,True,True) sets the magnetometer, gyroscope and accelerometer (in that order) to make measurements about the position (determined by the pitch, roll and yaw output parameters):
- Giving permissions of execution:
- The initial position of the Raspberry Pi and Sense Hat is flat on a table:
- Running the program:
- Tilting up the Raspberry Pi and the Sense Hat modules:
- After tilting up the module a variation for the pitch is detected while roll and yaw remain almost equal:
4 - Raspberry Pi and Sense Hat (I): measuring temperature, humidity and pressure
RASPBERRY PI AND SENSE HAT (I): MEASURING TEMPERATURE, HUMIDITY AND PRESSURE
- Layout for this exercise:
1 - Introduction
- The Sense HAT is an add-on board for Raspberry Pi made especially for the Astro Pi mission (it launched to the International Space Station in December 2015) and is now available to buy.
https://www.raspberrypi.org/products/sense-hat/
https://www.raspberrypi.org/education/programmes/astro-pi/
- The Sense HAT has an 8×8 RGB LED matrix, a five-button joystick and includes the following sensors:
- Accelerometer
- Magnetometer
- Temperature
- Barometric pressure
- Humidity
- Gyroscope
- Also, there is a Python library providing easy access to everything on the board:
http://pythonhosted.org/sense-hat/
- HAT stands for “Hardware attached on top”. It is a hardware specification for add-on modules for the Raspberry Pi:
https://www.raspberrypi.org/blog/introducing-raspberry-pi-hats/
- To install Sense Hat on Raspberry Pi:
2 - Displaying text
- A basic exercise to check whether Sense Hat is working correctly:
3 - Measuring temperature, humidity and pressure
- Sense HAT has got built-in sensors for temperature, humidity and pressure:
- Giving execution permissions:
- Running the Python script:
- About the temperature readings it is important to notice that the Sense HAT sensor gets a little extra warm because of the heat generated by the Raspberry Pi module.
3 - Raspberry Pi and ThingSpeak (II): channel for Sensor data
RASPBERRY PI AND THINGSPEAK (II): CHANNEL FOR SENSOR DATA
- Layout for this exercise:
1 - Creating a ThingSpeak Channel
- Once signed in the ThingSpeak account a New Channel can be created:
- ThingSpeak allows to collect and store data with the Channels tool:
- After creating the channel an API key is automatically available to be used for the communication between the Raspberry Pi module and the ThingSpeak web services:
2- Programming the sensor
- The Python program used in this exercise is an adapted version of this one:
https://github.com/simonmonk/raspberrypi_cookbook_ed2/blob/master/thingspeak_data.py
- Let's notice that the previously created API Key must be used in this program:
- The send_data function creates the web request providing the temperature to the field 1 (temp_c) of the channel, what will be display in the chart as the Y axis.
3 - Running the sensor
- Giving execution permissions to the Python script:
- Running the program, a series of of the Raspberry Pi CPU Temperature is generated:
- Let's notice that there is an increment of the CPU temperature (from 48.9 to 62.3 degrees) when a video is played on the Raspberry Pi:
https://www.youtube.com/watch?v=LNEEVsZt8vI
- The ThingSpeak channel shows a chart displaying the evolution of the Raspberry Pi CPU temperature along an interval of approximately 8 minutes:
Subscribe to:
Posts (Atom)