Street lighting represents one of the largest components of municipal electricity expenditure in Indian cities and towns. Traditional street lighting systems, operating on fixed timers or simple photo-switches, waste significant energy through imprecise switching times, inability to dim during low-traffic periods, and lack of remote configurability. Smart street lighting controllers that combine astronomical timing algorithms, ambient light sensing, dimming control, and wireless configuration offer municipal authorities and infrastructure operators a practical path to meaningful energy savings without replacing the luminaire hardware.
A leading Indian manufacturer of electrical control and automation equipment approached Embien to develop a production BLE-enabled astrotimer for their smart street lighting product line. The astrotimer had to automatically switch street lights on and off based on astronomical sunrise and sunset times for the installation location, augmented by lux sensor-based override to handle overcast and unusual lighting conditions, with PWM-based dimming capability for energy optimisation during low-traffic periods. Wireless configuration over BLE through an Android application was required to eliminate the need for physical access to the controller for commissioning and parameter adjustment.
The core algorithmic challenge was the astronomical sunrise and sunset calculation. Unlike a simple fixed-time schedule, an astrotimer must compute the precise local sunrise and sunset times for any geographic location on any date, accounting for the observer's latitude, longitude, and timezone, and for the continuous change in sunrise and sunset times throughout the year as the Earth orbits the Sun. The algorithm had to run correctly on the resource-constrained Renesas RL78/G1D MCU, a 16-bit microcontroller, without the floating-point hardware and memory resources available on larger embedded processors, requiring careful implementation of the trigonometric calculations involved in astronomical time computation within the RL78's integer arithmetic capabilities.
The lux sensor integration introduced a context-dependent switching logic challenge. Street lights should switch on at sunset under normal conditions, but should also switch on earlier when ambient light falls below a threshold due to heavy cloud cover or storm conditions, and should not switch off at sunrise if ambient light remains low due to fog or overcast. Balancing the astronomical time-based schedule with the lux sensor override, avoiding unnecessary switching cycles while responding correctly to genuine ambient light anomalies, required careful hysteresis and debounce logic in the switching control algorithm.
The onboard AC-DC converter, powering the astrotimer controller directly from the mains supply connected to the street light, had to be designed for reliability and long service life in an outdoor infrastructure context, where the controller may be exposed to supply voltage transients, power quality variations, and temperature extremes over a service life measured in years rather than months.
BLE configuration on the RL78/G1D, a 16-bit MCU with integrated BLE, required careful management of the BLE stack's resource requirements within the MCU's limited RAM and flash, while maintaining the controller's real-time switching and dimming functions during BLE communication sessions.

Renesas RL78/G1D Platform and Firmware Architecture
The astrotimer controller was implemented on the Renesas RL78/G1D, a 16-bit MCU with integrated BLE radio specifically designed for low-power, cost-sensitive IoT and control applications. The RL78/G1D's combination of BLE connectivity, rich peripheral set, and low-power operating modes made it well-suited to the astrotimer's requirements, providing all the necessary interfaces for sensor acquisition, RTC communication, PWM generation, and BLE connectivity within a single-chip solution. The firmware was structured around a time-driven event scheduler, with scheduled tasks for astronomical time calculation, lux sensor sampling, switching decision evaluation, dimming level management, RTC synchronisation, and BLE advertisement management, operating alongside interrupt-driven handlers for BLE events and critical timing functions.
Astronomical Sunrise and Sunset Algorithm
The astronomical time calculation engine implements the NOAA Solar Calculator algorithm, a well-validated astronomical computation method that accurately calculates sunrise and sunset times for any location on Earth for any date. The algorithm was adapted for implementation on the RL78/G1D's 16-bit integer arithmetic architecture, with trigonometric functions approximated using lookup tables and fixed-point arithmetic to achieve the computational accuracy required for switching time precision without floating-point hardware.
The algorithm inputs are the installation location's latitude and longitude, configured through the Android application during commissioning, and the current date obtained from the ISL12022M RTC. On each day, at midnight, the firmware computes the next day's sunrise and sunset times and stores them in the controller's schedule registers. The switching events, lights on at sunset, lights off at sunrise, are triggered by the RTC alarm interrupt at the computed times, with sub-minute precision across all geographic locations and dates supported by the algorithm.
A configurable offset parameter allows the operator to advance or retard the switching times relative to the computed astronomical times, enabling adjustment for local infrastructure factors such as streetlight mounting height, luminaire beam angle, and local regulatory requirements for switching margin relative to civil twilight.
Lux Sensor-Based Automatic Switching
An I2C-connected lux sensor provides ambient light measurement that supplements the astronomical switching schedule with real-world illuminance feedback. The lux sensor is sampled at a configurable interval, with the measured illuminance compared against configurable high and low thresholds. When ambient illuminance falls below the low threshold, indicating darkness due to sunset, heavy cloud cover, or other conditions, the switching logic activates the load output if it is not already active. When illuminance rises above the high threshold, indicating sufficient daylight, the switching logic deactivates the load output.
Hysteresis between the on and off thresholds prevents rapid switching cycling in conditions where ambient light hovers near the threshold, such as during partly cloudy periods or at dusk. A debounce timer requiring the threshold condition to be sustained for a configurable number of consecutive samples before a switching action is triggered further prevents spurious switching from transient illuminance fluctuations such as passing vehicle headlights or brief cloud gaps.
The lux sensor override operates in conjunction with the astronomical schedule, either source can activate the load, but deactivation requires both the astronomical schedule to indicate daytime and the lux sensor to confirm sufficient ambient illuminance. This logical AND deactivation condition ensures that street lights remain on during genuinely dark daytime conditions regardless of the astronomical schedule.
PWM Dimming Control
The load output is controlled through a PWM signal whose duty cycle determines the dimming level of the connected luminaire, compatible with PWM-dimmable LED street light drivers. The PWM frequency and duty cycle range are configured through the Android application to match the specifications of the connected luminaire driver. A configurable dimming schedule, defining dimming levels at different times of night, enables energy optimisation strategies such as full brightness during peak evening hours, reduced brightness during late-night low-traffic periods, and pre-dawn brightening in anticipation of morning activity. Dimming level transitions are implemented as gradual ramps rather than step changes, avoiding visible flicker and reducing thermal stress on the luminaire driver from abrupt power level changes.
ISL12022M RTC Integration
The ISL12022M real-time clock IC provides accurate timekeeping for the astrotimer's scheduling functions. The ISL12022M was selected for its battery-backed operation, maintaining accurate time through mains power interruptions, and its integrated temperature-compensated crystal oscillator, which provides the timekeeping accuracy required for precise astronomical switching over the controller's multi-year service life without manual time adjustment. The RTC is interfaced to the RL78/G1D over I2C, with the firmware reading the current time and date at each scheduling evaluation cycle and using the RTC alarm function to trigger time-based switching events with minimal CPU overhead.
Onboard AC-DC Converter
An onboard AC-DC converter powers the astrotimer controller directly from the mains supply, eliminating the need for a separate external power supply and simplifying installation in street lighting infrastructure. The converter was designed for the voltage range and power quality conditions typical of Indian distribution networks, with transient suppression and filtering to protect the controller electronics from supply voltage spikes and harmonics. The converter's output provides the regulated DC supply required by the RL78/G1D, RTC, lux sensor, and BLE radio, with sufficient current capability for the controller's full operational load.
BLE Configuration and Android Application
BLE v4.1 connectivity, provided by the RL78/G1D's integrated BLE radio, enables wireless configuration of the astrotimer through a companion Android application. The BLE GATT profile exposes configuration characteristics for all astrotimer parameters, installation latitude and longitude, switching time offsets, lux sensor thresholds and hysteresis, dimming schedule, PWM parameters, and RTC time setting. The Android application provides an intuitive configuration interface, with location selection through GPS or manual coordinate entry, time and date setting, threshold adjustment sliders, and dimming schedule programming, that enables a commissioning engineer to fully configure the astrotimer from their smartphone without opening the controller enclosure or connecting any physical interface cable.
The application also provides a real-time status view, displaying the current switching state, measured lux level, computed next sunrise and sunset times, and active dimming level, enabling on-site verification of correct controller operation after commissioning. Configuration profiles can be saved and reloaded within the application, enabling rapid deployment of consistent settings across multiple astrotimer installations on the same project.
This BLE astrotimer project demonstrates Embien's capability to develop production embedded controllers for smart infrastructure applications that combine precise algorithmic computation, multi-sensor control logic, and wireless connectivity within the resource constraints of a cost-optimised 16-bit MCU platform. By implementing the NOAA astronomical algorithm on the Renesas RL78/G1D in fixed-point arithmetic, combining it with lux sensor-based override and PWM dimming control, and providing BLE-based wireless configuration through an Android application, Embien delivered a smart street lighting controller that gives infrastructure operators meaningful energy optimisation capability without the complexity or cost of a networked lighting management system. This project reflects Embien's experience in precision algorithm implementation, low-power embedded design, and BLE application development for industrial and infrastructure control applications.
Partner with Embien for embedded controller development covering astronomical algorithms, sensor-based control, PWM dimming, and BLE wireless configuration.