TEMT6000 Illuminance Math with ESPHome

I use inexpensive TEMT6000 sensors in various projects to detect the level of ambient light. I originally hand-coded the firmware, but now I use ESPHome. My projects are usually 3.3V because I use pretty bare boards like ESP-12F instead of development boards like the the NodeMCU or WeMos D1. The TEMT6000 outputs a value between 0-Vcc (3.3V), but the ADC pin on the ESP8266 reads from 0-1V, so I use a simple voltage divider (10k/4700) to bring the voltage down to that range (1.055V) so it can be read properly by the ADC.

Illuminance is measured on my little purple TEMT6000 modules using the direct relationship between illuminance and the the current across the onboard 10k resistor in microamps at the original 3.3V. Here’s how I calculate it. (This same strategy can be applied to other projects, too, like those using Arduino or Raspberry Pi.)

  • The voltage at the ADC pin is 0-1.055V because of the 10k/4700 voltage divider…
  • So the voltage output by the TEMT6000 module is the voltage read at the pin with that voltage divider math backed out. V(temt6000) = V(pin) * (10k + 4700) / 4700. Or more simply, we’re scaling from 0-1 to 0-3.3, so just multiply by 3.3.
  • The current at the TEMT6000, then, is the voltage read at the output divided by the 10k resistor on the module, using Ohm’s law. A = V(temt6000) / 10k
  • Multiply by 1,000,000 to get microamps. uA = A * 1000000
  • Multiply by 2 to get illuminance in lux. lux = uA * 2.

Here’s an example of the calculations: If 0.21582V is read at the ADC pin, then

  • V(temt6000) = 0.712206, or V(pin) * (10k + 4700) / 4700 — or just multiply by 3.3
  • A = 0.0000712206, or V(temt6000) / 10000
  • uA = 71.2206, or A * 1000000
  • lux = 142.4412, or uA * 2

There are a lot of constants in there, so I just collapse the whole thing down to multiplying the voltage read at the ADC pin by 660 to get the illuminance. So, more simply, the

  • V(pin) * 660 = 142.4412.

Here’s the lambda filter I use in the ESPHome configuration.

sensor:
  - platform: adc
    name: "Brightness"
    pin: A0
    device_class: illuminance
    update_interval: 60s  # once a minute seems just fine. 
    unit_of_measurement: lx
    filters:
      - lambda: |-
          return x * 660.0; 

Leave a Reply

Your email address will not be published. Required fields are marked *