I have got 2 power metes (kWh meters) with a S0 output. They do 1000 pulse/kwh
The output is going to a D1 mini with Easy ESP. I made 2 pulse counters.
It is counting the pulses from the power meters.
I would like to make a rule (script) to do the following:
Pulses powermeter1 + pulses powermeter2 --> Led blink. (1000 pulses / kwh) with little delay.
How can we do this?
I'm not very good in scripting. I was thinking about this:
on system#clock=All,**:**:** do //run every second
let,1,[Solarsystem1#Count]+[Solarsystem2#Count]
Now we have a variable "1" with the pulse of meter 1 and 2.
How can i send it to the onboard led and make it do 1000 pulses/kwh?
It may not overlap or skip pulses and it need to be in a stable ritmh
On a Arduino nano V3 I use a arduino script. (This script is not working on a ESP8266 or D1 mini).
The script works, but the output is not in a stable ritmh. Source: https://forum.arduino.cc/t/2-power-mete ... /854753/30
The pulses of the arduino led are received by a smart thermostat. It is thinking it is a pulse from a power meter of a solar panel system. The unstable ritmh causes very high and low power generated peaks in the graphs.
Code: Select all
//Number of pulses, used to measure energy.
//Made by Johnwasser
volatile byte pulseCount = 0;
const byte Meter1Pin = 2; // External Interrupt Pin
const byte Meter2Pin = 3; // External Interrupt Pin
const byte LEDPin = 13;
void onPulse()
{
pulseCount++;
}
void setup()
{
pinMode(Meter1Pin, INPUT_PULLUP);
pinMode(Meter2Pin, INPUT_PULLUP);
pinMode(LEDPin, OUTPUT);
// KWH interrupts attached to external interrupts
attachInterrupt(digitalPinToInterrupt(Meter1Pin), onPulse, FALLING);
attachInterrupt(digitalPinToInterrupt(Meter2Pin), onPulse, FALLING);
}
void loop()
{
bool pulse = false;
noInterrupts();
if (pulseCount > 0)
{
pulse = true;
pulseCount--;
}
interrupts();
if (pulse)
{
// LED pulse rate is limited to 50 pulses per second, max.
// = 50 Wh per second
// = 3000 Wh per minute
// = 180 kWh per hour
// = 180 kW
// = over 800 Amps at 220 Volts, 1600 Amps at 110 Volts
// Should be fast enough for any home system
digitalWrite(LEDPin, HIGH);
delay(60);
digitalWrite(LEDPin, LOW);
delay(60);
}
}