The doll cries when the players approach when vibrations are detected.
Two vibration sensors SW-420 are connected to the Raspberry Pi GPIO and tuned to detect human approaching.
When vibration is detected, a sound is picked up randomly among seven audio files and played. The vibration detection can be activated / deactivated and a light is remotely switched on and off.
See INSTALLATION.md and as a good habit is the PyProps folder is /home/pi/Room/Props/PyProps
If you don't install the whole PyProps library, you will have to fulfill the PyCryingDollProp requirements:
PyProps/core/AsyncioProp.py
PyProps/core/PropData.py
PyProps/core/PropApp.py
PyProps/core/MqttApp.py
PyProps/core/Singleton.py
And you will have to install following Python packages:
$ pip3 install paho-mqtt
$ pip3 install PyYAML
Start main.py
script in /home/pi/Room/Props/PyProps/AsyncioProp/PyCryingDollProp
:
pi@raspberrypi:~ $ python3 ~/Room/Props/PyProps/AsyncioProp/PyCryingDollProp/main.py -s 192.168.1.42 -d
Config: {'host': '192.168.1.42'}
INFO - New periodic action added 'send all data' every 30.0 seconds
INFO - New boolean Publishable 'light' (1/0) with initial=0
INFO - New boolean Publishable 'crying' (1/0) with initial=0
INFO - New boolean Publishable 'activated' (yes/no) with initial=0
INFO - Setup vibration sensor input pin on 20
INFO - Setup vibration sensor input pin on 21
numid=3,iface=MIXER,name='PCM Playback Route'
; type=INTEGER,access=rw------,values=1,min=0,max=3,step=0
: values=1
INFO - Program connected to MQTT server
INFO - Program sending message 'CONNECTED' (mid=1) on Room/My room/Props/Raspberry CryingDoll/outbox
INFO - Program subscribing to topic (mid=2) : Room/My room/Props/Raspberry CryingDoll/inbox
Simple mixer control 'PCM',0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined
Playback channels: Mono
Limits: Playback -10239 - 400
INFO - Program sending message 'DATA light=0 crying=0 activated=no' (mid=3) on Room/My room/Props/Raspberry CryingDoll/outbox
Mono: Playback 400 [100%] [4.00dB] [on]
DEBUG - MQTT topic is subscribed : mid=2 granted_qos=(2,)
INFO - Program susbcribed to topic (mid=2) with QoS (2,)
DEBUG - MQTT message is published : mid=1 userdata={'host': '192.168.1.42', 'port': 1883}
INFO - Message published (mid=1)
INFO - Periodic task created 'send all data' every 30.0 seconds
DEBUG - MQTT message is published : mid=3 userdata={'host': '192.168.1.42', 'port': 1883}
INFO - Message published (mid=3)
INFO - Program sending message 'DATA light=0 crying=0 activated=no' (mid=4) on Room/My room/Props/Raspberry CryingDoll/outbox
INFO - Message received : '@PING' in Room/My room/Props/Raspberry CryingDoll/inbox
INFO - Program sending message 'PONG' (mid=5) on Room/My room/Props/Raspberry CryingDoll/outbox
The command to relaunch the prop is :
$ ps aux | grep python | grep -v "grep python" | grep PyCryingDollProp/main.py | awk '{print $2}' | xargs kill -9 && screen -d -m python3 /home/pi/Room/Props/PyProps/AsyncioProp/PyCryingDollProp/main.py -s %BROKER%
We use two vibration sensors module SW-420 connected on GPIO 20 and 21:
Vibration Sensor Module SW420.pdf
An SRD relay module is connected to GPIO 16 to control the light.
Crying Doll as a prop for xcape.io Room
To use PyCryingDollProp as a prop for xcape.io Room software, here are props commands and messages as well as a suggested control panel.
activate:0
: deactivate sensoractivate:1
: activate sensorlight:off
: switch off the lightlight:on
: switch off the lightcry:_
: trigger crying
Use activate
to enable the cries at the right time (when starting a new game or when a challenge is completed).
Use cry
if automatic detection doesn't work (sensor failure or calibration issue during a game) or to test sound level.
Add and configure Raspberry CryingDoll connected prop.
Configure Raspberry CryingDoll control panel using the SVG images provided in images folder.
Faure Systems (Mar 30th, 2020)