I'm trying to use an esprunio (pico) to interface some utility neter LED pulse counters (http://www.crucible-technologies.co.uk/products/WEB_LPS) these attach to the front of my electricity meter(s) over the LED which pules every 0.001 kWh of energy thats used.
The idea is to count the pulses each minute then output this over the usb prot to a host raspi for logging the data.
I've prototyped it with the button and the pulse counting works well, the issue I'm having is with the interfacing of the sensors to the digital input pins on the pico, I have the 2 wire passive sensors and according to their info Every time the LED on an energy meter pulses, the resistance between the signal and ground connections drops to around 2k ohm so if I connect the sensor across GND and D0 on the pico then use the internal pullup resistor I should get a 0 when the LED is on (or use the rising edge of the set watch to detect when the LED goes out. however I'm seeing very unreliable results.
My code is below
var count = {};
clearWatch();
const sensor =D0;
pinMode(sensor, 'input_pullup');
function printoutput(){
console.log("-----------------------------");
for (var property in count) {
if (count.hasOwnProperty(property)) {
console.log(property + " - " + count[property]);
}
}
}
function jsonoutput(){
console.log(JSON.stringify(count));
}
function reset(){
count = {};
}
setWatch(function() {
var dta = new Date().toString().split(":");
dta.pop();
var dt = dta.join(":");
if (count[dt]){
count[dt] +=1;
} else {
count[dt] = 1;
}
}, sensor, {edge:"rising", debounce:50, repeat:true});
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I'm trying to use an esprunio (pico) to interface some utility neter LED pulse counters (http://www.crucible-technologies.co.uk/products/WEB_LPS) these attach to the front of my electricity meter(s) over the LED which pules every 0.001 kWh of energy thats used.
The idea is to count the pulses each minute then output this over the usb prot to a host raspi for logging the data.
I've prototyped it with the button and the pulse counting works well, the issue I'm having is with the interfacing of the sensors to the digital input pins on the pico, I have the 2 wire passive sensors and according to their info
Every time the LED on an energy meter pulses, the resistance between the signal and ground connections drops to around 2k ohm
so if I connect the sensor across GND and D0 on the pico then use the internal pullup resistor I should get a 0 when the LED is on (or use therising
edge of the set watch to detect when the LED goes out. however I'm seeing very unreliable results.My code is below