What is Pyro?
Pyro is a python script that can run on a Raspberry Pi. It reads data from an acceleration sensor and sends its data via Wifi to your PC. HandyControl listens to the incomming data from Pyro and controls speed and/or stroke of Handy if you tilt the Pyro remote.
The Pi can run the script on boot so you don’t have to enable it. Just plug in the power and it should send data after a while. If you are using a power bank or a battery you can even make it wireless, which was the primary goal of this project.
How to use it in HandyControl?
Pyro is used as a mobile sensor in HandyControl. Just select it in the dropdown of the device settings. Make sure to make a firewall rule to allow incomming UDP traffic.
In the main window select Mobile App as source and press Start.
See this page to get more information on how to use sensors.
You need HandyControl 1.2.3 to use Pyro.
I am using the sensors mainly to adjust the stroke lenght on a script during a session. This way you can decrease the intensity of fast sections on the fly.
How to build a Pyro remote…
Since this is my very first project with a Raspberry Pi there will probably be things that can be made better. So if you have some hints how to improve it please let me know
I have expected it to be difficult but in the end it was quite easy to made.
Getting started with Raspberry Pi
What you need
- Raspberry Pi Zero 2 W (others with included wifi might also work) 15,90€
- MicroSD card to install the Raspberry Pi OS 6,40€
- GY-521 MPU-6050 Sensor 2,60€
- Wires, hot glue, soldering equipment
- microSD Cardreader
- Energy source (micro USB cable with at least 1A)
- The ‘Pyro’ script
Optional
- Mini HDMI Adapter (Until the VNC connection is enabled)
- USB OTG Cable, A Female / Micro B (Mouse + Keyboard)
- A compatible case 6,00€
Setup Guide copied from Pyro.py
# Attach sensor to Raspberry Pi
# Install OS on micro SD card
# Boot OS and setup your Wifi
# Enable VNC for remote access. Use VNC Viewer (RealVNC) on PC.
# Enable I2C
# Add modules
# sudo nano /etc/modules
# Add lines
# i2c-bcm2708
# i2c-dev
# Restart
# Setup Tools
# sudo apt-get install i2c-tools python-smbus
# Test I2C
# sudo i2cdetect -y 1
# It should show one device with adress 68
# sudo i2cget -y 1 0x68 0x75
# It should return "0x68"
# Copy the the script to the Desktop of your Raspberry Pi
# Change the IP for your PC
# To run the script on boot add it to .bashrc
# sudo nano /home/pi/.bashrc
# Enter the text at the end if the file
# echo Running at boot
# sudo python /home/pi/Desktop/Pyro.py
How to connect the sensor
In the images above I have used hot glue to attach the sensor in the top of the case.
Try to get it as horizontal as possible.
Raspberry Pi | MPU 6050 |
---|---|
3.3V | VCC |
SDA | SDA |
SCL | SCL |
GND | GND |
Improvements (ToDo)
Existing battery modules for the PI are quite expensive so I am trying to find another possibility to power the Pyro but you are free to build one and post your results here.
In the current state it consumes ~750mW which means that a 3.7V lithium battery with 4.44Wh could power it for ~6h in theory. Attaching and charging this battery is not solved yet but I have seen examples on how to do it.
Another way would be to just use a power bank and connect it with an USB cable. The power bank could be placed inside a mobile phone bag that is worn on the upper or lower arm. My current power bank is too large to be used this way so I need to get one first to test it.
I also have to look out for possibilities to lower the energy consumption. Any ideas?
I have noticed that the Pyro script sometimes does not load on boot and I have to open the Pi console in the VNC connection to trigger it.