Skip to content

report power (in watts) on the battery and vbus rails #501

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions RX_FSK/src/conn-mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,20 @@ void MQTT::publishPmuInfo()
float i_d = pmu->getBattDischargeCurrent();
float i_c = pmu->getBattChargeCurrent();
float i_batt = 0;
float v_batt = pmu->getBattVoltage() / 1000.;
float i_bus = pmu->getVbusCurrent();
float v_bus = pmu->getVbusVoltage() / 1000.;
float p_bus = i_bus * v_bus / 1000.;

if (i_c)
i_batt = i_c;
else if (i_d)
i_batt = -i_d;

float p_batt = i_batt * v_batt / 1000.;
snprintf(payload, sizeof(payload),
"{\"I_Batt\": %.1f, \"V_Batt\": %.3f, \"I_Vbus\": %.1f, \"V_Vbus\": %.3f, \"T_sys\": %.1f}",
i_batt, pmu->getBattVoltage() / 1000.,
pmu->getVbusCurrent(), pmu->getVbusVoltage() / 1000.,
"{\"I_Batt\": %.1f, \"V_Batt\": %.3f, \"P_Batt\": %.3f, \"I_Vbus\": %.1f, \"V_Vbus\": %.3f, \"P_Vbus\": %.3f, \"T_sys\": %.1f}",
i_batt, v_batt, p_batt, i_bus, v_bus, p_bus,
pmu->getTemperature());
LOG_D(TAG, "publishPmuInfo: sending %s\n", payload);

Expand Down