Process
Step1: Define basic logic
Step2: Get familiar with the FSR sensor
Step3: Record sleep start and end status
Detect sleep start and end status, and publish the events to the Particle Cloud.
Step4: Sleep data persistence
Since the data on Particle console is temporary, I decided to transfer sleep data from Particle to Google Cloud to make it long-term. I referred to tutorials in Particle docs (https://docs.particle.io/tutorials/integrations/google-cloud-platform/) and here are my main steps:
- Add Google Cloud Platform integration on Particle console.
- Transfer data from Particle to Google Cloud Pub/Sub.
- Store data from Pub/Sub in Google Cloud Datastore.
Step5: Use IFTTT to tell the pillow when to buzz
- Create a new applet on IFTTT with two services: Data&Time and Particle.
- Wire the buzzer to the circuit.
- Define and register a function called "alarm" to Particle Cloud so that IFTTT can call it directly.
Step6: Play the music!
I referred to a tutorial on Arduino (https://www.arduino.cc/en/Tutorial/ToneMelody) to learn how to code music for the buzzer.