Is there a way to do a differential analogRead on the Photon and/or Electron? Reading the posts I could find on it, it seems that there may not be; however, people mentioned some kind of dual mode that is similar. Can someone explain how to do this?
I guess you have seen this post
Can you elaborate what you’d need beyond that approach?
The STM32 hardware does not support differential ADC mode. However, you can use dual simultaneous mode to read a pair of ADCs at exactly the same time and difference them in software. Both signals need to be in the range of 0 to 3.3V relative to a common ground, not truly differential, however.
Rather than mess with using the ADC hardware at that low of a level I’d use an I2C differential ADC which is really designed for that purpose.
Adding to Rickkas7’s suggestion : I believe the ADS1115 is a common choice. It is a 4-channel ADC, It requires 2 channels (+/-) for each 16-bit Differential Measurement, so you can measure 2 different voltage sources. There is a lot of sample code floating around and can be found for ~$8 USD.
The code in the github linked in this post explores a lot of ADC features, which adds a lot of complexity. I just want to use one component of this – the dual sampling mode. Can someone show me how to use the dual sampling mode without all the other things this code is doing?