Heartbeat Plushie

by pantherman594 in Circuits > Gadgets

426 Views, 0 Favorites, 0 Comments

Heartbeat Plushie

Heartbeat Plushie Demo

Heartbeat Plushie is a plushie that can transmit heart rates via Bluetooth and MQTT, so that one can measure a heart rate to flash and vibrate on the other. This was designed to be created twice, and put inside of two plushie, so that each plushie would beat at the heart rate measured by the other.

For affordability, I used the cheapest board I could find that could work with CircuitPython--the micro:bit V2, which has a bonus of a built-in red LED matrix. I also chose to use the MAX30102 heart rate sensor, combined with Arduino Pro Micros that I already had.

Supplies

  • micro:bit V2 and battery pack (Adafruit)
  • Arduino Pro Micro
  • DRV2605L haptic controller breakout (Adafruit)
  • MAX30102 heart rate sensor (Amazon)
  • LRA haptic motor (such as the VLV101040A, Digikey)
  • 2 10k ohm resistors
  • Wires
  • USB cable
  • Soldering iron
  • Hot glue gun
  • Electrical tape

Install CircuitPython on the Micro:bit

  1. Connect the micro:bit to your computer with a USB cable
  2. In normal mode (you should see a MICROBIT device, not MAINTENANCE), copy in the latest CircuitPython hex.
  3. The device should disconnect and reboot.

Install Ampy

This will be used to load files onto the micro:bit, as it does not have a traditional file interface. See Adafruit's learn guide for more insructions.

Install Libraries and Copy Code

With the micro:bit still connected to your computer, run the following commands from inside the Github repository to install the necessary libraries and copy the code.

ampy --port /dev/ttyACM0 rmdir /lib
ampy --port /dev/ttyACM0 put lib /lib
ampy --port /dev/ttyACM0 put code.min.py /code.py

You may need to replace /dev/tty/ACM0 depending on how

Due to the limited storage on the micro:bit, I have removed characteristics/sphero.mpy, characteristics/midi.mpy, and characteristics/microbit.mpy from the adafruit_ble library. If you would like to make changes to code.py, please run minify.sh before copying, so that the code size will be reduced to fit on the micro:bit.

Upload the Arduino Code

The Arduino is used to read values from the heart rate sensor and calculate the heart beat. This cannot be done on the micro:bit, since it is not powerful enough to reliably measure heart rate.

  1. Connect the Arduino to your computer with a USB cable
  2. Using the Arduino IDE, open the "heartbeat" folder in the Github repository.
  3. Click "Upload" to upload the code onto the Arduino.

Wiring Diagram

finalproj_bb.png

This is the wiring diagram for the device. It may be helpful to refer to when following the next few steps.

Solder the Micro:bit

PXL_20220511_201400639.jpg
PXL_20220511_202207486.jpg

First, solder wires to each of the large pins on the micro:bit. Make sure you solder to the front side with the labels. The back side has gold pads, but they are not connected to anything.

Connect 3V, GND, 0, and 1 to VIN, GND, SCL, and SDA on the DRV2605, respectively. Connect the positive and negative outputs of the DRV2605 to the vibration motor.

On the back side, place a piece of electrical tape over pad 3, and solder a 10k ohm resistor from pad 1 to 3v3. Place another piece of electrical tape on top of that pad 1 and any part of the resistor leg before the resistor itself. Finally, solder another 10k ohm resistor from pad 0 to 3v3. These are pull-up resistors to use for I2C. I chose to use pins 1 and 0, instead of the built-in I2C pins, because it was too difficult to solder to the tiny pads.

Connect the Arduino

PXL_20220513_005425239.jpg

(click image to open labels)

Following the wiring diagram, connect the Arduino to the heart rate sensor, the micro:bit, and the battery pack. I made 3 way connections to bring power to both the Arduino and micro:bit. Connect the tx pin on the Arduino to pin 3 on the micro:bit.

Create Feeds on Adafruit.io

We will create two feeds on adafruit.io, so that the plushies can communicate with each other via MQTT.

  1. Go to https://io.adafruit.com/feeds
  2. Click "New Feed"
  3. Enter the name for the feed, I used "hbplush1"
  4. Repeat, steps 1-3, with "hbplush2"

Connect to the Micro:bit With the Bluefruit Connect App

  1. Install the Bluefruit Connect app on your phone
  2. Turn on the micro:bit
  3. Connect to "HBPlush" in the Bluefruit Connect App

Set Up MQTT

Screenshot_20220513-005331_Bluefruit Connect.png
Screenshot_20220513-005339_Bluefruit Connect.png
Screenshot_20220513-005322_Bluefruit Connect.png

(click images to open notes)

Once connected to the micro:bit, click on "UART", then "MQTT" in the top right.

Set Uart RX to "[username]/feeds/hbplush1", replacing "[username]" with your io.adafruit.com username.

Set Topic to "[username]/feeds/hbplush2" and the action to "Transmit"

Enter your username and key (you can find it by going to io.adafruit.com and clicking "My Key"

Repeat Steps 9-10 for the Second Plushie

Uart RX should be "[username]/feeds/hbplush2" and Topic should be "[username]/feeds/hbplush1"

Enjoy!

With both plushies connected, they can send heart rates wherever there is internet on your phone. One plushie will vibrate and pulse the lights at the heart rate measured on the other, and vice versa.