- The baby monitor has 5 indicator LEDs, which show the instantaneous amplitude of the monitored audio. I am hijacking these.
- The baby monitor is controlling the LEDs by sinking current, so I attach a wire to the negative side of each. They are powered with 3V, so I simply attach the other end of each of those wires to my microcontroller's GPIO.
- In my firmware's main loop, I read each of the 5 GPIOs and count the ones that are pulled low by the baby monitor - in other words, I count the number of LEDs that are turned on to get an approximation of the audio amplitude (aka the baby's cries).
- On a separate GPIO, I send a PWM signal to the input of a MOSFET motor driver. I update the duty cycle of the PWM based on the amplitude approximation. If 0 baby monitor LEDs are turned on, I set the duty cycle to 0%. If 3 LEDs are turned on, I set it to 60%. All 5 LEDs... 100%. (I am scaling these values down a little bit to not overdrive the motor).
- I created a BLE characteristic to wrap a variable that alters the strength of the haptic motor. The characteristic's value can be set between 0 and 10, which I internally map from 0.0 to 0.1. Whenever the PWM duty cycle for the motor is recalculated, it is multiplied by this variable before being output. That way the user can adjust the vibration strength remotely using any BLE desktop/mobile app.
- There is a second BLE characteristic that represents the amplitude approximation (aka the number of lit LEDs) in real time. BLE Central devices can register for notifications on this characteristic and receive a real-time stream of updates.