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

fix: potential infinite loop - add timeout handling #78

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

devmirek
Copy link
Contributor

@devmirek devmirek commented Jul 1, 2024

No description provided.

@RobTillaart
Copy link
Owner

Thanks for this PR,
Will look at it asap.

@RobTillaart RobTillaart self-assigned this Jul 1, 2024
@RobTillaart RobTillaart added the enhancement New feature or request label Jul 1, 2024
@RobTillaart
Copy link
Owner

OK, think the latter is quite optimal so I will merge and fix and bump the version number.

@RobTillaart RobTillaart merged commit bff9430 into RobTillaart:master Jul 3, 2024
3 checks passed
RobTillaart added a commit that referenced this pull request Jul 3, 2024
@RobTillaart
Copy link
Owner

@devmirek
Merged and refactored your code.
Created develop branch for version 0.4.5
Includes a redo of #76 and an initial section about error codes.

Again, thanks for the issue, appreciated!

RobTillaart added a commit that referenced this pull request Jul 3, 2024
RobTillaart added a commit that referenced this pull request Jul 4, 2024
- Fix #78, prevent infinite loop. (Thanks to devmirek).
- Fix #76 (again), update readme.md Comparator Polarity.
- add ADS1X15_ERROR_I2C, communication error.
- add minimal section in readme.md about error codes.
- minor edits.
@YLC35
Copy link

YLC35 commented Oct 29, 2024

Hello, I would like to point out that from this version 0.4.5, reading ports A0,...A3 no longer works by doing a simple ".readADC(x)
while it has worked since the implementation of this library.
It's a shame not to keep compatibility with older versions.

@RobTillaart
Copy link
Owner

@YLC35

Hello, I would like to point out that from this version 0.4.5, reading ports A0,...A3 no longer works by doing a simple ".readADC(x)
while it has worked since the implementation of this library.
It's a shame not to keep compatibility with older versions.

Can you please open an issue for this as .readADC(pin) just should work.
Please provide a minimal sketch that shows the issue.

@YLC35
Copy link

YLC35 commented Oct 29, 2024

This is my code : (After many tests, I found that it doesn't work after the 0.3.9 version.
Thanks for your reactivity ;-))

// test lecture ADS1115 (I2C) SUR ESP32
// BROCHAGE :
//  pin 21   ==>  SDA ADS1115 (I2C)
//  pin 22   ==>  SCL ADS1115 (I2C)

#include "ADS1X15.h"         // lib from Rob Tillaart  ADS1X15 v 0.3.9 (incluse dans le dossier) 
ADS1115 ADS(0x48);           // instance for the ADS1115 
int16_t valA0 = 0;           // valeur brute lue sur A0 (15 bits)
int16_t valA1 = 0;           // valeur brute lue sur A1 (15 bits)
int16_t valA2 = 0;           // valeur brute lue sur A2 (15 bits)
int16_t valA3 = 0;           // valeur brute lue sur 32 (15 bits)
int16_t difA2A3 = 0;         // valeur brute lue sur différence A2 - A3 (15 bits) 

void setup() {
  Serial.begin(115200);
  ADS.begin();                                        // démarrage ASD1115
  ADS.setDataRate(7);                                 // Taux de conversion rapide
  ADS.setMode(1);                                     // mesures à la demande
  ADS.readADC(0);                                     // lecture vide pour prise en compte des paramètres
  ADS.setGain(0);                                     // plage de lecture 0 à 6v.

}

void loop() {
   valA0 = ADS.readADC(0);              // lecture valeur brute A0 en 15 bits
   delay(100);
   valA1 = ADS.readADC(1);              // lecture valeur brute A1 en 15 bits
   delay(100);
   valA2 = ADS.readADC(2);              // lecture valeur brute A2 en 15 bits
   delay(100);
   valA3 = ADS.readADC(3);              // lecture valeur brute A3 en 15 bits 
   delay(100);
   difA2A3 = abs(ADS.readADC_Differential_2_3());  // différentiel de tension entre A2 et A3

   Serial.print(valA0);
   Serial.print("  ");
   Serial.print(valA1);
   Serial.print("  ");
   Serial.print(valA2);
   Serial.print("  ");
   Serial.print(valA3);
   Serial.print("  ");
   Serial.println(difA2A3);
   delay(500);
}

(updated code tags for syntax highlighting)

@RobTillaart
Copy link
Owner

@YLC35

Did a quick test with ADS_read.ino, connected one channel to GND and left other three lines floating .
Looks perfect, see below, so I can't reproduce your problem.

Please open an issue and provide a minimal sketch that shows the problem.

...Arduino\libraries\ADS1X15\examples\ADS_read\ADS_read.ino

ADS1X15_LIB_VERSION: 0.5.1
	Analog0: 2936	0.551
	Analog1: 2958	0.555
	Analog2: 2958	0.555
	Analog3: 1	0.000

	Analog0: 2937	0.551
	Analog1: 2959	0.555
	Analog2: 0	0.000
	Analog3: 2956	0.554

	Analog0: 2931	0.550
	Analog1: 2958	0.555
	Analog2: 2963	0.556
	Analog3: 2964	0.556

	Analog0: 2940	0.551
	Analog1: 1	0.000
	Analog2: 2946	0.552
	Analog3: 2969	0.557

	Analog0: 2937	0.551
	Analog1: 1	0.000
	Analog2: 2947	0.553
	Analog3: 2963	0.556

	Analog0: 1	0.000
	Analog1: 2944	0.552
	Analog2: 2958	0.555
	Analog3: 2967	0.556

	Analog0: 1	0.000
	Analog1: 2947	0.553
	Analog2: 2961	0.555
	Analog3: 2962	0.555

@RobTillaart
Copy link
Owner

@YLC35

Please open a new issue.

@YLC35
Copy link

YLC35 commented Oct 29, 2024

I don't know how to open a new issue on GitHub... i'm sorry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants