Measuring DC current with the CSLA2DH Honeywell sensor?

Hello,

I’m trying to measure DC current (from an automotive battery) with the CSLA2DH Honeywell current sensor and display the results using the particle electron. Does anyone have any experience with this as I am new to this and have absolutely no idea about the coding part!!


Here’s the link to the spec sheet of the sensor for reference.

Any help would be great, Thanks!

First, the “datasheet” you provided there does say the minimum supply voltag for the smaller of these sensors would be 6V, so with only a LiPo for a power source you won’t be able to run these sensors. Also signal to the Electron cannot exceede 3.3V hence you need to map the sensor’s output voltage into that range too.
So before you get into the coding part, you need to figure the electronic part :wink:

2 Likes

Thank you so much!!! I had no idea about this!! Will look into this and will figure it out!!! Thank you once again!

Hey!! thank you for your valuable input… I think i have successfully powered the sensor and was wondering if the code for reading the current value is correct:

int currentsensor = A5;
int lastReading;

void setup() {   
    pinMode(currentsensor,OUTPUT); 
    digitalWrite(currentsensor,HIGH);
   
    Particle.variable("lastReading", &lastReading, INT);
}

void loop() {    
   lastReading = analogRead(currentsensor);
   delay(1000);
}

What is the voltage and current your trying to measure? Is it AC or DC power?

There are other possibly better options with the code already written for the Particle devices depending on what you’re trying to do.

I do see some issues - or things not clear to me.

First the less important.

  Particle.variable("lastReading", &lastReading, INT);

This is the old way of writing this, which is now deprecated.
Rather write it this way now

  Particle.variable("lastReading", lastReading);

But here is the bit that puzzles me.
Why do you set the pin you want to read your value from as OUTPUT and drive it at 3.3V?

Actually when you want to analogRead() the pin, you shallnot set pinMode() at all. analogRead() will internally set a not commonly used pinMode(AN_INPUT) and - if there was some other mode set before - re-set that mode when the reading is done. This will consume extra time and possibly also impact the signal source.

And another reminder of the point I stated earlier - you need to make sure your sensor never provides more than 3.3V to the pin when in analogRead() mode otherwise you can say bye-bye to your ADC and if you exceed 5V even to the entire GPIO stage of that pin.

1 Like

hey!! I am trying to measure DC Current in the range of ± 72Amps

@manavjoshi, based on the specs, the sensor has a Vcc/2 DC offset on its output. So basically, the output will be at 3 volts by default! Depending on current flow direction, the voltage will either move down or up from there. The UP part is the one that can kill your Photon’s analog input. I suggest you measure the output with a voltmeter to make sure you are getting the current flow direction right and get the output going from 3 volts downwards. You could add a 3.6v zener on the output to clip the voltage to a safe 3.3v but that is not ideal for continuous overvoltage.

2 Likes

That’s a decent amount of current so the smaller chips will not work easily without big shunts.

Is it a battery based application?

@RWB, the current sensor uses a Hall-effect sensor so no shunt is required. The CSLA2DH is rated for 200Amps so 72 Amps is actually too low to get the full range of output voltage from the sensor since it is linear.

1 Like

Yes indeed, it is battery based need to monitor the current output of the battery but first testing out on a smaller scale then upgrading.

Point noted Sir!!! Thank you for your valuable input!!

1 Like

Ok Sir!!! Thank you for your valuable input!!

@peekay123 I know, I was just going to recommend the good old INA219 to him if his current was low enough since the code is already written. You could use the INA219 to measure 72 amps of current but it would require a large shunt and some code changes.

Another option you could do is add one of these battery monitors to your battery setup which includes a 500A shunt and then read the data it spits out every second and push that out over the web.

It’s more expensive but it gives you much more data about the battery status. I have the code to read from the battery monitor if you go this route.