/hamster-walkie-talkie

Toy hamsters hacked to send and receive voice messages from other hamsters over MQTT. Running all in JavaScript on a Raspberry Pi Zero W.

Primary LanguageJavaScript

Hamster walkie talkies

Make a pair (or army) of ridiculous toy hamsters that can send/receive voice messages from anywhere in the world using MQTT. Touch his hand and record and send a message to other hamsters.

These hamsters are running the hardware using only 100% Javascript and I think that's useless and also super cool. 😎

They recognize touch, turn on a mic, send your voice in a Buffer as array of bytes over MQTT to another hamster many many miles away from you all in JavaScript only!

Be prepared to debug hamsters!

hamster-diagram

Proof of concept Debugging
hamster.mp4
IMG_4829.MOV

Materials:

Setup hamster:

  • Stitch a conductive thread area on his hand to trigger recording and sending a message!
  • Assemble circuitry as shown above.
  • Remove hamster skin by cutting ziptie at bottom.
  • Insert circuit into hamster and file plastic case

IMG_4852 Medium

EC1CAC29-6966-414C-A06B-5220EEAE1530 Medium

IMG_4842 Medium

0A381C62-839B-45C0-91DE-566B17489EF3 2 Medium

Setup pi zero w:

  • format sd card - pi formatter

  • install git

  • install nvm

  • install node arm (https://gist.github.com/traumverloren/7b1140e6c438988df755d047e1e98a7b)

  • enable i2c & spi in sudo raspi-config (Interface options menu)

  • install i2s mems mic (https://learn.adafruit.com/adafruit-i2s-mems-microphone-breakout/raspberry-pi-wiring-test)

  • check working: arecord -l

  • enable autoloading of i2c: https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c#installing-kernel-support-with-raspi-config-5-4

  • sudo apt-get install i2c-tools

  • check i2c working: i2cdetect -y 1

  • setup i2s audio output over pwm pins:

    • sudo nano /boot/config.txt
    • add: dtoverlay=audremap, pins_12_13
    • then sudo reboot now
    • check working: aplay -l
    • if necessary, update to use audio over headphones in sudo raspi-config
  • git clone this repo

  • add .env w/ secrets

  • npm i

  • add the following to/boot/config.txt for neopixels to work properly:

    # Fix for running neopixels on SPI (GPIO 10)
    core_freq=250
  • update so can run node/npm with sudo (needed for neopixels):

    sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/node" "/usr/local/bin/node"
    sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/npm" "/usr/local/bin/npm"
  • run npm start

  • setup pm2:

    npm i -g pm2
    pm2 startup # setup pm2 to run at boot
    sudo env PATH=$PATH:/home/pi/.nvm/versions/node/v18.16.0/bin /home/pi/.nvm/versions/node/v18.16.0/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi # run command returned from above
    pm2 start npm --name "YOURNAMEHERE" -- start
    pm2 save
    pm2 logs

Useful links: