Hardware
The electrical components used in the general circuit include a light sensor (TSL2591), an OLED display, a Bluetooth module (HC-05), a blue LED, a pushbutton, various resistors, and an Arduino Nano. These components are powered by a 9V battery connected to a toggle switch. The circuit schematic can be seen below.
The TSL2591 light sensor measures illuminance using the combination of a broadband photodiode that has visible plus infrared capability along with an infrared-only photodiode on one CMOS integrated circuit. There are two analog-to-digital converters that integrate to convert the photodiode currents into a digital signal representing the irradiance measured on each channel which is then input to a microprocessor where illuminance is derived empirically. This sensor has a programmable analog gain and integration time, which allows for varying levels of sensitivity depending on the intensity of the light in the expected environment.
The light sensor and the OLED display both use I2C communication and therefore are connected to the two I2C pins of the Arduino Nano, A4 and A5. I2C is a serial communication protocol, meaning that the data is sent one bit at a time serially, rather than multiple packets of data being sent at the same time, in parallel. The Arduino pins A4 and A5 represent serial data (SDA) and serial clock (SCL) pins respectively. The SCL and SDA lines are both have an open-drain design, so pull-up resistors are required to pull the line to ground, creating a logic low output, and let the line float so that the pullup resistor creates a logic high output.
The HC-05 Bluetooth module’s RX (receive) pin connects to the TX (transmit) pin on the Arduino and vice versa. The state and enable pins were deemed unnecessary for the purposes of this project, so they were left alone.
The Arduino Nano was chosen as the microcontroller because of its small size, high performance, and ease of use. It has a very similar functionality to the more common Arduino Uno but takes up less than half of the size. The Arduino IDE is open-source and has lots of reference material, making it easy to troubleshoot common issues.
The circuit was created on a solderless breadboard for initial testing and most of the software development. The images below show the various stages of hardware development.
After the breadboard circuit was finalized, a custom printed circuit board was developed using KiCAD and the gerber files were sent to a PCB manufacturing company for fabrication.
The first PCB was found to have a few design flaws when it arrived, the analog pins on the Arduino had been mixed up. The problem was quickly resolved, and another PCB was ordered:
The PCB was then assembled and is fully functional: