A Node-RED node to simulate a Raspberry Pi Sense HAT
A Node-RED node to simulate a Raspberry Pi Sense HAT.
This allows you to create flows that interact with a virtual Sense HAT without the actual hardware - whether you're running on a Raspberry Pi, a laptop or elsewhere.
Once a Sense HAT simulator node has been deployed, the web page that provides a UI to the simulator can be accessed by clicking the link in the node's info panel.
Run the following command in your Node-RED user directory (typically
npm install node-red-node-pi-sense-hat-simulator
This node sends readings from the various sensors on the Sense HAT, grouped into three sets; motion events, environment events and joystick events.
The current version of the simulator does not support 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
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 include readings from the temperature, humidity and pressure
sensors. They are sent at a rate of approximately 1 per second. The
is set to
environment and the
payload is an object
with the following values:
temperature: degrees Celsius
humidity: percentage of relative humidity
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
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
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.
Set the colour of individual pixels
y must either be a value from 0 to 7, a
* to indicate the entire row
or column, or a range such as
colour must be one of:
- the well-known HTML colour names - eg
- the CheerLights colour names,
- a HEX colour value - eg
- an RGB triple -
- or simply
To set the entire screen to red:
To set the four corners of the display to red, green (#00ff00), yellow and blue (0,0,255):
To set a 3-pixel wide column to purple:
Rotate the screen
angle must be 0, 90, 180 or 270.
Flip the screen
axis must be either
V to flip on the horizontal or vertical axis respectively.
Scroll a message
The current version of the simulator does not support displaying text
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 -
The following message properties can be used to customise the appearance:
msg.color- the colour of the text, default:
msg.background- the colour of the background, default:
msg.speed- the scroll speed. A value in the range 1 (slower) to 5 (faster), default:
Set the screen brightness
level must be 0 (low) or 1 (high).