• I just made a few experiments with an Adafruit 1115 breakout board along with the module EspruinoDocs/devices/ADS1X15.js. I compared the datasheet of ADS1115 and ADS1015 and it appears that the datarate config (DR[2:0]) is not the same. Thus, the ADS1X15.js is only valid for ADS1015. As long as the ADC type cannot be discovered at runtime, it may be better to make 2 modules instead of one, but it means renaming the js file. I don't know @Gordon what would be the best way to go because renaming the current js module will break compatibility for those who currently use it.

    Any hint?

    Kind regards,

  • Thanks for figuring that out!

    Is everything else basically the same though? So as far as I can see the ADS1015 would run at 1600 samples/second by default while the ADS1115 is only 128 (which was the default in both cases) - but everything should still work ok?

    It's frustrating not having an I2C WHOAMI register! I thought pretty much every device had them now.

    I'd have said duplicating everything just for that might be overkill - what about extending the .connect function with an options object:

    var ads = require("ADS1X15").connect(I2C1, { part:"ads1115"});
    

    So then anyone using this already would have it work fine, but it could easily support the ADS1115

  • Thank you @Gordon. I tried to implement this feature according to your recommendation and made a pull request here: https://github.com/espruino/EspruinoDocsĀ­/pull/665

    However, when testing, I got this error

    Uncaught Error: Function "connect" not found!
     at line 96 col 26 in ADS1X15
    function ADS1X15(i2c,opts={part:"ads1015"}) {
                             ^
     at line 198 col 30
        ads = require("ADS1X15").connect(i2c,{part:"adĀ­s1115"});
                                 ^
    in function "onInit" called from line 212 col 8
    onInit();
    

    It is most probably a very noob, basic javascript error. Could you help me figure out what's going wrong with the way I made the change?

  • I think it's that you're using 'default arguments' which is a newish JS feature that Espruino doesn't support yet.

    I've just merged your PR and hopefully tweaked it though

  • Thank you very much, I must say that I didn't look so deep into other modules to check how optional parameters were handled.
    Anyway I just tested the new version of the ADS1X15 module and it works well with an ads1115. Thank you for your incredibly fast actions!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

[SOLVED] ADS1x15 module is not really compatible with ADS1115

Posted by Avatar for Jean-Philippe_Rey @Jean-Philippe_Rey

Actions