Full size image
This project displays information about the environment on an ST7789 display. There’s a text version of the data and a simple trend graph of the dust/pollen data. The sensors used are as follows:
Light : TLS2561
Dust : DM501A
The BMP280 and TLS2561 connect back to the STM32G071 over the I2C1 bus. The DM501A light sensor connects back to a GPIO pin. This pin is sampled at 1kHz. When a dust particle is detected in the sensor this pin is driven low. The program simply counts the number of milliseconds (samples) that this pin is low over a 1 minute interval and displays this figure.
Environmental information is sent back to a host PC using a UART. It is also written to the ST7789 display.
Code is available over here on github.
In some ways this example is a bit illogical. The TLS2561 consumes a few hundred micro amps while operating so using it to wake the STM32L031 from sleep doesn’t make a lot of sense. This example may be relevant to those who want to use an external I/O pin to wake the an STM32L031 generally or maybe as part of a larger circuit.
The TLS2561 can generate an interrupt signal when the light received on Channel 0 goes outside a user specified certain range. In this example, the range was arbitrarily set to go from 0 0x100. If the received light is equal to or greater than 0x100 then the interrupt signal is driven low which wakes the MCU. If the light is less than or equal to 0 an interrupt is also generated. This isn’t exactly what I wanted (I only wanted an interrupt if the light was bright) so if the circuit is plunged into complete darkness an interrupt will also be generated. This unintended waking could be dealt with by checking the value on Channel 0 and, if zero, going back to sleep again.
Code is available as usual over on github.
The TLS2561 is a digital light sensor which senses light on two wavelengths and outputs two 16 bit results. These values are accessed over an I2C bus. This test program simply reads and displays the ADC results. The manufacturer provides a C source example that can then be used to convert this to LUX. For now I’m not particularly interested in this feature. What is possibly of more interest is the interrupt capability of the device which may allow it to wake a slumbering MCU when light levels fall between certain values. This may be of use in a power saving context. More to follow but for now, source code for my various STM32L031 examples can be found over here on github