[ens160] - Can't read value

Hi all,

yesterday I configured a board d1_mini_pro with ens160 sensor, this is my code from the dashboard of esphome:

esphome:
name: “qualita-dell-aria”
friendly_name: Sensore Qualità Aria

esp8266:
board: d1_mini_pro

Enable logging

logger:
level: VERY_VERBOSE

Enable Home Assistant API

api:
encryption:
key: “lcS5D6qO4TxHxrgeXwMr19s4dcYUxpzTIMAaEFu0fHI=”

ota:

  • platform: esphome

i2c:
sda: D2
scl: D1
scan: true
id: bus_a

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password

Enable fallback hotspot (captive portal) in case wifi connection fails

ap:
ssid: “Esphome-Web-F03134”
password: “AxfnQkPNtPSj”

captive_portal:

Example configuration entry I2C

sensor:

  • platform: ens160_i2c
    eco2:
    name: “ENS160 eCO2”
    tvoc:
    name: “ENS160 Total Volatile Organic Compounds”
    aqi:
    id: ens160_air_quality_index
    name: “ENS160 Air Quality Index”
    update_interval: 60s
    address: 0x52
    #compensation:
    #temperature: id_temperature_sensor
    #humidity: id_humidity_sensor

everything seems work fine, this is the log:

> `INFO ESPHome 2024.8.1`
> `INFO Reading configuration /config/sensore-qualita-dellaria.yaml...`
> `INFO Starting log output from qualita-dell-aria.local using esphome API`
> `INFO Successfully connected to qualita-dell-aria @` [10.147.1.224](http://10.147.1.224/) `in 0.119s`
> `INFO Successful handshake with qualita-dell-aria @` [10.147.1.224](http://10.147.1.224/) `in 2.995s`
> `[11:03:09][I][app:100]: ESPHome version 2024.8.1 compiled on Dec 28 2024, 00:21:43`
> `[11:03:09][C][wifi:600]: WiFi:`
> `[11:03:09][C][wifi:428]: Local MAC: 34:5F:45:40:E3:19`
> `[11:03:09][C][wifi:433]: SSID: [redacted]`
> `[11:03:09][C][wifi:436]: IP Address:` [10.147.1.224](http://10.147.1.224/)
> `[11:03:09][C][wifi:439]: BSSID: [redacted]`
> `[11:03:09][C][wifi:441]: Hostname: 'qualita-dell-aria'`
> `[11:03:09][C][wifi:443]: Signal strength: -50 dB ▂▄▆█`
> `[11:03:09][C][wifi:447]: Channel: 4`
> `[11:03:09][C][wifi:448]: Subnet:` [255.255.255.0](http://255.255.255.0/)
> `[11:03:09][C][wifi:449]: Gateway:` [10.147.1.1](http://10.147.1.1/)
> `[11:03:09][C][wifi:450]: DNS1:` [10.147.1.1](http://10.147.1.1/)
> `[11:03:09][C][wifi:451]: DNS2:` [0.0.0.0](http://0.0.0.0/)
> `[11:03:09][C][logger:185]: Logger:`
> `[11:03:09][C][logger:186]: Level: DEBUG`
> `[11:03:09][C][logger:188]: Log Baud Rate: 115200`
> `[11:03:09][C][logger:189]: Hardware UART: UART0`
> `[11:03:09][C][i2c.arduino:071]: I2C Bus:`
> `[11:03:09][C][i2c.arduino:072]: SDA Pin: GPIO4`
> `[11:03:09][C][i2c.arduino:073]: SCL Pin: GPIO5`
> `[11:03:09][C][i2c.arduino:074]: Frequency: 50000 Hz`
> `[11:03:09][C][i2c.arduino:086]: Recovery: bus successfully recovered`
> `[11:03:09][I][i2c.arduino:096]: Results from i2c bus scan:`
> `[11:03:09][I][i2c.arduino:102]: Found i2c device at address 0x52`
> `[11:03:09][C][ens160:278]: ENS160:`
> `[11:03:09][D][ens160:300]: Setup successful`
> `[11:03:09][I][ens160:303]: Firmware Version: 5.4.6`
> `[11:03:09][C][ens160:306]: Update Interval: 60.0s`
> `[11:03:09][C][ens160:307]: CO2 Sensor: 'ENS160 eCO2'`
> `[11:03:09][C][ens160:307]: Device Class: 'carbon_dioxide'`
> `[11:03:09][C][ens160:307]: State Class: 'measurement'`
> `[11:03:09][C][ens160:307]: Unit of Measurement: 'ppm'`
> `[11:03:09][C][ens160:307]: Accuracy Decimals: 0`
> `[11:03:09][C][ens160:307]: Icon: 'mdi:molecule-co2'`
> `[11:03:09][C][ens160:308]: TVOC Sensor: 'ENS160 Total Volatile Organic Compounds'`
> `[11:03:09][C][ens160:308]: Device Class: 'volatile_organic_compounds_parts'`
> `[11:03:09][C][ens160:308]: State Class: 'measurement'`
> `[11:03:09][C][ens160:308]: Unit of Measurement: 'ppb'`
> `[11:03:09][C][ens160:308]: Accuracy Decimals: 0`
> `[11:03:09][C][ens160:308]: Icon: 'mdi:radiator'`
> `[11:03:09][C][ens160:309]: AQI Sensor: 'ENS160 Air Quality Index'`
> `[11:03:09][C][ens160:309]: Device Class: 'aqi'`
> `[11:03:09][C][ens160:309]: State Class: 'measurement'`
> `[11:03:09][C][ens160:309]: Unit of Measurement: ''`
> `[11:03:09][C][ens160:309]: Accuracy Decimals: 0`
> `[11:03:09][C][ens160:309]: Icon: 'mdi:chemical-weapon'`
> `[11:03:09][C][ens160:315]: Compensation: Not configured`
> `[11:03:09][C][ens160_i2c.sensor:028]: Address: 0x52`
> `[11:03:09][C][captive_portal:088]: Captive Portal:`
> `[11:03:09][C][mdns:116]: mDNS:`
> `[11:03:09][C][mdns:117]: Hostname: qualita-dell-aria`
> `[11:03:09][C][esphome.ota:073]: Over-The-Air updates:`
> `[11:03:09][C][esphome.ota:074]: Address: qualita-dell-aria.local:8266`
> `[11:03:09][C][esphome.ota:075]: Version: 2`
> `[11:03:09][C][safe_mode:018]: Safe Mode:`
> `[11:03:09][C][safe_mode:019]: Boot considered successful after 60 seconds`
> `[11:03:09][C][safe_mode:021]: Invoke after 10 boot attempts`
> `[11:03:09][C][safe_mode:022]: Remain in safe mode for 300 seconds`
> `[11:03:09][C][api:139]: API Server:`
> `[11:03:09][C][api:140]: Address: qualita-dell-aria.local:6053`
> `[11:03:09][C][api:142]: Using noise encryption: YES`
> `[11:04:05][D][ens160:172]: ENS160 readings unavailable - Normal Operation but readings not ready`




I turn on the sensor yesterday night, 5v5. If necessary I update an image of the wiring.

There’s 3min warm-up time after every reboot…

Hello,

The docs suggest to use GPIO so can you try:


sda: 4
scl: 5

Just double check your esp board for pinout.
Anyway from log it seems to pickup the right gpio.

from documentation address seems to be 0x53 or 0x52. Did you scan to get the address?

How do you power the sensor?
Have you tried an external power supply?

it doesn’t reboot from yesterday…

And what you get on log now?

I try to change from d1 to 4 and d2 to 5, I’ll check the pinout.

I activated the scan, 0x52 seems not work for me.

I power the sensor from a plug in the wall 5v…

[12:38:33][C][api:142]: Using noise encryption: YES
[12:39:29][D][ens160:172]: ENS160 readings unavailable - Normal Operation but readings not ready

Same as yesterday

Please wait 3 minutes as @Karosm said.

other way around…

sda: 4
scl: 5

oh yes! I wrote wrong…

anyway after the change and 3 minutes of wait, this is the log:

[13:01:54][VV][scheduler:225]: Running interval '' with interval=60000 last_execution=348753 (now=408753)
[13:02:00][VV][scheduler:225]: Running interval 'update' with interval=60000 last_execution=354732 (now=414732)
[13:02:00][VV][i2c.arduino:176]: 0x52 TX 20
[13:02:00][VV][i2c.arduino:148]: 0x52 RX 01
[13:02:00][V][ens160:156]: Status: ENS160 STATAS bit    0x0
[13:02:00][V][ens160:158]: Status: ENS160 STATER bit    0x0
[13:02:00][V][ens160:160]: Status: ENS160 VALIDITY FLAG 0x00
[13:02:00][V][ens160:161]: Status: ENS160 NEWDAT bit    0x0
[13:02:00][V][ens160:163]: Status: ENS160 NEWGPR bit    0x1
[13:02:00][D][ens160:172]: ENS160 readings unavailable - Normal Operation but readings not ready

It’s strange, 0x1 means there is data available on GPR registers.

I don’t understand why it doesn’t show nothing.

Is it possible power is dropping?
The power on the Vdo on sensor should not drop below 1.71 V.

Can you just change the interval to 30s, just a guess.

Ok, let’s try this… maybe can be the solution

Hello,

After more than 24 hours plugged in, nothing change. It showed always the same message. What can I try more? No one configured this sensor before in home assistant?

Hello,

still believe is a power related issue.

Did you try to change power supply?
How the sensor is wired can you share a drawing?
Did you try to power the sensor externally?

Tomorrow morning I’ll send a pic of the wiring and relatives power supply :slight_smile:

This is the power supply…

This is the wiring, 3V3 to Vin, GND to GND, sda and scl to the pinout of the board.

Hello,

This might lead to unstable power.
Maybe the 3V3 pin can’t provide the sufficient power to the sensor, peak power 65 mA.
You should provide 3V3 using a breadboard and external power supply, again I am guessing.

I don’t know if the ens board can accept 5V directly, this you have to check, it depends on arrangements of the board itself. You can try this if the board can stand it.

The if you have an oscilloscope you can investigate further the signals, but this will be more complex.

After that you might have a broken sensor.

Hello,

Thanks for your reply, I tried before to wire the sensor to the pin 5V of a board d1_mini_pro.

I should check if the power to the sensor is enough with this board. But now I can’t do it.

How can I power the sensor with an external breadboard?