Skip to content

Add MMM-SenseHat third-party module for Raspberry Pi Sense HAT#3984

Closed
GEmanuel2558 wants to merge 7 commits intoMagicMirrorOrg:developfrom
GEmanuel2558:sensehat-module
Closed

Add MMM-SenseHat third-party module for Raspberry Pi Sense HAT#3984
GEmanuel2558 wants to merge 7 commits intoMagicMirrorOrg:developfrom
GEmanuel2558:sensehat-module

Conversation

@GEmanuel2558
Copy link
Copy Markdown

Summary

This PR adds MMM-SenseHat, a third-party MagicMirror² module that integrates the official Raspberry Pi Sense HAT. It displays sensor readings (temperature, humidity, pressure, optional orientation) and can control the Sense HAT 8×8 LED matrix for status colouring or scrolling text.

The module lives entirely under modules/MMM-SenseHat and does not modify core functionality.


What’s included

  • New module folder: modules/MMM-SenseHat
    • MMM-SenseHat.js
      • Frontend module that renders:
        • Temperature (°C/°F)
        • Humidity (%)
        • Pressure (hPa)
        • Optional orientation (pitch/roll/yaw)
      • Handles loading / error / data states
      • Supports LED “status” mode with threshold-based colouring
      • Supports LED “text” mode with configurable text and RGB color
      • Multi-instance safe using identifier so multiple MMM-SenseHat instances can coexist
    • node_helper.js
      • Manages one polling loop per module instance
      • Spawns the Python helper on an interval to read sensors
      • Forwards sensor JSON and errors back to the correct instance via identifier
      • Accepts LED commands per instance
      • Supports config.pythonPath and config.pythonName (alias, for familiarity with MMM-PythonPrint)
    • python/reader.py
      • Uses from sense_hat import SenseHat
      • --read mode: reads temperature, humidity, pressure, orientation, accelerometer, gyroscope, magnetometer
      • Prints JSON to stdout in a stable schema
      • LED control (status colour, text, clear) via CLI arguments
      • Gracefully handles partial sensor failures (e.g. humidity init issues) by returning null values instead of crashing
    • README.md
      • Overview, features, installation and configuration
      • Links to official Sense HAT product page & documentation
      • Troubleshooting steps (i2c detection, kernel messages, Python tests, LED tests)
      • Multi-instance usage example
      • Screenshot and hardware image references
    • Images:
      • images/mmm-sensehat-dashboard.png
      • images/mmm-sensehat-hardware_1.jpg
      • images/mmm-sensehat-hardware_2.jpg

Usage (short example)

Add to config/config.js:

{
  module: "MMM-SenseHat",
  position: "top_right",
  config: {
    updateInterval: 5000,
    showTemperature: true,
    showHumidity: true,
    showPressure: true,
    showOrientation: false,
    temperatureUnit: "C",
    roundValues: 1,
    ledMatrixEnabled: true,
    ledMode: "status", // "off" | "status" | "text"
    ledText: "Hello from Sense HAT",
    ledColor: [0, 255, 0],
    criticalThresholds: {
      temperatureHigh: 30,
      temperatureLow: 10,
      humidityHigh: 80,
      humidityLow: 20
    },
    debug: false
    // optional:
    // pythonPath: "/usr/bin/python3",
    // pythonName: "/usr/bin/python3"
  }
}

…dule

- Move module from modules/default/sensehat to modules/MMM-SenseHat
- Rename main script to MMM-SenseHat.js and update Module.register name
- Adjust logs, docs and config examples to follow MMM-* third-party conventions
- Remove any changes to core files like CHANGELOG.md and config.js.sample
@sdetweil
Copy link
Copy Markdown
Collaborator

sdetweil commented Dec 6, 2025

You need to put this on your own GitHub repo , and add it to the 3party module list, by editing the wiki here
https://github.com/MagicMirrorOrg/MagicMirror/wiki

Made the module multi-instance safe: the node helper now tracks instances by identifier, keeps one polling loop per instance, and routes data/LED commands back to the correct frontend.

Improved error handling: Python spawn failures, non-zero exits, invalid JSON, and helper-reported errors are now forwarded as { error: ... } to the UI so the module can render a clear error state.

Added support for pythonName as an alias for pythonPath, to align with MMM-PythonPrint and make configuration more familiar.

Updated the README with details on multi-instance usage, Python path options (pythonPath / pythonName), and styling via .MMM-SenseHat .mmm-sensehat.
@GEmanuel2558
Copy link
Copy Markdown
Author

GEmanuel2558 commented Dec 6, 2025

You need to put this on your own GitHub repo , and add it to the 3party module list, by editing the wiki here https://github.com/MagicMirrorOrg/MagicMirror/wiki

Thanks for the feedback! I moved this into a standalone third-party module:
https://github.com/GEmanuel2558/MMM-SenseHat

I’ll add it to the 3rd-party modules wiki as suggested, so this PR can be closed.

@GEmanuel2558
Copy link
Copy Markdown
Author

Thanks for the review and guidance.
Based on your feedback, I’ll move this Sense HAT integration into its own third-party module repository and add it to the 3rd Party Modules list in the MagicMirror wiki.

Because of that, this PR is no longer needed, so I’m closing it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants