sen0465 only showing 0% on raspberry pi 4
Anika Hegde 2026-01-11 15:44:02 21 Views0 Replies I configured sen0465 on raspberry pi by following the wiring instructions - and copying the drivers. But the reading is showing 0% for long time.
I confirmed that the I2C sensor is actually communicating at address 0x74 by running i2cdetect.
```
sudo apt install i2c-tools -y
i2cdetect -y 1
i2c-tools is already the newest version (4.4-2).
Summary:
Upgrading: 0, Installing: 0, Removing: 0, Not Upgrading: 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- 74 -- -- --
```

And here is the code -
```
import os
import time
# We import the specific I2C class from the file DFRobot_Oxygen.py
from DFRobot_Oxygen import DFRobot_Oxygen_IIC
# Configuration
# Address 0x74 from your i2cdetect scan
O2_ADDRESS = 0x74
FILE_PATH = '/home/sciencefair/dht22/o2_data.csv'
INTERVAL = 10
def run_o2_logger():
# Initialize the sensor using the IIC (I2C) class
o2_device = DFRobot_Oxygen_IIC(1,O2_ADDRESS)
# Header initialization
if not os.path.exists(FILE_PATH) or os.stat(FILE_PATH).st_size == 0:
with open(FILE_PATH, 'a') as f:
f.write('Date,Time,Oxygen_Concentration_Pct\n')
print(f"Starting O2 Logging at address {hex(O2_ADDRESS)}...")
try:
while True:
# Read oxygen concentration
o2_val = o2_device.get_oxygen_data(20)
if o2_val is not None:
timestamp_date = time.strftime('%m/%d/%y')
timestamp_time = time.strftime('%H:%M:%S')
data_row = f"{timestamp_date},{timestamp_time},{o2_val:.2f}\n"
with open(FILE_PATH, 'a') as f:
f.write(data_row)
print(f"Time: {timestamp_time} | Oxygen: {o2_val:.2f}%")
time.sleep(INTERVAL)
except KeyboardInterrupt:
print("\nLogging stopped by user.")
except Exception as e:
print(f"\nAn error occurred: {e}")
if __name__ == "__main__":
run_o2_logger()
```
I waited for the script to run thinking the calibration will work but the script is showing 0% . How to

