# Not possible to read all values in SenseHat-Node

**URL:** <https://discourse.nodered.org/t/not-possible-to-read-all-values-in-sensehat-node/78052>\
**Category:** General\
**Created:** [30 April 2023 17:09 UTC](https://discourse.nodered.org/t/not-possible-to-read-all-values-in-sensehat-node/78052 "2023-04-30T17:09:11Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxfoxim](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxfoxim/32/79408_2.png) [@maxfoxim](https://discourse.nodered.org/u/maxfoxim)\
**Post date:** [30 April 2023 17:09 UTC](https://discourse.nodered.org/t/not-possible-to-read-all-values-in-sensehat-node/78052/1 "2023-04-30T17:09:11Z")

</div>

Hello together,

Last week I gave an IoT Course in Azure by using Raspberry Pis with a Sensehat. For connection, processing and data output to the cloud I was using Node-Red. Before I updated to the newest version of Pi-OS and Node-Red. But I got a problem with the Sensehat-Node. In the old version (0.) I could read enviroment, motion and joystick parallel. But now it seems to be stucked to use all groups together. If there are activated all three groups only enviroment **or** motion will be processed or seen in the debug node.  
In the end I had to correct the exercises to read only one group. So my question is, if there exists a solution or bug-fix for this problem.

I was using a Pi Version 3 and 3B+.

Best regards from Dresden  
Stephan

---

<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:** [30 April 2023 17:50 UTC](https://discourse.nodered.org/t/not-possible-to-read-all-values-in-sensehat-node/78052/2 "2023-04-30T17:50:13Z")

</div>

This is a known problem with python3. There was a change in python3 that causes the problem with the node`s code.

If you do a search on the forum using `sensehat` you will find the reports of the problem. I topknot a stab at updating the code along time ago but I’m not a python coder 😟

---

<div class="post-metadata">

**Author:** ![maxfoxim](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxfoxim/32/79408_2.png) [@maxfoxim](https://discourse.nodered.org/u/maxfoxim)\
**Post date:** [30 April 2023 18:18 UTC](https://discourse.nodered.org/t/not-possible-to-read-all-values-in-sensehat-node/78052/3 "2023-04-30T18:18:52Z")

</div>

Hey,

thanks for the fast answer. I was googeling for the error a few hours and also searching in the forum for a few minutes. Could not find something until I search for "python Sensehat". Then I saw your post. 🙂

Do you have any idea what the error in the Python code could be? Any hint or idea would be helpful. I know Python and maybe I find the time to debug the code.

---

<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:** [30 April 2023 20:26 UTC](https://discourse.nodered.org/t/not-possible-to-read-all-values-in-sensehat-node/78052/4 "2023-04-30T20:26:43Z")

</div>

Here is a link to the code:

> <https://github.com/node-red/node-red-nodes/blob/master/hardware/sensehat/sensehat.py>

---

<div class="post-metadata">

**Author:** ![maxfoxim](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxfoxim/32/79408_2.png) [@maxfoxim](https://discourse.nodered.org/u/maxfoxim)\
**Post date:** [30 April 2023 20:49 UTC](https://discourse.nodered.org/t/not-possible-to-read-all-values-in-sensehat-node/78052/5 "2023-04-30T20:49:35Z")

</div>

Thanks for sharing the link, but I found the source code a few hours ago and are looking for some suspicious lines in the moment. So far everything seems fine. It is a tough problem without debugging options.... 😕

---

<div class="post-metadata">

**Author:** ![maxfoxim](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxfoxim/32/79408_2.png) [@maxfoxim](https://discourse.nodered.org/u/maxfoxim)\
**Post date:** [30 April 2023 21:18 UTC](https://discourse.nodered.org/t/not-possible-to-read-all-values-in-sensehat-node/78052/6 "2023-04-30T21:18:15Z")

</div>

I found something interesting. When I change the two variables in the python code to "True" it seems to work:

hf\_enabled = True  
lf\_enabled = True

(Line 68). Could you check it with your device, please? 🙂

---

<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:** [30 April 2023 23:11 UTC](https://discourse.nodered.org/t/not-possible-to-read-all-values-in-sensehat-node/78052/7 "2023-04-30T23:11:49Z")

</div>

I'll check it out tomorrow since I have a test running on the Pi with the sensehat on it.

---

<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:** [1 May 2023 08:36 UTC](https://discourse.nodered.org/t/not-possible-to-read-all-values-in-sensehat-node/78052/8 "2023-05-01T08:36:23Z")

</div>

Nope, that doesn't fix the issue.

The issue is that when you have all three options checked in the node, 'environment' is never returned.  
Here is a simple test flow so you can see the number of msgs returned.

Remember the if you change `sensor hat.py` you must restart Node-RED before testing again.

NOTE: you will have to install 'node-red-contrib-counter' for this flow.

```auto
[{"id":"a94be90051639b30","type":"switch","z":"72bc62f170dc8752","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"environment","vt":"str"},{"t":"eq","v":"joystick","vt":"str"},{"t":"eq","v":"motion","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":450,"y":420,"wires":[["00565d90f8b06675","a3fdd7a258d8506b","1d8cadbb78ae0076","5628700cc303ddec"],["f79dfaa36cd93353","808f259f9bfd243b"],["cec6e96f900abe26"]]},{"id":"2f281db51b977dbd","type":"rpi-sensehat in","z":"72bc62f170dc8752","name":"","motion":true,"env":true,"stick":true,"x":280,"y":420,"wires":[["a94be90051639b30"]]},{"id":"808f259f9bfd243b","type":"counter","z":"72bc62f170dc8752","name":"joystick","init":"0","step":"1","lower":"","upper":"","mode":"increment","outputs":"1","x":620,"y":420,"wires":[["2db1fdc0ca54e01e"]]},{"id":"5628700cc303ddec","type":"counter","z":"72bc62f170dc8752","name":"environment","init":"0","step":"1","lower":"","upper":"","mode":"increment","outputs":"1","x":630,"y":360,"wires":[["e6014bc89d73560d"]]},{"id":"cec6e96f900abe26","type":"counter","z":"72bc62f170dc8752","name":"motion","init":"0","step":"1","lower":"","upper":"","mode":"increment","outputs":"1","x":610,"y":480,"wires":[["d1b47431a5a8936e"]]},{"id":"e6014bc89d73560d","type":"debug","z":"72bc62f170dc8752","name":"environment","active":false,"tosidebar":false,"console":false,"tostatus":true,"complete":"count","targetType":"msg","statusVal":"payload","statusType":"auto","x":810,"y":360,"wires":[]},{"id":"2db1fdc0ca54e01e","type":"debug","z":"72bc62f170dc8752","name":"joystick","active":false,"tosidebar":false,"console":false,"tostatus":true,"complete":"count","targetType":"msg","statusVal":"payload","statusType":"auto","x":800,"y":420,"wires":[]},{"id":"d1b47431a5a8936e","type":"debug","z":"72bc62f170dc8752","name":"motion","active":false,"tosidebar":false,"console":false,"tostatus":true,"complete":"count","targetType":"msg","statusVal":"payload","statusType":"auto","x":790,"y":480,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![maxfoxim](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxfoxim/32/79408_2.png) [@maxfoxim](https://discourse.nodered.org/u/maxfoxim)\
**Post date:** [1 May 2023 14:29 UTC](https://discourse.nodered.org/t/not-possible-to-read-all-values-in-sensehat-node/78052/9 "2023-05-01T14:29:57Z")

</div>

Hmmm, strange, because on my Pi it is working. See the screenshot. But I also changed the hf\_interval to 0.9. Further I inserted some print() commands in the while-loop at the end. But I do not think this should have an effect.

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/b/6b598f53d42bc0f3c6246b8c884ac2de8e114bf6.png)

---

<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:** [1 May 2023 16:12 UTC](https://discourse.nodered.org/t/not-possible-to-read-all-values-in-sensehat-node/78052/10 "2023-05-01T16:12:20Z")

</div>

1. What pi are you using?
2. what OS and version are you running?
3. what version of python on the pi?
4. is NR also running on the pi?  
If not, where is it running?  
What version of NR and node.js are you running? (See startup log)

---

<div class="post-metadata">

**Author:** ![maxfoxim](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxfoxim/32/79408_2.png) [@maxfoxim](https://discourse.nodered.org/u/maxfoxim)\
**Post date:** [1 May 2023 16:32 UTC](https://discourse.nodered.org/t/not-possible-to-read-all-values-in-sensehat-node/78052/11 "2023-05-01T16:32:15Z")

</div>

- Node-RED Version: v3.0.2
- Node.js Version: v16.19.1
- Linux version 6.1.21-v7+ (dom@buildbot) (arm-linux-gnueabihf-gcc-8 (Ubuntu/Linaro 8.4.0-3ubuntu1) 8.4.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #1642 SMP Mon Apr 3 17:20:52 BST 2023
- Raspberry Pi 3 Model B Plus Rev 1.3
- Python 3.9.2 (default, Mar 12 2021, 04:06:34)

I installed last weekend the newest version of PiOS and after that Node-Red and the SenseHat-Node. Node-Red is running on the Pi, but I am looking at the website from my Mac via local network.

Hope that helps.

---

<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:** [1 May 2023 17:53 UTC](https://discourse.nodered.org/t/not-possible-to-read-all-values-in-sensehat-node/78052/12 "2023-05-01T17:53:53Z")

</div>

> [@maxfoxim](#):
>
> Hope that helps.

Hmmm, I'm running it on a  
Pi 3 Model B Rev 1.2  
using Buster (lite)  
python 3.7.3  
NR 3.0.2  
Node.js 16.19.1

So NR and Node.js are the same and the rest is different. I'll try and flash another SD card but it will have to wait, grandkids depending (grin)

---

<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:** [2 May 2023 15:47 UTC](https://discourse.nodered.org/t/not-possible-to-read-all-values-in-sensehat-node/78052/13 "2023-05-02T15:47:04Z")

</div>

Well this is very interesting! With the updates done, when I run the flow (none of your edits to the code) it only shows motion and joystick data. But, if I send a character to display on the LEDs, suddenly the environment data starts showing up too!

Can you add this flow to your flow and see if activating the LEDs causes the others all to work.

```auto
[{"id":"1a13a2b31e5e71f3","type":"inject","z":"72bc62f170dc8752","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"*,*,red","payloadType":"str","x":150,"y":80,"wires":[["3149dd2b6fb6bf43"]]},{"id":"3149dd2b6fb6bf43","type":"rpi-sensehat out","z":"72bc62f170dc8752","name":"","x":630,"y":100,"wires":[]},{"id":"601c24e43f84de73","type":"inject","z":"72bc62f170dc8752","name":"clear LEDs","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":" ","payloadType":"str","x":160,"y":120,"wires":[["3149dd2b6fb6bf43"]]}]

```

---

<div class="post-metadata">

**Author:** ![maxfoxim](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxfoxim/32/79408_2.png) [@maxfoxim](https://discourse.nodered.org/u/maxfoxim)\
**Post date:** [2 May 2023 19:22 UTC](https://discourse.nodered.org/t/not-possible-to-read-all-values-in-sensehat-node/78052/14 "2023-05-02T19:22:29Z")

</div>

Hey again,

so I reveserd my changes, (hf,lf\_enabeld set to False and hf\_interval to 0.09) and the old bug was there again. Then I tried with your "character-flow" and it was working.

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/f/9f7cf0ff55cd1590d087f73054761152879ac3a1.png)

Maybe it is a malfunction of the initalisation process. That would explain "my" and "your" solution. I guess something is wrong with the

```auto
  if data[0] == "X":
    if data[1] == '0':
      hf_enabled = False
    else:
      hf_enabled = True
  elif data[0] == "Y":
    if data[1] == '0':
      lf_enabled = False
    else:
      lf_enabled = True

```

part.

So I reduced the changes further and found out the only line to change is "lf\_enabled=true". After this it works for me. So I assume strongly that your "character-flow" sets data[0]=="Y" and data[1] something unequeal 0.

Good International Teamwork by the way 😉

---

<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:** [1 July 2023 19:22 UTC](https://discourse.nodered.org/t/not-possible-to-read-all-values-in-sensehat-node/78052/15 "2023-07-01T19:22:38Z")

</div>

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