Build a Cloud-Connected WiFi Doorbell

3,541

27

2

About: Hello, my name is Toglefritz. That’s obviously not my real name; my real name is Scott, but on the Internet I use the nom de plume, Toglefritz. I like to make things and I like to share my work with others. ...

If you are a Maker like me, and there is a good chance you are since you are here on Instructables reading this project, you may have the following problem. If you are working in your office/workshop/garage or elsewhere in your home, and someone rings your doorbell, it can be difficult to hear the doorbell ring. You might be using power tools or have other machines that make a lot of noise. You might be listening to headphones or a Bluetooth speaker. You might just be far away from your doorbell chime.

So, in this Instructable, we will build an small IoT device that connects to your doorbell and delivers a notification to your phone when someone rings your doorbell. The project, called Wello 3, connects to your home WiFi network and is powered by your doorbell transformer. When someone rings your doorbell, the chime inside your house will still ring, but the Wello 3 will also send a notification to an app on your phone so that you don’t miss the doorbell ringing.

The project is made from a Particle Photon microcontroller/WiFi module, a power conversion and regulation system, a doorbell detection system, an Android application, and firmware running on the Photon. The project will also involve building a custom PCB and using reflow soldering to assemble the board.

Step 1: Project Overview

Building your own cloud-connected doorbell is a moderately complex project involving several different skills, techniques, and technologies. Therefore, before we get started with the build, it will be useful to have an overview of the steps involved that will act as a roadmap for the rest of this Instructable:

Order your PCB

The hardware for this project will be built on a custom PCB. We will start by ordering the PCB because it will take a little while to get delivered. We will also discuss the PCB design in much greater detail in a later step.


Order your Solder Paste Stencil
We will be using solder paste and a reflow skillet to build the PCB for this project. While it is possible to apply solder paste to the PCB manually using a syringe, the PCB is small and the parts are spaced close together. Therefore, it will make the process much, much easier to use a stencil for applying solder paste. In this step we will get the stencil ordered.

Go Shopping for Parts
Once we have the PCB ordered, we will also need to order all the remaining electrical components and hardware needed to build the project.

3D Print or Order the Base
We will use a 3D printed base for this project to hold the electronics. If you own a 3D printer, the design files needed to print the enclosure are provided in this step. Otherwise, if you don’t have access to a 3D printer, this step also discusses ordering your enclosure from a 3D printing service.

Populate and Reflow the PCB
The PCB is designed using a number of surface mount components. We will need to apply solder paste to the PCB, populate it with components, and reflow the board using a “reflow skillet.”

Assemble the Enclosure
Once we’re done assembling the PCB, we will put it into the enclosure to complete the physical build portion of this project.

Install the Device
The device receives power from the transformer that runs your doorbell. This step discusses how to find your doorbell transformer and safely install your cloud-connected dongle.

Program the Controller

With the PCB assembled and the device powered by the doorbell transformer, the onboard controller, a Particle Photon, will need to be flashed with the firmware that will make the device operate.

Download the App

This step is an easy one to complete. The Wello 3 app can be downloaded from the Play Store. In this section of the Instructable though, we will also discuss how the app functions.

Receive Notifications

When your Doorbell Rings With the build complete, controller flashed, and the app download, you can finally use your Wello 3 to receive notifications on your phone when somebody rings your doorbell. Furthermore, you can use services like IFTTT to extend your cloud-connected doorbell to controlling other devices in your home.

Step 2: Order Your PCB

Ordering your PCB

There are a number of parts we will need to order for this project. First is the PCB that will form the main part of the Wello 3 cloud-connected doorbell. You can download the PCB design files for this project from the website I created to host all the various design assets needed to complete this Instructable, toglefritz.com/wello.

The PCB design is available as SCH/BRD files for use in Autodesk Eagle. We will only need the BRD file to order the PCB, but the schematic will be useful in case you wish to modify the design or in case we need to troubleshoot the PCB after assembling it. As for ordering the PCB, there are a number of PCB fabhouses with the capabilities necessary to make the board; I highly recommend OSH Park. I’ve used OSH Park for dozens of projects and I’ve always been satisfied. The service offers high-quality boards, great customer service, and quick turnaround times.

[PCB images]

To get your order placed, head over to the OSH Park website. At the very top of the page, there is a button allowing you to upload your BRD file. It will take just a moment for OSH Park to upload and process the file.

After uploading the PCB design file, OSH Park will present a series of views for previewing the PCB before placing your order. If you were designing your own PCB from scratch, this is an extremely useful page for ensuring the PCB will turn out the way you want.

The next and final page of the ordering process will give you a few options for your order. The only option you might optionally select for this project is the Super Swift Service which will get your PCBs delivered more quickly for a higher per inch price.

It will take around two weeks for the PCB to come in (unless you upgrade to the Super Swift Service) but in the meantime, we can order the other parts for this project.

Understanding the PCB Design

You can certainly just order your PCBs, wait for them to arrive, and move on with the rest of this project. But if you’d like to learn a little more about the electronics’ design, this section goes over many of the details. The PCB holds a couple subsystems: the power system, a Particle Photon microcontroller and WiFi chip, user-interface components, and a circuit used to detect when the doorbell is pressed.

The Power System

One of the biggest challenges for this project is powering the Particle Photon (more on that later) off the doorbell transformer. The transformer provides between 16V and 21V AC. The Particle Photon requires 5V DC. Therefore, it will take a couple different components to run the Photon off the transformer. First we will convert the alternating current from the doorbell transformer into direct current using a bridge rectifier. A bridge rectifier made from a set of diodes that basically allow current to flow through the device in only one direction. The bridge rectifier connects to the transformer output and delivers DC voltage to the rest of the Wello 3 system.

So now we have direct current voltage from the bridge rectifier, but this conversion actually causes two more challenges. First, the way a bridge rectifier transforms AC voltage into DC voltage is as if you applied an absolute value to the AC voltage. If you graph AC voltage, it looks like a sine wave, alternating between positive and negative current. The bridge rectifier makes all the current positive.

This results in a “choppy” DC voltage, called ripple. This will cause the Particle Photon not to operate correctly. Therefore, a smoothing capacitor is used to even out the peaks and valleys in the voltage. You can see the smoothing capacitor in the schematic above.


The second issue, which is a little more complex to explain, so I will leave the explanation to Wikipedia, is that the voltage conversion from AC to DC will result in a higher voltage on the DC side. In fact, the DC voltage will be about 1.414 times greater than the AC voltage. So, converting and smoothing our 21V AC input from the doorbell transformer to DC will give us about 30V DC. This is obviously much too high for the Particle Photon and it would let all the magic smoke out of the chip if we connected the microcontroller directly to the bridge rectifier output.

So that brings us to the next component in the Wello 3 power system, a voltage rectifier. We can’t just use a simple linear voltage regulator though. The Particle Photon operates (estimating on the high side for safety) at 100mA. We need to step down the voltage from 30V to 5V. Therefore, a linear voltage regulator would dissipate (25V × 0.1A =) 2.5W of power. This would just overheat a linear regulator.

So, we will use a switching voltage regulator, also called a DC/DC converter, which provides a way of stepping down the voltage much, much more efficiently than a linear voltage regulator. This means that the DC/DC converter can deliver 5V without producing dangerous heat. For this project we will use a switching regulator module from RECOM Power.

So now, from the bridge rectifier, to a smoothing capacitor, to a switching voltage regulator, we get a clean 5V source to run the Photon from a doorbell transformer.

The Particle Photon

We mentioned the Particle Photon several times in the last section, but what is it? The Particle Photon is one of my favorite development platforms. The board integrates a powerful microcontroller along with WiFi functionality and an amazing cloud platform to allow communication between the controller and a smartphone app. Programming the Particle Photon is done via an online IDE but if you’ve ever used an Arduino, the code will look extremely familiar. Furthermore, the Particle Photon can be programmed over the air, meaning we do not need it plugged into a computer to upload code (although we can flash firmware that was too).

The User Interface

The user-interface physically on the board is part of the Particle Photon. First we have a button that will again be familiar if you’ve worked with Arduino boards. The Reset button allows the Photon to be rebooted in the event that an error of some kind causes the system to become unresponsive.

There is a second button on the Particle Photon, the setup button. This button is used to place the Photon into a couple different modes including Listening mode in which the Photon can be connected to a WiFi network or the network connection can be changed. Plus, the setup and reset buttons can be used together to put the Photon into some more advanced modes used for troubleshooting.

We should not need those modes for this project though, but just in case you want to explore, the PCB includes a set of header pins that can be used to interface the controller to a computer via USB.

The board also has an RGB LED used to indicate the status of the Photon. The LED will illuminate with different colors and different animation patterns to indicate the device mode and any errors. Particle has a guide explaining all the LED codes for the Particle P1.


Doorbell Detection
If running the Particle Photon off a doorbell transformer is the most difficult part of the electrical design for the Wello 3, allowing the controller to detect when the doorbell is pressed is the second biggest challenge. The Wello 3 doesn't connect to the doorbell button on the outside of the house. Rather, it connects directly to the transformer output. Therefore, we cannot detect when the button is pressed like we would a normal button in a basic Arduino tutorial.

We will need to get a bit clever to allow the Photon to detect a button press indirectly and without getting fried by the AC current. The circuit to make this happen takes advantage of the way the doorbell transformer delivers power. This type of transformer is designed to deliver a constant current to the system, not a constant voltage. When somebody presses your doorbell, the transformer energizes a solenoid that makes the doorbell ring. When this happens, the voltage delivered by the transformer drops from 21V AC to about 16V AC. It is this voltage drop that the Particle Photon will detect and interpret as the doorbell button being pressed.

The doorbell detection circuit has two main parts. First, as discussed in the power system above, the DC voltage off the bridge rectifier is high, about 30V. So the first part of the design uses a classic voltage divider to drop the voltage down to a safe level. SparkFun has a great article if you want to learn more about voltage dividers. When the doorbell button is not pressed, the output from the voltage divider will be about 1.59V. When somebody presses the doorbell button, this voltage drops to 0.84V.

This setup (with a little bit of modification) could be connected directly to a GPIO pin on the Particle Photon and detected as HIGH or LOW states. However, the transformer output is a little “dirty” and prone to high voltage transients. So, to protect the Particle Photon we will use an optoisolator (also called a phototransistor) between the controller and the voltage divider. An optoisolator allows the Particle Photon to detect the state of the transformer through the voltage divider without being connected directly to the power source.

The voltage divider is designed such that, when the doorbell button is not closed, and the transformer is at 21V, the power off the voltage divider is sufficient to activate the optoisolator. However, when the doorbell is pressed, and the voltage drops, it is no longer enough to power the optoisolator, so it turns off. The optoisolator will be connected to GPIO pin D4 on the Particle Photon.

Step 3: Order Your Solder Paste Stencil

Now that we’ve ordered the PCB, we will move on to the next item on our shopping list, a tool that will be basically essential for assembling the PCB later on. The PCB design uses several SMD components. Therefore, the easiest way to assemble the board will be with reflow soldering. The process will be covered in much greater detail once we get to assembling the PCB.

For now, we need to order a solder paste stencil that will be used to accurately, quickly, and easily apply solder paste to the blank PCB. If you’ve never worked with solder paste in the past, don’t worry. It is not a difficult technique to master, but knowing how to reflow PCBs with solder paste will pay dividends in later projects as the skill can be used to prototype professional-looking PCBs that can be transitioned directly to manufacturing. Solder paste is a thick slurry made from soldering flux mixed with extremely tiny particles of solder.

Solder paste typically comes in syringes when ordered in small quantities. It is certainly possible to apply solder paste manually by carefully using the syringe to apply a small dollop of solder paste onto each SMD pad on the PCB. However, having done this on quite a few prototype PCBs in the past, I highly, highly recommend, just spending a bit of extra cash to get a solder paste stencil. It will save you a bunch of time, frustration, eye strain, and it will produce much better results.

A solder paste stencil is a thin sheet of metal (typically stainless steel) or plastic polyamide film, with little holes cut out for each SMD pad in your PCB design.

To get your stencil ordered, I recommend OSH Stencils. Like OSH Park, OSH Stencils provides a painless ordering process that does not require you to work with confusing sets of Gerber files. The service also offers fair prices, and, in my experience, OSH Stencils makes and ships stencils remarkably quickly. The process for ordering your solder paste stencil is similar to the process used to order the PCB in the previous step.

First, head over to the OSH Stencils website. There is a button at the top of the page that will allow you to upload the SCH schematic file just like we did on OSH Park.

Next, OSH Stencils will process the file. The next page you will be presented with allows you to verify that OSH Stencils has correctly assigned each layer in your design. I’ve never had an issue with the service misidentifying any layers, but it could happen if you use custom layers in any PCB designs you might make in the future. As long as the layers have the correct file type, you can click the Generate Stencils button in the upper-right corner of the page.

The next screen allows you to customize how your stencil will be made. First of all, you will need to select the type of material that will be used for the stencil. There are two material types: stainless steel and polyamide film. Even though it costs more, I prefer using stainless steel stencils because they are stiffer and easier to use without a frame. However, if you’d like to save a bit of money on your stencil, polyamide will work just fine as well. As for the thickness of the material, the recommended 4 mil thickness will work just fine for this project. Once you select a material, you will get a preview of what your stencil will look like.

Then, with your stencil generated and material selected, you only need to fill in your shipping information and submit payment to complete your order. OSH Stencils makes and ships stencils in a remarkably short time so you should have your stencil within a week or so.

Step 4: Gather Your Parts

We’ve ordered the two most complex parts of this project, the PCB and the solder paste stencil, but there is still a whole list of other components and parts we will need to order, and also we will be 3D printing some parts. There are two tables below. The table below lists all of the electronic components and mechanical parts needed to complete the build. I also included links for each of the parts to Mouser for the electronic components, and McMaster Carr for the mechanical parts. You can feel free to get your parts from other vendors if you like others better.

In the case of the passive electronic components, you can substitute the parts linked in the table with any other generic part of the same specifications.

Electrical Components

PartQuantityApprox. CostLink
Particle P11$18Mouser
Bridge Rectifier1$0.66Mouser
DC/DC Converter1$4.91Mouser
Optoisolator1$1.35Mouser
10k Resistor 08051$0.57Mouser
10k Resistor 1W 25121$0.28Mouser
560 Resistor 63321$0.67Mouser
1.3 Resistor 1W 25121$0.47Mouser
Screw terminal1$0.75SparkFun
$27.66

Materials and Tools

In addition to the list of components and parts in the table above, you will need some materials and tools to complete this project. I am leaving out common tools like a screwdriver and masking tape.

  • Solder paste The PCB is designed with all SMD components and we will assemble the board using reflow soldering. Therefore, we will need solder paste. For this project, we will only need a small amount of solder paste, which can be purchased in syringes. I prefer using lead-free solder even though it is slightly more difficult to work with.
  • ESD Safe Tweezers Another essential tool for working with SMD components is a good set of tweezers. Tweezers make it much easier to pick up, manipulate, and accurately place components on a board. Tweezers built for this purpose are built with a coating that prevents static buildup in order to protect sensitive electronic components.
  • Magnifier There are a couple parts that need to be oriented in specific ways, that are also very small parts. A magnifying glass or loupe makes it much easier to identify the correct orientation for small SMD parts.
  • Electric hotplate There are a number of different tools we could use to reflow the PCB, which means melting the solder paste in order to connect all the components electrically to the board. There are professional reflow ovens, some Makers use modified toaster ovens, but in this Instructable we will use an electric hotplate/skillet. Using a “reflow skillet” is a common technique used for one-off PCB assembly. Compared with the other reflow tools, using a skillet has the advantage of being extremely cheap, and leaving the PCB visible for inspection during the reflow process. I use a cheap hotplate from Amazon, but you can really use just about any electric hotplate as long as you never plan on using it for food ever again.
  • Fume extractor As the solder paste melts on the reflow skillet, the flux it contains will boil off. While the fumes this produces are not extremely hazardous, they are still not the best thing to breathe or get into your eyes. Therefore, as an extra safety precaution, it is recommended to use a fume extractor during the reflow process. A fume extractor is simply a fan that sucks air through a filter. There are several different designs; I use a simple model available from Amazon. Just a quick note to address a common misconception about soldering fumes, there is absolutely no risk of inhaling lead while soldering. First of all, in this Instructable, we are using lead-free solder. But even if you are using solder than contains lead, the boiling temperature of lead is 3180oF, which is way, way, way hotter than anything we will be doing in this project. The fumes produced by soldering are just flux and rosin boiling out of the solder.

Step 5: 3D Print the Base

The Wello 3 PCB will be mounted on a plastic base we will 3D print in this step. The base is a simple design consisting of a plate with a hole on either end, along with two upright tabs. The Wello 3 PCB will mount into the base by snapping into the tabs. The base can be mounted to a wall or other surface using small screws or nails.

The design files for the part are available on the Wello 3 website just like the PCB design files. The files are available in STL format so that you can simply download the parts and get printing straight away. Otherwise, if you want to make any modifications to the design, you can also download the design files as Fusion 360 archive files (.f3d) or in STEP file format.

If you own a 3D printer, the Wello 3 base is not a demanding part to print. I used a Monoprice MP Select Mini V2 (which costs under $200) to print the enclosure pictured in this step. Just about any material will work fine for this project. I used black PLA, but ABS or even nylon would work perfectly well. As for print settings, I recommend a layer height of 0.1mm so that your printer will capture the small ridges on the tabs.

If you don’t have a 3D printer, there are several 3D printing services from which you can order your parts, have them professionally 3D printed, and delivered right to your door. I recommend 3D Hubs because the service has affordable pricing and is extremely easy to use.

Step 6: Apply Solder Paste to Your PCB

Alright, now that we’ve spent quite a bit of time getting all the parts ordered and the enclosure 3D printed, it is finally time to begin building. In this step, we will begin the process of assembling the Wello 3 PCB. The first phase of this process is to apply solder paste onto the board using the solder paste stencil.

We will begin by securing the blank PCB to the table. One of the issues we will need to address as we set up our work environment is that, because the Wello 3 PCB is so small, it can be difficult to get the solder paste stencil to sit completely flat on top of the PCB. It will have a tendency to bend over the PCB. In the image below, you can see that the solder paste stencil bows up slightly in the middle because the stencil is wider than the PCB.

To correct this issue, I like to arrange a couple PCBs around the one we will be working on to create a larger flat plane of PCBs. If you ordered your PCB from OSH Park, you should have at least three copies of the PCB. You can place the extras on either side of the PCB you will be using. I simply used a couple other PCBs from a past project. By arranging PCBs like this, it will be much easier to keep the solder paste stencil flat on top of the PCB, which is important for applying an even, accurate layer of solder paste.

Then, to keep your platform of PCBs in place, use masking tape to tape the PCBs onto the table. Of course, you will need to leave your main PCB open so we can apply solder paste.

Next, carefully position the solder paste stencil on top of the PCB. You will need to make certain that all the gold pads on the PCB line up perfectly with the holes in the stencil. Once you have the stencil in exactly the right place, apply a strip of tape onto one side of the stencil. This tape will serve two purposes. First, it will keep the solder paste in place. Second, after we apply the solder paste, we will be able to use this strip of tape like a hinge. This will make it easier to remove the stencil from the PCB without smearing any of the solder paste.

Now it’s time to apply the solder paste. Now, solder paste is a fairly expensive material. So, in order to minimize waste, I like to use the solder paste syringe to apply a small drop of solder paste next to each of the holes in the PCB. I find that this technique works better than loading up a solder paste squeegee with paste and running it across the PCB because we will not be able to get the solder paste back into the syringe. You should dispense the solder paste on the same side of each hole because we will be using the squeegee in one direction on the first pass.

The final step is to use a solder paste squeegee to wipe the solder paste across the stencil, which will deposit solder paste onto each pad on the PCB. If you ordered your stencil from OSH Stencils, it should have come with a solder paste spreader that looks like a credit card. Starting from the side of the stencil closest to the tape holding it down, hold the solder paste spreader at a 45 degree angle and slowly move it across the stencil. Ideally you will be able to get the solder paste into each hole in one pass. However, with the DIY setup we are using, I find that it almost always takes two or three passes with the solder paste spreader before each hole in the stencil will be perfectly filled.

Once you get the solder paste evenly applied to the PCB through the stencil, carefully remove the stencil from the board. You will want to make certain not to move the stencil laterally or it will smear the solder paste. Fortunately, if you do make a mistake, you can just clean the solder paste off the board with rubbing alcohol and start again.

In the video below, you can see one pad in the middle with a bit too much solder paste, but the rest of the board turned out well. Once it melts during the reflow process, the surface tension of the molten solder is very high. So if you have little mistakes like the one in the video, don’t worry about it too much. Solder paste has a way of self-correcting small issues with amount and alignment.

So now you should have a PCB with a perfect rectangle of solder paste applied to each pad.

Step 7: Populate the PCB

The next step in assembling the PCB is to place all the electronic components onto the board in the correct places. This process can be a little bit tedious, but if you just put on some good music, it can be fun too. To help you put the parts in the right places, especially all the passive components, I created a visual guide. The guide has all the passive components on it so you know which resistor and capacitor values go where on the PCB.

There is a strategy to populating a PCB. First of all, since I am right handed, I like to populate the board from left to right. This way, I can avoid reaching over existing parts and risking accidentally bumping them. I started on the side of the board opposite the place for the Particle Photon by placing the three large resistors used as part of the voltage divider circuit. These resistors are not polarized, so their orientation does not matter. In fact, none of the resistors or capacitors in this design are polarized.

Next, again working from left to right, I placed the two smaller passive components. Next up are the two larger components, the optoisolator and the bridge rectifier. We will start with the optoisolator. This component is asymmetrical so it must be oriented in the correct way. If you take a look at the PCB where the optoisolator goes, you will notice a small line next to one of the pins on the outside edge of the board. Then, if you look at the optoisolator, it has a round dot in one corner. That round dot should be positioned closest to the line on the PCB. Finally, we have the bridge rectifier. This part also needs to be oriented correctly. Fortunately, the way the bridge rectifier should be oriented is quite obvious. On the PCB, there are two pins with ~ marks next to them, one with a + symbol and one with a - symbol. On the top of the bridge rectifier, you will find the same symbols. Simply orient the part so that the symbols match up.

Step 8: Reflow Your Board

Now it’s time to don your chef’s hat because it is time to cook a PCB. Right now, we have the board populated with components and covered in solder paste. To melt the solder paste and complete the PCB assembly process, we will use a reflow skillet. A reflow skillet is simply an electric hotplate onto which we will place the PCB to heat it up to the point that the solder paste melts. The Chip Quik solder paste I am using in this Instructable has a relatively low melting temperature around 300oF.

The setup for reflow soldering is simple. Just plug in your hotplate with the fume extractor positioned just behind the hotplate. I also like to get a small cardboard box about the same height as the hotplate onto which we will be able to slide the PCB after all the solder reflows to let the PCB cool.

The actual process of reflowing the PCB is simple as well. First, being careful not to bump any of the components, place the PCB onto the cold hotplate and turn on the solder fume extractor. Then, turn the hotplate to a medium setting (also, if you have a space heater and a bunch of powerful photography lighting, you might want to turn those off to avoid tripping a breaker like I did). As the PCB heats, you will see the solder paste go through a couple phases. First, the paste will liquify and flow outward from the pads a little bit. Then you will start to see fumes come off the board as the flux inside the solder paste beings to boil. Next, you will see the paste turn more silver like liquid metal (which is what it is) and it will begin to contract onto the pads again. As the solder melts, I like to move the PCB around slightly just to help with even heating. The smaller pads on the PCB will reflow more quickly than the largest ones. The pads on the bridge rectifier will likely be the last to reflow so keep an eye on those pads. Once you see that all the pads on the PCB are covered by a shiny layer of liquid solder, gently slide the PCB off the hotplate onto a cardboard box or other surface that will not be damaged by the heat. Let the PCB cool completely before touching it again.

In the video below, you can see the process of reflowing the Wello 3 PCB. The video starts with a cold hotplate and ends with the finished PCB being removed from the hotplate and placed on a cardboard box to cool.

Step 9: Add Through-Hole Components

We have all the SMD parts added to the PCB now. Next we will solder on the through-hole components in order to complete the PCB assembly. There are three different PTH parts we need to add: the DC/DC converter module, the screw terminal, and the Particle Photon.

We will begin with the screw terminal. This part should be placed on the end of the board opposite the “Wello 3” label. The openings of the screw terminal should face the outside of the board so that the wires we will connect to the terminal in a later step will not go over the rest of the PCB.

Next we will add the DC/DC converter. This part needs to be oriented in the correct direction. If you take a look at the PCB, you will find a dot next to one of the pins for the DC/DC converter. The converter itself also has a dot above one of the pins. The converter should be oriented with the dots matching up. Finally, we can add the Particle Photon.There are two sets of pads for the Photon. The inner set of pads will be used to connect the Photon. The outer set breaks out all of the Photon pins in case you want to add to the design or incorporate other components. The Photon board should be oriented with the USB port opposite the power circuitry we just added. To connect the Particle Photon, just solder on each of the pins.

Step 10: Add Transformer Connection Wires

The only parts missing from the PCB at this point are the wires that will connect the system to the doorbell transformer. In this step we will add those wires. The wires connect to the screw terminal. Installing the wires is nothing special. Simply loosen both pins on the screw terminal, install the wires, and tighten the screw terminal again.

On the opposite ends of the wires, strip off about one inch of insulation so that enough wire is exposed to wrap around the screws on the doorbell transformer. Then, twist the wires together so that they do not fray too much when we install the device.

Step 11: Assemble the Base

At this point, we are done assembling the PCB. Yay! The next step is to mount the Wello 3 PCB assembly into the base before installing it onto the doorbell transformer. Mounting the PCB into the 3D printed base is an easy step. Start by placing the end of the PCBs with the wires into the mounting base. Then, using moderate pressure, snap the other end of the PCB into the other tab on the base.


Step 12: Connect Wello 3 to Your Doorbell System

We are completely finished now with the physical build portion of this Instructable. The next phase of the project is to flash firmware to the Particle Photon on board the Wello 3, download the app on your phone, and enjoy our cloud-connected doorbell. Before any of this can happen, however, we will need to connect the Wello 3 to power.

Cutting Power to and Locating your Transformer

The Wello 3 runs directly off your doorbell system’s transformer, which was discussed in great detail previously. Before we start working with any electrical systems though, we make safety our top priority by turning off the power to your doorbell. Even though the voltage output of the transformer is not high enough to hurt you, the transformer does still connect to mains voltage so we can’t be too careful. So, locate and turn off the circuit breaker to your doorbell. Your doorbell may have its own breaker or it could piggyback off another system. For example, my doorbell is tied to the circuit for my AC. You can test to make sure the power has been cut to the doorbell by pressing the button outside and seeing if the doorbell rings.

With the power turned off, the next challenge is to locate your doorbell transformer. Yours is likely somewhere in the vicinity of your electrical panel. The transformer in my house is connected to one of the lights on the ceiling. Another common spot is mounted directly to the side of the electrical panel. Your doorbell transformer may also be mounted to the furnace or AC system. Take a look at the doorbell transformer below to get an idea about how the transformer looks.

To make it easier to understand this Instructable, I made a small bench with a doorbell transformer, button, and chime. It is difficult to take photos of the basement rafters looking straight into a light bulb so this platform will make the photos much more clear.

Connecting the Wello 3 to the Transformer

You should find two wires coming from the doorbell transformer on two screws. The Wello 3 will connect to these two screw terminals. Because the output of the transformer is AC current, there is no polarity to worry about when connecting the Wello 3’s wires to the transformer. The wires can connect in either order.

Connect the Wello 3 to the transformer by loosening each screw and adding the wires from the Wello 3.

Once you get the Wello 3 connected to the transformer, turn back on the circuit breaker to power the doorbell and the Wello 3.

Step 13: Claim the Wello 3 Particle Photon

Before we can flash firmware to the Particle Photon on the Wello 3, first we need to “claim” the board. Claiming a Particle board is the terminology the Particle platform uses for managing device ownership. Only devices you claim can interact directly with your Particle Cloud account. Also, as the owner of the board, only you can flash firmware onto the Photon.

There are a few different ways to claim the Particle Photon. The easiest is the use the Particle app.

1) Log into the Particle app

With the app downloaded and open on your phone, we will get started by logging into your Particle account. If you don’t have a particle account, you can create one.

2) Add a new Particle Photon
Next we need to add the Photon to the Particle account. To do this, tap the + button in the lower-right corner of the screen. You will be presented with a small menu with different types of Particle devices. Select the option to Set up a Photon.


3) Choose the Photon
On the next screen, click the Ready button and the app with begin searching for your Particle Photon. After a short moment, you should see the default name of your device appear in the list. It will be formatted like “Photon-xxxx”. Tap the name of the device to start the pairing process.

4) Connect the Photon to WiFi
The Photon communicates with the outside world over WiFi. The next step in setting up the Photon is to connect it to your WiFi network. The Particle app will search for nearby WiFi networks. Once your home network appears, select it and enter your WiFi password to allow the Photon to connect.

5) Name your Photon

With the Photon connected to WiFi, the final step in the setup process is to name the device. You can choose any name you’d like but the only important step is that the name of your Particle Photon must contain the string “Wello.” The Wello app will search for devices on your Particle account the name of which contains the string “Wello” in order to identify which devices are the connected doorbell ones versus any other Particle devices you might have on your account.

Step 14: Flash the Firmware

With the Wello 3 fully assembled and the Particle Photon claimed, we will move on to flashing the firmware that will make the system run. One of the most powerful features offered by the Particle platform is the ability to flash firmware to the boards over WiFi rather than requiring the board to be plugged into your computer via USB like most other microcontrollers (although the Photon can be programmed this way if you want).

Particle has an online IDE for writing the code that will run on the Photon: https://build.particle.io. If you’ve ever worked with Arduino boards, the code will look extremely familiar, in fact it is almost the same. There are just a few functions and features unique to the Particle platform that are discussed in more detail below.

So, begin by opening the Particle IDE and logging into it with your Particle account. Then we will need to copy/paste the code into the IDE. You can download the firmware from the Wello 3 website either as a .ino file, the same type used in the Arduino IDE, or in a text file. Once you download the code, copy/paste it into the Particle IDE.

/*
   Project: Wello 3, IoT Doorbell Button
   Author: Toglefritz
*/
/*  //////////////////
    ///    INFO    ///
    //////////////////
*/
/*
  DESCRIPTION: 
    This code, written for the Particle Photon, controls an Internet-connected doorbell. The hardware consists
    of a Particle Photon module, a power delivery system, and an optoisolator used to detect when the doorbell
    circuit is closed (when the doorbell gets pressed). The Particle Photon connects to the 
    Internet and pushes a notification when the button is triggered. Other devices listen for the notification that the button
    was pressed and respond in different ways depending upon the device.
*/

/*  
   /////////////////////////
   ///    CONNECTIONS    ///
   /////////////////////////

   This section defines to which pins various components are connected.
*/

const int buttonPin = 4;       // The optoisolator is connected to digital pin 4

/*  
   /////////////////////
   ///    GLOBALS    ///
   /////////////////////

   This section contains global variables used throughout the sketch, including those
   used for configuration options from the Wello app.
*/

bool cloudRing;     // This variable is ued to check that the ring notification was published to the cloud successfully

/*  
   ////////////////////
   ///    SKETCH    ///
   ////////////////////
*/

unsigned long previousRing = 0;     // This variable is used to track when the doorbell was last rung. The code compares this time
                                // to the current time to make sure somebody does not ring the doorbell repeatedly. 

void setup() {
    // Define pin modes
    pinMode(buttonPin, INPUT);
}

void loop() {
    // Disable the doorbell until the Particle Photon is fully booted
    if(millis() > 5000) {
        // If the button is pressed, and it has been more than ten seconds since the last time it was pressed,
        // send a notification to the Particle Cloud
        if(digitalRead(buttonPin) == LOW && millis() - previousRing > 10000) {
            // Send a notification to the cloud
            cloudRing = Particle.publish("WelloConnectedDoorbellRing");
            if (!cloudRing) {
                // get here if event publish did not work
                Particle.publish("Error: failed to ring");
            }
            
            // Get the time of the current ring event
            previousRing = millis();
        }
        
        // The millis() function resets to zero after it hits a maximum value of 4,294,967,295. So, if the 
        // current value of millis() is within 10000 ms of this value, we need to set the previousRing variable
        // back to zero, otherwise, the millis() - previousRing will never be greater than 5000 and the doorbell
        // will stop working.
        if(4294962295 - millis() <= 10000) {
            previousRing = 0;
        }
    }
}

With the code copied into the Particle IDE, we first need to make sure the Photon has an Internet connection before moving on. The status LED on the Particle Photon should be breathing a cyan color to indicate it is connected to the Internet.

Once you verify that a connection has been established, the first step in flashing code to the board is to “target” the Particle Photon. Targeting a board is how the Particle IDE knows to which board you want to upload firmware. In the menu on the left side of the screen, click the Devices tab near the bottom corner of the window. The icon looks like crosshair. In the list of devices, find the name you gave your Particle Photon earlier, the one containing the string “Wello”. To target that device, click the star icon next to the name of the Photon. Finally, to flash the firmware to the board, click the lightning bolt icon in the upper-left corner of the screen. When you do this, you will see the status LED on the Photon flash a few different colors while the firmware upload progresses. After the upload is complete, the status LED on the Photon will return to breathing cyan and you will be presented with a confirmation message in the Particle IDE.

Understanding the Firmware

The firmware running on the Particle Photon to make the Wello 3 connected doorbell work is not too complex. Most of the code will be familiar if you have any experience working with Arduino boards or other Arduino-compatible microcotrollers. There are only a few parts that are specific to the Particle platform.

First we have the pin definition for the GPIO pin on the Photon to which the optoisolator is connected. This line is exactly the same as you would use for Arduino.

const int buttonPin = 4;       // The optoisolator is connected to digital pin 4
Then, skipping down a little in the firmware, inside the setup function, the D4 pin is designated as an input.
void setup() {
    // Define pin modes
    pinMode(buttonPin, INPUT);
[...]

Next up, inside the body of the firmware, the loop function, is the code that responds to the doorbell button being pressed. This section of code begins with a if statement that checks to make certain the Wello 3 does not send you too many notifications in a short time, because that would be annoying. Each time the doorbell button is pressed, the firmware records when that took place in terms of the length of time the program has been running. This is stored in a variable that is defined at the beginning of the code.
unsigned long previousRing = 0;     
/* This variable is used to track when the doorbell was last rung. The code compares this time
to the current time to make sure somebody does not ring the doorbell repeatedly. */

The firmware will only send a notification once every ten seconds. In other words, if it has been less than ten seconds since that last time the Photon pushed an event that the button was pressed, the firmware does nothing. Assuming that more than ten seconds has elapsed since the previous doorbell ring, the firmware then uses one of the unique features of the Particle Cloud platform. The Photon will publish an event to the Particle Cloud indicating that the doorbell has been pressed. That event can be received by other devices. In this case, it will be received by your smartphone running the Wello app.
// If the button is pressed, and it has been more than ten seconds //since the last time it was pressed, send a notification to the //Particle Cloud
        if(digitalRead(buttonPin) == LOW && millis() - previousRing > 10000) {
            // Send a notification to the cloud
            cloudRing = Particle.publish("WelloConnectedDoorbellRing");
            if (!cloudRing) {
                // get here if event publish did not work
                Particle.publish("Error: failed to ring");
            }
            
            // Get the time of the current ring event
            previousRing = millis();
        }
You can also see at the end of that if statement that the firmware updates the timestamp of the most recent ring each time it sends a notification. The last bit of code inside the loop function is a bit of a safeguard to prevent a potential bug. The firmware tracks each doorbell press by recording the time according to millis() when the doorbell was pressed. However, the value of millis can only get so large. Its maximum value is 4,294,967,295. So, when the millis gets close to that value, the timestamp on the doorbell ring will be set closer to that value than 10000. When this happens, it will effectively prevent the system from ever sending another notification. It would break your doorbell because, as far as the program logic is concerned, it will never be over ten seconds since the last ring.
// The millis() function resets to zero after it hits a maximum value of 4,294,967,295. So, if the 
// current value of millis() is within 10000 ms of this value, we need to set the previousRing          // variable back to zero, otherwise, the millis() - previousRing will never be greater than 5000     // and the doorbell will stop working.
        if(4294962295 - millis() <= 5000) {
            previousRing = 0;
        }

Step 15: Install the App

The very last step before this project is complete is installing the app that allows your phone to receive notifications from the Wello 3 and give you the heads up when somebody rings your doorbell. The app is available for Android and can be downloaded from the Google Play Store. The app is currently in beta (I only have two phones to test it on so it may have some issues depending upon what phone you use - if you run into any errors, let me know).

With the app installed on your phone, when someone rings your doorbell, you will receive a high-priority notification so that you will not miss that visitor.

Understanding the App

The Wello 3 Android application is a bit more complex than the firmware in the previous step, but it is still not too complex to understand. There are two main parts of the application: the login activity, and the main activity. The login activity is fairly simple. Before the app will be able to receive notifications published by your Wello 3, you will need to log into your Particle account inside the app so that it can subscribe to notifications from your Particle Cloud account. The login functionality is provided by the Particle Android SDK, the same with the majority of the functions in the app. Before we can do anything with the Particle SDK, we must first initialize it.
// Initialize the Particle Cloud SDK
ParticleCloudSDK.init(LoginActivity.this.getApplicationContext());
Then, with the SDK initialized, we can log into the Particle account.
// Log in to Particle Cloud using username and password
ParticleCloudSDK.getCloud().logIn(username, password);
return true;
So, logging into the Particle account requires only one method from the SDK. Here, the username and password information is provided from a pair of EditText elements on the page.
// Get the username and password from the editTexts
final EditText usernameField = findViewById(R.id.username);
final String username = usernameField.getText().toString();

final EditText passwordField = findViewById(R.id.password);
final String password = passwordField.getText().toString();
Once you click the Login button at the bottom of the activity, the app will switch to the main activity. The login activity will pass the login credentials to the main activity.
// Go to the WelloMainActivity activity
Intent intent = new Intent(LoginActivity.this, WelloMainActivity.class);
intent.putExtra("username", username);
intent.putExtra("password", password);
startActivity(intent);
So, then we arrive at the main activity which is where the majority of the hard work in getting the app to receive notifications from the Particle Cloud takes place. The first thing the activity does, after some basic setup, is to use the Particle Android SDK to retrieve a list of all the Particle devices on your account. Note that these might be devices other than the Particle Photon used in the Wello 3 - that will be addressed in a moment.
devices = ParticleCloudSDK.getCloud().getDevices();
Next, the app will look through the list of devices and grab those whose name contains the substring “Wello”. This is why it was so important to name the Photon something containing the string “Wello” earlier when we were claiming the board. This method also allows you to have multiple Wello 3 devices in case your house has more than one doorbell, like one on the front door and one on the side door.
for (int ct = 0; ct < devices.size(); ct++) {
   // If the device is a doorbell (product id=####)
   //if (devices.get(ct).getProductID() == ####) {
   if (devices.get(ct).getName().contains("Wello")) {
       welloDevices.add(devices.get(ct));
   }
}
With the list of Wello 3 devices, the app then subscribes to events published by those devices. This way, the app can react when the Wello 3 publishes an event to say the doorbell rang. This function is fairly large. These first few lines simply subscribe the app to events.
// Subscribe to an event
long subscriptionId = ParticleCloudSDK.getCloud().subscribeToDeviceEvents(
       null, "",
       new ParticleEventHandler() {
           // Trigger this function when the doorbell event happens
           public void onEvent(String eventName, ParticleEvent event) {
Finally, the app sets up a notification channel on your phone. This allows the app to deliver notifications to the system that will show up regardless of whether or not you have the Wello app open on your phone.
NotificationCompat.Builder mBuilder =
       new NotificationCompat.Builder(WelloMainActivity.this);
NotificationManager mBuilder_O = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
String channelId = "Wello_Doorbell_Notifications";  // The id of the channel

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
   CharSequence channelName = "Wello Doorbell Notifications";  // The user-visible name of the channel
   String description = "An alert when your Wello doorbell rings.";
   int importance = NotificationManager.IMPORTANCE_HIGH;
   NotificationChannel mChannel = new NotificationChannel(channelId, channelName, importance);
   mChannel.setDescription(description);
   mChannel.enableVibration(true); //TODO change from settings
   mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
   mBuilder_O.createNotificationChannel(mChannel);
}
Epilog X Contest

Participated in the
Epilog X Contest

Share

    Recommendations

    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Sensors Contest

      Sensors Contest
    • Backyard Contest

      Backyard Contest

    2 Discussions

    0
    None
    RobertB126

    2 months ago

    This is by far the best Instructable that I have personally read. The thoroughness, the detail, the hints and tips and the understandability are all outstanding. Even if I do not duplicate this project, you have introduced me to a number of techniques and outlets that I can use for other endeavors. Thank you.

    0
    None
    audreyobscura

    2 months ago

    This is so thorough! Thanks so much for sharing all these amazing tips and ideas!