Having problems with erratic readings from sensor

hi,

i’m looking for some help.

I’ve got a ESP32 NodeMCU development board and I’m trying to set up a light sensor using the TEMT6000 ground is set to ground, V is set to 3v and data is to p32

the readings i am getting are

[21:31:22][D][adc:056]: 'Testing Brightness': Got voltage=0.53V
[21:31:22][D][sensor:092]: 'Testing Brightness': Sending state 105.46032 lux with 2 decimals of accuracy
[21:31:23][D][adc:056]: 'Testing Brightness': Got voltage=0.81V
[21:31:23][D][sensor:092]: 'Testing Brightness': Sending state 162.19292 lux with 2 decimals of accuracy
[21:31:24][D][adc:056]: 'Testing Brightness': Got voltage=0.14V
[21:31:24][D][sensor:092]: 'Testing Brightness': Sending state 28.84982 lux with 2 decimals of accuracy
[21:31:24][D][sensor:092]: 'Testing uptime do not use': Sending state 39.75800 s with 0 decimals of accuracy
[21:31:24][D][text_sensor:015]: 'Testing Uptime': Sending state '0d 00h 00m 39s'
[21:31:25][D][adc:056]: 'Testing Brightness': Got voltage=0.00V
[21:31:25][D][sensor:092]: 'Testing Brightness': Sending state 0.00000 lux with 2 decimals of accuracy
[21:31:26][D][adc:056]: 'Testing Brightness': Got voltage=0.11V
[21:31:26][D][sensor:092]: 'Testing Brightness': Sending state 21.81197 lux with 2 decimals of accuracy
[21:31:27][D][adc:056]: 'Testing Brightness': Got voltage=0.80V
[21:31:27][D][sensor:092]: 'Testing Brightness': Sending state 159.02321 lux with 2 decimals of accuracy
[21:31:28][D][adc:056]: 'Testing Brightness': Got voltage=0.62V
[21:31:28][D][sensor:092]: 'Testing Brightness': Sending state 124.63981 lux with 2 decimals of accuracy
[21:31:29][D][adc:056]: 'Testing Brightness': Got voltage=0.20V
[21:31:29][D][sensor:092]: 'Testing Brightness': Sending state 40.40049 lux with 2 decimals of accuracy
[21:31:30][D][adc:056]: 'Testing Brightness': Got voltage=0.74V
[21:31:30][D][sensor:092]: 'Testing Brightness': Sending state 147.25764 lux with 2 decimals of accuracy
[21:31:31][D][adc:056]: 'Testing Brightness': Got voltage=0.42V
[21:31:31][D][sensor:092]: 'Testing Brightness': Sending state 84.18559 lux with 2 decimals of accuracy
[21:31:32][D][adc:056]: 'Testing Brightness': Got voltage=0.00V
[21:31:32][D][sensor:092]: 'Testing Brightness': Sending state 0.00000 lux with 2 decimals of accuracy
[21:31:33][D][adc:056]: 'Testing Brightness': Got voltage=0.81V
[21:31:33][D][sensor:092]: 'Testing Brightness': Sending state 162.51527 lux with 2 decimals of accuracy
[21:31:34][D][adc:056]: 'Testing Brightness': Got voltage=0.66V
[21:31:34][D][sensor:092]: 'Testing Brightness': Sending state 132.96704 lux with 2 decimals of accuracy
[21:31:35][D][adc:056]: 'Testing Brightness': Got voltage=0.36V
[21:31:35][D][sensor:092]: 'Testing Brightness': Sending state 71.07693 lux with 2 decimals of accuracy
[21:31:36][D][adc:056]: 'Testing Brightness': Got voltage=0.00V
[21:31:36][D][sensor:092]: 'Testing Brightness': Sending state 0.00000 lux with 2 decimals of accuracy
[21:31:37][D][adc:056]: 'Testing Brightness': Got voltage=0.30V
[21:31:37][D][sensor:092]: 'Testing Brightness': Sending state 60.17094 lux with 2 decimals of accuracy
[21:31:38][D][adc:056]: 'Testing Brightness': Got voltage=0.51V
[21:31:38][D][sensor:092]: 'Testing Brightness': Sending state 102.66666 lux with 2 decimals of accuracy
[21:31:39][D][adc:056]: 'Testing Brightness': Got voltage=0.06V
[21:31:39][D][sensor:092]: 'Testing Brightness': Sending state 12.35653 lux with 2 decimals of accuracy
[21:31:39][D][sensor:092]: 'Testing uptime do not use': Sending state 54.76800 s with 0 decimals of accuracy
[21:31:39][D][text_sensor:015]: 'Testing Uptime': Sending state '0d 00h 00m 54s'
[21:31:40][D][adc:056]: 'Testing Brightness': Got voltage=0.00V
[21:31:40][D][sensor:092]: 'Testing Brightness': Sending state 0.00000 lux with 2 decimals of accuracy
[21:31:41][D][adc:056]: 'Testing Brightness': Got voltage=0.24V
[21:31:41][D][sensor:092]: 'Testing Brightness': Sending state 48.62027 lux with 2 decimals of accuracy
[21:31:42][D][adc:056]: 'Testing Brightness': Got voltage=0.79V
[21:31:42][D][sensor:092]: 'Testing Brightness': Sending state 158.64713 lux with 2 decimals of accuracy

in this instance the sensor was in a dimly lit room, but I get similar readings if I put the sensor in a box void of any light or under a lamp and pointing directly at the sensor.

this is my yaml in total

esphome:
  name: testing
  platform: ESP32
  board: esp-wrover-kit

wifi:
  networks:
  - ssid: !secret ssid
    password: !secret wifi_password
  - ssid: !secret sky-ssid
    password: !secret sky-password
  manual_ip:
    static_ip: 192.168.0.41
    gateway: 192.168.0.1
    subnet: 255.255.255.0
    dns1: 192.168.0.1
    dns2: 192.168.0.1

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

# Enable Web server.
#web_server:
#  port: 80
  
sensor:
  - platform: adc
    pin: GPIO32
    name: "Testing Brightness"
    update_interval: 1s
    attenuation: 11db
    unit_of_measurement: lux
    filters:
      - lambda: |-
          return (x / 10000.0) * 2000000.0;
  - platform: wifi_signal
    name: "Testing WiFi signal"
    update_interval: 300s

  - platform: uptime
    name: "Testing uptime do not use"
    id: testing_uptime
    update_interval: 15s

text_sensor:
  - platform: version
    name: "Testing ESPHome version"
    
  - platform: template
    name: "Testing Uptime"
    lambda: |-
      uint32_t dur = id(testing_uptime).state;
      int dys = 0;
      int hrs = 0;
      int mnts = 0;
      if (dur > 86399) {
        dys = trunc(dur / 86400);
        dur = dur - (dys * 86400);
      }
      if (dur > 3599) {
        hrs = trunc(dur / 3600);
        dur = dur - (hrs * 3600);
      }
      if (dur > 59) {
        mnts = trunc(dur / 60);
        dur = dur - (mnts * 60);
      }
      char buffer[17];
      sprintf(buffer, "%ud %02uh %02um %02us", dys, hrs, mnts, dur);
      return {buffer};
    icon: mdi:clock-start
    update_interval: 15s

switch:
  - platform: restart
    name: Testing Restart

all help appreciated thank you

Are you providing exactly 3 Volts? Maybe that isn’t enough for the sensor to provide stable readings. I would up the voltage to at least 3.3V (maybe utilize an output pin from the esp32 as your voltage source assuming it can supply sufficient current for the sensor.

thank you for your reply,

my apologies for not being clear above, all the points of the sensor are connected using dupont from the sensor to the ESP32 board so the sensor is recieving 3.3V from the board with is being powered via usb cable which is plugged into a plug in the wall and rated to 5v 2a DC

my thought was that either i have something wrong in my configuration or the power source us pulsing the power, but then how do i check that?

Where on the board are you getting 3.3 Volts?

If you’re taking it from the pin labeled 3.3V that is input only. That would explain your sensor readings blowing in the breeze. Basically no power to the circuit hence noise only which is what you are seeing.

Ahh, ok… yes it’s connected to the pin marked on the board as 3v3

i’ll have a look for a pinout diagram to see where the voltage should be

As I wrote earlier. Designate another pin to be your 3.3V supply and in the bootup just turn it on and you’re good to go.

thanks but i dont know how… trying to find somewhere i can learn how to do that

Here some of my code doing this. Actually pretty simple

esphome:
  name: esp003
  platform: ESP32
  board: nodemcu-32s
  on_boot:
    then:
      lambda: |-
        // power to the dhts and keys (gpio)
        id(gpio_3V3).turn_on();


output:
  - id: gpio_3V3
    platform: gpio
    pin: 32

Thank you! i’ve been searching frantically to find that :slight_smile:

so that is setting pin 32 as your voltage pin? right?

Yeah, obviously you’re already using that pin so pick some other pin.

You’re probably ok but make sure your sensor doesn’t draw more current than the pin can supply!

you are a Legend ! thank you! just uploading it now to test it

what am i looking for to learn more about that? i’m very new to all this but I want to learn so i can maybe work things out.

All the sensors should have a spec sheet. You’ll typically want to note max current draws (worse case scenario) for sizing hardware.

Regarding the software, Most of my code is written in lambdas utilizing c++ . I find it easier to code things up that way. I’ve picked up a lot of knowledge by perusing the open source code for this project and the online manual. Unfortunately it just takes time there is no magic brain dump.

just uploaded and still got the same problem… have i done something wrong?

here is what I’ve chenged in the configuration

esphome:
  name: testing
  platform: ESP32
  board: nodemcu-32s
  on_boot:
    then:
      lambda: |-
        // power to the dhts and keys (gpio)
        id(gpio_3V3).turn_on();


output:
  - id: gpio_3V3
    platform: gpio
    pin: 33

the power is now connected to pin 33 and the read out is as follows

INFO Reading configuration...
INFO Starting log output from 192.168.0.41 using esphome API
INFO Connecting to 192.168.0.41:6053 (192.168.0.41)
INFO Successfully connected to 192.168.0.41
[23:35:26][I][app:096]: esphome version 1.13.6 compiled on Oct 26 2019, 23:28:24
[23:35:26][C][wifi:372]: WiFi:
[23:35:26][C][wifi:254]:   SSID: [redacted]
[23:35:26][C][wifi:255]:   IP Address: 192.168.0.41
[23:35:26][C][wifi:257]:   BSSID: [redacted]
[23:35:26][C][wifi:258]:   Hostname: 'testing'
[23:35:26][C][wifi:262]:   Signal strength: -52 dB ▂▄▆█
[23:35:26][C][wifi:263]:   Channel: 1
[23:35:26][C][wifi:264]:   Subnet: 255.255.255.0
[23:35:26][C][wifi:265]:   Gateway: 192.168.0.1
[23:35:26][C][wifi:266]:   DNS1: 192.168.0.1
[23:35:26][C][wifi:267]:   DNS2: 192.168.0.1
[23:35:26][C][template.text_sensor:020]: Template Sensor 'Testing Uptime'
[23:35:26][C][template.text_sensor:020]:   Icon: 'mdi:clock-start'
[23:35:26][C][gpio.output:010]: GPIO Binary Output:
[23:35:26][C][gpio.output:011]:   Pin: GPIO33 (Mode: OUTPUT)
[23:35:26][C][logger:137]: Logger:
[23:35:26][C][logger:138]:   Level: DEBUG
[23:35:26][C][logger:139]:   Log Baud Rate: 115200
[23:35:26][C][logger:140]:   Hardware UART: UART0
[23:35:26][C][adc:026]: ADC Sensor 'Testing Brightness'
[23:35:26][C][adc:026]:   Unit of Measurement: 'lux'
[23:35:26][C][adc:026]:   Accuracy Decimals: 2
[23:35:26][C][adc:026]:   Icon: 'mdi:flash'
[23:35:26][C][adc:035]:   Pin: 32
[23:35:26][C][adc:044]:  Attenuation: 6db (max 2.2V)
[23:35:26][C][adc:051]:   Update Interval: 1.0s
[23:35:26][C][restart:021]: Restart Switch 'Testing Restart'
[23:35:26][C][restart:021]:   Icon: 'mdi:restart'
[23:35:26][C][version.text_sensor:015]: Version Text Sensor 'Testing ESPHome version'
[23:35:26][C][version.text_sensor:015]:   Icon: 'mdi:new-box'
[23:35:26][C][ota:029]: Over-The-Air Updates:
[23:35:26][C][ota:030]:   Address: 192.168.0.41:3232
[23:35:26][C][api:103]: API Server:
[23:35:26][C][api:104]:   Address: 192.168.0.41:6053
[23:35:26][C][wifi_signal.sensor:009]: WiFi Signal 'Testing WiFi signal'
[23:35:26][C][wifi_signal.sensor:009]:   Unit of Measurement: 'dB'
[23:35:26][C][wifi_signal.sensor:009]:   Accuracy Decimals: 0
[23:35:26][C][wifi_signal.sensor:009]:   Icon: 'mdi:wifi'
[23:35:26][D][adc:056]: 'Testing Brightness': Got voltage=0.23V
[23:35:26][D][sensor:092]: 'Testing Brightness': Sending state 46.41758 lux with 2 decimals of accuracy
[23:35:27][D][adc:056]: 'Testing Brightness': Got voltage=0.70V
[23:35:27][D][sensor:092]: 'Testing Brightness': Sending state 140.21979 lux with 2 decimals of accuracy
[23:35:28][D][adc:056]: 'Testing Brightness': Got voltage=1.17V
[23:35:28][D][sensor:092]: 'Testing Brightness': Sending state 233.59219 lux with 2 decimals of accuracy
[23:35:29][D][adc:056]: 'Testing Brightness': Got voltage=0.96V
[23:35:29][D][sensor:092]: 'Testing Brightness': Sending state 192.76192 lux with 2 decimals of accuracy
[23:35:30][D][adc:056]: 'Testing Brightness': Got voltage=0.00V
[23:35:30][D][sensor:092]: 'Testing Brightness': Sending state 0.00000 lux with 2 decimals of accuracy
[23:35:31][D][adc:056]: 'Testing Brightness': Got voltage=0.00V
[23:35:31][D][sensor:092]: 'Testing Brightness': Sending state 0.00000 lux with 2 decimals of accuracy
[23:35:32][D][adc:056]: 'Testing Brightness': Got voltage=0.16V
[23:35:32][D][sensor:092]: 'Testing Brightness': Sending state 32.12699 lux with 2 decimals of accuracy
[23:35:33][D][adc:056]: 'Testing Brightness': Got voltage=0.81V
[23:35:33][D][sensor:092]: 'Testing Brightness': Sending state 162.99878 lux with 2 decimals of accuracy
[23:35:34][D][adc:056]: 'Testing Brightness': Got voltage=1.10V
[23:35:34][D][sensor:092]: 'Testing Brightness': Sending state 220.80588 lux with 2 decimals of accuracy
[23:35:35][D][sensor:092]: 'Testing uptime do not use': Sending state 312.82001 s with 0 decimals of accuracy
[23:35:35][D][adc:056]: 'Testing Brightness': Got voltage=1.23V
[23:35:35][D][sensor:092]: 'Testing Brightness': Sending state 245.73383 lux with 2 decimals of accuracy
[23:35:36][D][adc:056]: 'Testing Brightness': Got voltage=0.99V
[23:35:36][D][sensor:092]: 'Testing Brightness': Sending state 197.59708 lux with 2 decimals of accuracy
[23:35:37][D][text_sensor:015]: 'Testing Uptime': Sending state '0d 00h 05m 12s'
[23:35:37][D][adc:056]: 'Testing Brightness': Got voltage=1.03V
[23:35:37][D][sensor:092]: 'Testing Brightness': Sending state 206.19292 lux with 2 decimals of accuracy
[23:35:38][D][adc:056]: 'Testing Brightness': Got voltage=0.91V
[23:35:38][D][sensor:092]: 'Testing Brightness': Sending state 181.05006 lux with 2 decimals of accuracy
[23:35:39][D][adc:056]: 'Testing Brightness': Got voltage=0.29V
[23:35:39][D][sensor:092]: 'Testing Brightness': Sending state 57.05495 lux with 2 decimals of accuracy
[23:35:40][D][adc:056]: 'Testing Brightness': Got voltage=0.03V
[23:35:40][D][sensor:092]: 'Testing Brightness': Sending state 5.90965 lux with 2 decimals of accuracy
[23:35:41][D][adc:056]: 'Testing Brightness': Got voltage=0.97V
[23:35:41][D][sensor:092]: 'Testing Brightness': Sending state 194.80342 lux with 2 decimals of accuracy
[23:35:42][D][adc:056]: 'Testing Brightness': Got voltage=0.43V
[23:35:42][D][sensor:092]: 'Testing Brightness': Sending state 86.92552 lux with 2 decimals of accuracy
[23:35:43][D][adc:056]: 'Testing Brightness': Got voltage=0.00V
[23:35:43][D][sensor:092]: 'Testing Brightness': Sending state 0.00000 lux with 2 decimals of accuracy
[23:35:44][D][adc:056]: 'Testing Brightness': Got voltage=0.68V
[23:35:44][D][sensor:092]: 'Testing Brightness': Sending state 135.27718 lux with 2 decimals of accuracy
[23:35:45][D][adc:056]: 'Testing Brightness': Got voltage=0.97V
[23:35:45][D][sensor:092]: 'Testing Brightness': Sending state 194.26617 lux with 2 decimals of accuracy
[23:35:46][D][adc:056]: 'Testing Brightness': Got voltage=1.23V
[23:35:46][D][sensor:092]: 'Testing Brightness': Sending state 246.37852 lux with 2 decimals of accuracy
[23:35:47][D][adc:056]: 'Testing Brightness': Got voltage=1.21V
[23:35:47][D][sensor:092]: 'Testing Brightness': Sending state 242.08060 lux with 2 decimals of accuracy
[23:35:48][D][adc:056]: 'Testing Brightness': Got voltage=0.84V
[23:35:48][D][sensor:092]: 'Testing Brightness': Sending state 168.37119 lux with 2 decimals of accuracy
[23:35:49][D][adc:056]: 'Testing Brightness': Got voltage=0.21V
[23:35:49][D][sensor:092]: 'Testing Brightness': Sending state 41.90476 lux with 2 decimals of accuracy
[23:35:50][D][sensor:092]: 'Testing uptime do not use': Sending state 327.81799 s with 0 decimals of accuracy
[23:35:50][D][adc:056]: 'Testing Brightness': Got voltage=0.00V
[23:35:50][D][sensor:092]: 'Testing Brightness': Sending state 0.00000 lux with 2 decimals of accuracy
[23:35:51][D][adc:056]: 'Testing Brightness': Got voltage=0.00V
[23:35:51][D][sensor:092]: 'Testing Brightness': Sending state 0.00000 lux with 2 decimals of accuracy
[23:35:52][D][text_sensor:015]: 'Testing Uptime': Sending state '0d 00h 05m 27s'
[23:35:52][D][adc:056]: 'Testing Brightness': Got voltage=0.00V
[23:35:52][D][sensor:092]: 'Testing Brightness': Sending state 0.00000 lux with 2 decimals of accuracy
[23:35:53][D][adc:056]: 'Testing Brightness': Got voltage=0.00V
[23:35:53][D][sensor:092]: 'Testing Brightness': Sending state 0.00000 lux with 2 decimals of accuracy
[23:35:54][D][adc:056]: 'Testing Brightness': Got voltage=0.00V
[23:35:54][D][sensor:092]: 'Testing Brightness': Sending state 0.32234 lux with 2 decimals of accuracy
[23:35:55][D][adc:056]: 'Testing Brightness': Got voltage=0.15V
[23:35:55][D][sensor:092]: 'Testing Brightness': Sending state 29.33334 lux with 2 decimals of accuracy
[23:35:56][D][adc:056]: 'Testing Brightness': Got voltage=0.00V
[23:35:56][D][sensor:092]: 'Testing Brightness': Sending state 0.00000 lux with 2 decimals of accuracy
[23:35:57][D][adc:056]: 'Testing Brightness': Got voltage=0.00V
[23:35:57][D][sensor:092]: 'Testing Brightness': Sending state 0.00000 lux with 2 decimals of accuracy
[23:35:58][D][adc:056]: 'Testing Brightness': Got voltage=0.22V
[23:35:58][D][sensor:092]: 'Testing Brightness': Sending state 44.80586 lux with 2 decimals of accuracy
[23:35:59][D][adc:056]: 'Testing Brightness': Got voltage=0.91V
[23:35:59][D][sensor:092]: 'Testing Brightness': Sending state 182.55434 lux with 2 decimals of accuracy
[23:36:00][D][adc:056]: 'Testing Brightness': Got voltage=0.26V
[23:36:00][D][sensor:092]: 'Testing Brightness': Sending state 51.46764 lux with 2 decimals of accuracy
[23:36:01][D][adc:056]: 'Testing Brightness': Got voltage=0.00V
[23:36:01][D][sensor:092]: 'Testing Brightness': Sending state 0.00000 lux with 2 decimals of accuracy

Since you’re supplying 3.3V to the chip you should probably set the attenuation for the ADC to 11db instead of 6

yeah all the best things come with time to learn :slight_smile: the best chance of succeeding is knowing where to start :smiley:

i changed it from 11db as it’s only set to 3.3v and the documentation said it was for up to 3.9v (if I understand it right)

but i’ll give it a go

started to upload it now, lets see… and than you very much for your help with this :smiley:

edit: just uploaded, no change still all over the place, tried setting the db to 0,2.5,6 and 11 same results

If you don’t have anything connected to 2 put the power on that pin. The blue led will at least show you that you have power going to the circuit. Then I would recheck your connections as your results still looks like noise. Unless you have a voltmeter then check the voltages on the sensor.

Also are you sure all your dupont wires are good conductors?