Discrete Light detector alarm by email:
This is not an USB charger ! This is a light detector, sending any ambient light change by email, receiving command by email too. All has been placed into a simple USB charger, which is very discrete...
This project aim is to monitor silently any light change in a room, sending an email when the ambient light change from light to dark or dark to light, through Wifi network.
It has been developed on an ESP32 and integrated into a simple USB charger.
Technical description: Hardware:
- A simple LDR, connected to the ADC port connected to Vcc and with a pull down read the ambient light, given a value between 0 (dark) to 4095 (full light)
- The USB charger provides 5V and a simple uA78M3.3 gives power to the miniboard ESP32 in 3.3v
- This miniboard, with the button for the boot download, with the enable circuit (resistor/capacitor) and a 4 pin connectors has been placed into the USB charger
Software:
- Developed in C under Ardiuno
- Wifimanager library is used to defined the Wifi network if any recorded network has been found before
- 2 different libraries are used to send and receive email.
- One google email need to be setup and attached to the ESP32, with low security (requested by the library)
- The destination email is defined also in the software
- Every xx seconds, the software will wake up, read the ambient light, read if any command email is received, then send email status is the light has been change (from light to dark or dark to light)
Several command can be send by email to the ESP32:
- PERIOD: define in seconds how long between 2 checks. Can be between 60 to 36000 (1h)
- STATUE: Receive an email with the different parameter and light measurement
- GMT: As the time is sent in the email, a GMT can be adjust, as the software read the GMT (0) time
- MIDDLE: Adjust what is the center value for the LDR. It may depend of the position of the charger, the ambient light and so
- GAP: Used for the hysteresis. Dark to light means: more than MIDDLE+GAP. Light to dark means less than MIDDLE-GAP
At each power on, the software will send an email for module start working
Some improvement can be done to have as parameter the email of recipient, or even the main gmail email which is in "hard" in the software.
The small ESP32 board has been place in an old USB charger (with a screw to open). The LDR is on one side, hidden with a transparent black sticker.
UPDATE APRIL 2022:
Many change during the last months:
- Design a small PCB with the ESP32 on one side and a 3.3v regulator, 2x2N2222 for auto download and reset, a connector for download.
- Add many new features in the Arduino software:
* As gmail is adding new security (low security not allowed anymore), need change the way to access to the email from gmail
* Now, many chargers can be address with one email. An alias based on the MAC (or ChipID) of the ESP32 can be defined.
* Most of command can be send to only one device or all device
- Example: PERIOD:180 will setup 180 sec to wake up and check the light for all charger but PERIOD::test:180 will setup only for the charger name test
* It works as well with recipient email. Each charger can send to one different recipient email
* Some new commands: ID::ChipID:Alias to setup alias by charger
* RESET::alias to reset all parameters
* A trace with webserial function is possible
* Very interesting, software update by OTA. I tried to use husarnet but didn t work with Arduino simply. So, I use another solution, free, OTADRIVE. so far so good. Great feature.
* ALIVE function. If no change of light within xx hours, possible to send an ALIVE email, just to be sure that the charger is still working. Parameter xx hours can be define with a email function
* a MAINTENANCE command can send in hidden copy (bcc) all emails sent by the charger to a default email address
* Each email sent has the alias in the title. So, it is easy to know which charger is sending the email
* IP address of the charger is inside the body of each email
* A major change: Now, the charger is always connected to the Wifi. Before it was disconnected and reconnect after each wake up. But many issue with this mode
The program space is becoming large. In case of Webserial need, a new partition need to be use, keeping OTA feature.
In term of integration in the charger, I m using now some direct module 220v=> 5V or 3.3v. Please check the pictures joined
Laurent
It has been developed on an ESP32 and integrated into a simple USB charger.
Technical description: Hardware:
- A simple LDR, connected to the ADC port connected to Vcc and with a pull down read the ambient light, given a value between 0 (dark) to 4095 (full light)
- The USB charger provides 5V and a simple uA78M3.3 gives power to the miniboard ESP32 in 3.3v
- This miniboard, with the button for the boot download, with the enable circuit (resistor/capacitor) and a 4 pin connectors has been placed into the USB charger
Software:
- Developed in C under Ardiuno
- Wifimanager library is used to defined the Wifi network if any recorded network has been found before
- 2 different libraries are used to send and receive email.
- One google email need to be setup and attached to the ESP32, with low security (requested by the library)
- The destination email is defined also in the software
- Every xx seconds, the software will wake up, read the ambient light, read if any command email is received, then send email status is the light has been change (from light to dark or dark to light)
Several command can be send by email to the ESP32:
- PERIOD: define in seconds how long between 2 checks. Can be between 60 to 36000 (1h)
- STATUE: Receive an email with the different parameter and light measurement
- GMT: As the time is sent in the email, a GMT can be adjust, as the software read the GMT (0) time
- MIDDLE: Adjust what is the center value for the LDR. It may depend of the position of the charger, the ambient light and so
- GAP: Used for the hysteresis. Dark to light means: more than MIDDLE+GAP. Light to dark means less than MIDDLE-GAP
At each power on, the software will send an email for module start working
Some improvement can be done to have as parameter the email of recipient, or even the main gmail email which is in "hard" in the software.
The small ESP32 board has been place in an old USB charger (with a screw to open). The LDR is on one side, hidden with a transparent black sticker.
UPDATE APRIL 2022:
Many change during the last months:
- Design a small PCB with the ESP32 on one side and a 3.3v regulator, 2x2N2222 for auto download and reset, a connector for download.
- Add many new features in the Arduino software:
* As gmail is adding new security (low security not allowed anymore), need change the way to access to the email from gmail
* Now, many chargers can be address with one email. An alias based on the MAC (or ChipID) of the ESP32 can be defined.
* Most of command can be send to only one device or all device
- Example: PERIOD:180 will setup 180 sec to wake up and check the light for all charger but PERIOD::test:180 will setup only for the charger name test
* It works as well with recipient email. Each charger can send to one different recipient email
* Some new commands: ID::ChipID:Alias to setup alias by charger
* RESET::alias to reset all parameters
* A trace with webserial function is possible
* Very interesting, software update by OTA. I tried to use husarnet but didn t work with Arduino simply. So, I use another solution, free, OTADRIVE. so far so good. Great feature.
* ALIVE function. If no change of light within xx hours, possible to send an ALIVE email, just to be sure that the charger is still working. Parameter xx hours can be define with a email function
* a MAINTENANCE command can send in hidden copy (bcc) all emails sent by the charger to a default email address
* Each email sent has the alias in the title. So, it is easy to know which charger is sending the email
* IP address of the charger is inside the body of each email
* A major change: Now, the charger is always connected to the Wifi. Before it was disconnected and reconnect after each wake up. But many issue with this mode
The program space is becoming large. In case of Webserial need, a new partition need to be use, keeping OTA feature.
In term of integration in the charger, I m using now some direct module 220v=> 5V or 3.3v. Please check the pictures joined
Laurent
Updates vom Autor