Menu
Proteus schematic of the HELA ambient-light module: a mains transformer and bridge rectifier feeding a 7805, a PIC16F1768 with a 16x2 LCD, three buttons, a DS1307 RTC, an APDS-9002 light sensor and a BC547-driven relay switching a mains LED strip

Sensor-Based Ambient Lights — the “HELA” Module

The HELA Module is a modular ambient‑light controller: one piece of hardware that can switch an ordinary mains 110 V / 220 V AC LED strip on and off manually, on a schedule, or automatically from the ambient light level. It was built for PG‑7232 Embedded Systems at the Universidad Simón Bolívar as a six‑person team project, with the firmware on a PIC16F1768 and the whole circuit validated in Proteus.

The brief was written as a product exercise: build to a target cost (electronics under US$7), run straight off mains, keep the operating mode through a power cut, and provide a simple user interface. The design that came out of it is deliberately conservative — a small non‑isolated 5 V supply for the logic and a relay to switch the mains strip.

Hardware

Hardware block diagram: a power cord into an HLK-10M05 AC/DC module giving 5 VDC to a PIC16, which connects to an ICSP header, three buttons, an APDS-9002 light sensor on an ADC, an LM016L LCD, a DS1307 RTC over I2C, a debug console over UART, and an HF46F-5-HS1 relay switching a 110 VAC LED strip

Hardware block diagram — the logic runs from a small 5 V supply; only the relay touches the mains.

BlockPartNotes
MCUPIC16F1768 (20‑pin, 8‑bit)I²C, 2× 10‑bit ADC, Flash for persistent state
PowerHLK‑10M05 AC/DCNon‑isolated, 5 VDC @ 700 mA, 3×2 cm — powers the logic only
Light sensorAPDS‑9002Current output across a load resistor, read by the ADC
Real‑time clockDS1307 module, battery‑backedKeeps time through a mains outage
RelayHF46F‑5‑HS1 (5 VDC coil, 5 A)BC547 + base resistor drive; 1N4007 flyback diode
DisplayLM016L 16×2 LCD4‑bit interface
Buttons3× momentary, pull‑upSelect / mode, Accept / enter, Cancel
Full Proteus schematic of the module: mains source, transformer, bridge rectifier and 7805 regulator, PIC16F1768, 16x2 LCD, three pull-up buttons, DS1307 with crystal and backup battery, APDS-9002 light sensor, and a BC547-driven relay

The complete circuit as simulated in Proteus.

Operation Modes

The LCD shows the current screen; the three buttons walk a small menu.

ModeWhat it does
HomeShows the time and whether the light is forced on. Accept toggles a manual on/off override; Select cycles the menu.
Configure timeSet the clock hours / minutes / seconds.
Auto on/off (schedule)Enter a start and end time; the light is on while the clock is inside that window.
Night light (sensor)Enable the light sensor; the screen shows the live reading, and pressing Select captures it as the darkness threshold. Below that level, the light turns on.
Menu state diagram: from the Inicio start state to Screen 1 (time display), then Screen 2 (set time) with hour/minute/second sub-states, Screen 3 (schedule on/off) with its own hour/minute/second sub-states, and Screen 4 (automatic on/off by sensor), navigated with the mode and enter buttons

The menu state flow (from the project report) — the mode and enter buttons move between screens.

The relay logic is a simple priority chain: manual override → inside the scheduled window → ambient light below the captured threshold → otherwise off.

Firmware

Software block diagram: a button-logic block in the middle connected to display logic, set/get time, on/off logic and a get-luminosity block, with persistent memory, and I/O to the LCD, DS1307, relay and debug console

Software block diagram — six subsystems: display, clock, sensor, buttons, persistent memory and the on/off logic that ties them together.

Hela.X/main.c is a single cooperative loop — read the light sensor (ADC), edge‑detect the three buttons, render the current menu screen, decide the relay state, and print the time and sensor value on a 9600 baud debug UART. The LCD is driven by a 4‑bit HD44780 library; the ADC, UART and pin setup come from MPLAB Code Configurator. The device runs from the 8 MHz internal oscillator.

PIC pinSignal
RA4 / RA5 / RC6Buttons — Select / Accept / Cancel
RA2Light sensor (ADC AN2)
RC0–RC3LCD data D4–D7
RC4 / RC5LCD RS / E
RC7Relay drive
RB5 / RB7Debug UART RX / TX

Simulation

The whole module — mains supply, regulator, PIC, LCD, RTC, sensor and relay — is simulated in Proteus using only stock library parts. A virtual terminal on the debug UART shows the time and the live light‑sensor reading.

Proteus running the simulation: a virtual terminal printing repeated 'Current sensor value is: 120' and 'Current time is: 00:00:00' lines next to the powered circuit with the LCD showing 00:00:00

Running in Proteus — the debug terminal streams the time and sensor value. There is also a demo video of the last firmware version.

Notes

  • The committed firmware implements the menu, the light sensor, the schedule comparison and the relay control. The DS1307 is on the board and in the schematic, but this build does not yet read it over I²C (no I²C module is generated and there is no timekeeping interrupt) — the clock is set and held through the Configure time screen. Wiring the RTC and writing the selected mode to Flash are the open items.
  • From the report's BOM analysis the electronics come to about $7 in one‑off quantities and the full production cost (with assembly and lamp materials) to about $31 against a $70 retail target — inside the 50% goal.
  • The repository has no LICENSE file yet.
  • Team: Carlos Sanoja, Jesús Guillen, Leonardo Ward, Mauricio Marcano, Oscar Moreno and Vincenzo D’Argento.
Posted In:
Embedded Software