-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include <BslibEnergyMeter.h> | ||
|
||
// Sensores | ||
#define PIN_CURRENT_REF 12 | ||
#define PIN_CURRENT 13 | ||
#define PIN_VOLTAGE 14 | ||
#define PIN_BATTERY 15 | ||
|
||
#define CURRENT_FACTOR 0.200 | ||
#define VOLTAGE_FACTOR 0.60 | ||
#define BATTERY_FACTOR 0.20 | ||
#define BATTERY_OFFSET 1.00 | ||
|
||
BslibEnergyMeter CurrentMeter; | ||
BslibEnergyMeter VoltageMeter; | ||
BslibEnergyMeter BatteryMeter; | ||
|
||
void setup() { | ||
CurrentMeter.SensorCurrent(PIN_CURRENT_REF, PIN_CURRENT, CURRENT_FACTOR); | ||
VoltageMeter.SensorVoltage(PIN_VOLTAGE, VOLTAGE_FACTOR); | ||
BatteryMeter.SensorBattery(PIN_BATTERY, BATTERY_FACTOR, BATTERY_OFFSET); | ||
} | ||
void loop() { | ||
|
||
// calibracion de el sensor cuando hay cero amperios fluyendo por el sensor | ||
|
||
int referenceSensorCurrent = CurrentMeter.AutoCalibrationCurrent(179); | ||
Serial.print("referenceSensorCurrent:\t"); | ||
Serial.println(referenceSensorCurrent); | ||
CurrentMeter.SetCurrentReference(referenceSensorCurrent); | ||
|
||
// lectura individual de cada sensor | ||
// ! la cantidad de lecturas debe ser configurada a discreción | ||
|
||
float corriente = CurrentMeter.GetCurrent(50); | ||
float voltaje = VoltageMeter.GetVoltage(50); | ||
float battery = BatteryMeter.GetBattery(50); | ||
|
||
Serial.print("Corriente en motor N del sistema:\t"); | ||
Serial.println(voltaje); | ||
|
||
Serial.print("Voltaje en motor N del sistema:\t"); | ||
Serial.println(corriente); | ||
|
||
Serial.print("Nivel de bateria del sistema:\t"); | ||
Serial.println(battery); | ||
} |
File renamed without changes.
File renamed without changes.