npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-red-node-pi-sense-hat

v0.1.5

Published

A Node-RED node to interact with a Raspberry Pi Sense HAT

Downloads

198

Readme

node-red-node-pi-sense-hat

A Node-RED node to interact with a Raspberry Pi Sense HAT.

Pre-requisites

The Sense HAT python drivers need to be installed manually:

sudo apt-get update
sudo apt-get install sense-hat
sudo pip-3.2 install pillow

See the driver documentation for more information.

Install

Run the following command in your Node-RED user directory (typically ~/.node-red):

npm install node-red-node-pi-sense-hat

Usage

Input Node

This node sends readings from the various sensors on the Sense HAT, grouped into three sets; motion events, environment events and joystick events.

Motion events

Motion events include readings from the accelerometer, gyroscope and magnetometer, as well as the current compass heading. They are sent at a rate of approximately 10 per second. The topic is set to motion and the payload is an object with the following values:

  • acceleration.x/y/z : the acceleration intensity in Gs
  • gyroscope.x/y/z : the rotational intensity in radians/s
  • orientation.roll/pitch/yaw : the angle of the axis in degrees
  • compass : the direction of North in degrees

Environment events

Environment events include readings from the temperature, humidity and pressure sensors. They are sent at a rate of approximately 1 per second. The topic is set to environment and the payload is an object with the following values:

  • temperature : degrees Celsius
  • humidity : percentage of relative humidity
  • pressure : Millibars

Joystick events

Joystick events are sent when the Sense HAT joystick is interacted with. The topic is set to joystick and the payload is an object with the following values:

  • key : one of UP, DOWN, LEFT, RIGHT, ENTER
  • state : the state of the key:
    • 0 : the key has been released
    • 1 : the key has been pressed
    • 2 : the key is being held down

Output Node

This node sends commands to the 8x8 LED display on the Sense HAT.

Commands are sent to the node in msg.payload. Multiple commands can be sent in a single message by separating them with newline (\n) characters. You must use a function node or a change node (jsonata expression) when using the newline (\n) character to create a payload containing multiple commands.

Set the colour of individual pixels

Format: <x>,<y>,<colour>

x and y must either be a value from 0 to 7, a * to indicate the entire row or column, or a range such as 3-6.

colour must be one of:

  • the well-known HTML colour names - eg red or aquamarine,
  • the CheerLights colour names,
  • a HEX colour value - eg #aa9900
  • an RGB triple - 190,255,0
  • or simply off

To set the entire screen to red: *,*,red

To set the four corners of the display to red, green (#00ff00), yellow and blue (0,0,255):

0,0,red,0,7,#00ff00,7,7,yellow,7,0,0,0,255

To set a 3-pixel wide column to purple: 4-6,*,purple

Rotate the screen

Format: R<angle>

angle must be 0, 90, 180 or 270.

Example: R180

Flip the screen

Format: F<axis>

axis must be either H or V to flip on the horizontal or vertical axis respectively.

Example: FV

Scroll a message

If msg.payload is not recognised as any of the above commands, it is treated as a text message to be scrolled across the screen.

If the text is a single character, it will be displayed without scrolling. To scroll a single character, append a blank space after it - "A ".

The following message properties can be used to customise the appearance:

  • msg.color - the colour of the text, default: white
  • msg.background - the colour of the background, default: off
  • msg.speed - the scroll speed. A value in the range 1 (slower) to 5 (faster), default: 3

Set the screen brightness

Format: D<level>

level must be 0 (low) or 1 (high).

Example: D1