measure 10..15V DC and send it to Domoticz?
Posted: Wednesday 15 February 2017 22:56
Is is possible to (build a system that) measure(s) the voltage of a 12V lead cell and make the result visible as a device within domoticz?
Open source Home Automation System
https://forum.domoticz.com/
Code: Select all
send(msgBat.set(Vbat, 2))
Code: Select all
sendBatteryLevel(batteryPcnt)
Code: Select all
#define VMIN 11 // Vmin (radio Min Volt)=11
#define VMAX 14.5 // Vmax = (2xAA bat)=14.5
int batteryPcnt = 0; // Calc value for battery %
int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point
void setup() {
analogReference(INTERNAL);
}
void presentation()
{
// Send the sketch version information to the gateway and Controller
sendSketchInfo("BATLEVEL", "1.0");
present(CHILD_ID_BAT, S_MULTIMETER);
}
void loop()
{
int sensorValue = analogRead(BATTERY_SENSE_PIN);
float Vbat = sensorValue * 0.0139644;
int batteryPcnt = static_cast<int>(((Vbat-VMIN)/(VMAX-VMIN))*100.);
sendBatteryLevel(batteryPcnt);
send(msgBat.set(Vbat, 2));
/*Serial.print("VBat");
Serial.print(Vbat);
Serial.print("SensorValue");
Serial.print(sensorValue);*/
wait(SLEEP_TIME);
}