measure the energy consumed by the engine

Hi i'm a beginner on arduino and i need to measure the energy consumed by the engine, i don't how to write th program, so if someone can help me . I use an arduino uno ,a motor shield L239D, and a DC motor. Ps: the speed is variable. I am available for any questions

How accurately do you need to measure this? Because if you are driving the motor using PWM it will not be straightforward.

If it was my project and I just needed a rough indication I would use my multimeter to measure the voltage supplied TO the L293 and the current going into it. There will probably be a substantial voltage drop within the L293 and you could get a rough idea of that by measuring the voltage difference between input and output at different motor speeds and loads and then figure a rough average to deduct from the input voltage to get a fair approximation of the voltage at the motor. You could measure the voltage at the motor but I'm not sure how well your multimeter would average the PWM output.

If you need a much more precise value then you need to take voltage and current readings throughout the PWM cycle and integrate the data. You could do that with the Arduino. Measuring the current will be the difficult part.

...R

OK, there's a number of issues there. Are you trying to measure the motor alone or does the power consumption of the Arduino and the L239D have to be measured too?

Have you got the motor working and running how you want, without measurement?

How much voltage and current do you expect to be measuring?

And do you want energy or power? You might need an RTC.

In fact the program need to calculate himself the power and i just print it on the monitor. So it nor really me who measure the energy consumed by the motor . Tell if u need more information, because i'm not very comfortable with the english so i try to answer to everybody.

starkuyss: Tell if u need more information,

We do.

Please start by answering all of the questions that have already been asked.

...R

Robin2: How accurately do you need to measure this? Because if you are driving the motor using PWM it will not be straightforward.

...R

I haven't got instructions about that

KeithRB: And do you want energy or power? You might need an RTC.

I need the energy.

MorganS: OK, there's a number of issues there. Are you trying to measure the motor alone or does the power consumption of the Arduino and the L239D have to be measured too?

Have you got the motor working and running how you want, without measurement?

How much voltage and current do you expect to be measuring?

I want the measure of the motor alone, and print that on the monitor. The engine runs as I wish.

Energy over how long of a time span? What units? Joules? W-seconds? kWhr?

KeithRB: Energy over how long of a time span? What units? Joules? W-seconds? kWhr?

The measurement should be done over a period of 10 minutes, and i will use the Joules

starkuyss: I haven't got instructions about that

Then you need to get instructions or make a decision yourself.

You have not answered the question

How much voltage and current do you expect to be measuring?

That answer is essential for knowing what sort of measuring equipment is required.

...R

For the voltage it's 7V and for the current it's 0.35A but i'm not sure but it is around these values.

You need one of these: https://www.sparkfun.com/products/8882

to measure the current. And a voltage divider to monitor the voltage.

Then take a power measurement every second for the 10 minutes. Get an average power over that time and multiply x 10*60.

Ok thx all for help me

KeithRB: You need one of these: https://www.sparkfun.com/products/8882

to measure the current. And a voltage divider to monitor the voltage.

Then take a power measurement every second for the 10 minutes. Get an average power over that time and multiply x 10*60.

I will try this Friday because i do not have access to it before.