Comments (7)
@rin67630 I have modified the library a bit and now you can call setVoltageRange_mV and immediately request voltages. The necessary delays are added in the background. The delays are adjusted to the conversion rate.
from ads1115_we.
Yes correct, there is no register for this to store the information. So you would have to work with an case/switch or if, like:
if(channel == ADS1115_COMP_0_1){setVoltageRange_mV(range)}
Another option is use setAutoRange(); when you change the channel.
Or you modify the general function to read the channels in the example sketch:
float readChannel(ADS1115_MUX channel) {
float voltage = 0.0;
adc.setCompareChannels(channel);
voltage = adc.getResult_V(); // alternative: getResult_mV for Millivolt
return voltage;
}
to individual channels:
float readChannel_1() {
float voltage = 0.0;
adc.setCompareChannels(channel_1);
setVoltageRange_mV(channel_1_range);
voltage = adc.getResult_V(); // alternative: getResult_mV for Millivolt
return voltage;
}
or you extend the function to read the channel:
float readChannel(ADS1115_MUX channel, ADS1115_RANGE range) {
float voltage = 0.0;
adc.setCompareChannels(channel);
setVoltageRange_mV(range);
voltage = adc.getResult_V(); // alternative: getResult_mV for Millivolt
return voltage;
}
and call readChannel accordingly, for example:
readChannel(ADS1115_COMP_0_GND, ADS1115_RANGE_2048);
If I implement this in the library it will take some additional memory space for the variables. And the effort/complexity on your side does not differ much, since you still have to define somewhere which range you want to apply for which channel. But happy to hear your view. Maybe it would be an alternative to add this as another example sketch?
from ads1115_we.
Thank you.
Will it react to a change of setVoltageRange_mV(range); immediately or could a change immediately followed by an adc.getResult() lead to errors?
Could you change it in setAutoRange() without delay?
from ads1115_we.
setVoltageRange shouldn't need a delay. Why don't you just try it? And yes, you can use setAutoRange() instead. It changes into the full range, measures the voltage and then selects the lowest range in which the measured is below 80% of the maximum (to have some buffer). The only disadvantage is that it takes some conversion cycles. But you don't need to add a delay.
from ads1115_we.
I need to correct myself: setVoltageRange() needs a delay. But if you first change the range and then the channel, the delays I have implemented for the change of the channel are sufficient. So do it this way round or take the setAutoRange() function. Sorry for the confusion.
from ads1115_we.
Thank you. I wrote here to share our experience and let others benefit as well
I prefer not it use AutoRange to preserve performance (minimize the processing time).
Once I am through, maybe we could add an example?
from ads1115_we.
Yes, let's add an example. I'm also considering to add an automatic delay for the change of range.
from ads1115_we.
Related Issues (15)
- Ability to use result range HOT 44
- Hysteresis HOT 27
- Can you make an example on how to use the library in continous mode using more than one input? HOT 3
- ADS1115 - real 16 bit resolution? HOT 11
- Connecting another device change the voltage of the other device HOT 2
- Differential example HOT 5
- getResultWithRange(), can you please precise? HOT 2
- Why autorange blocks so much time when range is under 80% max? HOT 4
- Example with 2 I2C addresses HOT 1
- add license to library.properties HOT 2
- Using Wire1 with teensy 4.0 HOT 3
- Question: wrong read value HOT 9
- SPS is Low HOT 3
- Reduce code duplication HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ads1115_we.