Skip to content

Latest commit

 

History

History
167 lines (104 loc) · 7.96 KB

FHmonitor.rst

File metadata and controls

167 lines (104 loc) · 7.96 KB

Intro

The FHmonitor package runs on a Raspberry Pi that is communicating with an atm90e32 chip over SPI. We use Circuit Setup's energy meter, which uses the atm90e32. Current Transformers (CTs) that are plugged into the energy meter clamp onto the power lines. The CTs provide a signal to the elecriticy monitor that is then interpreted into power line measurements like voltage and current.

The FHmonitor package:

  • reads power readings from the electricity monitor.
  • stores readings into the mongodb running on the Raspberry Pi.

image

The Hardware

Before using the FHmonitor package, you must have a running energy monitor. The energy monitor consists of:

Hardware Setup Steps

  • Set up the Raspberry Pi. <rasppi>
  • Connect the Hardware. <connect_the_hw>

Once the hardware is setup, the CTs need to be installed. Circuit Setup has an excellent write up on installing CTs

Calibrating the Meter

Getting good readings from the atm90e32 assumes the parameters defined in calibration.json are set to reflect the environment in which the meter will be taking readings. The various calibration parameters are:

  • Frequency of AC coming into your home - lineFreq: Since we are in North America where the AC frequency is 60Hz, We set this to 4485. The rest of the world is at 50Hz. If that is how your home's power is configured, change this value in calibration.json to 389.
  • Gain for the CT clamps - PGAGain: The default setting is for homes that have 100 amp service - 21. Many houses are big and/or suck up more electricity than a 100 amp service provides. The PGAGain must be set to 42 for homes with electricity service between 100-200 amps.
  • Gain adjustment for Voltage Readings - VoltageGain: This value depends on the power 9v/12v power supply being used with the energy meter. One of CircuitSetup's web pages provides default values for some common power supplies. We decided to standardize on the Jameco 9V power supply, part no. 157041.
  • Gain adjustment for Current Readings - CurrentGain: This value depends CT (Current Transformer) being used. We are using the SCT-016.

NOTE: We used the command line utilities:

calibrate_voltage
calibrate_current

discussed below to set VoltageGain and CurrentGain. Also Note: CircuitSetup's firmware for the energy meter uses a current gain setting for each of the CTs. We simplified this to use just one parameter - CurrentGain - for both CTs.

calibrate_voltage

After starting up the venv and pip installing FHmonitor, the calibrate_voltage command is available. This command runs a python script that will adjust the VoltageGain value within calibration.json. Prior to using the command, you should have the energy meter plugged into a Kill-A-Watt. The Kill-A-Watt will be the reference voltage. Running the command with the -s (--save) option will figure out the new VoltageGain value and then update calibration.json. If the -s option is not specified, the new VoltageGain value will not be saved.

calibrate_current

calibrate_current is similar in concept to calibrate_voltage. Instead of using voltage readings, current readings are used. The CT can be plugged into either of the CT plugs on the meter. We use a test wire assembly to read the current of a device (for example a lamp) using a CT.

image

systemd service

The systemd service, FHmonitor_main.service starts a shell script, run_FHmonitor_main.sh. The shell script starts FHmonitor_main.py.

start_service

Use the command:

(venv)$ start_service

To start the FHmonitor_main.service systemd service. The code for start_service. At the end of start_service, the service status is given. The PID will be shown in the results. To make sure your service is still running, find the PID and use the command:

(venv)$ journalctl _PID=<PID number>

stop_service

Use the command:

(venv)$ stop_service

To execute the OS command for stopping the FHmonitor_main.service systemd service. The code for stop_service

status_service

Use the command:

(venv)$ status_service

To execute the OS command for checking the status of the FHmonitor_main.service systemd service. The code for status_service

hello_monitor

Once the:

  • monitor is plugged in with the CTs strapped around the power lines.
  • the venv has been installed and activated.
  • the FHmonitor package has been installed.

Type:

(venv)$hello_monitor

If all is working, you should get reasonable active and reactive power readings.

The code for hello_monitor.

Monitor class

The class you will use the most is ~FHmonitor.monitor.Monitor. This class contains methods to:

  • Take an active and reactive power reading (see ~FHmonitor.monitor.Monitor.take_reading).

    • Before taking a reading, the energy meter must be initialized (see ~FHmonitor.monitor.Monitor.init_sensor).
  • Store the reading into the mongo db running on the Raspberry Pi (see ~FHmonitor.monitor.Monitor.store_reading).

    • Before storing readings, the mongo db must be opened (see ~FHmonitor.monitor.Monitor.open_db).

FHmonitor.monitor

Store class

The ~FHmonitor.monitor.Monitor class uses an implementation of the ~FHmonitor.store.Store abstract class to store power readings into a datastore. The only data store currently available is the mongo db. We originally started with a Firebase DB, but decided running everything on a Raspberry Pi was much easier. Mongo db can be run on the Raspberry Pi at no additional $ cost.

FHmonitor.store