Passing Variables from one pi to another - python

I'm making a Skeeball program and boards that both work off of a raspberry pi and GPIO sensors with a tkinter gui. The first table and program is working great and now I was thinking about the possibility of adding a second table with multiplayer games.
Each pi would have to talk to each other, preferably over a LAN network instead of using I2C or serial pins. Basically I just need something mostly to pass variables from one pi to another.
My first thought was to use pickle to save to a shared network folder since I'm already using pickle to save my highscores. I just have no clue how to set up a shared folder over raspbian and I'm guessing that probably a pretty bad approach to solving the problem.
I'm also really new when it comes to python and raspbian so sorry if this problem is something super easy all I could find online was how to have a pi talk with a windows pc or an arduino.
Thanks for any help you can give me!

Related

How to automatically send signal using pysignal on Python?

I’m quite new to programming world so this might be a really basic question.
Currently, I’m trying to switch on/off of LED on Arduino by using Python (pyserial).
I found some examples that require key input like on or off after running.py
That example codes actually worked with my device, but I want it without key input and couldn’t find that examples.
I mean if I run LED_ON.py, Python automatically sends on signal to Arduino and LED should be ON. Then to turn it off, close LED_ON.py and just run LED_OFF.py
Is my plan can be implemented?? 😖

How to make python talk to puredata?

This is my first post. I am trying to make a drum kit using a raspberry pi. The drum triggers are some peizoelectric sensors. I have used pygame inside python to play sounds. When the script detected gpio inputs, it played drum sounds. It was fine for the most part but due to latency issues, I took another approach and decided to use puredata.
I want python to detect gpio inputs and then send signals to puredata, which will play the desired sounds.
My question is, how can I get python to send simple signals to puredata??? I am running both python and pd on the same pi.
Also, what do you think of this approach i.e. using puredata directly from gpio inputs? Can having a microcontroller like arduino to send the signals as midi signals to pd affect anything???
Thank you in advance!
I'm going back about a decade but I used Python to send data from the 3d modelling software Blender to PureData using the socket library.
This article might help a bit more with packaging up and sending across.
If you know what your components within PD are expecting as an input that will help you know how best translate your input triggers into packages to ship over socket to PD.

Raspberry Pi Keyboard Splitter

I would like to program a Raspberry Pi to take a single keyboards inputs in one USB port and then output through the Pi's two other USB ports in order to control two Macs at once with one keyboard.
I'm very new to Python. Which functions and commands do I need in order to program this function to my Pi?
I've been searching for the proper command, but I came here for help.
This isn't exactly something easily done with Python. This is because you're delving into developing device drivers on your Macs' side. Please allow me to explain:
Assuming you're using Raspbian on the Raspberry Pi (a flavor of Linux, and thus a Posix system onto itself), you would need to read the appropriate /dev/tty* file which maps to your keyboard first, and then appropriately convert and write out to the appropriate /dev/usb* files. Do note, most computers also send handshakes back and forth to the USB devices (for example, to register them on their own USB busses).
To be frank, you'd probably have better luck splicing wires from your keyboard, and connecting it to another USB male-socket, and then plugging both male-socket ends into your Macs.

Continuously speech recognition

I'm currently working on a project where I need to create some functionality where the user can talk to the product (Raspberry Pi 3). And with talking I mean that the user should be able to say one or two words something like "product start" to the Pi and then it would get activated and do it's thing.
Now because of this, the Pi would need to be able to continuously listen and get activated when a certain combination of words is said by the user.
I've implemented the SpeechRecognition library, this sort of works but sadly there is a maximum of ~10 seconds where the Pi would listen.
I'm wondering if there are any library's which would help me with my use case, any help is welcome.
Can you explain better what do you mean by
sadly there is a maximum of ~10 seconds where the Pi would listen.
From my experience using CMUSphinx (Let me recomend the pocketsphinx version for your use-case), works continuously without problem.
Did you manage to know if the problem is on the Pi side, or the SpeechRecognition side?
What engine are you using behind SpeehRecognition. CMUSphinx, Google, Microsoft? With Google and Microsoft, it iis normal that they have a 10 seconds limitation. However, using CMUSphinx this should not happen. But, you might need to learn a bit how to set up an ASR system.

DHT11 sensor failure on Edison whereas working successful on RPi

Some time ago I was connecting DHT11 sensor to Arduino UNO and wrote a simple library based on the one from Arduino website.
At the moment I'd like to connect DHT11 to Intel Edison with Arduino Expansion Board running Yocto Linux. While trying to rewrite the library to Python I expected a problem with microseconds's sleeps in that language and finally decided to remake Raspberry Pi DHT11 Library using mraa. However, sensor isn't working as well. I found the topic on Intel forum blaming Edison ports fast IN/OUT switching inability. The proposed solution using two wires also didn't help me.
After this introduction, a few questions come to my mind:
Since both Raspberry and Edison are computer systems with real
processors and Linux (unlike the Arduino which consists of simple
microcontroller), why are people facing a problem with DHT11 on
Edison, while those who are using Raspberry aren't?
What is the source of those problems? Is it connected with
non-deterministic OS timing on Edison (RPi has the same, hasn't
it?), with digital pins flaw or both?
Is it even possible to solve this using two wires (alternatively
with a diode)? Maybe it's impossible without a suggested tri-state
buffer?
What is the simplest way to connect one-wire devices to Edison?
The 1-Wire protocol, as you know, requires deterministic timing.
It is not possible to do deterministic timing on a computing platform like Edison, or even a PC. You might get somewhere close to it using usleep() but your app may get interrupted at any time, thereby messing up your timings.
What you need to do when using a system without deterministic timing of GPIO is attach the sensor using an interface. That interface should use a small micro which DOES have deterministic timing. (ie a Pic, ATTINY, etc).
OR -
Use an existing peripheral on your system which does have deterministic timing, such as a UART.
I wrote a blog-post some years ago on how you can use a UART to do 1-Wire protocol. You should be able to find it here: http://wphost.spider-e.com/?p=231

Categories