In this project you will learn how to use Azure IoT Edge by Microsoft on a Raspberry Pi Model 3 B+ as the edge device with a Sense HAT attached to it. This project can be used as a base for larger Azure IoT Edge projects or as a Proof of Concept for Azure IoT Edge with real sensors instead of the simulator examples provided by Microsoft (or to just to have fun). Sense HAT for Raspberry Pi 4B/3B+/3B/2B/Zero,Pi 40PIN GPIO Extension Header Onboard Gyroscope Accelerometer Magnetometer Barometer Temperature Humidity Multi Sensors I2C Interface. 5.0 out of 5 stars 1. Get it as soon as Wed, May 13. FREE Shipping on.
- Sense Hat Raspberry Pi Zero
- Sense Hat Raspberry Pi Zero Case
- Raspberry Pi Zero Cluster Hat
- Sense Hat Raspberry Pi Zero 2
This example shows you how to read the sensor values, read the position of joystick and control the LED Matrix on Raspberry Pi™ Sense HAT using MATLAB™ Support Package for Raspberry Pi Hardware.
Introduction
The Raspberry Pi Sense HAT is an add-on board that includes an 8X8 RGB LED matrix, a five-position joystick and the following sensors:
![Amazon Amazon](/uploads/1/2/6/4/126459681/404346740.jpg)
- Humidity sensor
- Pressure sensor
- IMU sensor (Accelerometer, Gyroscope, and Magnetometer).MAMP & MAMP PRO 5.7 macOS 10.10+ & 64-Bit processor (Intel) Users of version 4 can update at a low price. MAMP & MAMP PRO 4.2.0 Windows 7, 8.1, 10 Download MAMP Viewer. The MAMP is a free, open source utility that enables Mac OS X users to install Apache server, MySQL, PHP, eAccelerator and PHPMyAdmin with ease. MAMP for Windows. MAMP is a free, local server environment that can be installed under macOS and Windows with just a few clicks. MAMP provides them with all the tools they need to run WordPress on their desktop PC for testing or development purposes, for example. You can even easily test your projects on mobile devices. MAMP PRO is the commercial, professional grade version of the classic local server environment for OS X: MAMP. Designed for professional Web developers and programmers, MAMP Pro allows easy installation and administration of their development environment under OS X. As a professional Web developer you have to test your programs in detail. MAMP PRO is a configuration application that helps you set up and run the Apache or Nginx web servers and the MySQL 5.7 database server. It also takes care of the configuration of different versions of PHP. MAMP PRO also comes with a text editor, and built in functionality to move your site. Mamp pro 4 for mac os.
In this example you will learn how to create a
sensehat
object to connect to the Raspberry Pi Sense HAT, read sensor values, read the position of the joystick and control the LED matrix.Prerequisites
- We recommend completing Getting Started with MATLAB Support Package for Raspberry Pi Hardware example
Required Hardware
To run this example you will need the following hardware:
Connect Sense HAT
Attach the Sense HAT to the Raspberry Pi expansion header. Make sure that you power down your Raspberry Pi before attempting to attach the Sense HAT.
Create a Sense HAT object
Create a Sense HAT object by executing the following on the MATLAB prompt.
mysensehat
is a handle to a sensehat object.Uninstaller apps for mac. Are you looking for the best uninstaller app for mac, which can enhance its speed.
Let us read the temperature from Sense HAT.
Reading Environmental Sensors
Sense HAT includes humidity and pressure sensors which measure the temperature, the pressure and the humidity. Let's read the value of humidity and pressure measured by these sensors.
Temperature can be read from either the humidity sensor or the pressure sensor. To read the temperature from the humidity sensor, execute the following on the MATLAB prompt:
To read the temperature from the pressure sensor, execute the following on the MATLAB prompt:
By default, the temperature is read from the humidity sensor. Hence,
readTemperature(mysensehat)
is same as readTemperature(mysensehat,'HumiditySensor')
.Read the IMU sensor.
Sense HAT has an IMU sensor which consists of an accelerometer, a gyroscope and a magnetometer. The IMU sensor measures acceleration, angular velocity and magnetic field along the X, Y and Z axis. To read the acceleration, execute the following on the MATLAB prompt:
readAcceleration
returns a 1-by-3 vector of acceleration values measured along the X, Y and Z axis.To read the angular velocity, execute the following on the MATLAB prompt:
readAngularVelocity
returns a 1-by-3 vector of angular velocity values measured along the X, Y, and Z axis.To read the magnetic field, execute the following on the MATLAB prompt:
readMagneticField
returns a 1-by-3 vector of magnetic field values measured along the X, Y, and Z axis.Read the state of the joystick
Sense HAT has a 5 position mini joystick. Let us read the position of the joystick.
readJoystick
returns the a value between 0 to 5 depending on the position of the joystick.- 0 - Not pressed
- 1 - Centre
- 2 - Left
- 3 - Up
- 4 - Right
- 5 - Down
The numerical values representing joystick positions are ordered with respect to the reference position of the Sense HAT. The HDMI port of the Raspberry Pi board facing downwards is the reference position.
Sense Hat Raspberry Pi Zero
You can monitor a particular joystick position by executing the following on the MATLAB prompt:
readJoystick(sensehatObj,position)
will return a logical one if the joystick is in the specified position and zero otherwise.Use the LED matrix
Sense HAT has a matrix of 8x8 RGB LEDs. You can set the color of a particular pixel, display an image or display a scrolling message on the LED matrix. Let us set the color of the pixel in the 3rd row, 6th column to cyan.
Observe that the pixel in the specified location is now cyan in color.
The rows and columns are numbered 1 to 8. Pixel at location [1 1] is at the top left corner of the LED Matrix. The location is with respect to the reference position of the Sense HAT. The HDMI port of the Raspberry Pi board facing downwards is the reference position.
Color of a pixel can be specified by name. The supported colors are:
- Red
- Blue
- Green
- Magenta
- Yellow
- White
You can also specify any other color by using a 1x3 array of R, G, B values. For example, setting the pixel to [255 192 203], would set it to pink. Now, let us display an image on the LED matrix.
The image must be an NxMx3 array of uint8 values. You can change the orientation of the displayed image by executing the following on the MATLAB prompt:
The Orientation of the image can be set to 0, 90, 180 or 270 degrees. These are defined with respect to the reference position of the Sense HAT. The HDMI port of the Raspberry Pi board facing downwards is the reference position.
LED Matrix can be used to display messages in the form of a scrolling text. The text scrolls from left to right. You can change the orientation of scroll by setting the 'Orientation' property of LEDMatrix. Let us display 'Hello World' on the LED Matrix.
By default, the text scrolls with a scrolling speed of 0.1 second and the color of the text is red. To increase the scrolling speed to 0.05 second, execute the following on the MATLAB prompt:
In order to set the text color to yellow, execute the following on the MATLAB prompt:
Similarly, in order to set the background color to white, execute the following on the MATLAB prompt:
You can rotate the text by specifying the orientation for the display. Let us specify orientation as 90 and display the text message.
Sense Hat Raspberry Pi Zero Case
Now, let us try to display a numeric value on the LED matrix. Read the value of temperature and display it on the LED matrix.
Raspberry Pi Zero Cluster Hat
To clear the LED matrix, execute the following on the MATLAB prompt.
Summary
Sense Hat Raspberry Pi Zero 2
This example introduced the workflow for using MATLAB Support Package for Raspberry Pi Sense HAT.