Alerto! is a Spanish word that means "alert" in English. Alerto! is a small and portable motion detection device based around the KEMET's new SS-430L-N Pyroelectric Infrared sensor module.
Alerto! allows you to monitor motion activity remotely. The device has Wi-Fi and GSM connectivity. You will receive a notification on your smartphone, or an SMS whenever motion is detected. The device has theft prevention and tracking features, so that even when the device is stolen you will be able to track it.
Features- High sensitivity PIR motion/proximity detection sensor from KEMET, with up to 5 meters detection range.
- Detect motion or proximity at any place, from anywhere in the world.
- Receive push notifications or SMS on your smartphone when motion is detected.
- Wi-Fi and GSM connectivity.
- Small and portable.
- Rechargeable Li-Ion battery.
- RTC for time keeping and GPS for real-time location.
- Theft prevention and live tracking.
- Open source - hardware design files and source code are available for download.
To use the device, first remove the small deactivation magnet from the slot. This enables the notification. Then turn on the switch if you need the LED to be on. You also need a Wi-Fi hotspot where you're using the device so that it can connect to the internet (this is a limitation for now, but it will be addressed in the next version).
Alerto! can be programmed with a custom delay period, only after which it will start to monitor motion. This gives you enough time to leave the place once it is activated. Once the device is on, the motion sensor will start to sense its surroundings for human presence. The SS-430-LN motion sensor produces pulses for any motion detected. When a certain number of pulses are detected within a preset time window, Alerto! will instantly connect to the Wi-Fi hotspot and send a push notification to the owner's smartphone with detected motion count, time and location.
If the device can not connect to Wi-Fi for some reason, Alerto! can still use its GSM module to send the owner an SMS with the same information. The time data is retrieved from an on-board RTC and location from a GPS module.
Alerto! is battery powered and has an additional dummy battery (as a disguise) for theft protection and tracking. When someone finds a suspiciously looking device, usually the intruder, their first action would be to turn it off and take it with them. Turing off the switch doesn't actually deactivate the device. It simply turns off the LED which we have labelled as ON/OFF. Next, they will be removing the battery. This would not turn off the device either. Only placing a small piece of magnet in the slot would actually disable the device. The intruder who is not aware of this would possibly take the device with them and we will be able to track motion activity and realtime location all that time.
Alerto! Block DiagramThe heart of Alerto! is an ESP32-WROOM-32 based development board. ESP32 is one of the two most popular SoCs used in IoT applications; the other being ESP8266. Both are produced by Espressif. ESP32 has a dual core CPU that runs at 240MHz and has 520KB RAM, 4MB Flash, Wi-Fi, Bluetooth and all sorts of other peripherals.
The power supply is a 3.7V 18650 Li-Ion cell with 3000mAh capacity. The battery can be charged via a micro USB port. The charge controller used is the TP4056.
MT3329 is the GPS module used. It is interfaced via serial port. The module outputs NMEA sentences containing location info at a frequency of 10Hz.
SIM800L module connects to a 2G mobile service to send SMS. It also uses a serial port.
The 1.2V Ni-MH or 1.5V Alkaline cell is interfaced to one of the GPIO pins of ESP32 through an NPN transistor. The LED will be turned on only if there's battery voltage available. So when an intruder remove the battery, LED can not be turned on with the switch. This will make him/her think that the device was disabled.
KEMET SS-430L-N PIR SensorThe SS-430L-N is a Passive Infrared (PIR) sensor module that works based on the principle of pyrolectric effect of ceramic materials when it absorbs IR radiation emitted by objects such as human body. The sensor element used is the PL-N823-01 Pyroelectric Infrared sensor.
The module comes with all the necessary circuits such as amplifier, comparator and a microcontroller. It has a small form-factor of 15.00 x 15.00 x 5.65 mm while the sensor lens is 6.6 x 7 mm only.
There are three lens options to suit applications - Natural, White and Black. There's a lens-less version too. As part of the contest giveaway I received the one with natural lens with 5 meters range. The detection range is about 2m without the lens. Even though the lens increases range, it reduces the detection angle by some amount.
KEMET hasn't provided any schematic of the module, but I found one from one of their product documents.
The microcontroller used is PIC12F617. The sensor element output is analog. The MCU's internal ADC is used to read the analog input and produce 3V pulses of 200mS for each motion detected.
For each detection, the module outputs two pulses depending on how fast the object is moving within the range. The pulse spacing is not constant or consistent. I couldn't find any information on this apart from some waveform capture provided in this document.
You might wonder how does SS-430L-N differ from an ordinary PIR sensor. The SS-430L-N has the following advantages when compared,
- No dead zone in the detection range - ordinary PIR sensors have dead zones where an object moving in that space won't be detected.
- Wide detection angle - the SS-430L-N has a viewing angle of 74° and detection range of 5m. Ordinary PIR sensors have much less detection angle and range.
- Compact - the SS-430L-N and lens are very small, and can be integrated into small and portable products without affecting the aesthetics or functionality of it. Ordinary sensors require large dome lenses that is not suitable for good designs. Also, SS430L-N uses very few components compared to ordinary sensors, which means less point of failures.
- Faster responses - the sensor is highly sensitive to motion and produces pulses faster.
The pin assignments are as per below.
The TX and RX pins are not used. Unfortunately KEMET did not include the cable in the giveaway package. I had to remove the connector and solder wires directly.
To test the sensor, I used a small Arduino sketch.
float adcVoltage = 0.0;
uint16_t adcCount = 0;
void setup() {
// initialize serial:
Serial.begin(9600);
pinMode (A1, INPUT); // IR Sensor connected to A1
}
void loop() {
adcCount = analogRead(A1);
adcVoltage = float(adcCount) * 0.0048828125;
Serial.println(adcVoltage);
delay(1);
}
The sensor output is connected to A1 pin of Arduino (I used Arduino Uno). The ADC value is converted to voltage and sent to the serial port. You can see the pulses as a waveform in the Arduino IDE's Serial Plotter window.
Follow this article to learn more about the performance characteristics of SS-430L-N : https://www.digikey.sg/en/maker/projects/things-to-consider-when-designing-with-the-kemet-ss-430-sensor-module/b4abe77a5ec247adaa147a165ddfcb3f
SchematicWe are mostly using modules here since this is a prototype. The ESP32 development board I used is different from ESP32-DEVKit but the pin assignments are the same for all ESP32 boards using the WROOM-32 module. I designed the schematic in KiCad, which is an open source EDA tool.
The schematic source file and PDF versions can be downloaded from download section.
Why we have to use a transistor for battery sense is that, 1.5V or 1.2V are not within the high logic level of 3.3V logic systems. So directly connecting the cell voltage to a GPIO won't work. Other sections are self-explanatory.
FirmwareThe firmware is written as an Arduino sketch (.ino) making use of ESP32-IDF and FreeRTOS features. Let's start with the flow charts.
The main activity initializes all modules and GPIO pins initially. If secondary battery is present, we can turn on all LED notifications. Otherwise, keep them disabled because we don't want LEDs to function when the supposed ON/OFF switch is OFF or battery is not present.
All interrupts are enabled at this point and three FreeRTOS tasks are executed in parallel. This is necessary because we need to continuously monitor serial ports for data from GPS and GSM modules and process them without much delay. For example, GSM can sometimes take long time to respond to a command.
The PIR Interrupt Service Routine (ISR) is used to detect pulses from the motion sensor and count them. These functions are executed only when an event occurs at those pins. That event can be change in voltage, transitions etc. When the pulse count reaches a preset threshold, we can trigger a notification event. But we do not simply count all pulses. This is because there can be multiple pulses for same motion activity. Therefore, we will set a time window, and when more than one pulses are detected in that time window, they will be treated as single activity. If the new pulse is outside this time window, we can assume a new motion activity was detected.
Even after adding the time window algorithm, I was getting too many pulses which are sometimes triggered by the environment. So I needed a better algorithm.
In this new algorithm, we first wait for a pulse to occur and then start a time window. We will wait for n number of pulses to occur within that time window. If we get that many pulses, we can expect that significant motion has happened. If a pulse is outside the time window, we will start a new time window and wait for the pulses again.
There are three parameters we can customize to control the motion detection behavior.
#define TIME_WINDOW 1000
#define PULSE_THRESHOLD 2
#define MOTION_THRESHOLD 20
The TIME_WINDOW
is the length of the time window the device will wait for pulses, PULSE_THRESHOLD
is the number of pulses the device will count before determining a motion activity, and the MOTION_THRESHOLD
is the number of motions detected after which the notification will be sent.
Below is the battery ISR. If the battery is present, enable all LEDs. Otherwise disable them.
The following are also self-explanatory.
The firmware is released under MIT and here's the GitHub link : https://github.com/vishnumaiea/Alerto-Motion-Alert-Device.
The library used for the ISL1208 RTC is a one I published and complete tutorial is available on my website : https://www.vishnumaiea.in/projects/hardware/interfacing-intersil-isl1208-rtc-with-arduino
Using Serial Command InterfaceIf you connect the device to a computer via USB, you will be able to set the time and test other functions. You can use any serial monitor softwares such as Arduino Serial Monitor, YAT, Tera Term etc. Following is a screenshot from Arduino IDE.
If you type and send cmd
you can enter the command mode. In this mode, the device will pause its normal operation. You have to do this at least once to set the time. Once it is set, the RTC will keep track of it.
To set the time you can use the command as settime TYYMMDDhhmmssp#
where the second part is a formatted time string. For example if we send T20022810304213#
, the time set will be 10:30:42 PM, 28-2-20, Wednesday
Other available commands are,
exit
- to exit the command modetime
- to print the date and timegps
- to get the GPS locationpush
- to send the push notificationsms
- to send SMSledr
- to turn the red LED onledg
- to turn the green LED onledb
- to turn the blue LED onenableled
- to enable the LEDs
We will use two free cloud services to receive notifications to our smartphone; PushBullet and PushingBox. There are countless such alternatives such as Blynk. Use the one you're most familiar with.
PushBullet is a notification aggregating application. It can forward your notifications to multiple devices and it has a free usage feature. Install PushBullet from here : https://play.google.com/store/apps/details?id=com.pushbullet.android&referrer=utm_source%3Dpushbullet.com for Android phones.
Follow https://www.geekstips.com/android-push-notifications-esp8266-arduino-tutorial/ this tutorial to learn how to activate both PushBullet and PushingBox services.
When creating a "scenario" in PushingBox, use the following message string :
Alerto! Motion detected $motion_count$ times. Time: $time_string$, Location: $location_string$.
Now, the data sent from ESP32 will replace those place holders when the notification is sent.
String postStr = "devid=";
postStr += String(deviceId);
postStr += "&motion_count=";
postStr += String(pulseCount);
postStr += "&total_motion_count=";
postStr += String(pulseCountTotal);
postStr += "&time_string=";
postStr += String(myRtc.getTimeDateDayString());
postStr += "&location_string=";
postStr += String(lastLocationString);
postStr += "\r\n\r\n";
See the above part of our code. The parameters are converted into Strings and sent.
AssemblingI had to test the whole setup on a breadboard first. The main issue was supplying power. Since we are using a Li-Ion battery, the voltage range is from 3.3-4.2V. We need to convert this to 3.3V. None of the buck converter modules I had were good at doing this. Therefore the ESP32 would always reset from brownout (a low voltage condition).
So what I did was to use a boost converter to step-up the Li-Ion cell voltage to around 7V. This can be then supplied to the on-board regulators of all modules. The SIM800L modules works fine in the cell voltage range.
My initial plan was to 3D print an enclosure for Alerto!. But I did not have much time. So I found a nice plastic enclosure of a power supply that I repurposed for Alerto! It seemed like it was designed for this project! LOL
Then I cut a section of perforated PCB to fit inside the enclosure.
I stacked the modules to save space.
Both the GSM module and ESP32 have high surge current requirements when their RF transmitters are at full power. This can reach up to 2A. So some capacitors were necessary. I used T491C226K025AT, 22uF Tantalum caps which also happens to be from KEMET. I made small modules since I could not solder them on the solder side.
Then I added all other components such as resistors, transistor and other connectors. The reed switch was placed to the side and I put a steel screw there so what we can place the magnet there. And it works!
Since the board was so compact, I had to use multiple wires to make all the connections.
I created a rectangular opening for the lens to stick out.
The USB port can used to charge the Li-Ion cell and also programming the ESP32.
The enclosure did not have enough space to hold the AA battery holder. So I had to place it outside.
Everything is tightly packed. I love how everything turned out to be perfect in this project.
I set the time window to 1 second and motion count threshold to 20 for testing. When 20 consecutive motion are detected I will receive a notification from PushBullet. Set the priority to high to get instant alert.
Following is a screenshot of what is printed to the serial monitor when motion activity is detected.
Below is a video that demonstrates the operation of the device.
What's Next?This is the first prototype of Alerto! I want to make it as a usable product in the next version. Next version goals are,
- Get rid of all modules and make a single custom PCB with all components.
- Make it even smaller.
- Create a dedicated smartphone application for Alerto!
- 3D printed enclosure.
- Add Accelerometer and Gyro sensors.
- GPRS/3G connectivity.
Comments