From cf28e8ae1048eb1f00164f873d3050b8aa8b720f Mon Sep 17 00:00:00 2001 From: anschrammh Date: Thu, 28 Nov 2019 06:37:42 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20d'un=20nouveau=20programme=20de=20test?= =?UTF-8?q?=20de=20type=20multim=C3=A8tre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Measurement_ToolBox.ino | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 test/Measurement_ToolBox/Measurement_ToolBox.ino diff --git a/test/Measurement_ToolBox/Measurement_ToolBox.ino b/test/Measurement_ToolBox/Measurement_ToolBox.ino new file mode 100644 index 0000000..21b2c80 --- /dev/null +++ b/test/Measurement_ToolBox/Measurement_ToolBox.ino @@ -0,0 +1,51 @@ +/** + * Auteur : Anatole SCHRAMM-HENRY + * Date : 11/11/2019 + * Programme de test permettant de se familiariser avec les différentes formules U=R*I + */ +#include +#define V_STEP 0.000805860 //Volt 3.3/(4096-1) +const double R_PREC(1471.0); //Ohm + +unsigned int Raw(0.0); +double Vref(0.0); +double Iref(0.0); +double Rvar(0.0); +char buffer[300]; + + + +void setup() { + // put your setup code here, to run once: + Serial.begin(115200); + pinMode(PA0, INPUT); +} + +void loop() { + Raw = analogRead(PA0); + Vref = rawToVref(Raw); //En Volt + Iref = Vref / R_PREC; //En Ampère + + Rvar = (3.3-Vref)/Iref; + // put your main code here, to run repeatedly: + Serial.println("------------------------------------"); + sprintf(buffer, "%d",Raw); + Serial.print("Raw : ");Serial.println(buffer); + + sprintf(buffer, "%.6f Volts",Vref); + Serial.print("Voltage : ");Serial.println(buffer); + + sprintf(buffer, "%.6f Amperes -> %.6f mA",Iref, Iref*1000.0); + Serial.print("Current : ");Serial.println(buffer); + + sprintf(buffer, "%.6f Ohm",Rvar); + Serial.print("Resistance : ");Serial.println(buffer); + + Serial.println("------------------------------------"); + delay(1000); +} + +float rawToVref(float raw) +{ + return V_STEP * (float)Raw; +}