You are reading a single comment by @tage and its replies. Click here to read the full conversation.
  • the VBAT pin does not have a stable voltage, so the way I would do it is to use a second ADC input and two resistors. if for example you connect two resistors (with the same value) in series, from VBAT to GND, you get VBAT/2. Measure this signal (you get a reading from 0 to 1) and subtract the current sensor signal reading from this reading. Divide the result by 0.0303 and you get a reading in Amperes. This will give good accuracy even if the VBAT voltage drifts.
    Because the sensor can give out a signal that is higher than the 3.3V rating of the analog input pins of the Espruino you have to make sure you connect the current sensor to the load in a way that as the load increases, the output signal decreases. That way, you will apply VBAT/2 (about 2.1...2.5V) and lower to the analog pin. There should not be any risk that you exceed the maximum voltage for the analog input, unless the current flows in reverse for some reason.

About

Avatar for tage @tage started