# Using python script to read Wiiboard data using bluetooth

**URL:** <https://discourse.nodered.org/t/using-python-script-to-read-wiiboard-data-using-bluetooth/17600>\
**Category:** General\
**Created:** [6 November 2019 17:49 UTC](https://discourse.nodered.org/t/using-python-script-to-read-wiiboard-data-using-bluetooth/17600 "2019-11-06T17:49:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![YLM](https://avatars.discourse-cdn.com/v4/letter/y/59ef9b/32.png) [@YLM](https://discourse.nodered.org/u/YLM)\
**Post date:** [6 November 2019 17:49 UTC](https://discourse.nodered.org/t/using-python-script-to-read-wiiboard-data-using-bluetooth/17600/1 "2019-11-06T17:49:04Z")

</div>

Hi,

I have a python script to read the data of the Wiiboard (it's works correctly if I run the python code from the terminal).

 ![Capture%20du%202019-11-06%2015-34-14](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/2d7d36b4f6891a96c50883a4eb8ec2db64da5ab4.png)

I'd like to run the same thing in Note-red, so I have done a simple flow `[{"id":"e7d70765.df79d8","type":"exec","z":"91cb8da0.1019d8","command":"python /home/franck/Bureau/Yann/wiiboard_test.py","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":390,"y":220,"wires":[["50e195f7.d2d324"],["49bfc4f6.1d350c"],["1c185622.fe1422"]]}]`  
but I got an error in the 3 outputs...

![Capture%20du%202019-11-06%2010-47-03](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/82289c4b65c78aaec8ef0b249ada6c0fa35493a7.png)

I have not idea why it is not working since it worked in my terminal...

Thank you

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [6 November 2019 19:58 UTC](https://discourse.nodered.org/t/using-python-script-to-read-wiiboard-data-using-bluetooth/17600/2 "2019-11-06T19:58:11Z")

</div>

It says "Host is down" near the end! Looks like the Python script it throwing an error.  
Also you have appended the msg.payload, does that contain valid parameters?

---

<div class="post-metadata">

**Author:** ![YLM](https://avatars.discourse-cdn.com/v4/letter/y/59ef9b/32.png) [@YLM](https://discourse.nodered.org/u/YLM)\
**Post date:** [7 November 2019 08:15 UTC](https://discourse.nodered.org/t/using-python-script-to-read-wiiboard-data-using-bluetooth/17600/3 "2019-11-07T08:15:31Z")

</div>

Yes, I think the python script throw an error but I do not get why since when I run my code inside the terminal it works perfectly... the error "Trying to connect..." comes from my python code..

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 November 2019 08:35 UTC](https://discourse.nodered.org/t/using-python-script-to-read-wiiboard-data-using-bluetooth/17600/4 "2019-11-07T08:35:46Z")

</div>

You did not reply to the question about the payload.

---

<div class="post-metadata">

**Author:** ![YLM](https://avatars.discourse-cdn.com/v4/letter/y/59ef9b/32.png) [@YLM](https://discourse.nodered.org/u/YLM)\
**Post date:** [7 November 2019 10:02 UTC](https://discourse.nodered.org/t/using-python-script-to-read-wiiboard-data-using-bluetooth/17600/5 "2019-11-07T10:02:37Z")

</div>

what does mean by "valid parameters" ?

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [7 November 2019 10:23 UTC](https://discourse.nodered.org/t/using-python-script-to-read-wiiboard-data-using-bluetooth/17600/6 "2019-11-07T10:23:16Z")

</div>

There is an option in the exec node to append the payload as parameters to the python script as you would if you executed the script manually:

Python3 myscript.py myparameter

You have checked this option in the node. This means that the exec node is appending the payload to your script. This may not be what you want.

---

<div class="post-metadata">

**Author:** ![YLM](https://avatars.discourse-cdn.com/v4/letter/y/59ef9b/32.png) [@YLM](https://discourse.nodered.org/u/YLM)\
**Post date:** [7 November 2019 16:28 UTC](https://discourse.nodered.org/t/using-python-script-to-read-wiiboard-data-using-bluetooth/17600/7 "2019-11-07T16:28:54Z")

</div>

Thank you. It's better, the code begins to work. But I think that my main trouble is that inside my python code I do the init, then the connection and when this is done I can print the output of the signal... Probably that by doing this node-red, my python code is every time re read from the beginning whereas the init and connection should not be done a second time... I need to figure out how to pass this...

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [7 November 2019 16:37 UTC](https://discourse.nodered.org/t/using-python-script-to-read-wiiboard-data-using-bluetooth/17600/8 "2019-11-07T16:37:28Z")

</div>

maybe use the node-red-node-daemon node - that is designed for longer running process (like scanning). You specify an app to run - then you can send it commands via the input and get outputs as they come back.
