This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error processing ADS1015: has no attribute 'P0'
#11
Hi, I've tried now with a little help from my friend... ;-) to fix it. I have made a pull request for it.
Have not been able to test it myself yet.
 
Decription:
The Adafruit library moved P0–P3 from module-level exports into the class itself in a recent update. The fix:
ADS11.P0 → ADS11.ADS1115.P0 (lines 251–254)
ADS10.P0 → ADS10.ADS1015.P0 (lines 264–267)
Both ADS1115 and ADS1015 are fixed in openplotterI2cRead.py.

/Leif
Reply
#12
hello Leif

I modified    /usr/lib/python3/dist-packages/openplotterI2c/openplotterI2cRead.py    as indicated

unfortunately that doesn't fix the error
I still get the same error

Checking I2C sensors... | service running | I2C enabled | Access to Signal K server validated
↳Error processing ADS1115: type object 'ADS1115' has no attribute 'P0'

Code:
                    elif i2c_sensors[i]['type'] == 'ADS1115' or i2c_sensors[i]['type'] == 'ADS1015':
                        from adafruit_ads1x15.analog_in import AnalogIn
                        if i2c_sensors[i]['type'] == 'ADS1115':
                            import adafruit_ads1x15.ads1115 as ADS11
                            if i2c_sensors[i]['channel'] == 0:
                                if i2c_sensors[i]['address']:
                                    instances.append({'name':i,'type':'ADS1115','tick':[now,now,now,now],'sensor':i2c_sensors[i],'object':ADS11.ADS1115(i2c, address=int(i2c_sensors[i]['address'], 16))})
                            else:
                                if i2c_sensors[i]['address']:
                                    instances.append({'name':i,'type':'ADS1115','tick':[now,now,now,now],'sensor':i2c_sensors[i],'object':ADS11.ADS1115(muxInstances[i2c_sensors[i]['address']][i2c_sensors[i]['channel']-1])})
                            if instances[-1]['sensor']['data'][0]['SKkey']: instances[-1]['sensor']['data'][0]['object'] = AnalogIn(instances[-1]['object'], ADS11.ADS1115.P0)
                            if instances[-1]['sensor']['data'][1]['SKkey']: instances[-1]['sensor']['data'][1]['object'] = AnalogIn(instances[-1]['object'], ADS11.ADS1115.P1)
                            if instances[-1]['sensor']['data'][2]['SKkey']: instances[-1]['sensor']['data'][2]['object'] = AnalogIn(instances[-1]['object'], ADS11.ADS1115.P2)
                            if instances[-1]['sensor']['data'][3]['SKkey']: instances[-1]['sensor']['data'][3]['object'] = AnalogIn(instances[-1]['object'], ADS11.ADS1115.P3)

                        elif i2c_sensors[i]['type'] == 'ADS1015':
                            import adafruit_ads1x15.ads1015 as ADS10
                            if i2c_sensors[i]['channel'] == 0:
                                if i2c_sensors[i]['address']:
                                    instances.append({'name':i,'type':'ADS1015','tick':[now,now,now,now],'sensor':i2c_sensors[i],'object':ADS10.ADS1015(i2c, address=int(i2c_sensors[i]['address'], 16))})
                            else:
                                if i2c_sensors[i]['address']:
                                    instances.append({'name':i,'type':'ADS1015','tick':[now,now,now,now],'sensor':i2c_sensors[i],'object':ADS10.ADS1015(muxInstances[i2c_sensors[i]['address']][i2c_sensors[i]['channel']-1])})
                            if instances[-1]['sensor']['data'][0]['SKkey']: instances[-1]['sensor']['data'][0]['object'] = AnalogIn(instances[-1]['object'], ADS10.ADS1015.P0)
                            if instances[-1]['sensor']['data'][1]['SKkey']: instances[-1]['sensor']['data'][1]['object'] = AnalogIn(instances[-1]['object'], ADS10.ADS1015.P1)
                            if instances[-1]['sensor']['data'][2]['SKkey']: instances[-1]['sensor']['data'][2]['object'] = AnalogIn(instances[-1]['object'], ADS10.ADS1015.P2)
                            if instances[-1]['sensor']['data'][3]['SKkey']: instances[-1]['sensor']['data'][3]['object'] = AnalogIn(instances[-1]['object'], ADS10.ADS1015.P3)

                        gain = 1
                        if 'sensorSettings' in instances[-1]['sensor']:
                            if 'gain' in instances[-1]['sensor']['sensorSettings']:
                                try: gain = int(instances[-1]['sensor']['sensorSettings']['gain'])
                                except: pass
                        instances[-1]['object'].gain = gain

                        for ii in range(4):
                            if 'magnitudeSettings' in instances[-1]['sensor']['data'][ii]:
                                instances[-1]['sensor']['data'][ii]['ranges'] = getRanges(instances[-1]['sensor']['data'][ii]['magnitudeSettings'])

/Wolfgang

the I2C gui lists the inputs as A0...3

if I rename to
ADS11.ADS1115.A0
same error

after I rename to ADS11.ADS1115.0
error gets worse :

Checking I2C sensors... | I2C enabled | Access to Signal K server validated
↳service not running
Error processing ADS1115: type object 'ADS1115' has no attribute 'A0'

/Wolfgang
Reply
#13
(2026-05-21, 06:02 AM)bobcat Wrote: hello Leif

I modified    /usr/lib/python3/dist-packages/openplotterI2c/openplotterI2cRead.py    as indicated

unfortunately that doesn't fix the error
I still get the same error

Checking I2C sensors... | service running | I2C enabled | Access to Signal K server validated
↳Error processing ADS1115: type object 'ADS1115' has no attribute 'P0'
/Wolfgang

the I2C gui lists the inputs as A0...3

    Error processing ADS1115: type object 'ADS1115' has no attribute 'A0'

/Wolfgang

Hi, yes, later last evening I managed to work locally in my Openplotter with the help of Claude, and now my code is working. I will make a new pull request and also try to publish the file here. I can now see A0-A4 as it should be. It was changes like above for the names and also a small change for the GUI in the same file.

/Leif
Reply
#14
Leif
please, please, please give me some detailed info about how to solve this.
I am banging my head since some month as I need voltage readings to switch off automated processes to run openplotter 24/7

/Wolfgang
Reply
#15
Finally :-). Now I managed to have my openplotter working with the updated code. Also managed to create a pull request for it:
https://github.com/openplotter/openplotter-i2c/pull/16

There you have all information about how to clean config, and updated code in :
https://github.com/LeifYKlasson/openplot...I2cRead.py

Now just waiting to have it confirmed and merged in...

/Leif


Attached Files Image(s)
   
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)