The Scary Mirror Part 2

image
Scary Mirror - Table of Contents

Scary Mirror Part 1 |  Scary Mirror Part 2 |  Scary Mirror Part 3 |  Scary Mirror Part 4

Return to Halloween  

 

 

Intro

After the preparation of the components and the structure, in this second episode, we will see the first part of the building of the scary mirror... With something new and an upgrade to the original project.

<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>

In this second part, we will deal with the Scary Mirror electronic components building.  One of the difficulties I met proceeding in this project was the absence of a box that includes the electronics: the boards, wires, and components, as well as the custom circuit, are part of the same structure.

As the project started I realized that it was impossible to follow the classical steps like making the circuit, wiring the parts together, and assembling everything: the components should be inside, part of the mirror itself.

 

Project Variation and Upgrade

After I started organizing the components connections following my first version of the project I had the possibility to add a long strip of 144 Neopixel LEDs to the project; perfect to add some scenic effects to the back of the mirror.

<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>

To drive the light RGB strip without problems, and avoiding to add another task to the Raspberry Pl3B+ I decided to add an Arduino Uno, dedicated to this task.

Obviously, as frequently occurs, this variation introduced a couple of problems that I solved designing a simple circuit. The effect of the Neopixel strip around the back of the mirror I imagine is sufficient to justify the effort.

 

A New Design of the Components

<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>

The scheme above shows the components used and how they are connected. It is not difficult to connect the Arduino to the Raspberry PI through the I2C protocol; the problems arose between when I decided to battery power Arduino and the Neopixel strip.

 

Powering Arduino with a Power Pack for Smartphones

As I tried to connect a power bank to Arduino, after about ten seconds the battery stopped working.Unfortunately, I have verified this happens almost on all smartphone power banks and similar recharging devices.

The reason is that the battery includes a circuit controlling when the current request by the charging smartphone ends as it is fully charged. The Arduino board does not interact with the power bank in the same way as a smartphone usually do, so I had to find a solution.

<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>

And the solution was just to emulate the smartphone "power request" with the Arduino.

With a few discrete components and an unused digital PIN of the Arduino GPIO, I setup the sketch to generate a current peak of few milliseconds every five seconds.

This event does not impact too much on the performances of the board, but it is sufficient to keep the battery constantly on without difficulty.

To make the event occurring on a specified number of milliseconds, independently by the rest of the tasks that Arduino will do (communicating with the Raspberry PI and driving the Neopixel strip) I have used the timer interrupt on the Arduino sketch.

 

The Timer Interrupt

First of all, I included the timer header in the sketch and defined some constants

 

#include <TimerOne.h>

// Pulse pin to avoid the power pack automatically shut down.
#define PULSE_PIN 5
// Uses the builtin LED to monitor the pulse generation to keep the power bank
// battery always on
#define PULSE_MONITOR LED_BUILTIN
// Pulse duration. Should be empirically calibrated on the power bank used
#define PULSE_MS 5
// Interval between two pulses (long interval, about 1 second)
#define PULSE_INTERVAL 5000000

 

At the end of the Setup() function of the sketch, I have defined the timer parameters and started it (the timer start should be the last function called in the setup).

 

  Timer1.initialize(PULSE_INTERVAL);
  Timer1.attachInterrupt(pulsePower);
  Timer1.start();

As shown in the above example, the Timer1.attachInterrupt(pulsePower); set the pulsePower() function name; this means that when the timer interrupt is triggered the function is called automatically, without taking care of what the program is doing.

To avoid the time triggering during critical events, like when the Arduino is communicating with the Raspberry PI through the I2C protocol the Timer can be temporary disable and re-enabled when the critical task ends.

// Timer callback function.
// Stop the timer, output the pin for 20 ms then restart the timer
void pulsePower(void)
{
  Timer1.stop();
  digitalWrite(PULSE_PIN, LOW);  
  digitalWrite(PULSE_MONITOR, LOW);
  delay(PULSE_MS);
  digitalWrite(PULSE_PIN, HIGH);
  digitalWrite(PULSE_MONITOR, HIGH);
  Timer1.start();
}

 

When the interrupt function pulsePower() is called it generates the output pulse to the designated GPIO pin fro the PULSE_MS duration as shown in the example above.

 

The same 5500 mA/h power bank is sufficient to power both the Arduino and the Neopixel strip, that should have only the ground cable in common with the Arduino board.

In order to avoid any dangerous current peaks on the circuit when the LEDs are lightened, I also added a 1000µF polarized capacitor between the two wires of the power line of the Neopixel strip. During the first pre-assembling tests, the result was satisfactory and reliable.

 

Preparing the Mirror Frame and Setting Up the Speakers

Before making the back of the mirror and fitting the components inside, I modified the plastic frame in order to host the PIR sensor - where there was the round power button - and applied the two speakers, with my inseparable hot glue gun.

<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>

I added the hole for the Omron Vision camera...

<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>

... then added some holes for the speakers to the two sides of the frame.

<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>
<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>

Above, a detail of the speakers and the small amplifier.

Before inserting the internal part of the scary mirror embedding all the electronics in a block of 5 cm thick cardboard I painted the frame black.

<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>

The Body of the Scary Mirror

I obtained the interior of the mirror frame from a couple of pieces of 5 cm cardboard plates. The same cardboard block keeps in place the parts, including the two-ways mirror on the front side and the Raspberry Pl, the screen and the Pl camera, as well as the Arduino and Omron face recognition board and its camera on the back side.

<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>
<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>

<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>
<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>

<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>
<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>

<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>
<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>

The cardboard block inside the mirror helps to keep the Neopixel strip in place around the internal border of the frame, embedded in a cardboard rail.

<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>

In the next episode, we will setup the Arduino MKR1000 with the second PIR sensor that acts as a remote activator of the Scary Mirror and we will develop the software and sketch to logically connect all the parts.

What do you think of the solutions presented in this episode? If you had problems trying to power a microcontroller with a battery pack or some idea of alternative solutions instead of the periodic pulse with the Arduino, write down a comment to this post.

 

To be continued...

Related
Engagement
Recommended