Introduction: IOT Rube Goldberg Very Inefficient Doorbell
Our final project offers a playful and Inefficient solution for managing visitors and enhancing home security.
With this innovative use of technology (after many unnecessary events) you'll never be caught off guard by a visitor again.
To use this system, simply follow this guide.
The intricate series of CPXs and sensors will do the rest, notifying you when someone is at the door and even interacting with the visitor for you.
The chain of events is similar to a Rube Goldberg machine, involving light detection, internet-triggered events, smart home technology, and a touch of social media presence.
We have 3 CPXs in use.
- 1st CPX is placed outside the house on the door.
- 2nd CPX is used to detected someone at the door (after unnecessary few steps, like string behing pulled).
- 3rd CPX is placed inside the house with the house owner.
In our explanation we will refer to them as 1st, 2nd and 3rd CPXs.
Please note that we attached 4 coding files. One to check your wifi connection, and 3 more in accordance to each CPX.
The video above shows how the cool doorbell works in real life!
Supplies
General Requirements:
- Adafruit.io Account
- Blynk.cloud Account
- Make.com Account
- Gmail Account
- Facebook Account and a Facebook page
- Arduino Software
Hardware Requirements:
- 3 x CPXs of type Arduino CircuitPlayground Express
- 3 x ESP8266 microchip
- 1 x Speakers + AUX cable (optional)
- 2 x Wires (optional)
- 2 x Transparent cup
- 1 x Colored piece of paper
- 1 x String
API Requirements:
- Open AI
- TextCortex AI
- GIPHY
- Gmail
Step 1: Establish Wifi Connection
The ESP8266 is an affordable microchip that offers Wi-Fi capabilities and comes with integrated TCP/IP networking software.
By establishing a connection between the ESP8266 and the CPX as illustrated above, the CPX gains the ability to connect to Wi-Fi networks.
This newfound functionality enables the CPX to communicate wirelessly and exchange information with other devices.
For further instructions on how to connect the microchips please use the following link:
https://tttapa.github.io/ESP8266/Chap07%20-%20Wi-Fi%20Connections.html
In order to assure your WIFI is properly connected you can run script of the file attached below.
Attachments
Step 2: Light Shielding
Take a plastic cup and tape a colored paper around it to block out light.
Connect the 2nd CPX to a string.
This string will act as our improvised "doorbell".
Place the 2nd CPX insinde the taped cup (see photos attached).
The colored paper wrap will ensure that the CPX isn't exposed to ambient light, only detecting changes when the "doorbell" is used (the string is pulled).
The change in light level will trigger next events.
Make sure the string's tension triggers the CPX's movement.
Place the side of the string that isn't connected to the CPX outside the door, and the other side above the door and inside the house (see photos attached).
Step 3: Speaker Setup
Connect the 1st CPX to a speaker using an AUX cable (this is optional, though recommended for best use of the CPX's speaker).
Place the CPX and speakers outside the house.
This will be used to welcome customer into the house by playing "please go in" or to deny entrance by saying "sorry you can not go in".
In addition, appropriate LEDs will be turned on (green for permitted entry and red for denied entry).
Connect one wire end to pin A0 and the other end to the AUX cable.
Then, connect another wire end to the GND pin, and the other end to the AUX cable (see photos attached).
Step 4: Chain of Events
If you like spoilers please read this step.
It will describe the chain of events of our doorbell.
If you prefer not knowing until everything is set and ready to go, please skip this step.
Either way, the chain of events will be described again in step 15 along with some pictures of the output of our cool doorbell.
So... if you decided to read- BE PREPARED FOR FUN!
The chain of events:
1. Someone pulls a string by the door. The 2nd CPX senses light change and sends a message to 1st CPX using MQTT (through adafruit.io) that someone is at the door. How is the message sent?
2nd CPX publishes a light value to a light feed which 1st CPX is subscribed to.
2. 1st CPX changes the value of virtual pin VO to 2 on Blynk.
Using a Blynk webhook, the change of V0 value to 2 triggers a make.com scenario.
3. A line is added to google sheets with time of the new visits and adds 1 to a counter counting all visits.
4. 1st CPX lets 3rd CPX know someone is at the door using Blynk and make.com. How?
The new counter value is retrieved from google sheets, then it is send using an HTTP post request to change the value of V0 using the 3rd CPX Blynk url (as explained in part 9 of this tutorial).
5. Using Make.com a random happy gif is added to a Facebook post on the house owner’s Facebook page, posting “YAY! I have a new visitor” with the chosen gif.
6. The HTTP request using Blynk webhook, triggers an alarm noise on 3rd CPX (by changing the value of V0 as explained in line 4).
The noise alerts the house owner someone is at the door.
7. On the house owner blynk’s application it says “Wow, u have had X visitors this month!” and average calculation of entrance acceptance rate.
8. When it is 7pm virtual pin VO is changed to 1 (1st CPX code).
Then, using make.com scenario and router we ask chat gpt to come up with a funny sentence in Spanish to cheer up the person.
Then using a TextCortexAI translator (free version of google translate), the sentence is translated to English.
9. The sentence is sent to the house owner’s email account through Gmail (using Make.com), saying “Hey Buddy, I know it has been a long day but I just wanted to say: {the translated sentence} ☺”.
10. 3rd CPX senses temperature in the house and sends it to the 1st CPX. How?
3rd CPX sets virtual pin V2 value to the detected temperature.
The 1st CPX is updated on V2 value using a webhook (V2 callback function is on the 1st CPX code).
11. If temp is below 16 Celsius degrees, the house owner’s blynk app says “Don't forget a jacket!”, if it’s between 16-30 it says “Weather is wonderful inside!” and if it’s above 30 it says “It's boiling inside. T shirts only!”.
12. If house owner presses right button on 3rd CPX, 1st CPX shows green lights and says “please go in”. else, house owner presses left button on 3rd CPX 1st CPX shows red lights and says “sorry you can not go in”. how does it work? By changing value of virtual pin V1 on 3rd CPX code, the new value is updated on 3rd CPX (V1 callback function is on 1st CPX code). If V1 equals 1 entrance allowed, if V0 equals 0 entrance denied.
Step 5: Arduino.io Setup
Log into your Adafruit.io account.
Go to "Feeds" on the top menu bar.
Click "new feed", type your chosen name for the feed (we called it "Light") and then press create (see image 1).
Then go to "Dashboards", click "new dashboard" and select a name (We called it "Light Dashboard"), then click "Create".
Click your newly created dashboard and then click on the setting button on the top right of the screen (see image 2).
Click “create new block”.
Choose your desired display option (slider, chart, text and etc).
We chose a line chard for this project.
Under default (or using the search bar) chose the "Light Feed".
Then click “next” and then “create block” (see image 3).
This is it! Your Adafruit.io web is ready to go!
Step 6: Blynk Setup
Log into your Blynk account and configure the settings as explained below.
Make sure your virtual pins and widgets are set correctly.
For the home owner CPX, create 3 datastreams:
- V0 - Name: Visitors, Data-Type: Integer, Min-Max: 1-1000
- V1 - Name: EntranceAllowed, Data-Type: String
- V2 - Name: Daily AVG, Data-Type: String, Default Value: "Your entrance ratio today is 0%"
Home Owner Dashboard/ Mobile App:
- Labeled Value - Visitors (V0)
- Labeled Value - Daily AVG (V2)
For the guest CPX, create 4 datastreams:
- V0 - Name: days since visit, Data-Type: Integer, Min-Max: 0-1000
- V1 - Name: Alert 2nd CPX, Data-Type: Integer, Min-Max: 0-2
- V2 - Name: Temp, Data-Type: Integer, Min-Max: 0-40
- V3 - Name: Weather Sentence, Data-Type: String
Guest Dashboard/ Mobile App:
- Labeled Value: "Temperature inside is..."
- Labeled Value: (V2) °C (choose celsius degrees as type of value)
- Labeled Value: (V3) (this will show the weather sentence)
**Note the provided pictures is the layout for the web and mobile app.
You can change the layout and design of the boards as you wish.
Step 7: Set Up the Make.com Account
Log in to your Make.com account.
Ensure you have a logged-in Gmail account and all necessary API keys and access as mentioned in the requirements.
You can do this through the connections sections (on the left menu bar) or as we go along and create new actions.
For additional information on how to create such API keys and access please search online (google is your best friend) or ask us in the questions.
Now...
Create a Facebook account and a Facebook page.
Create an empty Google Sheets file.
Lets get started...
- go to "scenarios" on the left menu bar.
- click "create a new scenario" on the top right of the page.
- click the plus button (botton of the page).
- search "webhooks" in the search bar, then select "custom webhook".
- click the new webhook icon than click "create a webhook".
- click "save" and then "ok".
The webhook we just created will be triggered by the 3rd CPX (after someone pulls the "doorbell" string).
For more clearity regarding the chain of events, please go back to step 4 but don't forget to come back here :)
We will now create 2 routes to trigger different chain of events.
Connect a router to the Webhook and filter divide the scenario into 2 sections. How?
- add a router application.
- connect an OpenAI application to its top part and a Google Sheets Add a Row to its button part (as shown in the picture).
- on the top's connection (to the OpenAI), click "set up a filter".
- on condition choose: {data} (from webhooks).
- choose Numeric operators: Equal to 1.
- repeat for the button part (connection to google sheets) with Numeric operators: Equal to 2.
- use the attached photos for help.
During the make.com steps please feel free to add any other events or actions you think might be useful or fun!
At any point, if you wish to check your senario flow you can click the "Run Once" button.
Step 8: Make.com First Scenario Setup
** Upper route in the attached first picture (V0 equals 1)**
**All steps selections are also shown in pictures**
1.Make connection to Open-AI and choose the options as desribed below:
- connection: My OpenAI connection.
- model: gpt-3.5-turbo.
- messages, role: user.
- messages, message content: "Hey, could you please come up with a funny sentence in Spanish to cheer up my friend who has been home all day with no visitors? Please just write the sentence with no other introduction. Thanks!".
2. Send the response provided by the Open-AI to the TextCortex AI to translate to English. How?
- use a tools set variable application.
- variable name: response.
- variable life time: one cycle.
- variable value: on the open AI section choose "choices[].message.content".
3.Then add a "TextCortex AI" and select-
- text Input: choices[].message.content
- Target Language: "English British".
4.Save the result on google sheets. How?
- set up the connection with your Gmail username and password.
- choose the desired google sheets file (out of your google drive).
- on column A choose value: "text" (under TextCortex AI).
5.Send the quote on Gmail to the home owner. How?
- set up the connection with your Gmail username and password.
- choose the desired email address under "to -> email address".
- subject: "Happy Surprise"
- content: "Hey Buddy, I know it has been a long day but I just wanted to say: {text} :)
- to retrieve the text, select text under TextCortex AI.
By now, your scenario should look similar to the second picture above.
Reminder: at any point, if you wish to check your senario flow you can click the "Run Once" button.
Step 9: Make.com Second Scenario Setup
** Lower route in the attached first picture (V0 equals 2)**
**All steps selections are also shown in pictures**
1.Add a row in google sheets file with the current time and date to annotate visitors arrival. how?
- set up the connection with your Gmail username and password.
- choose the desired google sheets file (out of your google drive).
- on column A value: click the calender icon then click "now".
2.Fetch the cell where the number of visitors is saves. how?
- add a "Google Sheets Get a Cell" application.
- cell: B2 (from the sheet from the previous step).
3.Increase the number by 1 and update it. how?
- add a "Google Sheets Update a Cell" application.
- cell: B2 (from the sheet from the previous step).
- value: "= {value} + 1"
- where for {value} choose the value button under "google sheet get a cell".
4.Make an HTTP request to the 3rd CPX (home owner CPX) sending the number of visitors to virtual pin V0.
- Url: https://spg1.blynk.cloud/external/api/update?token={token}
- NOTICE! instead of {token} insert the home owner blynk auth token (can be found on the blynk website under "device info".
- NOTICE! we are assuming you are in israel. In case you are not, you might need to change "spg1" to the closest server to you. For more information please write us a question in the comments.
- method: post
- Query String Name: V0
- Query String Value: {value} (from the google sheets get a cell)
5.Create a GIPHY request to "get a random GIF" and tag with "happy" (or any description you would like)
- Create a Facebook pages create a post application.
- connect your facebook
- on Page select the relevant page
- message: "YAY! I have a new visitor!"
By now, your scenario should look similar to the first picture above.
Reminder: at any point, if you wish to check your senario flow you can click the "Run Once" button.
Step 10: Blynk URL Setup
We will now do our last Blynk setup part.
Go back to the Blynk website.
Setup the Webhooks:
- On Both Blynk accounts, click on settings -> developers -> webhooks -> add new webhook -> choose a name (for example: House Owner Webhook) -> choose the relevant device (for example: Final Project) -> data stream (for both webhooks choose: V0) -> WEBHOOK URL: (paste the url from the make.com website! this is super important. For both Blynk account paste the same url) -> request type: post -> for the query parameters type "data" and select "Visitors" -> click "save webhook".
- we will refer to the house owner's Blynk webhook URL as house owner webhook from now on.
- we will refer to the guest's Blynk webhook URL as guest webhook from now on.
** From now on, everytime a virtual pin V0 will be changed the make.com url will be triggered.
**Explanation: When the 1st CPU detects a change in light, it changes the virtual pin V0.
This change will trigger make.com scenario because this is the url we just chose.
Step 11: 1st CPX Code Setup
Attached is the file relevant to the 1st CPX named cpu1.ion
In this file, change the code sections (shown in pictures) according to your Adafruit.io device, your Blynk account information and your Wi-Fi credentials.
Then run this code.
Step 12: 2nd CPX Code Setup
Attached is the file relevant to the 2nd CPX named FinalProjectCPU2.ion
Change the provided code section (shown in pictures) according to your Blynk device information and your Wi-Fi credentials.
In addition, adjust the light sensor sensitivity in the code according to your house's light conditions (we recommend to test the light level by simply printing the detected light level to the monitor).
Then run this code on another computer.
Attachments
Step 13: 3rd CPX Code Setup
Attached is the file relevant to the 3rd CPX named FinalProjectCPU3.ion
Change the provided code section (shown in the pictures in step 8) according to your Blynk device information and your Wi-Fi credentials.
Then run this code on a third computer.
Attachments
Step 14: CPX Positions
Make sure all your CPXs are positioned appropriately.
1st should be placed outside the house, where it will give/deny entrey to visitors,
2nd inside the shielded cup (attached to the string "doorbell") where it senses the light change,
3rd should be placed inside the house where it will notify the house owner if a guest has arrived using sound.
Step 15: Chain of Events
Well done! you've finished the hard work...
Now, once everything is set up properly and all CPX's code are running the following chain of events will occur.
BE PREPARED FOR FUN!
1. Someone pulls a string by the door. The 2nd CPX senses light change and sends a message to 1st CPX using MQTT (through adafruit.io) that someone is at the door. How is the message sent?
2nd CPX publishes a light value to a light feed which 1st CPX is subscribed to.
2. 1st CPX changes the value of virtual pin VO to 2 on Blynk.
Using a Blynk webhook, the change of V0 value to 2 triggers a make.com scenario.
3. A line is added to google sheets with time of the new visits and adds 1 to a counter counting all visits.
4. 1st CPX lets 3rd CPX know someone is at the door using Blynk and make.com. How?
The new counter value is retrieved from google sheets, then it is send using an HTTP post request to change the value of V0 using the 3rd CPX Blynk url (as explained in part 9 of this tutorial).
5. Using Make.com a random happy gif is added to a Facebook post on the house owner’s Facebook page, posting “YAY! I have a new visitor” with the chosen gif.
6. The HTTP request using Blynk webhook, triggers an alarm noise on 3rd CPX (by changing the value of V0 as explained in line 4).
The noise alerts the house owner someone is at the door.
7. On the house owner blynk’s application it says “Wow, u have had X visitors this month!” and average calculation of entrance acceptance rate.
8. When it is 7pm virtual pin VO is changed to 1 (1st CPX code).
Then, using make.com scenario and router we ask chat gpt to come up with a funny sentence in Spanish to cheer up the person.
Then using a TextCortexAI translator (free version of google translate), the sentence is translated to English.
9. The sentence is sent to the house owner’s email account through Gmail (using Make.com), saying “Hey Buddy, I know it has been a long day but I just wanted to say: {the translated sentence} ☺”.
10. 3rd CPX senses temperature in the house and sends it to the 1st CPX. How?
3rd CPX sets virtual pin V2 value to the detected temperature.
The 1st CPX is updated on V2 value using a webhook (V2 callback function is on the 1st CPX code).
11. If temp is below 16 Celsius degrees, the house owner’s blynk app says “Don't forget a jacket!”, if it’s between 16-30 it says “Weather is wonderful inside!” and if it’s above 30 it says “It's boiling inside. T shirts only!”.
12. If house owner presses right button on 3rd CPX, 1st CPX shows green lights and says “please go in”. else, house owner presses left button on 3rd CPX 1st CPX shows red lights and says “sorry you can not go in”. how does it work? By changing value of virtual pin V1 on 3rd CPX code, the new value is updated on 3rd CPX (V1 callback function is on 1st CPX code). If V1 equals 1 entrance allowed, if V0 equals 0 entrance denied.
** the pictures above demonstrate some possible output of this sequence of events.
Step 16: Thank You!
YAY! You did it!
We hope you enjoyed it as much as we did!
Thank you for reading!