Read this story on my blog https://iotbyhvm.ooo/sense-hat/
measure Temperature, Relative humidity and Pressure. Accelerometer, Gyroscope and magnetometer are available. It also has a full-color 8*8
LED matrix display. Sense HAT requires a RPi with 40 Pin GPIO header and some softwares to be installed before you can use it.
What you will need
- Raspberry Pi
- Sense HAT
- Python 3
- Sense HAT for Python 3
Install the Sense HAT Python library
sudo apt-get install sense-hat
sudo pip-3.2 install pillow
sudo python
>>> from sense_hat import SenseHat
>>> hat = SenseHat()
>>> hat.show_message('RPi Tutorials by IoTbyHVM')
Measuring temperature, Humidity, and Pressure with a Sense HAT
# Program for measuring temperature and humidity and pressure with Sense Hat # Visit https://iotbyhvm.ooo IoTbyHVM.ooo Explore TechBytesfrom sense_hat import SenseHat import timehat = SenseHat()while true: t = hat.get_temperature() h = hat.get_humidity() p = hat.get_preesure() print ('Temp C:{:.2f} Humd:{:.0f} Pres:{:.0f}' .format(t, h, p ) ) time.sleep(1)
sudo pyhton sense_thp.py
Temp: C:27.12 Humd:45 Pres:1232
Temp: C:27.45 Humd:44 Pres:1231
Sensing a Magnet with Sense HAT
# Sense magnet with SenseHAT from sense_hat import SenseHat import timehat = SenseHat() fill = (255,0,0)while true: reading = int(hat.get_compass_raw()['z']) if reading > 200: hat.clear(fill) time.sleep(0.2) else: hat.clear()
Finding magnetic North with Sense HAT | How To make Compass
from sense_hat import SenseHat import timehat = SenseHat()while true: bearing = sense.get_compass() print ('bearing: {:.0f} to north' .format(bearing))
sudo python sense_compass.py
Bearing : 138 to north
Bearing : 138 to north
No comments:
Post a Comment