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

Frans ov ads1115 settings #15001

Merged
merged 4 commits into from
Mar 2, 2022
Merged

Frans ov ads1115 settings #15001

merged 4 commits into from
Mar 2, 2022

Conversation

FransOv
Copy link
Contributor

@FransOv FransOv commented Feb 28, 2022

Description:

Related issue (if applicable): fixes #

Checklist:

  • The pull request is done against the latest development branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • The code change is tested and works with Tasmota core ESP8266 V.2.7.4.9
  • The code change is tested and works with Tasmota core ESP32 V.2.0.2.3
  • I accept the CLA.

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

Added setting of Single-Ended / Differential and voltage range of the ADS1115 sensor
@FransOv
Copy link
Contributor Author

FransOv commented Feb 28, 2022

The support for the ADS1115 Analog to Digital converter currently has hard-coded settings for input mode (Singel-Ended) and voltage range (6.144 mV). Using another mode or range would necessitate maintaining a specific image for each setting. This PR uses the sensor12 command to set input mode, Either Single-Ended or Differential and Voltage range.
The command accepts a single parameter of two characters. The first character is the input mode, either S(ingle-ended) or D(ifferential). The second character specifies the voltage range with a numeric value of 0-5 corresponding with a voltage range of respectively 6.144, 4.096, 2.048, 1.024, 512 and 256 mV. The command responds with a json string with the settings. E.g.
15:53:25.400 CMD: sensor12 d4
15:53:25.406 MQT: stat/tasmota_CD4398/RESULT = {"ADS1115":{"Settings":"D4","Mode":"Differential","Range":512,"Unit":"mV"}}

Copy link
Contributor

@barbudor barbudor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution
I think the little change below would make it much more usefull

if (Ads1115.channels == ADS1115_SINGLE_CHANNELS) {
config |= (ADS1115_REG_CONFIG_MUX_SINGLE_0 + (0x1000 * channel));
} else {
config |= (ADS1115_REG_CONFIG_MUX_DIFF_0_1 + (0x1000 * channel));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in single ended mode, as before, the driver supports channels 0..3 which are AIN0 to AIN3.
In the differential mode that you added, only 2 channels, as expected. But those 2 channels are

  • 0 = AIN0-AIN1 and
  • 1 = AIN0-AIN3

which makes AIN2 useless.
It would be more versatile to use:

  • 0 = AIN0 - AIN1
  • 3 = AIN2 - AIN3

Which can be easily achieved by using

config |= (ADS1115_REG_CONFIG_MUX_DIFF_0_1 + (0x3000 * channel));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are quite right. I'll change it this way..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, took two tries. I realy should no do a commit on a tablet.

@arendst arendst merged commit 4ff8e44 into arendst:development Mar 2, 2022
@FransOv FransOv deleted the FransOv-ADS1115-Settings branch October 27, 2023 10:31
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

Successfully merging this pull request may close these issues.

3 participants