Open source low-cost power monitoring system

Powered by TCPDF (www.tcpdf.org) This material is protected by copyright and other intellectual property rights, and duplication or sale of all or part of any of the repository collections is not permitted, except that material may be duplicated by you for your research use or educational purposes in electronic or print form. You must obtain permission for any other use. Electronic or print copies may not be offered, whether for sale or otherwise to anyone who is not an authorised user. Oberloier, Shane; Pearce, Joshua M.


Hardware in context
As the open source method of technological development [1] has moved aggressively into technically-sophisticated scientific hardware [2][3][4][5][6][7][8], there has been another push towards open source appropriate technology (OSAT) for sustainable development [9][10][11]. One leading example of OSAT is the work by Open Source Ecology (OSE) to fabricate the tools needed for civilization itself [12]. OSE has identified the top 50 most relevant machines to comfortably sustain civilization [13]. OSE uses a model where the design is global and open source, but the manufacturing is distributed, local peer production [14,15]. One of the main pillars of OSE's plan is distribution on every level: distributed agriculture, manufacturing, and energy production [12].
The OSE mindset has fostered the development of the Open Building Institute (OBI), which was created to design and build comfortable and highly functional homes, such as their first model shown in Fig. 1 [16]. OBI houses can be built using OSE's Open Village Construction Set and are designed to be ecologically responsible, scalable, and replicable in the fully open source sense. Ideally these houses are constructed and powered using a sustainable source of electric power such as solar photovoltaic (PV) technology [17], which converts sunlight directly into electricity. Thus, the current designs of OBI all utilize building integrated photovoltaics (BIPV) for energy generation as it has distinct advantages in reducing ecological impact [18], net energy [19] and cost [20]. The OBI building is optimized to supply multiple different configurations of power (i.e. 5 V, 12 V, 24 V, 48 V, and 120VAC), in order to cut down on conversion losses (energy conversion processes always result in energy loss [21]). In order to fully understand the designs, and provide valuable feedback in order to enable the OBI design to evolve technically there is a need for a low-cost, flexible an open source monitoring system to log the consumption and generation of electricity.
Some commercial solutions exist for an energy monitoring systems, including the Neurio [22], the Eyedro EHWEM1 [23], the Smappee [24], and CURB [25]. These cost of these solutions range from $200 to $400 [22,25]. The designs are all proprietary, and are capable of taking very few measurements [22] (e.g. the Neurio can only measure 2 AC currents).
There are also many designs for energy monitoring published in the literature. Some of these designs rely on commercially available industrial components [26][27][28], which severely drive up costs, minimize customization, and decrease accessibility. Many are built around the popular Arduino prototyping platform [29][30][31]. Some are built for user conveyance by highly integrating the usage of a smartphone [32,33]. Internet of things (IOT) capability is the premier focus of some designs [34,35]. Others rely on software packages such as LabVIEW which is not open source, and has a non-trivial license cost (e.g. $399-$4999) [36][37][38]. Furthermore, some designs do not provide permanent hardy solutions and lack integration [39].
Lastly, some relevant academic designs only report on results, and do not share details to pertinent components, which limit their utility [40][41][42][43][44][45][46][47][48]. Finally, there is an open source alternative commercially available, called the OpenEnergyMonitor [49]. The design consists of multiple modules with a relatively high cost of $150 per channel (2 AC current measurements, Fig. 1. A simple sustainable house designed by OBI. The proposed system would monitor loads and sources such as the 3000 W PV panels, LED lighting, and water pump. Stars denote measurable electrical devices. . Adapted from [16] 1 AC voltage measurement). The solution does not appear to be able to be used for custom DC measurements, which can be a major pitfall for this system for some applications such as solar photovoltaic systems.
In order to overcome these limitations of existing energy monitoring systems this study presents an entirely open-source, low-cost power monitoring system, which is capable of many types of measurements for both loads and generation sources such as solar photovoltaic systems, wind power, microhydro, biomass, or fuel cells.

Hardware description
The design revolves around the Digital Universal Energy Logger (DUEL) node, which is responsible for reading and properly scaling the voltage and current of a particular load and then serializing it via an on board ATTiny85 chip. The configuration of the DUEL node allows for design-able sensitivity ranges, and can handle up to 50 amps and 400 V. DUEL nodes communicate via Inter-Integrated Circuit (I2C), which allows up to 127 nodes on a bus [50]. The bus can be monitored and logged through an Arduino UNO, or any other I2C compatible microcontroller. All designs are made such that they can be manufactured using OSE's proposed tool-set. The proposed design is simple, automatic, and meets the requirements of OBI. Equipped with this system, OBI or other users can make informed decisions on optimization of their power systems for a given building or home.
This hardware, although specifically designed for OBI can be used for the following: Monitoring electricity generation systems (e.g. a PV system of virtually any size) Measuring energy converter efficiency High channel count, high precision measurement platform for Arduino Measuring power consumption of individual devices

Overall system
The system is split into two sets of components: 1) the main hub, and 2) the DUEL nodes. The main hub consists of an Arduino UNO with a small display and SD card breakout, a power supply, and a custom RJ-45 breakout board. The main hub communicates with the sensor nodes via I2C. Because of this, it necessary to introduce a splitting-hub to facilitate multiple sensors. An example configuration can be seen in Fig. 2.
The DUEL node is a custom circuit implementing an ATTiny85 used for measurement and I2C serialization. The DUEL node is a universal node for virtually any power range. The node measures voltage directly through a single diode rectifier and 10 KO potentiometer. Current is measured using a CQ2334 Hall effect current sensor [51], amplified by an operational amplifier circuit. Though the standard DUEL nodes utilize the CQ2334, it is possible to construct the node without the Hall effect sensor, and instead break out signals with header pins, and hook up an external Hall effect, or current transformer for non-invasive sensing [52]. This functionality allows the DUEL node to be configured for a wide range of current and voltage measurements.

Design files
All electrical designs are carried out in KiCAD EDA [53] and follow the general design procedure for free and open source scientific hardware [54].

Main hub
The measurement hub is designed around the Arduino UNO. There are a few justifications for this choice. First, there is a well-established support community for open source Arduino technology, as well as many open-source programs available for reference [55,56]. Second, the Arduino is a component used in many other OSE designs (e.g. The Compressed Earth Brick Press and Micro-Inverter [57,58]), so this will prevent more on-stock back up components. Lastly, the Arduino UNO will have more than enough spare input and outputs (IO) that may be used for future expansion and enhancements. The system is equipped with peripherals in order to handle debugging, power and communication, with the rest of the system, human machine interface (HMI) and data storage, as shown in Figs. 3 and 4.
I2C is chosen as the method of communication with DUEL nodes due its single bus connection style, as seen in Fig. 5, which allows for a 7 bit address field that in turn allows for 127 addressable nodes [50]. Serial communication has the   benefit of being much more noise tolerant [59], which prevents transmitted analog signals from the DUEL nodes from being flawed by noise, and forcing an overly complex multiplexing circuit [60]. Although the max sampling rate will be significantly reduced because of the serialization, it is important to note that the system is designed for long term analysis and high-resolution data is not the objective.
The RTC module is connected to the Arduino UNO via I2C. With each power measurement, the RTC is polled and the current date and time is recorded. This will be used for synchronization during the data analysis. In order to cut costs, a delay function can be used to time sample intervals, however in order for this method to work consistently, the number of nodes cannot be changed on the fly, and the firmware cannot go under any revision without having to recalculate time delays.
A small 128x128 TFT display with a micro-SD card [61] is attached to the system. The module can communicate to the Arduino via serial peripheral interface (SPI) [61]. The display and SD card are selectable by respective chip select pins. This module is used to display system status, as well as log information. The details to be listed are: The Arduino is also connected to an RJ-45 female connector, in order to allow inter-communication with the DUEL nodes. The wiring of the display/SD and RJ-45 is condensed into a circuit board ''shield" and can be easily plugged into the board.
The software for the main hub is developed in the Arduino IDE [62]. The IDE is chosen for its capability for rapid development, and large community support, as well as its compatibility with multiple designs [62]. The firmware utilizes Wire.h for I2C communication, as well as Arduino's stdio (which is not syntactically included in the firmware, as the IDE includes it as a default) for serial debugging. The software is designed from the logic in Fig. 6. To clarify, the firmware waits a predetermined amount of time and will begin polling each DUEL node for measurements once it is time.
The entire main-hub costs a total of US$62.37 in materials to produce. The design is made using entirely open source components, and has potential to be completely integrated as a means of cost savings. However, it should be noted that integration will cut down on the modulated design, decreasing maintainability. A cost breakdown of the design can be seen in the Bill of Materials section. Additionally, the schematic and board layout can be viewed in Figs. 7 and 8 respectively.

Splitting hub
The splitting-hub (Figs. 9 and 10) is a simple distribution board for the I2C, as well as power. Each port has identical connections (meaning that no port is unique or intended for a main host). Each port is connected to an LED which is enabled and disabled by the connected node. This LED can be used as a debug mechanism to indicate proper connection and communication.
Splitting-hubs can be daisy-chained in order to further expand channel availability. Though power can be distributed through the RJ45 connection from one splitting-hub to the next, it is not recommended, as ground loops can be created, as well as resistive losses may compound [60]. The daisy chain should be configured in a star formation to reduce noise potential [63]. Lastly it should be noted that only a DUEL node is capable of controlling LED's. Therefore that indication will not propagate through splitting node inter-connections. Only the LED at the connection point of the DUEL node will be controllable.
The design consists of a milled circuit board with a 3-D printed enclosure and costs a total of $7.17 to manufacture. The cost breakdown can be seen in the Bill of Materials section. The schematic and board layout can be viewed in Figs. 11 and 12, respectively.

Duel node.
The measurement node (Fig. 13) is designed as a non-specialized circuit with room for nearly endless customization. This customization is made possible by the dual op-amp signal conditioning circuit, as well as the ability to replace the on-board sensor with an external larger ranged device. The conditioning circuit applies a gain and offset to the signal coming from the current sensor. This allows for full utilization of the 10 bit 0-5 V rand of the ATTiny analog to digital converter (ADC) [64]. Voltage is simply rectified by a diode, and divided by a 10 K potentiometer. The potentiometer can be adjusted to divide any input range to the ADC max of 5 V. Additionally, each signal (both current and voltage) is fed through a low-pass filter to remove high frequency noise. The RC filter utilizes a 10 K resistor, and 0.1mF capacitor, giving a cutoff frequency of 160 Hz.
The output of the current conditioning circuit is determined by equation 1 [65]. Where R P is the position of the potentiometer, R g is determined from Table 1, and R f is 10 kO. If using the on board Hall effect sensor, typically R P will be set to 50%, in order to have an input offset of -2.5 V. The reason for this is the CQ2334 outputs on a 0 to 5 V scale, where 0 V indicates -50A, 2.5 V indicates 0A, and 5 V indicates 50A [51]. The À2.5 V offset allows for measurement positive current only, though, at a higher resolution.
The voltage input circuit can be adjusted simply by changing the position of the 10 kO potentiometer. The potentiometer acts as a voltage divider and brings the input voltage down to the 5 V range. Additionally, there is a 0.7 V drop across the rectifying diode, which must be taken into account. In Table 2, potentiometer positions are calculated for various common voltage ranges.
The aforementioned Hall effect sensor is rated for 50A [51]. However for high current applications, it is recommended that this feature is not used (not soldered in place) and an external current transform or Hall effect sensor is used. If an external sensor is used, the excitation and signal pins can be broken out using header pins placed at the signal pins used for the Hall effect sensor.
After the signals are conditioned, they are fed into the ADC input of the ATTiny. The ATTiny is set to constantly acquire data and keep a cumulative average using Equation 2 [59].The DUEL node continues to make measurements in between data requests from the master hub. This insures a more accurate representation of the power consumption over the sample interval. The code can be easily reconfigured to only measure and reply with data as requested.     9. The splitting-hub is used for connecting multiple DUEL nodes to the main-hub.
The final design for the DUEL node can be seen in Fig. 14. The total cost is acquired in the Table below, and is found to be $18.25.
The design is placed onto a 9x4cm single layer board, seen in Fig. 15.
Much like the main-hub, the firmware for the DUEL node is developed in the Arduino IDE. IDE cannot program the ATTiny85 in the default configuration, and multiple configuration steps must be gone through in order to program the chip [66]. The ATTiny can be programmed by configuring an Arduino UNO as an ISP, and then connecting it to an RJ-45 breakout board (BOB). The necessary connections from the Arduino UNO to the BOB are detailed in Table 3 below.
The designed firmware utilizes the tinyWireS.h library in order to send signals via I2C to the measurement node. The data packet structure consists of 4 bytes, two for the current measurement, and two for the voltage measurement. The final firmware design follows the flowchart in Fig. 16.

Design files summary
All files are available at [67] and are described in Table 5. Main_Hub, BOB, and Duel.pro can be edited in KiCAD. They reference to the schematic, and PCB for each respective component. Duel.ino and Main_Hub.ino contain the Arduino based firmware for the DUEL and Main-hub, respectively. Enclosures is the generic location for all design files for the component enclosures and in separate 3-D printing files folder.

Bill of materials
The bill of materials is shown in Tables 6-8.

Build instructions
All designs are made such that they can be milled on a low cost CNC mill [68] (or even a converted multi-material additive and subtractive system [69]), on a single layer board. The specific mill is not necessary, and the methods used for fabrication can be applied to any CNC router or mill. The CNC mill is used in order to expedite prototyping, but if one is not available, the circuits are also manufacturable using standard ferric chloride etching methods.
The circuit boards are exported to Gerber files in KiCAD, and then are turned to G-Code in an open source computer aided manufacturing program (CAM) called FlatCAM [70]. Multiple g-code files are generated in order to produce an accurate high density board, which is easy to assemble. The first pass uses a 1 mm carbide end mill to remove a bulk of the material around traces and pads. Any areas slimmer than 1 mm will not be touched by this mill. In the next pass, a 0.1 mm V-shaped engraving bit will finish the isolation routing, by going over the 1 mm end mill's path, as well as any of the traces untouched by the 1 mm end mill. Then a drilling pass is used to cut all holes smaller than a diameter of 1 mm. All holes large than 1 mm are cut in the next pass with the 1 mm carbide end mill. Finally the rectangular board outline is generated with a margin of 1 mm from all traces, and cut out with a 3.16 mm carbide end mill. For isolation routing, the engrave depth is 0.125 mm. A feed rate of 100 mm/min is used for all V-mill cutting, and 50 mm/min for all end mill cutting.
A common issue faced with most inexpensive circuit board mills is surface leveling. The raw copper clad fiberglass is not a uniformly flat along the surface and may vary much further than the engraving depth of 0.125 mm. Because of this, it is highly likely that the board will be defective, due to missed cuts in the engraving cycle.
The uneven height of the PCB raw material can be compensated by automatically moving the Z-axis to compensate for any curvature. The CNC control software, Copper Carve [71], has a feature which measures and compensates for this distortion. This software takes in a variable grid of evenly spaced height points, and adjusts each g-code command to follow an approximate contour based on the measurements. The height can simply be probed by connecting an alligator clamp from ground to the copper material, and another alligator clamp from the engraving bit to the Z-axis limit switch. When the cutting tool makes contact with the copper, the motion will be halted, and the Z-height can be manually input into the leveling software. It is recommended that 1 data point is collected for each square cm.
The DUEL node takes a total of 2 h to mill from start to finish. The edges of all freshly cut traces are rough, and highly prone to causing short-circuits. 320 grit sand paper (or any very fine equivalent) is used to sand the surface, making sure to stroke in all directions for a full smoothing effect. The finalized board is now ready to be cleaned, and assembled.
The board must be thoroughly cleaned with cotton swabs and isopropyl alcohol in order to remove the coating of copper and fiberglass dust that is left in the channels of the board. By exposing the board to UV light, the residue becomes more visible and can be cleaned more easily.
Lastly, the components can be soldered onto the circuit board. It is recommended that surface mount devices are soldered first. Do so by first wiping flux over all pads to help prevent solder bridges. Then apply a small amount of solder to each pad before soldering the component. Using forceps, the component is placed and soldered 1 pad at a time. Soldering in this fashion will cause the components to ''hover" about any traces that may be passing under them, thereby reducing risks for shortcircuits. Lastly, a multimeter set on the continuity setting should be used to verify no short circuits are present in the board. The board is then placed in the 3-D printed case as shown in Fig. 17.

Operation instructions
Each DUEL node is calibrated individually. The node is pre-programmed with either firmware for DC measurements or AC measurements. Regardless of configuration, the node will send raw ADC readings via I2C when a request is made of it. In Fig. 17. The completed DUEL node. order to calibrate the voltage measurements, the node is wired according to the configuration in Fig. 18. Fig. 19 is used for calibrating current. For this procedure a Lavolta (BPS-305) DC power supply, a 10A 0-130VAC Variac, and a Fluke 187 True RMS multimeter (to verify supply output) are used, however other equivalent devices may be substituted.
The DUEL node must be connected to an Arduino (or the Main Hub) such that there is a valid I2C connection between the two. Then ''Calibration Utility" firmware must be installed onto the Arduino. This procedure is made to automatically walk the user through the calibration process, and generate scaling coefficients. The utility goes through the following steps: Input the I2C address of the node Select type of calibration (Current, Voltage, or Both) Readings from the node will now start streaming. Using the supply, set the voltage and/or current to a known value. Type the known values into the serial interface to create calibration points. Repeat step 3 a max of 16 times. Once complete, the linear scaling coefficients, and calibration point data may be displayed The scaled data is streamed -allowing for a validation step Using this process, a single node can be characterized in less than 5 min.

Validation and characterization
The testing procedure uses the same circuit configurations as the calibration feature (namely Figs. 18 and 19). It is important that points other than the values used for calibration are measured, in order to gauge the effectiveness of the linear scaling.

Validation by simulation
The current measurement scaling circuit is validated first through simulation in the Quite Universal Circuit Simulator (QUCS) [72]. The configuration is shown below in Fig. 20. For this simulation a simulated input voltage is created, representing a 10A AC current wave. The simulation is configured for both an AC frequency sweep, to verify the filter effectiveness, as well as a transient simulation to verify proper gain and offset functionality.  Though it is not in the physical circuit, an ideal diode is added to the output of the circuit. This is due to a limitation in QUCS that assumes an op-amp always has a positive and negative supply. The physical circuit only has access to a +5 V source, and will therefore saturate at 0 V for all input voltages below 0 V. The simulation in QUCS has shown that the conditioning circuit is capable of applying both a controllable gain and offset. Some minor effects of the filter are observed in Fig. 21, such as the slight lag in voltage V out compared to V in . This lag will not cause a measurement error. Additionally, the frequency response of the circuit is generated in a Bode plot. It shows that the designed cutout frequency of 160 Hz is indeed present.

Results from calibration procedure
The DUEL node under test is configured to accept a maximum of 130 V and 25A inputs. First, the firmware for DC measurement is uploaded, and the calibration procedure is carried out. Previous iterations of the DUEL node showed indications of a slight voltage dependence on the current sensing circuit. Because of this, two calibration curves are generated, one made by varying applied voltages, and the other by varying the load.
Figs. 22 and 23 show the results from recording and calibrating off of nine points ranging from 0.5A to 4.5A and 3 V to 28 V respectively.
For the second part of this comparison, the voltage is kept at a constant 5 V, and the load is varied from 1 to 9 Ohms, generating the calibration curve in Fig. 24. The voltage calibration curve in Fig. 25 is generated by keeping the supply current constant at 1 A, and varying the load from 1 to 9 Ohms.      For both DC and AC configurations the DUEL node proves to follow the expected linear relationship and operates in a completely predictable fashion. The linear scaling coefficients found in this process can be recorded and used later to scale the raw ADC readings of the node.

Validation from physical implementation
Given the linear scaling coefficients found in the previous section, the overall device is now tested for accuracy. This is carried out by subjecting the DUEL node to incrementing supply voltages and or currents and measuring the scaled response. First the node is tested for a DC configuration, and then an AC configuration. The results for both voltage and current (AC and DC) are shown in Figs. 28-31. Averaging the acquired errors, it is found that DC voltage measurement has a mean error of 0.4%. DC Current measurement has a mean error of 0.6%. AC voltage measurement has a mean error of 0.76%, and AC current measurement has a mean error of 1.69%.

Preliminary application
As an initial test of the system, a node is connected to measure a segment of the 3000 W solar photovoltaic array in the SEED Eco-home. Fig. 32 displays an example of the data logged over time. The dips in voltage at minute 40 and minute 100 are consistent with observed cloud cover.

Discussion
A comparison of some available commercial units to the open source system provided here based on total price, channel type, price per measurement and storage can be seen in Table 4. As can be seen in Table 4, the open source solution proposed in this study out performs commercial solutions as the price per measurement is significantly smaller, while the number of serviceable channels is significantly higher. The primary limitation of the proposed system is the amount of rewiring required (namely provisions made for invasive current sensors). However if this system is installed at the time of power system construction, the extra effort to install it is minimalized. The DUEL nodes also have an advantage in that they are completely customizable, making them fit for any input range, where all competitors are fixed range. This solution also is capable of advertising a known error, making it more suitable for precision and scientific applications.
The accuracy of both the voltage and current channel is less than 2% error for AC measurements and 1% error for DC measurements, which for the intentions of solar power monitoring systems is satisfactory. It should be noted that the accuracy is only as good as the accuracy of the multimeter used for calibration. The DUEL nodes can be used to monitor individual panel output, bulk array output, power converter efficiency, load draw, and any other current drawing (or producing) application. It is highly scalable design and CAT-IV compatibility allow for the system to easily be wired throughout a building, recording draws on all appliances.
The system is also able to be fabricated on single layer circuit boards, using only open source software and hardware. This and the open source nature reduces the complexity and the barrier of acquiring this scientific equipment, and will help further science and society as a whole -but most specifically in the areas of renewable energy and energy conservation. The open source system has achieved the project goal of being inexpensive, at a cost of $158.94 for a basic system. Using widely available equipment, the DUEL node can be calibrated to a desirable accuracy of less than 1%. The proposed system is also infinitely flexible, as it can be used in multiple configurations, including a sufficiently large amount of connected nodes. The system has a heightened advantage over most competing systems due to the measurement of both current and voltage. The DUEL node also has the advantage of endless customization to meet any measurement need and thus has a wide range of applications as listed (but not limited to) below: TIG welder power usage Automotive power usage Multi-node computing power usage Automated assembly line power usage Redundant home power meter to test utility meter accuracy General purpose expandable data logger for voltage or current based sensors 7.1. Future work The proposed system has many places for improvement and increased functionality including: Adapt the Main-Hub for internet connectivity. Adapt the DUEL nodes for wireless usage, with an included battery. Create a calibration device that automatically tests DUEL nodes by injecting various known voltages and currents and calculates the calibration coefficients. This can be used to greatly expedite calibration, as well as reduce the cost. Integrate a DUEL node and Main-Hub into a single board for small, single node applications.

Conclusions
The open source power monitoring system has validated as a low cost and flexible system, which can be used to measure various loads and sources. The system is capable of being fabricated using standard distributed manufacturing techniques, furthering its utility. The serial communication feature allows for an expansive configuration, which is capable of making a substantially larger number of measurements than competing tools.

Declarations of interest
Declarations of interest: none.