Closed FahrJo closed 3 years ago
What platform are you building on?
I build on an ESP32 Devkit V1 with Platformio.
It may be a PlatformIO thing? Are you sure it's bringing in the latest version of this library? I just tested this with a Feather ESP32 to see if it was something ESP32 specific and can't recreate the behavior.
Using an ADS1015 with channels 0 and 1 wired to the same voltage divider, channel 2 wired to GND, and channel 3 wired to 3.3V and running the example sketch: https://github.com/adafruit/Adafruit_ADS1X15/blob/master/examples/singleended/singleended.ino gets the expected output:
Channels 0 and 1 follow each other as the voltage divider is changed and channel 2 stays at 0 and channel 3 at ~3.3V.
Sorry, first I have to revise my previous answer, this sketch is running on an ESP8266 NodeMCU, sorry for that mistake. And yes, it is the same sketch. My first channel is connected to an as voltage divider wired poti and the other ports are connected to GND or VDD (doesn't change the behavior). The first three channels return the expected value of the first channel and only the last channel returns the right value again.
By adding the parentheses around the bitwise operation, I get the correct value for all channels. I'm building on an MacOS system. And it currently depends on the compiler whether it prioritizes the & or the !=.
OK, thanks for clarifying. Let's just merge it. Being more explicit with the parans won't break it for anything else.
Thank you😉!
Without those parentheses the associativity does not fit to the expected behavior, at least in my case. I got the same known issue with the same value over all channels (#46).