Skip to content

Control AC lamp based on LUX sensor readings with Qt GUI and Arduino microcontroller

Notifications You must be signed in to change notification settings

N-M-T/LUX_light_dimmer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Qt AC lamp dimmer

Control AC powered lamp with Arduino using Qt GUI application based on LUX sensor readings.

Requirements

An Arduino Uno microcontroller, an Adafruit LUX sensor, a circuit with a zero cross detector and a TRIAC (available from Krida electronics), an AC powered light bulb, and a computer. If you want to build the QT GUI on Linux, follow the instructions below. There are also instructions for building a static Windows version on Ubuntu, although I've already included a pre-build example in the Release folder. Upload the included Arduino sketch with Arduino Create. Follow the wiring instructions that come with the LUX sensor and the AC dimmer module, and you should be good to go.

Theory of phase control

The AC power applied to the lamp is directly related to the total surface area of an AC waveform. Varying the amount of time that the full voltage is applied to a lamp will thus reduce the average power.

To achieve this, a TRIAC is used to turn the voltage supply on and off at precise intervals. E.g. at every zero crossing, a detector sends a pulse to the Arduino. The Arduino then initiates an interrupt (an interrupt essentially makes the ardiuno stop whatever else it is doing and focus on the task at hand, which is necessary to synchronise with the AC wave), and turns off the TRIAC for a specified amount of time. The longer the time, the less average power reaches the lamp. Once this time has elapsed, the arduino turns on the TRIAC by sending a voltage to the gate. The TRIAC will then remain on, even after the gate voltage has been removed, until the next zero crossing event.

In the UK, the AC current oscillates at 50Hz. There are 1000ms in a second, so 1000ms/50 oscillations equates to 20ms per wave. Since there are 2 peaks in a wave, there are 10ms after each zero crossing event which can be regulated. E.g, turning the TRIAC off for 5ms after each zero crossing (10ms for each wave) would mean the voltage is turned off for 50% of the time. This = half the surface area of the waveform = half of the average power.

Qt Build instructions

Build on Ubuntu (need Qt5 and git):

sudo git clone https://github.com/N-M-T/LUX_light_dimmer

cd ~/LUX_light_dimmer/Serial_LUX_Qt

sudo qmake && sudo make



Build version for Windows on Ubuntu

  1. build mxe with required modules (if you haven't already done so), this can take a while

sudo git clone https://github.com/mxe/mxe

cd ~/mxe

sudo make qtbase qtserialport

  1. get to project directory (this might not work from ~/. In which case make a copy of the git repo and save somewhere else) and run the Qt Makefile generator tool (from the mxe build)

export PATH=~/mxe/usr/bin:$PATH

~/mxe/usr/bin/i686-w64-mingw32.static-qmake-qt5

make

License Information

All code is released under GNU GPLv3.0.

About

Control AC lamp based on LUX sensor readings with Qt GUI and Arduino microcontroller

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages