I will like to know how many watts are consumed in a led

Hi
I will like to know if it is possible to know how many watts are consumed in a led when it is turn on.

Lets said I have a led connected to PIN 13 in my arduino. For 3 hours with the following code

int LED=13;
void setup() {
  pinMode(LED, OUTPUT);
 
}

void loop()
{
 digitalWrite(LED, HIGH);
}

Is there a way to know how many watts where consumed?

...Your are confusing Power (Watts) and energy (Watt-hours). For example, small batteries are rated in milliamp-hours (mA-hr), and from that you can calculate mW-hours. You can "pull" a lot of milliwatts (maybe a few Watts) from a battery for a short time, or the battery will run longer if you pull less power out of it.

Power is calculated as Voltage X Current. If you have 2 Volts across an LED and 20milliamps flowing through it, that's 40mW. Over 3 Hours, that's 120mW-hours.

If you don't know how much current is flowing through the LED you can calculate (or estimate) it if you know the series resistance and the applied voltage.

Let's say you have an LED rated for 2V @ 20mA. Unlike resistors, LEDs have (approximately) constant voltage drop (when they are on and operating normally). In a series circuit, the same current flows through all components, but the applied voltage is divided among the components. (That's [u]Kirckhoff's Laws[/u].)

Let's say we have a 200 Ohm resistor. With 5V from the Arduino and 2V across the LED, that leaves 3V across the resistor. Using [u]Ohm's Law[/u], we can calculate the current. 3V/200 Ohms = 0.015 Amps (15mA). The same 15mA is flowing through the LED with 2V across it, so we have 30mW of power dissipated in the LED (2V x 15mA). Plus 45mW wasted in the resistor (3V x 15mA). Or if you want the total power coming out of the Arduino, 5V x 15mW = 75mW, which is the same as 30mW + 45mW.

If you have a multimeter, you can measure the voltage across the resistor and LED to make a better calculation. (The LED voltage rating is not always exact.) In order to measure current you have to break the connection and insert the multimeter in series. So, it's usually best to measure the voltage across the known resistance and calculate the current through it.

DiegoTc:
Hi
I will like to know if it is possible to know how many watts are consumed in a led when it is turn on.

Watts = Volts * Amps

DVDdoug:
If you have a multimeter, you can measure the voltage across the resistor and LED to make a better calculation. (The LED voltage rating is not always exact.) In order to measure current you have to break the connection and insert the multimeter in series. So, it's usually best to measure the voltage across the known resistance and calculate the current through it.

However, that only tells him how much power is consumed by the LED and its associated resistor. The Arduino is also consuming power, probably more than the LED and resistor.

Thanks for your answer.
Lets said I want automatize the lights of my house. And I will like my system to tell me how many energy (Watt-hours) has been consumed. How can I do this? I have to calculate this for each light bulb? Or is there anyway to do this? Any idea

Unless you can measure the rms current of each bulb, the best way is to program a table of each bulb's wattage rating and just keep track of how long it is one. If a 13 W bulb is on for 1 hour, you have 13 W-Hrs of energy consumed. Of course, if you change the bulb for one of a different rating, you will have to change the table.