Home | pfodApps/pfodDevices | WebStringTemplates | Java/J2EE | Unix | Torches | Superannuation | | About Us

Forward Logo (image)      

Dusk to Dawn Auto Night Lights
No Internet connection needed.

by Matthew Ford 4th June 2023 (original 4th June 2023)
© Forward Computing and Control Pty. Ltd. NSW Australia
All rights reserved.

Introduction and Features

This project provides Auto Night lights that provide safe passage around the house for those nighttime trips.

They have the following features;-
– Turns on a Dusk and off at Dawn
– Does not need access to the internet or other clock source
– Works across daylight saving changes.
– Unaffected by other lights in the house.
– Does not need a geo location to be set
– Works in all locations including areas shadowed by mountains or high building.
– Can be retrofitted to mains light switches without rewiring.
– Can control standard lamps.
– Has manual override to turn on/off.

This project combines four other project to provide Dusk to Dawn Auto Night Lights that are driven by the outside ambient light level. It uses a long life (4+ years) battery powered BLE light sensor placed outside the house which connects to a BLE controlled light switch via a BLE to BLE bridge.

Using an ambient light sensor means the light switch on at dusk and off at dawn through out the year without the need for an internet clock and geo location while taking into account local conditions like shadowing from mountains or tall buildings. Locating the ambient light sensor outside avoids internal lights affecting the night light.

Two BLE controlled lights are covered in this project. One is mains powered retrofit to an existing light switch. The other is a long life (4+years) battery powered relay that can be inserted in the power lead to a standard lamp. Both of these have a manual over-ride to turn the light on/off that does not interfere with the subsequent Dusk to Dawn switching.
Both BLE to BLE bridge circuits make permanent connections to the BLE light switches. This is not necessary as the code could be changed to only connect when the light needs to be turned on/off. However making a permanent connection turns off the BLE advertising for those switches and so removes them from list of BLE devices the pop up on your mobile.

The hall lights and the standard lamp were fitted with blue blocking light globes so that they provided soft light glow without any harsh glare.

The Components

There are three components:- the ambient light sensor, the BLE controlled light switch and BLE to BLE bridge to connect the two.

The Ambient Light Sensor

The WL_1 – Temperature, Humidity Sensor, Barometric Pressure and Lux level Sensor from the BLE Low Power Indoor/Outdoor Weather Station is used to read the outside ambient light level. Note that the one sensor can be read by multiple receivers as it just broadcasts its reading in its BLE advertising message. So here the same sensor that is being used for the Weather Station is also used to control both of the Auto Night lights. Note: In cold climates the ambient light sensor should be mounted inside against an external window as the coin cell does not work well at low temperatures.

The Battery Powered BLE Controlled Light Switch for a Standard Lamp

To turn a standard lamp on/off at Dusk/Dawn, either the DFROBOT or the Panasonic latching relay version (shown above) of the Very Simple BLE Power Switch is used with the manual push button override fitted.
It is inserted into the power lead of the standard lamp by cutting one of the leads and connecting the two ends to the relay terminals.

BLE to BLE bridge for the Battery Powered BLE controlled Light Switch

This BLE to BLE bridge was used to control the Battery Powered BLE controlled Light switch. It has a small display that shows the current lx level, the on/off state of the lamp and the battery voltage of the BLE controlled light switch. This unit has a small PCB antenna and has limited range. See below for a longer range alternative.

The BLE Controlled Mains Light Switch – Retrofit

WARNING: This BLE Controlled Mains Light Switch is for Experienced Constructors Only. The board is Mains Powered and can be deadly if any part of it is touched while it is running. The wiring of this board into the existing light switch circuit should only be done by a qualified Electrician.

To control the Hall lights, the existing light switch was retrofitted with the BLE LED Light Switch. No extra wiring was needed as the BLE LED Light Switch works without a neutral connection.

BLE to BLE bridge for the BLE Controlled Mains Light Switch – Retrofit

To connect the lux sensor to the BLE Controlled Mains Light Switch, this small ESP32-C3 board with an external antenna was used. The external antenna allows longer range connections.

Parts List:-
1 x Seeed Studio XIAO ESP32C3 including external antenna Core Electronic (SKU: SS113991054) – ~US5.75 OR Seeed Studio XIAO ESP32C3 (SKU 113991054)
1 x USB-A to USB-C cable 50cm – Core Electronics SKU: CE09370 or similar – ~US$2.0 OR Seeed Studio 1m (SKU 106990248)
1 x Small Plastic Box – Core Electronics Room Sensor Enclosure - Small Vented (Size 3) or similar – ~US$3.25 OR Pi Hut (SKU: 104037)


File slots for the antenna lead and the USB cable and stick antenna on the outside of the enclosure and place ESP32-C3 in the enclosure.
NOTE: Use a vented enclosure as the ESP32-C3 runs hot.


Install Arduino IDE V1.8.19 or later.
Install ESP32 board support V2.0.9, the stable release.
Unzip LuxToHallLights.zip to your Arduino sketch directory.
Install the Nordic nRF Connect app (Android or iPhone) and scan for the BLE Light Switch and update the LuxToHallLights.ino
static char deviceAddress[] with the BLE address found.
Select the XIAO ESP32C3 board in the Arduino IDE and program the board with the LuxToHallLights sketch.
See the FAQ near the end of the page on Getting Started with Seeed Studio XIAO ESP32C3 if you cannot see the COM port for the ESP32C3 or if your program download fails.


This project allows existing lights and standard lamps to be automatically turned on at dusk and off at dawn. The on/off transitions are driven by the outside ambient light and so are independent of the local time zone and geo location and take into account shadowing by mountain ranges and high buildings. Two versions were shown. A battery powered BLE standard lamp light switch and a retrofit of an existing hallway mains power light switch which did not require any rewiring. The battery powered BLE ambient light sensor and the battery powered BLE standard lamp light switch both run for 4+years before a battery replacement is needed.

AndroidTM is a trademark of Google Inc. For use of the Arduino name see http://arduino.cc/en/Main/FAQ

The General Purpose Android/Arduino Control App.
pfodDevice™ and pfodApp™ are trade marks of Forward Computing and Control Pty. Ltd.

Forward home page link (image)

Contact Forward Computing and Control by
©Copyright 1996-2020 Forward Computing and Control Pty. Ltd. ACN 003 669 994