Skip to content

Commit f972e34

Browse files
docs(MMM-SenseHat): add module screenshot
1 parent 2f7e98a commit f972e34

File tree

2 files changed

+129
-0
lines changed

2 files changed

+129
-0
lines changed

modules/MMM-SenseHat/README.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
MMM-SenseHat
2+
============
3+
4+
A 3rd‑party MagicMirror² module that integrates the Raspberry Pi Sense HAT. It reads sensor data (temperature, humidity, pressure, optional orientation) and can control the Sense HAT 8×8 RGB LED matrix for simple status indication or scrolling text.
5+
6+
## Screenshot
7+
![MMM-SenseHat screenshot](images/how_its_working.png)
8+
9+
Features
10+
- Display temperature, humidity, pressure, and optionally orientation (pitch/roll/yaw)
11+
- Periodic polling interval (configurable)
12+
- Optional LED matrix control: off, status color, or scrolling text
13+
- Basic threshold‑based LED status (green when normal, red when out‑of‑range)
14+
15+
Requirements
16+
- Raspberry Pi with a Sense HAT attached
17+
- Python 3 with the official sense HAT library
18+
19+
Install dependencies on the Raspberry Pi
20+
```bash
21+
sudo apt update
22+
sudo apt install -y sense-hat python3-sense-hat
23+
```
24+
25+
Installation (as a 3rd‑party module)
26+
1) Clone this module into your MagicMirror installation under `modules/MMM-SenseHat`:
27+
```bash
28+
cd ~/MagicMirror/modules
29+
git clone https://github.com/YOUR_GITHUB_ACCOUNT/MMM-SenseHat.git MMM-SenseHat
30+
```
31+
32+
2) (Optional) Ensure the Python helper is executable:
33+
```bash
34+
chmod +x ~/MagicMirror/modules/MMM-SenseHat/python/reader.py
35+
```
36+
37+
Configuration
38+
Add the module to your `config/config.js`:
39+
```js
40+
{
41+
module: "MMM-SenseHat",
42+
position: "top_right",
43+
config: {
44+
updateInterval: 5000,
45+
showTemperature: true,
46+
showHumidity: true,
47+
showPressure: true,
48+
showOrientation: false,
49+
temperatureUnit: "C",
50+
roundValues: 1,
51+
ledMatrixEnabled: true,
52+
ledMode: "status", // "off" | "status" | "text"
53+
ledText: "Hello from Sense HAT",
54+
ledColor: [0, 255, 0],
55+
criticalThresholds: {
56+
temperatureHigh: 30,
57+
temperatureLow: 10,
58+
humidityHigh: 80,
59+
humidityLow: 20
60+
},
61+
debug: false,
62+
// Optional: override Python executable path if needed (e.g., "/usr/bin/python3")
63+
// pythonPath: "/usr/bin/python3"
64+
}
65+
}
66+
```
67+
68+
How it works
69+
- Frontend (MMM-SenseHat.js): Displays data and optionally sends LED status commands based on thresholds.
70+
- Node Helper (node_helper.js): Spawns the Python helper to read sensors at a set interval and forwards LED commands to it. Respects `config.pythonPath` if provided.
71+
- Python Helper (python/reader.py): Uses `from sense_hat import SenseHat` to read sensors and control the LED matrix. Prints JSON to stdout in read mode.
72+
73+
Troubleshooting
74+
1) Check that the Sense HAT is detected by the kernel
75+
```bash
76+
ls -l /dev/i2c*
77+
dmesg | grep -i "sense"
78+
```
79+
Expect:
80+
- `/dev/i2c-1` present
81+
- A line similar to: `fb1: RPi-Sense FB frame buffer device`
82+
- A joystick device entry for the Sense HAT
83+
84+
2) Probe I²C bus 1
85+
```bash
86+
sudo i2cdetect -y 1
87+
```
88+
On a working Sense HAT, you should see several non-"--" addresses (for example `1c`, `39`, `5c`, `5f`, `6a`). If everything shows `--`, the HAT might not be seated correctly or could be faulty.
89+
90+
3) Test using the official Python library
91+
```bash
92+
python3 - << 'PY'
93+
from sense_hat import SenseHat
94+
95+
sh = SenseHat()
96+
97+
print("Temperature:", sh.get_temperature())
98+
print("Humidity :", sh.get_humidity())
99+
print("Pressure :", sh.get_pressure())
100+
PY
101+
```
102+
- If you get numeric values, the sensors are working.
103+
- If you see errors like `OSError: Humidity Init Failed`, there may be a contact problem on the header or a sensor issue.
104+
105+
4) Check the LED matrix
106+
```bash
107+
python3 - << 'PY'
108+
from sense_hat import SenseHat
109+
from time import sleep
110+
111+
sh = SenseHat()
112+
sh.clear()
113+
sh.show_message("HI", text_colour=(0, 255, 0), scroll_speed=0.07)
114+
sleep(1)
115+
sh.clear()
116+
PY
117+
```
118+
If you don’t see LEDs:
119+
- Power off the Raspberry Pi.
120+
- Firmly press the Sense HAT onto the 40‑pin header (common on new boards).
121+
- Boot again and re‑run the test.
122+
123+
5) What the MagicMirror module will show
124+
- "Loading Sense HAT data…" → Python helper hasn’t delivered any data yet.
125+
- "Sense HAT: no sensor data (check hardware or drivers)" → helper runs, but all sensor fields are null.
126+
- "Sense HAT error: …" → helper reported an explicit error (library missing, init failure, etc.).
127+
128+
License
129+
MIT (follow the MagicMirror² project license)
418 KB
Loading

0 commit comments

Comments
 (0)