Leaving a Carloop running

Has anyone any experience leaving a Carloop running in a parked vehicle?

I want to deploy my TPMS eliminator app and leave it plugged in but am concerned about killing my car’s battery.

My next question would be, any recommendations on how to sense if the vehicle is running?

I suspect you would be drawing less than 100mA of current on average even if you are transmitting regularly. With that level of current draw you should be able to go several day of not running the vehicle to recharge the battery.

As for sensing if the vehicle is running, you should be able to leverage the voltage of the vehicle with the engine off (~12.5 Volts) is less than when the vehicle is running (~14.2 Volts). These voltages are way too high to input into a Particle Photon or Electron so you would need to use a voltage divider circuit. Something like a 4000 ohm resistor in series with a 1000 ohm resistor would work. The combination of the resistors would be put across the vehicles “12 volt” power with the 4000 ohm resistor connected to positive and the 1000 ohm resistor connected to ground. Take a lead off of the connection between the two resistors and connect them to one of the analog inputs of the Particle. You’ll need to test what the analog port reading constitutes the transition from the vehicle being off and on.

Thanks for the suggestion, will try it out as soon as I can! For now I’m just keeping the Carloop handy in case my wife manages to get the car stuck, as Honda brilliantly does not allow you to disable Traction Control if TPMS is not functioning…

Hey folks!
Battery voltage comes included in Carloop library. This sketch shows how to get battery voltage with Carloop library. https://github.com/carloop/carloop-library/blob/master/firmware/examples/carloop_minimal.cpp

Cool I’m going to try this and see how it works:

void loop() {
// Send a message at a regular time interval
unsigned long now = millis();
unsigned long voltage = carloop.battery();
if ((voltage > 14) && (now - lastTransmitTime > transmitInterval)) {
CANMessage message;

// A CAN message has an ID that identifies the content inside
message.id = 0x333;
// It can have from 0 to 8 data bytes
message.len = 7;

// Pass the data to be transmitted in the data array
message.data[0] = 0x00;
message.data[1] = 0x00;
message.data[2] = 0x00;
message.data[3] = 0x00;
message.data[4] = 0x00;
message.data[5] = 0x00;
message.data[6] = 0x0F;

// Send the message on the bus!
message.data[6] = 0x1E;
message.data[6] = 0x2D;
message.data[6] = 0x3C;

lastTransmitTime = now;


I am working on a project to monitor my Leaf battery and am having trouble keeping the carloop and photon from killing the 12v accessory battery. With the car parked and off the 12v battery lasts about 12 hours before I can’t start the car. I put the following check in the code but it is still taking the battery down. Is there a constant current draw from the carloop when the photon is in deep sleep mode? Any other suggestions to code around this?


void setup() {
  volt = (byte)int((carloop.battery()*100)/8);
  if (volt < 154) { //not enough volts to run 154=12.32v

void loop() {
Program Code (carloop.update() and parsing messages)
    trans[6] = (byte)int((carloop.battery()*100)/8);
    if (trans[6] < 156) { //Go into power save mode 156=12.48v
        if (trans[15] > 0) { //Sleep only if we got a GID value
            logthis("Battery Low, sleeping");
    if (trans[15] > 232) {
        logthis("Full Charge going to sleep");

Hey @Ceer123!
If I am reading your code correctly, it looks like you are putting the Photon into Deep Sleep Mode for about 90 seconds if battery is below 12.32V. Based on Particle Photon’s Power Consumption Documentation, that should not kill your battery:

Typical average current consumption is 80mA with 5V @ VIN with Wi-Fi on. Deep sleep quiescent current is typically 80uA (Please refer to Recommended Operating Conditions for more info).

On a healthy 60Ah 12V battery with no other current drains, a Photon would discharge the battery in approximately 750 hours (31.25 days) with WiFi on. Do you have the battery-drain problem when Carloop is not connected to the OBD-II port?

@ScruffR @jvanier any other ideas?

Here’s an interesting operating current table based on different modes:

What capacity has your 12V battery?

In addition to this

Does it make a difference whether the Photon is plugged into the CarLoop or not?
I would doubt that the Photon would drain a few Ah capacity battery that quickly, especially when being asleep for most of the time.
Do you see the device going to sleep properly?

BTW, where is the carloop.update() call in loop()?

Thanks for the replies.

I believe the Leaf battery is smaller than normal cars at about 40Ah. That still should be enough to power through a day at least.

I did some current measurements on the carloop. With the carloop only (photon removed) it pulls 2mA. When adding the photon that is connected to wifi it was about 37mA. I assume those are within normal expectations.

I did find a possible issue with my code that would prevent the photon from going to sleep. In the normal loop I was checking the battery and going to sleep if I had a value (GID) from the car. However it looks like the car, seemingly at will, will shut down the canbus which would prevent my program from getting that value so the power save would never trigger. I have commented out that check and will now do a powersave based only on the battery voltage.

The carloop.update() is at the beginning of the loop after I check if the wifi is still connected. I do see it going to sleep like it should during my testing.

One other thought - Is it possible the carloop is keeping the car computer alive when it would normal not be? I am not writing anything to the bus, the car spits out everything I need without asking. I haven’t figured out why the can messages start and stop on the bus yet.

Not in the code you have shown above.

The line is commented and never executing that way.

Right, I was just showing that to keep the post simple. That Program Code section is where the 200+ lines of parsing the can messages is in the main loop.

Hey @Ceer123,
Did you figure out what was draining your battery? Would love to know how it went!

I ran this weekend with the carloop connected and not starting the car for two days and the battery was fine. I think the code I commented out where I was waiting for a CAN message before going to sleep fixed it. However it is apparent that if the photon is connected without sleeping it will drain the battery about 12 hours. I believe the battery is original on the car and is four years old now so it is possible the battery capacity is not as good as it should be.

Hi @Ceer123 - I found carloop while looking for a solution for exactly what you seem to be doing - remote monitoring SoC on my Nissan Leaf. Can you comment on what you’ve done so far and how its working for you? If you have a blog or other page that documents your project, could you include that too please?

Depending on the level of success you’re having, I’d definitely like to make use of and contribute to your project.