# Problems with Sensehat on Pi4 with Bookworm (Python3) and NR 4.0.3

**URL:** <https://discourse.nodered.org/t/problems-with-sensehat-on-pi4-with-bookworm-python3-and-nr-4-0-3/92220>\
**Category:** General\
**Created:** [7 October 2024 16:15 UTC](https://discourse.nodered.org/t/problems-with-sensehat-on-pi4-with-bookworm-python3-and-nr-4-0-3/92220 "2024-10-07T16:15:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefan24](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stefan24/32/23075_2.png) [@stefan24](https://discourse.nodered.org/u/stefan24)\
**Post date:** [7 October 2024 16:15 UTC](https://discourse.nodered.org/t/problems-with-sensehat-on-pi4-with-bookworm-python3-and-nr-4-0-3/92220/1 "2024-10-07T16:15:06Z")

</div>

My smarthome still uses a Pi3, Sensehat, NR 3.x with buster (with Python 2.7.16).  
Here the Sensehat out node works without problems.

In my test environment on a Pi4 with Bookworm (Python3) and NR 4.0.3 the  
Sensehat nodes (node-red-node-pi-sense-hat 0.1.5) starts connected after deploy and gets "disconnected" whenever I send a (valid) command to the Sensehat out node:  
[top]

`payload: "*,*,yellow"`

The Sensehat show all pixels in yellow, but gets stuck for 5 seconds.  
After 5 seconds all pixels switch off without another command being send.  
I cannot send another command within this time frame.  
But input via Joystick or acceleration arrive at the debug node within these 5 seconds (and also afterwards).  
As soon the pixels are blank, the game starts from [top].

Any idea other than using old versions of Python or PiOS?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [7 October 2024 18:19 UTC](https://discourse.nodered.org/t/problems-with-sensehat-on-pi4-with-bookworm-python3-and-nr-4-0-3/92220/2 "2024-10-07T18:19:01Z")

</div>

There were issues when the Pi's OS upgraded python from 2 to 3 back in 2021. Check out these threads:

> [@SenseHat environment / motion problem](https://discourse.nodered.org/t/sensehat-environment-motion-problem/46851):
>
> Hello to all, for a project I got the task to display the temperature and compass value from a Sense Hat in a dashboard. Now I have the problem, if I activate both hooks at environment and motion in the node of the SenseHat, I get only the values of the Compass displayed and no more temperature values. What can I do differently, if I want to read both range or do I have to make a correction in a configuration file? (I have also already slowed down the transmission of the messages with a delay …

> [@Raspberry sense hat problem](https://discourse.nodered.org/t/raspberry-sense-hat-problem/57918):
>
> Trying to get my sense hat working after a crash of my pi. created a new image ( basic ) and installed node red. using nr version 2.2.0 every time i get the message [node-red-node-pi-sense-hat/sensehat] Error: Can't find Sense HAT python libraries. Run sudo apt-get install sense-hat on install of sudo pip-3.2 install pillow i get sudo: pip-3.2: command not found maybe this is the problem? i cannot find in google how to solve that thanks!

---

<div class="post-metadata">

**Author:** ![stefan24](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stefan24/32/23075_2.png) [@stefan24](https://discourse.nodered.org/u/stefan24)\
**Post date:** [7 October 2024 21:38 UTC](https://discourse.nodered.org/t/problems-with-sensehat-on-pi4-with-bookworm-python3-and-nr-4-0-3/92220/3 "2024-10-07T21:38:08Z")

</div>

I read them already. The problem seemed to be Python3. BUT:  
The test script from Python (Hello World) was running from the shell.

Vice versa: The same Pi4, the same Sensehat board, a new Micro-SD card with PiOS Bullseye, the same NR 4.0.3 and again Python3 are running flawlessly!  
BTW: My flow is a snake-like demo:

```auto
[
    {
        "id": "1ee6c70d.db7dc9",
        "type": "tab",
        "label": "4Snakes",
        "disabled": false,
        "info": ""
    },
    {
        "id": "f11e7cc7.903c18",
        "type": "rpi-sensehat in",
        "z": "1ee6c70d.db7dc9",
        "name": "Joystick",
        "motion": false,
        "env": false,
        "stick": true,
        "x": 70,
        "y": 200,
        "wires": [
            [
                "7797264.1122758"
            ]
        ]
    },
    {
        "id": "64d622a8.6628ec",
        "type": "inject",
        "z": "1ee6c70d.db7dc9",
        "name": "Init",
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 150,
        "y": 120,
        "wires": [
            [
                "46df4e58.7b521"
            ]
        ]
    },
    {
        "id": "46df4e58.7b521",
        "type": "function",
        "z": "1ee6c70d.db7dc9",
        "name": "Variablen 1",
        "func": "\nflow.set(\"Spur\",true);\nflow.set(\"Shutdown\",false);\nflow.set(\"Joystick\",true);\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 510,
        "y": 120,
        "wires": [
            [
                "1f5eee13.28c082"
            ]
        ]
    },
    {
        "id": "9f3c018.ca8d8",
        "type": "function",
        "z": "1ee6c70d.db7dc9",
        "name": "Reset Display",
        "func": "return {\n payload: \"*,*,off\"\n\n}\n",
        "outputs": 1,
        "noerr": 0,
        "x": 1020,
        "y": 120,
        "wires": [
            [
                "e1d5b8e6.fdc06",
                "1c613d46.f07333"
            ]
        ]
    },
    {
        "id": "a397b650.2f4b1",
        "type": "function",
        "z": "1ee6c70d.db7dc9",
        "name": "Enter",
        "func": "\nvar Pixel = flow.get(\"Pixel\");\nPixel++;\nif (Pixel === 4) { Pixel = 0}\nflow.set(\"Pixel\", Pixel);\n\nmsg.payload = Pixel;\n\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "x": 610,
        "y": 420,
        "wires": [
            [
                "cf3a0b88.e5e2b"
            ]
        ]
    },
    {
        "id": "9a487c3.1355a8",
        "type": "switch",
        "z": "1ee6c70d.db7dc9",
        "name": "Taste",
        "property": "payload.key",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "ENTER",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "UP",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "DOWN",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "LEFT",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "RIGHT",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 5,
        "x": 370,
        "y": 580,
        "wires": [
            [
                "5a9abf13.16397"
            ],
            [
                "a9178747.86ca98"
            ],
            [
                "91a34a51.0f5208"
            ],
            [
                "9220ea6f.88a3a8"
            ],
            [
                "b8c2bb28.fabb58"
            ]
        ],
        "outputLabels": [
            "Enter",
            "Up",
            "Down",
            "Left",
            "Right"
        ]
    },
    {
        "id": "2c663e14.6c29d2",
        "type": "switch",
        "z": "1ee6c70d.db7dc9",
        "name": "Losgelassen",
        "property": "payload.state",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "2",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "0",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 350,
        "y": 200,
        "wires": [
            [
                "1108bc5e.be50b4"
            ],
            [
                "9a487c3.1355a8"
            ]
        ]
    },
    {
        "id": "a9178747.86ca98",
        "type": "function",
        "z": "1ee6c70d.db7dc9",
        "name": "Up",
        "func": "var Pixels = flow.get(\"Pixels\");\nvar Pixel = flow.get(\"Pixel\");\n\nif (Pixels.Pix[Pixel].y > 0)\n {\n Pixels.Pix[Pixel].y--;\n flow.set(\"Pixels\", Pixels);\n }\n\nflow.set(\"Shutdown\",false);\n\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "x": 530,
        "y": 560,
        "wires": [
            [
                "868106d9.88e6"
            ]
        ]
    },
    {
        "id": "868106d9.88e6",
        "type": "function",
        "z": "1ee6c70d.db7dc9",
        "name": "Matrix",
        "func": "var Pixels = flow.get(\"Pixels\");\n\n// Einzelpixel:\nvar coll =\"*,*,off,\"\n\nif (flow.get(\"Spur\"))\n{\n//Pixelspur:\ncoll =\"\"\n}\n\nfor (let i = 0; i < 4; i++) {\n coll = coll + Pixels.Pix[i].x+\",\";\n coll = coll + Pixels.Pix[i].y+\",\";\n coll = coll + Pixels.Pix[i].farbe+\",\";\n \n}\n\nmsg.payload = coll.substring(0, coll.length-1);\n\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "x": 930,
        "y": 640,
        "wires": [
            [
                "e1d5b8e6.fdc06",
                "7afbdd39.bf67c4"
            ]
        ]
    },
    {
        "id": "e1d5b8e6.fdc06",
        "type": "rpi-sensehat out",
        "z": "1ee6c70d.db7dc9",
        "name": "",
        "x": 1250,
        "y": 460,
        "wires": []
    },
    {
        "id": "cf3a0b88.e5e2b",
        "type": "function",
        "z": "1ee6c70d.db7dc9",
        "name": "Matrix white",
        "func": "var Pixels = flow.get(\"Pixels\");\n\nvar Pixel = flow.get(\"Pixel\");\n\n// Einzelpixel:\nvar coll =\"*,*,off,\"\n\nif (flow.get(\"Spur\"))\n{\n//Pixelspur:\ncoll =\"\"\n}\n\n\nfor (let i = 0; i < 4; i++) {\n coll = coll + Pixels.Pix[i].x+\",\";\n coll = coll + Pixels.Pix[i].y+\",\";\n if (Pixel === i) {\n coll = coll + \"white,\";\n } else\n {\n coll = coll + Pixels.Pix[i].farbe+\",\";\n } \n}\n\nmsg.payload = coll.substring(0, coll.length-1);\n\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "x": 970,
        "y": 420,
        "wires": [
            [
                "8e87a570.b1505",
                "e1d5b8e6.fdc06"
            ]
        ]
    },
    {
        "id": "8e87a570.b1505",
        "type": "delay",
        "z": "1ee6c70d.db7dc9",
        "name": "500 Msek",
        "pauseType": "delay",
        "timeout": "500",
        "timeoutUnits": "milliseconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "outputs": 1,
        "x": 960,
        "y": 540,
        "wires": [
            [
                "868106d9.88e6"
            ]
        ],
        "info": "Solange bleibt der aktive Pixel weiß, bis er wieder die ursprüngliche Farbe erhält.\n"
    },
    {
        "id": "91a34a51.0f5208",
        "type": "function",
        "z": "1ee6c70d.db7dc9",
        "name": "Down",
        "func": "var Pixels = flow.get(\"Pixels\");\nvar Pixel = flow.get(\"Pixel\");\n\nif (Pixels.Pix[Pixel].y < 7)\n {\n Pixels.Pix[Pixel].y++;\n flow.set(\"Pixels\", Pixels);\n }\n\nflow.set(\"Shutdown\",false);\n\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "x": 530,
        "y": 600,
        "wires": [
            [
                "868106d9.88e6"
            ]
        ]
    },
    {
        "id": "9220ea6f.88a3a8",
        "type": "function",
        "z": "1ee6c70d.db7dc9",
        "name": "Left",
        "func": "var Pixels = flow.get(\"Pixels\");\nvar Pixel = flow.get(\"Pixel\");\n\nif (Pixels.Pix[Pixel].x > 0)\n {\n Pixels.Pix[Pixel].x--;\n flow.set(\"Pixels\", Pixels);\n }\n\nflow.set(\"Shutdown\",false);\n\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "x": 530,
        "y": 640,
        "wires": [
            [
                "868106d9.88e6"
            ]
        ]
    },
    {
        "id": "b8c2bb28.fabb58",
        "type": "function",
        "z": "1ee6c70d.db7dc9",
        "name": "Right",
        "func": "var Pixels = flow.get(\"Pixels\");\nvar Pixel = flow.get(\"Pixel\");\n\nif (Pixels.Pix[Pixel].x < 7)\n {\n Pixels.Pix[Pixel].x++;\n flow.set(\"Pixels\", Pixels);\n }\n\nflow.set(\"Shutdown\",false);\n\n\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "x": 530,
        "y": 680,
        "wires": [
            [
                "868106d9.88e6"
            ]
        ]
    },
    {
        "id": "1108bc5e.be50b4",
        "type": "switch",
        "z": "1ee6c70d.db7dc9",
        "name": "lang Taste",
        "property": "payload.key",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "ENTER",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "UP",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "DOWN",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "LEFT",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "RIGHT",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 5,
        "x": 570,
        "y": 220,
        "wires": [
            [
                "46df4e58.7b521"
            ],
            [
                "1d7b9b2c.83e99d"
            ],
            [
                "1f5eee13.28c082",
                "54037e1f.7a5c"
            ],
            [
                "1d1d137e.25e085"
            ],
            []
        ],
        "outputLabels": [
            "Enter",
            "Up",
            "Down",
            "Left",
            "Right"
        ]
    },
    {
        "id": "3f90715a.600436",
        "type": "comment",
        "z": "1ee6c70d.db7dc9",
        "name": "4Snakes V 0.97 / 07.10.2024)",
        "info": " **Steuere 4 farbige Schlangen auf dem Sense Hat!** \n\nDurch kurzes Drücken von Enter wählt man den aktiven Pixel aus. Dieser wird kurz weiß.\nDurch die Bewegungen des Joysticks wird der aktive Pixel gesteuert.\nDurch langes Drücken von Enter wird das Display zurück gesetzt.\nDurch langes Drücken von Up wird die Spur umgeschaltet.\nDurch langes Drücken von links wird die Bedienung zwischen Joystick und Bewegungssensor umgeschaltet.\n\nDurch langes Drücken von Down wird nach erneutem kurzen Druck von Enter der Pi herunter gefahren.\n\n **move 4 colored snakes on the Sense Hat!** \n\nshort press Enter: select the pixel, which turns white for a fraction of a second.\njoystick: move the pixel\nlong press Enter: resets the Display\nlong press up: enable/disable a trail\nlong press down + short press Enter: shutdown the Raspi\nlong press left: switch between joystick and motion sensor\n\n_(c) 2020-2024 Stefan Braunstein, stefan@braunstein.de_\n",
        "x": 170,
        "y": 60,
        "wires": []
    },
    {
        "id": "1d7b9b2c.83e99d",
        "type": "function",
        "z": "1ee6c70d.db7dc9",
        "name": "Spurwechsel",
        "func": "\nif (flow.get(\"Spur\"))\n{\n flow.set(\"Spur\",false)\n}\nelse\n{\n flow.set(\"Spur\",true)\n}\n\nmsg.payload = flow.get(\"Spur\");\n\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "x": 830,
        "y": 200,
        "wires": [
            [
                "1f5eee13.28c082"
            ]
        ]
    },
    {
        "id": "1f5eee13.28c082",
        "type": "function",
        "z": "1ee6c70d.db7dc9",
        "name": "Variablen 2",
        "func": "var Pixels = { \n Pix: [\n { x: 0, y: 0, farbe: \"red\" },\n { x: 0, y: 7, farbe: \"green\"},\n { x: 7, y: 7, farbe: \"blue\"},\n { x: 7, y: 0, farbe: \"yellow\"}\n]\n}\n\nflow.set(\"Pixels\",Pixels);\nflow.set(\"Pixel\",1);\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 810,
        "y": 120,
        "wires": [
            [
                "9f3c018.ca8d8"
            ]
        ]
    },
    {
        "id": "1c613d46.f07333",
        "type": "delay",
        "z": "1ee6c70d.db7dc9",
        "name": "100 Msek",
        "pauseType": "delay",
        "timeout": "100",
        "timeoutUnits": "milliseconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "outputs": 1,
        "x": 1220,
        "y": 120,
        "wires": [
            [
                "cf3a0b88.e5e2b"
            ]
        ]
    },
    {
        "id": "7797264.1122758",
        "type": "rbe",
        "z": "1ee6c70d.db7dc9",
        "name": "",
        "func": "rbe",
        "gap": "",
        "start": "",
        "inout": "out",
        "property": "payload",
        "x": 210,
        "y": 200,
        "wires": [
            [
                "2c663e14.6c29d2"
            ]
        ]
    },
    {
        "id": "7249dfd2.5af27",
        "type": "function",
        "z": "1ee6c70d.db7dc9",
        "name": "Matrix off",
        "func": "\nflow.set(\"Spur\",false);\n\nvar Pixels = flow.get(\"Pixels\");\n\nPixels.Pix[0].x++;\nPixels.Pix[0].y++;\nPixels.Pix[1].x++;\nPixels.Pix[1].y--;\nPixels.Pix[2].x--;\nPixels.Pix[2].y--;\nPixels.Pix[3].x--;\nPixels.Pix[3].y++;\n\nflow.set(\"Pixels\", Pixels);\n\n\nflow.set(\"Shutdown\",true);\n\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "x": 1160,
        "y": 760,
        "wires": [
            [
                "868106d9.88e6"
            ]
        ]
    },
    {
        "id": "69f7afc0.523a38",
        "type": "delay",
        "z": "1ee6c70d.db7dc9",
        "name": "",
        "pauseType": "delay",
        "timeout": "500",
        "timeoutUnits": "milliseconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "outputs": 1,
        "x": 720,
        "y": 760,
        "wires": [
            [
                "7249dfd2.5af27"
            ]
        ]
    },
    {
        "id": "1716c070.44dcd",
        "type": "debug",
        "z": "1ee6c70d.db7dc9",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "x": 1270,
        "y": 640,
        "wires": []
    },
    {
        "id": "93066940.1c329",
        "type": "delay",
        "z": "1ee6c70d.db7dc9",
        "name": "",
        "pauseType": "delay",
        "timeout": "750",
        "timeoutUnits": "milliseconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "outputs": 1,
        "x": 720,
        "y": 820,
        "wires": [
            [
                "7249dfd2.5af27"
            ]
        ]
    },
    {
        "id": "588ae072.5a16c8",
        "type": "delay",
        "z": "1ee6c70d.db7dc9",
        "name": "",
        "pauseType": "delay",
        "timeout": "1",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "outputs": 1,
        "x": 700,
        "y": 880,
        "wires": [
            [
                "7249dfd2.5af27"
            ]
        ]
    },
    {
        "id": "54037e1f.7a5c",
        "type": "function",
        "z": "1ee6c70d.db7dc9",
        "name": "Reset Pixels",
        "func": "var Pixels = { \n Pix: [\n { x: 0, y: 0, farbe: \"red\" },\n { x: 0, y: 7, farbe: \"green\"},\n { x: 7, y: 7, farbe: \"blue\"},\n { x: 7, y: 0, farbe: \"yellow\"}\n]\n}\n\nflow.set(\"Pixels\",Pixels);\n\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "x": 790,
        "y": 320,
        "wires": [
            [
                "69f7afc0.523a38",
                "93066940.1c329",
                "588ae072.5a16c8"
            ]
        ]
    },
    {
        "id": "5a9abf13.16397",
        "type": "switch",
        "z": "1ee6c70d.db7dc9",
        "name": "",
        "property": "Shutdown",
        "propertyType": "flow",
        "rules": [
            {
                "t": "false"
            },
            {
                "t": "true"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 450,
        "y": 460,
        "wires": [
            [
                "a397b650.2f4b1"
            ],
            [
                "99773fdc.a4a4a",
                "fe8eb4d0.41144"
            ]
        ]
    },
    {
        "id": "37a842ab.2647b6",
        "type": "exec",
        "z": "1ee6c70d.db7dc9",
        "command": "sudo",
        "addpay": false,
        "append": "init 0",
        "useSpawn": "false",
        "timer": "",
        "winHide": false,
        "oldrc": false,
        "name": "Shutdown",
        "x": 1220,
        "y": 840,
        "wires": [
            [],
            [],
            []
        ]
    },
    {
        "id": "fe8eb4d0.41144",
        "type": "delay",
        "z": "1ee6c70d.db7dc9",
        "name": "",
        "pauseType": "delay",
        "timeout": "1",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "outputs": 1,
        "x": 1040,
        "y": 840,
        "wires": [
            [
                "37a842ab.2647b6"
            ]
        ]
    },
    {
        "id": "99773fdc.a4a4a",
        "type": "function",
        "z": "1ee6c70d.db7dc9",
        "name": "Reset Display",
        "func": "return {\n payload: \"*,*,off\"\n\n}\n",
        "outputs": 1,
        "noerr": 0,
        "x": 640,
        "y": 460,
        "wires": [
            [
                "e1d5b8e6.fdc06"
            ]
        ]
    },
    {
        "id": "7bfb2244.9418cc",
        "type": "rpi-sensehat in",
        "z": "1ee6c70d.db7dc9",
        "name": "Gyroskop",
        "motion": true,
        "env": false,
        "stick": false,
        "x": 80,
        "y": 300,
        "wires": [
            [
                "4095335d.a98e84",
                "dc479121.0600c"
            ]
        ]
    },
    {
        "id": "4095335d.a98e84",
        "type": "function",
        "z": "1ee6c70d.db7dc9",
        "name": "Roll",
        "func": "var taste = \"\";\nvar mm = {\n \"payload\": {\n \"key\": \"\"\n }\n}\n\nif (msg.payload.orientation.roll <340 && msg.payload.orientation.roll >310)\n{taste = \"UP\";}\n\nif (msg.payload.orientation.roll <50 && msg.payload.orientation.roll >20)\n{taste = \"DOWN\";}\n\nmm.payload.key = taste;\n\nif (taste === \"\" || flow.get(\"Joystick\") === true )\n{return [null,mm];}\nelse\n{return [mm,null];}\n\n",
        "outputs": 2,
        "noerr": 0,
        "x": 270,
        "y": 320,
        "wires": [
            [
                "77fd816d.0ae62"
            ],
            []
        ]
    },
    {
        "id": "dc479121.0600c",
        "type": "function",
        "z": "1ee6c70d.db7dc9",
        "name": "Pitch",
        "func": "var taste = \"\";\nvar mm = {\n \"payload\": {\n \"key\": \"\"\n }\n}\n\nif (msg.payload.orientation.pitch <340 && msg.payload.orientation.pitch >310)\n{taste = \"RIGHT\";}\n\nif (msg.payload.orientation.pitch <40 && msg.payload.orientation.pitch >10)\n{taste = \"LEFT\";}\n\nmm.payload.key = taste;\n\nif (taste === \"\" || flow.get(\"Joystick\") === true)\n{return [null,mm];}\nelse\n{return [mm,null];}\n\n",
        "outputs": 2,
        "noerr": 0,
        "x": 270,
        "y": 280,
        "wires": [
            [
                "77fd816d.0ae62"
            ],
            []
        ]
    },
    {
        "id": "77fd816d.0ae62",
        "type": "delay",
        "z": "1ee6c70d.db7dc9",
        "name": "",
        "pauseType": "rate",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "3",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": true,
        "outputs": 1,
        "x": 190,
        "y": 580,
        "wires": [
            [
                "9a487c3.1355a8"
            ]
        ]
    },
    {
        "id": "1d1d137e.25e085",
        "type": "function",
        "z": "1ee6c70d.db7dc9",
        "name": "Joystickwechsel",
        "func": "if (flow.get(\"Joystick\"))\n{\n flow.set(\"Joystick\",false)\n}\nelse\n{\n flow.set(\"Joystick\",true)\n}\n\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "x": 840,
        "y": 240,
        "wires": [
            [
                "1f5eee13.28c082"
            ]
        ]
    },
    {
        "id": "7afbdd39.bf67c4",
        "type": "function",
        "z": "1ee6c70d.db7dc9",
        "name": "",
        "func": "\n\nmsg.payload = flow.get(\"Joystick\");\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 1090,
        "y": 640,
        "wires": [
            [
                "1716c070.44dcd"
            ]
        ]
    }
]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [8 October 2024 11:41 UTC](https://discourse.nodered.org/t/problems-with-sensehat-on-pi4-with-bookworm-python3-and-nr-4-0-3/92220/4 "2024-10-08T11:41:33Z")

</div>

I installed your flow on my Pi3 that I have my sensehat installed on (running bullseye) and I see the lights and can move the green dot around. (My 7 year old granddaughter just took it away from me and is having fn playing with it.)

What issue is happening?

---

<div class="post-metadata">

**Author:** ![stefan24](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stefan24/32/23075_2.png) [@stefan24](https://discourse.nodered.org/u/stefan24)\
**Post date:** [8 October 2024 14:55 UTC](https://discourse.nodered.org/t/problems-with-sensehat-on-pi4-with-bookworm-python3-and-nr-4-0-3/92220/5 "2024-10-08T14:55:40Z")

</div>

> [@stefan24](#):
>
> In my test environment on a Pi4 with Bookworm (Python3) and NR 4.0.3 the  
> Sensehat nodes (node-red-node-pi-sense-hat 0.1.5) starts connected after deploy and gets "disconnected" whenever I send a (valid) command to the Sensehat out node:

Every (even simplest) Sensehat flow on my P4 with Bookworm will get "disconnected", when sending a valid command to the Sensehat out node.  
On the same Pi4 under Bullseye even the "4snakes" flow is working without a problem.  
BTW: Did you read the doc in the comment node?

> \*\* move 4 colored snakes on the Sense Hat! \*\*
> 
> short press Enter: select the pixel, which turns white for a fraction of a second.  
> joystick: move the pixel  
> long press Enter: resets the Display  
> long press up: enable/disable a trail  
> long press down + short press Enter: shutdown the Raspi  
> long press left: switch between joystick and motion sensor

Have fun!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [6 January 2025 14:55 UTC](https://discourse.nodered.org/t/problems-with-sensehat-on-pi4-with-bookworm-python3-and-nr-4-0-3/92220/6 "2025-01-06T14:55:53Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
