felixdrp / ads1x15

Ultra-Small, Low-Power, BitAnalog-to-Digital Converter with Internal Reference
GNU General Public License v2.0
3 stars 1 forks source link

Address set to x48 #1

Closed meeki007 closed 2 years ago

meeki007 commented 3 years ago

I'm running 2 ads1115's wondering if you can expand the options to allow selection of addresses x48, x49, x4A, and x4B ???

the same way you change the i2c bus with

await adc.openBus(1);

but maybe

await adc.address(x49);

????

felixdrp commented 3 years ago

Hello, I added setAddress to the last update. try: adc.setAddress(0x49)

Also you could try directly: adc.address = 0x49

Thank you

meeki007 commented 3 years ago

I took the time to read through your code ...... Its rather nice and concise.... and that makes it hard without documentation to understand how to play with it. I never bothered playing with ES6 Destructuring Assignment inside of function parameters. Learned allot :)

Would you be interested in a pull request updating the documentation ? I'd like to show examples for setting the programmable_gain_amplifier and the samples_per_second.

I'd format this correct for your documentation but here is a code snippet of how I worked it out.

const channels_array_of_objects = [
              {channel: 0, programmable_gain_amplifier: 2048, samples_per_second: 250},
              {channel: 1, programmable_gain_amplifier: 2048, samples_per_second: 250},
              {channel: 2, programmable_gain_amplifier: 2048, samples_per_second: 250},
              {channel: 3, programmable_gain_amplifier: 2048, samples_per_second: 250}
              //{p: 2, n: 3},
            ];

            //notify_user_errors('Reading Single shot:');
            for await (let request of channels_array_of_objects) {
              try {
                voltage_output_object[format_i2c_device_number][format_number_of_chip][format_number_of_i2c_address][format_inputsForChannel]['channel_'+request.channel] = {};
                const measure = await adc.readSingleEnded({
                  channel: request.channel,
                  pga: request.programmable_gain_amplifier,
                  sps: request.samples_per_second
                });
                //notify_user_errors("request.channel="+request.channel);
                voltage_output_object[format_i2c_device_number][format_number_of_chip][format_number_of_i2c_address][format_inputsForChannel]['channel_'+request.channel]['Volts'] = measure / 1e3;
                voltage_output_object[format_i2c_device_number][format_number_of_chip][format_number_of_i2c_address][format_inputsForChannel]['channel_'+request.channel]['miliVolts'] = measure;

              } catch (error) {
                notify_user_errors(error);
              }
            }
felixdrp commented 2 years ago

Hello meeki007,

Would you be interested in a pull request updating the documentation ?

Yes, please.

I would like the community to have a place to share examples, so I opened the wiki. Please, add a link to your example at the wiki.

Cheers,

meeki007 commented 2 years ago

Awesome! Busy at work at the moment. Give me a week or 2 and I'll add some documentation. Thanks for opening the wiki. Feel free to close this issue if ya like.

Thanks again Felix

On Wed, Dec 15, 2021 at 4:19 PM Felix D Rodriguez Perez < @.***> wrote:

Hello meeki007,

Would you be interested in a pull request updating the documentation ?

Yes, please.

I would like the community to have a place to share examples, so I opened the wiki. Please, add a link to your example at the wiki.

Cheers,

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/felixdrp/ads1x15/issues/1#issuecomment-995221563, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNNLRGM2P5UHYB6PEIWOR3UREA5PANCNFSM5CG5M2PQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.