Différences
Ci-dessous, les différences entre deux révisions de la page.
| materiels:capteurs:intensite:intensite [2024/06/24 17:19] – [Modifier - Pane] phil | materiels:capteurs:intensite:intensite [2025/06/19 19:30] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 3: | Ligne 3: | ||
| ===== Capteurs - Intensité du courant ===== | ===== Capteurs - Intensité du courant ===== | ||
| - | [Mise à jour le 24/6/2024] | + | [Mise à jour le 25/6/2024] |
| \\ | \\ | ||
| Ligne 59: | Ligne 59: | ||
| <pane id=" | <pane id=" | ||
| + | * // | ||
| + | * //**Fiche guide**// pour l' | ||
| + | |||
| * //Connexion à un shield// < | * //Connexion à un shield// < | ||
| - | * // Exemple pour tester le capteur// | + | * // Exemple pour tester le capteur |
| {{ : | {{ : | ||
| - | <code cpp acs714.cpp> | + | <code cpp acs714_V1.cpp> |
| + | /* | ||
| + | ACS714 sur Arduino Uno | ||
| + | */ | ||
| + | |||
| + | #define RefVal 5.0 | ||
| + | #define Pin A0 | ||
| + | |||
| + | // Take the average of 500 times | ||
| + | const int averageValue = 500; | ||
| + | long int sensorValue = 0; | ||
| + | float sensitivity = 1000.0 / 185.0; | ||
| + | |||
| + | // Output voltage with no current: 2500mV | ||
| + | float Vref = 2500; | ||
| + | |||
| + | void setup() { | ||
| + | Serial.begin(9600); | ||
| + | } | ||
| + | |||
| + | void loop() { | ||
| + | // Read the value 500 times: | ||
| + | for (int i = 0; i < averageValue; | ||
| + | sensorValue += analogRead(Pin); | ||
| + | |||
| + | // wait 2 milliseconds before the next loop | ||
| + | delay(2); | ||
| + | } | ||
| + | sensorValue = sensorValue / averageValue; | ||
| + | |||
| + | // The on-board ADC is 10-bits | ||
| + | // Different power supply will lead to different reference sources | ||
| + | // example: 2^10 = 1024 -> 5V / 1024 ~= 4.88mV | ||
| + | // unitValue= 5.0 / 1024.0*1000 ; | ||
| + | float unitValue = RefVal / 1024.0 * 1000; | ||
| + | float voltage = unitValue * sensorValue; | ||
| + | |||
| + | // When no load, | ||
| + | Serial.print(" | ||
| + | Serial.print(voltage); | ||
| + | Serial.println(" | ||
| + | |||
| + | // Calculate the corresponding current | ||
| + | float current = (voltage - Vref) * sensitivity; | ||
| + | |||
| + | // Print display current (mA) | ||
| + | Serial.print(current); | ||
| + | Serial.println(" | ||
| + | |||
| + | Serial.print(" | ||
| + | |||
| + | // Reset the sensorValue for the next reading | ||
| + | sensorValue = 0; | ||
| + | // Read it once per second | ||
| + | delay(1000); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | * //Exemple à compléter (étude dans la fiche guide)// | ||
| + | |||
| + | <code cpp acs714_V2.cpp> | ||
| / | / | ||
| - | | + | |
| * Vcc -> 5V # Alimentation du module | * Vcc -> 5V # Alimentation du module | ||
| * GND -> GND | * GND -> GND | ||
| Ligne 93: | Ligne 156: | ||
| <pane id=" | <pane id=" | ||
| - | A venir | + | < |
| </ | </ | ||