如何通过arduino读取12v铅酸电池的连续电压?

how to read continuous voltage of 12v Lead acid Battery by arduino?

提前谢谢你。我是铅酸电池初学者。

其实我是用太阳能给我的12v密封铅酸电池充电的。问题是我需要持续监控我的电池电压。我使用分压器来做到这一点。

现在我的问题是,我可以将分压器连续连接到电池吗?

并且计算出的电压是波动的,如何减少这种波动?

谢谢。

是的,您可以将分压器连接到 Arduino 的模拟引脚之一!

事实上,我昨晚在 Arduino forum 回答了同样的问题。

看看它,如果您还有其他问题,请随时询问。

// number of analog samples to take per reading
#define NUM_SAMPLES 20

int sum = 0;                    // sum of samples taken
unsigned char sample_count = 0; // current sample number
float voltage = 0.0;            // calculated voltage

void setup()
{
    Serial.begin(9600);
}

void loop()
{
    // take a number of analog samples and add them up
    while (sample_count < NUM_SAMPLES) {
        sum += analogRead(A2);
        sample_count++;
        delay(10);
    }
    // calculate the voltage
    // use 5.0 for a 5.0V ADC reference voltage
    // 5.015V is the calibrated reference voltage
    voltage = ((float)sum / (float)NUM_SAMPLES * 5.0) / 1024.0;
    // send voltage for display on Serial Monitor
    // voltage multiplied by 11 when using voltage divider that
    // divides by 11. 11.132 is the calibrated voltage divide
    // value
    Serial.print(voltage * 11.002);
    Serial.println (" V");
    sample_count = 0;
    sum = 0;
}

在 setup() 中,正在初始化串行通信。这样输出就可以显示在串行监视器中。

在循环中() n 获取模拟引脚的读数并存储总和。 然后计算电压并将结果报告给用户。

由于我们处于空循环中,因此该过程将重复进行,直到 Arduino 板的电源断开。

是的,您可以将电池连续连接到分压器。确保使用非常大的电阻器。当前输出 = V/R 。所以如果你想要 I<0.1mA 你想要 0.1mA < 12/R。这意味着您必须使用兆欧范围内的电阻器。

要减少波动,您可以平均电压读数。一个简单的比例平均值会很好地工作。

V[0] = 0.4V[-1] + 0.3V[-2] + 0.2[V-3] + 0.1V[-4]。

这将使您的读数更加平滑。

我发现这个网站对我的项目很有用。看看它,如果有兴趣。这是一个"solar charge controller"。他们使用最好的编码技术 "calculate 12v battery" 和太阳能电池板电压。 谢谢。

http://www.instructables.com/id/ARDUINO-SOLAR-CHARGE-CONTROLLER-Version-20/?ALLSTEPS