Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check the i2c address of the sensor (using HassOS I2C Configurator) #31

Open
nonapatatra opened this issue Sep 6, 2024 · 4 comments
Open

Comments

@nonapatatra
Copy link

Can you explicit how to find the i2c address ?
I installed correctly HassOS I2C Configurator
last lines are

/dev/i2c-1
/dev/i2c-0 /dev/i2c-1 /dev/i2c-10 /dev/i2c-22
Found i2c access!  Nothing to do!  You can remove this add-on.

I am guessing, my module3 has not the default address ?
in my config.yaml :

ina219_ups_hat:
  name: Hassio UPS          # Optional
  unique_id: hassio_ups     # Optional
  addr: 0x41                # Required
  scan_interval: 10         # Optional
  batteries_count: 3        # Optional
  battery_capacity: 3000    # Optional
  max_soc: 91               # Optional
  sma_samples: 5            # Optional
  min_online_current: -100  # Optional, mA
  min_charging_current: 55  # Optional, mA   

and got this message

Error during setup of component ina219_ups_hat
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 416, in _async_setup_component
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/ina219_ups_hat/__init__.py", line 69, in async_setup
    coordinator = INA219UpsHatCoordinator(hass, config)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ina219_ups_hat/coordinator.py", line 43, in __init__
    self._ina219 = INA219(addr=int(self._addr))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ina219_ups_hat/ina219/ina219.py", line 79, in __init__
    self.set_calibration_32V_2A()
  File "/config/custom_components/ina219_ups_hat/ina219/ina219.py", line 162, in set_calibration_32V_2A
    self.write(_REG_CALIBRATION, self._cal_value)
  File "/config/custom_components/ina219_ups_hat/ina219/ina219.py", line 89, in write
    self.bus.write_i2c_block_data(self.addr, address, temp)
  File "/usr/local/lib/python3.12/site-packages/smbus2/smbus2.py", line 643, in write_i2c_block_data
    ioctl(self.fd, I2C_SMBUS, msg)
OSError: [Errno 5] I/O error
@odya
Copy link
Owner

odya commented Sep 7, 2024

How to scan i2c buses to find your device addr

  1. Install addon Advanced SSH & Web Terminal
  2. Enter the web interface and execute docker exec -it homeassistant bash -c "apk add i2c-tools && i2cdetect -y 0 && i2cdetect -y 1"

After that you'll get list of found i2c devices. First table is for channel 0, second for channel 1.

➜  ~ docker exec -it homeassistant bash -c "apk add i2c-tools && i2cdetect -y 0 && i2cdetect -y 1"
OK: 267 MiB in 224 packages
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- 41 -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --  

@nonapatatra
Copy link
Author

Thanks.
Nothing appears.

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

I will double check the i2c cable connection.

I connect the following gpio on my rpi4
i2c_rpi4

And I followed the UPS Module 3S connection
UPS_Module_3S

@nonapatatra
Copy link
Author

I verified. Connections are physically correct.
I have no idea where the problem comes from.

@odya
Copy link
Owner

odya commented Sep 7, 2024

Maybe bad wiring? Or try to swap SDA and SCL)

I have all SDA, SCL, GND, 3v3, 5v connected)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants