How to create an iot haunted doll with ifttt and particle photon

Hey Particle community! It’s Halloween and dolls are creepy so I decided to use a photon and IFTTT to make an iot haunted doll.

Check out the video tutorial here!

Technical Skills Covered in this tutorial:

  • How to publish an event to the cloud
  • How to connect with ifttt

What does this doll even do?

  • Uses ifttt to turn the lights on and off
  • Makes the doll’s head glow red
  • Makes a mask move with a servo

Technical Components:

  • Particle Photon
  • Breadboard
  • Male to male wires
  • Resistors
  • Hue lights
  • Govee RBG LED strip lights
  • Servo motor (micro servo would also work)
  • PIR Sensor
  • Battery pack

Non Technical Components

  • Vinyl doll with removable head
  • White acrylic paint
  • Black acrylic paint
  • Black/navy dye (optional)
  • Fake blood
  • Halloween mask
  • Styrofoam block roughly the same size as the halloween mask
  • Something to house the circuit

Steps:

Setup

  • Attach the Photon to the breadboard
  • Connect to Power
  • Connect from the GND pin to the negative section on the side of your breadboard
  • Connect from the VIN Pin to the positive section.

Wire the PIR Sensor

PIR( Passive Infra Red) sensors can detect the movement of things that emit heat, like warm bodies. The PIR sensor has three pins: 5V, OUT , and GND

1.Connect 5v to the positive side of your breadboard
2. Connect out to D1
3. Connect the ground pin to the negative side of your breadboard,
4. Now the PIR Sensor will be able to transmit signals to the D1 pin.

Program the PIR Sensor

We need our sensor code to do two main things: detect if the input to the pin is high or low voltage. If the input is high then motion has been detected. If it’s low then no warm body has moved.

  1. Open Particle Workbench

  2. Declare your sensor. Mine is called “motionSensor” and it is assigned to pin D1.

  3. int motionSensor = D1;

  4. Next create a variable called sensorState and set it to low since we want to start it off with no motion detected.

  5. int sensorState = LOW;

  6. Make another variable called sensorValue that is set to zero.

  7. int sensorValue = 0;

  8. Create a variable called led and declare it at pin D7. This is the photon’s onboard light.

  9. int led = D7;

  10. In the setup loop, tell our code that the sensor is an input.

  11. inMode(motionSensor, INPUT);

  12. Declare the onboard light as an output so we can later use it to test if our code is working as expected.

  13. pinMode(led, OUTPUT);

  14. Inside our loop function, set the value of sensor to be equal to the read of the sensor

  15. sensorValue = digitalRead(motionSensor);

  16. Digital write to the led to low so it starts off with the light off.

  17. digitalWrite(led, LOW);

  18. Create an if else statement. First let’s test to make sure that the sensor is working. Inside the if statement turn on the LED, keep it on for two seconds, then turn it off. Inside the else statement keep the light off

  19. if(sensorValue == HIGH){

  20. digitalWrite(led, HIGH);

  21. delay(2000);

  22. digitalWrite(led, LOW);

  23. }else{

  24. digitalWrite(led, LOW);

  25. }

  26. Write another if statement inside the first. Check if the sensor state matches the sensor value. If it doesn’t,have it update here.

  27. if(sensorState == LOW){

  28. sensorState = HIGH;

  29. }

  30. Then do the same within the else statement.

  31. if(sensorState == HIGH){

  32. sensorState = LOW;

  33. }

  34. Compile and flash your code.

  35. Wave your hand in front of the sensor. If the sensor senses movement the blue light on your photon should turn on for two seconds. If it doesn’t work, check your wiring.

  36. Inside the if statement we’re going to call the Particle publish function three times. Particle.publish() is a cloud function that allows you to push an event to the Particle Cloud. This means that any hook or application that is registered to listen to the event will be notified when it is called.

Our publish functions will take two strings. The first one is the event name and the second one is the event contents.

  1. Our first instance of Particle Publish will contain the strings “hue” and “blink”. This will eventually make the lamps with our hue lights blink.

  2. Particle.publish(“hue”, “blink”);

  3. Our second instance will contain the strings “led” and “red”. This will eventually cue our led strip to change to red, the most sinister of all the led colors.

  4. Particle.publish(“led”, “red”);

  5. After this publish event, have the program keep the lights red for two seconds with delay(3000);

  6. delay(2000);

  7. Then call Particle publish for the last time and give it the strings “led” and “purple”. We’ll be using this to change the led lights back to purple, in tribute to Prince and because I think purple is a creepy color for a haunted house.

  8. Particle.publish(“led”, “purple”);

  9. Compile and flash your code.

Connect to IFTTT

Next we’re going to connect our particle device to a service called if this then that which will allow us to control smart devices through the cloud without having to wire them to our photon.

  1. Go to ifttt.com and create an account.

  2. Once you’re logged in, click on the “Create” button in the top right corner. Select the “Add” button next to the “If this” option

  3. Search services for “Particle” You’ll have to log into your particle account and grant permissions.

  4. Select the “new event published” trigger. Type in “hue” for the event name and “blink” for the contents.

  5. Make sure the device name that the trigger is watching is the correct device.

  6. Press the create trigger button. You have set up the if portion.

  7. Now click the “Add” button next to the phrase “Then that”. Search the services for the smart light provider that you’re using.

  8. Note: I used zigbee lights connected to my hue hub for lamp lights and govee LED strip lights for the LEDs around my doll. If you use the govee lights make sure to use the wifi version of the strip lights and not the bluetooth one. It doesn not work with the bluetooth version and I found out the hard way. You’ll need a pro ifttt account to use govee so feel free to use hue lights only if you don’t have a pro account.

  9. Select the blink option.

  10. Select the name you’ve given your lights and press “create action”.

  11. Review your applet and press the “finish” button to set it up.

  12. Test it out to make sure it’s working. There may be a bit of lag for new applets, but you can trigger the app to run by pressing the “check now” button to speed things up.

  13. Repeat this process with your other publish functions and set of lights, selecting govee instead of hue. Feel free to experiment with the options available to you. If you see any things that interest you create an applet for them and have them be triggered by motion sensors.

Wire the Servo

Much like our PIR Sensor, the servo has three pins: the ground, the 5V, and the digital pin.

  1. Connect male to male wires to them. Use the longest ones you have. I used a giant spool of wire so the jump scare could happen far away from the doll.

  2. Connect the darkest colored pin to the ground in the negative section of our breadboard.

  3. Connect the middle pin to the positive section.

  4. Connect the final pin to D5.

Program the Servo

  1. Declare your motor at the top of the program, establishing its pin as D0. I named mine maskMotor.
1. Servo maskMotor;
  1. In setup, attach the motor to pin D0
1. maskMotor.attach(D0);
  1. Servo motors operate between the degrees of zero and one eighty. Inside our sensor checking if statement, use maskMotor.write to set the motor to go to 180 degrees, delay for two seconds, and then go back to zero degrees.

  2. maskMotor.write(180);

  3. delay(2000);

  4. maskMotor.write(0);

  5. Compile and flash your code. Now that everything is programmed, let’s turn this from a standard circuit to a haunted doll.

The Creepy Crafty Part

  1. Dolls are creepy by nature. We’re going to make this one even creepier. First, derobe the doll. Paint all of the vinyl portions with a layer of black paint, making sure to get all of the crevices.

  2. While the paint is drying, begin distressing the doll clothes. Use your fabric dye to start the dying process now.

  3. Once the black paint is dry, paint a coat of white acrylic paint over the doll, giving it a greyish, undead complexion.

  4. Behead the doll and stab out its eyes. If this doll ever does come to life it will haunt you and then it will haunt me for telling you to do that in the first place. I accept this fate.

  5. Shove part of your led strip into the doll’s head so its eyes will glow when it is triggered.

  6. Wrap the wrest of the led strip around/ near the doll.

  7. Put your Halloween mask around the block of styrofoam.

  8. Attach chopsticks to your servo motor and shove them through the bottom of the foam block.

  9. Put the styrofoam mask across from the doll and hide it behind a curtain, box, or other large object.

Attach the Circuit to the doll

  1. There are many options for attaching the circuit to the doll. I put my board on the doll’s lap and covered it with an old pillowcase, with the PIR sensor sensor sticking out. Now when you walk by the haunting begins.
1 Like