Skip to content

Coin-cell operated monitoring of blinking on utility meter

License

Notifications You must be signed in to change notification settings

martintv/nrf52-utilitymeter

 
 

Repository files navigation

Utility meter

General idea

In my house I use way to much power (40 MWh per year), and I wanted to figure out why. On my power meter I have a blinking light that blinks 10 000 times per kWh. Thus, enter nRF52 with SAADC and some photo sensitive diodes. The setup is shown below:

Setup

The general idea is to detect the blinking light with an photo-sensitive diode, and use a second diode for ambient light cancellation. The pull-up resistors in the SAADC are used to bias the diodes, which prevents static current since the pull-up's are disconnected when SAADC is not sampling.

Equipment

  • nRF52832 DK PCA 10040
  • Photo sensitive diode (I'm using TEPT 5600, which is actually a phototransistor, but that's details)

Algorithm

The best way to understand the algorithm is to read the code, because it may have changed, but in broad strokes

  • Wait for RTC tick
  • Sample differential voltage with SAADC
  • Check if its a blink
//Remove median value, helps with offset
if(results[0] < min){
    min = results[0];
}
if(results[0] > max){
    max = results[0];
}
results[0] -= (max + min)/2;

//Detected a blink, basically a zero cross detection
last_blink_status = blink_status;
if(results[0] <  0 - adc_hysteresis){
    blink_status = 0;
}else if(results[0] > 0 + adc_hysteresis){
	blink_status = 1;
}
if(last_blink_status ==1 && blink_status == 0){
	blink_counter++;
}
  • Count blinks over 4 seconds, and calculate the kW
  • Transmit an advertizing packet with the kW result embedded in the payload.

Status

✅ Get low power sampling with SAADC working

✅ Add light sensor, and see if I can detect the blinking from the utility meter

✅ Add low-power beacon based on https://github.com/NordicSemiconductor/solar_sensor_beacon

✅ Setup a nRF52 to capture the packets https://github.com/wulffern/nrf52-utilitycapture . At this point my laptop is reading out from the nRF52 capture memory, and plotting the kWh over a day, but I need to migrate to a Raspberry Pi or similar

❌ Try it on a Raspberry Pi to use as a gateway

❌ Add nRFCloud functionallity

Results (so far)

Power meter Result

To run

Ideally it should be

make
make SERIAL=<debugger serial> flash 

But rarely that will suffice, you probably have to at least change SDKPATH in the Makefile

The debugger serial can be found with

nfjprog -f nrf52 --ids

Excuses

I'm not a professional embedded programmer (i.e I don't get paid to program embedded code), so I'm sorry if you find these examples a bit messy.

Any concrete criticism/improvment requests are welcome. Send me a private message on devzone.nordicsemi.com

Thanks to

  • Hans E. for help with the Solar Sensor Beacon Packet format
  • Håkon A., Jon Gunnar S. and the Nordic support team for answering questions.

Disclamer

This is not an official Nordic Semiconductor release, it's examples I've compiled in my "offline" time.

About

Coin-cell operated monitoring of blinking on utility meter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 40.3%
  • Makefile 24.9%
  • MATLAB 19.7%
  • Perl 12.9%
  • Python 2.2%