Can't read motion data from sense hat in Node Red

Hello community ,
i am using Raspberry Pi 3 and Sense Hat to get Environment events and Motion events
I can get temperature and pressure and humidty , but i can't get the mention data at all.
i tried to reinstall all packages , but it didnt help.
i am using python 3 on my raspberry by the way.
Thanks for your help.

There was a change in python between v2 and v3 and the sensehat code has a problem with v3. If you install python v2 you can get it to work.

For background take a look at SenseHat environment / motion problem - #22 by cymplecy

Thank you for your fast reply .
actually , i ended up clollecting my motion data , using this node-red-contrib-ibm-watson-iot (node) - Node-RED
Now the problem is i cant collect them both at once , i read the solution you ve sent me, and indeed i made the same modifications , but it still dosent work.
the first image is the sensehat file
and the second image is the sensehat.js file
Capture

Do you have python 2 installed?

I guess yes , i used this

sudo apt install python2

Why are you using Watson?
If you disable the Watson node does it work?

before installing Watson , i could'nt get the Motion data .
after i installed it , it worked .
Even if i want to disable it , ican't , because it's always used
4

What other needs do you have for using Watson? I'm just trying to understand why you installed it in the first place.

You say you couldn't get motion data before installng Watson, was Python 2 installed at that point?

Have you gone thru your flows and found the watson node and disabled it there? (bottom of the configuraion should be a disable button)

I deleted all Watson nodes , and installed python 2 , and now i can get motion data as well as the envir data .
However , i still can't get them at the same time.
what should i do after installing python 2 , is there another step to make Node Red ru Python 2 not Python 3.

Try this flow and see what you get

[{"id":"2f1ce5a518f7038c","type":"debug","z":"72bc62f170dc8752","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":630,"y":380,"wires":[]},{"id":"f79dfaa36cd93353","type":"ui_text","z":"72bc62f170dc8752","group":"47aa14e39a93548c","order":0,"width":0,"height":0,"name":"","label":"direction","format":"{{msg.payload.key}}","layout":"row-spread","className":"","x":640,"y":200,"wires":[]},{"id":"a94be90051639b30","type":"switch","z":"72bc62f170dc8752","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"joystick","vt":"str"},{"t":"eq","v":"environment","vt":"str"},{"t":"eq","v":"motion","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":430,"y":300,"wires":[["f79dfaa36cd93353"],["00565d90f8b06675","a3fdd7a258d8506b","1d8cadbb78ae0076"],["2f1ce5a518f7038c"]]},{"id":"cfc50256585fba98","type":"ui_gauge","z":"72bc62f170dc8752","name":"","group":"47aa14e39a93548c","order":1,"width":0,"height":0,"gtype":"gage","title":"temperature","label":"units","format":"{{value}}","min":0,"max":10,"colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":930,"y":260,"wires":[]},{"id":"0cb4be89d2525e83","type":"ui_gauge","z":"72bc62f170dc8752","name":"","group":"47aa14e39a93548c","order":2,"width":0,"height":0,"gtype":"gage","title":"humidity","label":"units","format":"{{value}}","min":0,"max":10,"colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":920,"y":300,"wires":[]},{"id":"ede3ec40fb37212d","type":"ui_gauge","z":"72bc62f170dc8752","name":"","group":"47aa14e39a93548c","order":3,"width":0,"height":0,"gtype":"gage","title":"pressure","label":"units","format":"{{value}}","min":0,"max":10,"colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":920,"y":340,"wires":[]},{"id":"00565d90f8b06675","type":"change","z":"72bc62f170dc8752","name":"temperature","rules":[{"t":"move","p":"payload.temperature","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":260,"wires":[["cfc50256585fba98"]]},{"id":"a3fdd7a258d8506b","type":"change","z":"72bc62f170dc8752","name":"humidity","rules":[{"t":"move","p":"payload.humidity","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":300,"wires":[["0cb4be89d2525e83"]]},{"id":"1d8cadbb78ae0076","type":"change","z":"72bc62f170dc8752","name":"pressure","rules":[{"t":"move","p":"payload.pressure","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":340,"wires":[["ede3ec40fb37212d"]]},{"id":"2f281db51b977dbd","type":"rpi-sensehat in","z":"72bc62f170dc8752","name":"","motion":true,"env":true,"stick":true,"x":260,"y":300,"wires":[["a94be90051639b30","566d6385f0d1d5ac"]]},{"id":"566d6385f0d1d5ac","type":"debug","z":"72bc62f170dc8752","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":330,"y":380,"wires":[]},{"id":"47aa14e39a93548c","type":"ui_group","name":"Default","tab":"4e80112e637d60e5","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"4e80112e637d60e5","type":"ui_tab","name":"Home","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

If I remember right, you will see more of the motion than the environment readings.

even with this , still the same issue.
i just wanna know , how can i know which python my Red Node is using ?

On the pi, open a terminal window and enter python -V (capitilize the V0 and you should get something back like:
Python 2.7.16

To force python2 to be used with the sendehat, you will need to edit a file. On the Pi

  1. open a terminal window
  2. issue the following command:
    nano $home/pi/.node-red/node_modules/node-red-node-pi-sense-hat/sensehat
  3. change line 3 from:
    python_cmd='python3'
    to
    python_cmd='python'
  4. press ctrl-x then y and press enter
  5. Stop and start node-red and test it out.

That should force Python2 to run.

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