After having reviewed the process of compiling and flashing our firmware, let's move on to building our very own bluetooth curtains!

A stepper motor will be used to drive a timing belt which moves the curtains open and close. The stepper motor is driven by a Half-H driver IC that will be controlled by the BluChip.

For power, we will use a 12V AC-DC voltage regulator that is fed to the motor, together with a LM317 DC-DC voltage regulator to step down 12V to 3.3V which will power the BluChip and Stepper Driver IC.

You can get your very own BluChip module from MakerChips' brand new store over at Tindie, or from the MakerChips Website.

Let's get the parts listed below in addition to the BluChip Explorer Kit to begin assembling the automatic curtains:

Tools (optional):

Hot Glue Gun $3.75

Solder Iron $6.79

Download Bill of Materials from GitHub(Amazon)

Figure 20 shows how you are going to wire up the system, depending on what features you choose to add. If you want more precise movement, you would add limit switches to the project.

Limit switches are endpoints to the curtains which tell the BluChip when it is opened or closed. Without the Limit Switches, you would need to configure the firmware to indicate how far your curtains move in the upcoming "Firmware Configuration" section.

Figure 20 also includes an optional photo resistor which allows for day and night detection, also configurable in the "Firmware Configuration" section.

Start the assembly of the hardware off by mounting the stepper motor, pulley & timing belt to the top of your curtains. (Figure 21)

Temporarily tension the timing belt with rubber band. Later on, before completing the project, you are going to zip tie it together to hold it permanently.

To attach the curtains to your timing belt, loop Wire Ties around the belt and curtain hook.

To get a better idea on how to hook up the curtains to the belt, follow Figure 22. You will be tying the left curtain to the rear of the timing belt with a wire tie, and the right curtain to the front of the timing belt with a wire tie.

Once you get the belt secured and curtain tied, remove the stepper motor so that we can begin to assemble and test the electronic circuit that will drive it.

Start building the electronics by placing the Bluchip, L293d IC and LM317t Voltage Regulator on the breadboard according to Figure 20.

Insert the 200 & 330 ohm resistors according to Figure 20. The resistors adjust the LM317's output so that it provides ~3.3V. (Figure 24)

Insert the jumper wire then a wired barrel jack as shown in Figure 26.

Let's plug in our power adapter to the wall socket, and plug the adapter into the barrel jack to test the voltages as seen in Figure 27.

Once correct voltages have been ascertained, remove the power jack and start placing the remaining breadboard jumper wires according to Figure 20.

Next up, we are going to wire up our bipolar stepper motor to the L293d IC.

First, place Dupont jumper wires into the stepper motor connector as shown in Figure 29.

To know which wire goes where, follow the schematic in Figure 30.

As seen in the schematic, the leads from one coil goes to Pin2 & Pin6 of the L293D. Leads from the other coil goes to Pin11 & Pin14.

The modified 28BYJ-48 bipolar stepper motor has four usable colored wires as seen in Figure 31.

We wire blue to Pin3, yellow to Pin6, orange to Pin11 and pink to Pin14 on the L293d.

The basic circuitry is now complete!

If you want to implement limit switches, wire the NO & C leads to some 22AWG wire. At the other end, attach DuPont jumpers to form leads that fit onto the breadboard. (Figure 32)

You can mount them onto the curtain rail as shown in Figure 33 with rubber bands, or if you have a hot glue gun at hand you can zip tie it to the rail then dab a good amount of hot glue to ensure it doesn't move around.

To get an idea of where to place them, refer to Figure 34.

One limit switch is attached to the far-left end of the curtain rail, between the first rail hook and the second, so that when the curtains open the hook presses against the switch and activates it. The other limit switch is placed directly at the center of the rail, facing left. This way, it gets activated when the curtains close.

Insert the limit switch leads onto the breadboard according to Figure 20.

Finally, if you want your curtains to open when the sun rises and close when it sets, you would need to wire up the photo resistor as shown in FIgure 36, and set it up close to where it has access to sunlight during dawn.

After you're done with the breadboard circuit set up, get ready and connect your programmer to the BluChip to flash the firmware. Download the firmware from GitHub and extract it into your SDK directory as you did before.

Download ble_app_ahc.zip from Github.

Open the project up, then compile and upload the firmware to the BluChip.

Before testing it out, we will enclose the breadboard in a box and make holes for the wires and our Curtain Status LED.

Place the breadboard onto the base of the enclosure box and make an opening for the wires. The opening also serves as a point for the BluChip to communicate to other devices through its antenna. (Figure 37)

Drill a hole the size of the LED on the side of the enclosure and mount the LED on it. Wire the LED according to Figure 20.

Find a suitable place to mount the enclosure box to the left of the curtain rail, close to a power outlet. Remount the motor and do a final tension test of the timing belt, making sure no slack is present. (Figure 39)

Now it's time to test our assembled system. Insert the power adapter and fire up your nRF Connect app. You will discover a device named Curtains.BluChip.

Connect to it, send a value of UINT8 1(Open curtains) to the Unknown Characteristic under Unknown service, and watch the curtains open!

Now that you have successfully tested your system, let's have a look at configuring some of the code that is running the show on the BluChip.