1st Grab yourself a Pinata. It seems every mexican pinata shop carries trump pinatas right now.
2nd: Assemble your hardware... see components section above.
- teensy uController https://www.pjrc.com/store/teensy32.html
- teensy Audio Shield https://www.pjrc.com/store/teensy3_audio.html
- accelerometer https://www.adafruit.com/product/1413
- teensy prop_shield** https://www.pjrc.com/store/prop_shield_lowcost.html
- nodeMcu http://tinyurl.com/zph7gz6
- small speaker**
The teensy continuously reads the accelerometer and trigger audio output random WAV files on the SD card. The nodeMcu posts the 'hits' on the pinata to data.sparkfun.com and graphs it at http://analog.io/sADI
**I started this project with the PJRC's prop_shield. It fits on the teensy uController. The prop shield is great for broadcasting in a small quite place through a small speaker. During the party we opted to run a 1/8" jack from the teensy audio shield to an amplifier to make it terribly loud.... If you go that route, you don't need the prop_shield... It's kind of fun to cut a hole in trump though..
Solder your components....
Use the longest headers you can find or an assortment of male headers and female headers (safer/easier for troubleshooting) to sandwich the teensy between the prop_shield and the audio shield....
Above is shown the prop shield on the bottom of a teensy uController.
Above is shown the Audio shield on top of the teensy.
Above is essentially the same thing accept with female and male headers. The advantage to this setup is you can easily take it apart for troubleshooting. The disadvantage is it is quite a bit more bulky but you'll have plenty of space in the pinata.
Finally the accelerometer needs to be soldered or connected to the uController analog inputs. I used three analog inputs for a big 200G accelerometer. If you are not interested in measuring exact magnitude of 'hits' you may use a cheaper accelerometer and read it over i2C or something similar.
Although it's hard to tell in this picture, I connected the accelerometer as follows:
teensy => accelerometer
3.3 pad to Vin (accelerometer)
gnd pad to gnd
A15 pad to zAxis accelerometer
A16 pad to yAxis
A17 pad to zAxis
To connect the nodeMcu, simply connect the teensy Serial1 TX1 (pin 1) to the RX pin on the nodeMcu. You also need to connect ground and may also want to share power by matching the Vin pins or 3.3 pin (don't mix them!)...
There are three files on github trump-pinata: https://github.com/hydronics2/trump-pinata
The teensy.ino code needs to be uploaded onto a teensy using teensyduino, ad add onto the Arduino IDE. It's here https://www.pjrc.com/teensy/teensyduino.html
The ESP file is for the nodeMcu. There's a separate github repo that describes how to move data from an arduino/teensy uController to an ESP. It's here: https://github.com/hydronics2/esp8266-serial-receive-and-send
The 3rd file is a handy simple wav player for teensy to test your files and settings.
Add trump audio files to the SD card. I added 42 audio sound bites to the SD card. I numbered them 1.wav, 2.wav, 3.wav.... and so on to make it easier to call out the files randomly using
fileNumber = random(1,43); //picks a random track
the wav files need to be saved as 16bit, 44khz, stereo files. There is a sample_wave_player.ino file in the github repo that you can use to test your audio. It's extremely useful.
After the data is posted to data.sparkfun; such as, https://data.sparkfun.com/streams/XG3a7JLA2xCox1DajOr3
there is an option to post to analog.io and have the data graphed. In this case it shows Gs before it was completely destroyed. I still have not determined what the exact failure mode was... but it happeed hafter some big 120g hits...