/* This example (“The Software”) and the related documentation (“The Documentation”) are supplied to you by the Author in consideration of your agreement to the following terms, and your use or installation of The Software and the use of The Documentation constitutes acceptance of these terms. If you do not agree with these terms, please do not use or install The Software. The Author grants you a personal, non-exclusive license, under author's copyrights in this original software, to use The Software. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by the Author, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which The Software may be incorporated. The Software and the Documentation are provided by the Author on an "AS IS" basis. THE AUTHOR MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION AND MODIFICATION OF THE SOFTWARE AND OR OF THE DOCUMENTATION, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Author: Fabrizio Boco - fabboco@gmail.com Version: 1.0 All rights reserved */ // Calculated resistors values float Rf = 10000.0; float Rg = 20000.0; float R1 = 5000.0; float R2 = 2500.0; // Actual resistors values // float Rf = 9950.0; // float Rg = 20014.0; // float R1 = 4999.98; // float R2 = 1010.03 + 1500.4; float alpha = (Rf + Rg) / (Rg * (R1 + R2)); float referenceVoltage = 2.5; // External Gain and Shift circuit reference voltage float arduinoSupplyVoltage = 4.09; // Measured @5V pin void setup() { Serial.begin(115200); } void loop() { int sensorValue = analogRead(A0); float outputVoltage = sensorValue * (arduinoSupplyVoltage / 1023.0); float inputVoltage = (outputVoltage / alpha - R1 * referenceVoltage) / R2; Serial.print("Output Voltage "); Serial.print(outputVoltage, 3); Serial.print(" Input Voltage "); Serial.println(inputVoltage, 3); delay(100); }