Connect with us

Arduino as sensing device

Discussion in 'Microcontrollers, Programming and IoT' started by AlenZGB, Oct 20, 2015.

Scroll to continue with content
  1. AlenZGB


    Feb 19, 2014
    Im asking for some help.

    Situation is this, i need to measure current,but voltage would be ok i guess,on car battery in some time
    i got some battery drain and i dont know when or what, when i put it in series with DMM it show 0.01 amp draw.
    Im suspecting that something wakes up somewhere in the day or night and starts to draing then good to sleep,

    Now i want to program arduino, to read voltages,current if possible, and log when the current/voltage starts to
    rise and when starts for fall. So far i only have program code that i found on the web.

    didint test it yet.

    i could use any help with hardware and program code

  2. Bluejets


    Oct 5, 2014

    Attached Files:

  3. AlenZGB


    Feb 19, 2014
    10mA should be ok, up to 300mA should be ok if i got correct info for that vehicle.
    Guess ill have to buy ammeter for arduino. The key thing is to record when it drain so that i can plug off devices and see if
    theres any difference with current drawing.
    Battery is new, and if car doesent run for 3 days battery dies and i cant start.
    I want to plug the arduino 24/7 and when i come read the resaults.
  4. AlenZGB


    Feb 19, 2014
    i got current sensor ACS712,
    and i combine some code.
    can you modify code so that stored maxamps get stored on the max value?


    const int analogIn = A0;
    int mVperAmp = 185; // use 100 for 20A Module and 66 for 30A Module
    int RawValue= 0;
    int ACSoffset = 2500;
    double Voltage = 0;
    double Amps = 0;
    float maxAmps = 0;
    float minAmps = 0;
    float lastAmps = 0;
    float noise = 0;

    void setup(){

    void loop(){

    RawValue = analogRead(analogIn);
    Voltage = (RawValue / 1023.0) * 5000; // Gets you mV
    Amps = ((Voltage - ACSoffset) / mVperAmp);
    Amps = (Amps + lastAmps) / 2;
    lastAmps = Amps;
    maxAmps = max(maxAmps, Amps);
    minAmps = min(minAmps, Amps);
    noise = maxAmps - minAmps;

    Serial.print("Raw Value = " ); // shows pre-scaled value
    Serial.print("\t mV = "); // shows the voltage measured
    Serial.print(Voltage,3); // the '3' after voltage allows you to display 3 digits after decimal point
    Serial.print("\t Amps = "); // shows the voltage measured
    Serial.print(Amps,3); // the '3' after voltage allows you to display 3 digits after decimal point
    Serial.print("\t MAXAMPS = ");

Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day