15 changes: 15 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
emonPi User Guide
=================

.. toctree::
:maxdepth: 2

Install Guide <install.md>
connect.md
pulse_counting.md
temperature_sensing.md
firmware.md
configuration.md
modifications.md
north-america.md
Technical <technical.md>
99 changes: 99 additions & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# EmonPi Install Guide

The following guide provides an quick overview of how to setup the hardware part of an emonPi energy monitoring system for monitoring up to two AC circuits.

![emonpi install digram](img/emonpilabel.png)

![emonpi install](img/emonPi_install_diagram.png)

```{warning}
[Please read the CT installation guide before installing.](../electricity-monitoring/ct-sensors/installation)
Your safety is your responsibility. Clip-on current sensors are non-invasive and should not have direct contact with the AC mains. However, installing the sensors will require working in close proximity to cables carrying high voltage. As a precaution, we recommend ensuring the cables are fully isolated; i.e., switch off the power prior to installing your sensors and proceed slowly with care. If you have any doubts, seek professional assistance.
```

## 1. CT sensor

- Clip the CT sensor around either the **Line** or **Neutral** cable
- Connect jack plug into either CT1 or CT2 socket on the emonPi
- If the power reading is negative, reverse the CT sensor orientation
- CT sensor cable should not be extended to avoid induced noise
- For Solar PV install see [Solar PV Application page](../applications/solar-pv.md)
- [Learn more about how CT sensors work...](https://learn.openenergymonitor.org/electricity-monitoring/voltage-sensing/measuring-voltage-with-an-acac-power-adapter)

```{note}
The clip-on CT sensors must be clipped round either the Line or Neutral AC wire. **NOT BOTH**
```

![CT sensor installation ](img/ctinstall.jpg)

## 2. AC-AC Adapter

- Plug the AC-AC adapter into a power outlet
- This may require installation of a new outlet or extending an existing one
- AC-AC adapter cable can be extended if required
- Plug power connector into the AC socket on the emonPi
- Essential for [Solar PV monitoring](../applications/solar-pv.md)
- Provides AC waveform reference for accurate Real Power measurements.
- [Learn more about measuring voltage with AC-AC power adapator...](https://learn.openenergymonitor.org/electricity-monitoring/voltage-sensing/measuring-voltage-with-an-acac-power-adapter)

## 3. DC 5V USB Adapter

- Plug the DC 5V USB adapter into a power outlet
- Plug the mini-B USB connector into the emonPi
- High quality minimum [1.2A power supply recommended](https://shop.openenergymonitor.com/power-supplies/)

## 4. Optical Utility Meter LED Pulse Sensor (optional)

- See [Optical Pulse Sensor setup page](https://guide.openenergymonitor.org/setup/pulse-counting/)
- Connects to emonPi / emonTx via RJ45 connector
- Self-adhesive velcro attachment to utility meter
- One optical pulse sensor per emonPi/emonTx
- Can be used in conjunction with temperature sensors using [RJ45 Breakout](http://shop.openenergymonitor.com/rj45-expander-for-ds18b20-pulse-sensors/)

## 5. Temperature Sensors (optional)

- Connect to emonPi / emonTx via RJ45 connector.
- Up to 6x [RJ45 sensors](https://shop.openenergymonitor.com/rj45-encapsulated-ds18b20-temperature-sensor/) can be connected using the [RJ45 expander](http://shop.openenergymonitor.com/rj45-expander-for-ds18b20-pulse-sensors/).
- Up to 6x [wired sensors](https://shop.openenergymonitor.com/encapsulated-ds18b20-temperature-sensor/) can be connected using the [terminal block breakout board](https://shop.openenergymonitor.com/rj45-to-terminal-block-breakout-for-ds18b20/).
- Sensor wire can be extended using RJ45 cable and the [RJ45 Extender](http://shop.openenergymonitor.com/rj45-extender/).

## 6. Installation Examples

![home energy](img/home-energy-emonpi-install.jpg)

![home energy2](img/emonpi-install2.jpg)

The included clips can be used to mount the emonPi / emonTx on a wall.

See [Solar PV Application Note](/applications/solar-pv/) for emonPi solar PV install guide & images.

## 7. Power Up

```{note}
Ensure all sensors are connected before powering up.
```

a.) **Switch on DC & AC power**

b.) **Check CT sensor(s) & AC Wave are detected:**

![acwave_ct1.JPG](img/acwave_ct1.JPG)

c.) **emonPi should remember WiFi network and re-connect**

![wifi_connected.JPG](img/wifi_connected.JPG)

## 8. Shutdown

Optional: Shut down the emonPi, hold down the shutdown button for 5 seconds, then wait 30 seconds for unit to fully shut down.

![emonPi_shutdown.png](img/emonPi_shutdown.png)

```{warning}
Unplugging power from the emonPi without following the correct shutdown procedure can result in a corrupted SD card.
```

## 9. Video Guide
<div class='videoWrapper'>
<iframe width="560" height="315" src="https://www.youtube.com/embed/6SB4fRYQjno" frameborder="0" allowfullscreen></iframe>
</div>
92 changes: 92 additions & 0 deletions docs/modifications.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Modifications

## Adding a Real Time Clock (RTC)

The emonPi updates its internal linux time via NTP when connected to the internet. However, if the emonPi is used in an offline network, or an accurate time stamp is essential, a hardware Real Time Clock (RTC) can easily be added to the Pi's GPIO. We have tested using a [DS3231 based RTC module](http://thepihut.com/products/mini-rtc-module-for-raspberry-pi). This RTC module communicates with the emonPi via I2C, it can be easily connected as follows by soldering a five-pin header onto the emonPi aux GPIO pins:

![](img/DS3231rtc.jpg)

![](img/EmonPi_RTC.JPG)

Once connected, check it's detected on the I2C bus by running:

sudo i2cdetect -y 1

If the RTC is successfully detected it should return the following:

![](img/Emonpi_rtc_i2c.png)

**0x27** is the emonPi's I2C LCD display and 0x68 is the RTC module.

To setup the DS3231 RTC:

git clone https://github.com/Seeed-Studio/pi-hat
cd pi-hats/tools
sudo ./install.sh -u rtc_ds3231
sudo reboot

When the RTC has been successfully installed, the output of `sudo i2cdetect -y 1` should show "UU" insted of "68" that is showed previously before the RTC was installed.

Read hardware clock and print result

sudo hwclock -r

Set the system time from the hardware clock

sudo hwclock -s

Set the hardware clock from the current system time

sudo hwclock -w

Access help for more usage

hwclock --help

## LightWaveRF OOK

*Guide below copied for posterity from old wiki, we havent tried this for some time and the steps below may need modification to work on more recent emonSD images.*

[OOK (On-Off-Keying)](http://en.wikipedia.org/wiki/On-off_keying) is a simple RF modulation commonly used by RF controled remote plugs. With the addition of a OOK module the emonPi can be used to control RF plugs.

This documentation is focused on controlling LightWaveRF plugs & dimmers however it would possible to control other OOK plugs with the correct protocol e.g FS20. The LightWaveRF OOK protocol has been reverse engineered and open-sourced.

There is a development comunity at [http://lightwaverfcommunity.org.uk](http://lightwaverfcommunity.org.uk).

Thanks to [Lawrie Griffiths](https://github.com/lawrie)/[Geek Grandad blog](https://geekgrandad.wordpress.com) for creating [LightWaveRF Arduino library](https://github.com/lawrie/LightwaveRF) and porting it to [Raspberry Pi with MQTT service](https://github.com/openenergymonitor/lightwaverf-pi).

The OOK transmitter footprint is (from left to right): ANT, 5V, D6 + (on emonPi V1.6 GPIO18 / Pin 12), GND.

The OOK transmitter data line is connected to Dig 6 of ATmega328 and on current rev of emonPi (V1.6 - sold since Nov 2015) the OOK is also be connected directly to to GPIO 18 (pin 12) and the antenna connection of the OOK module can be jumpered to share the main SMA emonPi antenna.

OOK Tx module footprint on emonPi V1.6:

![](img/EmonPi_V1_6_OOK_Tx.png)

OOK Tx module hacked onto the older emonPi V1.5 (sold pre Nov 2015), the white wire connects to OOK RF antenna to the SMA antenna. A separate antenna could be used. The red wire connects the OOK Data pin to GPIO 18 (labeled G18):

![](img/Emonpi_ook.jpg)

Installation (process needs review):

git clone https://github.com/lawrie/lightwaverf-pi.git
cd lightwaverf-pi
make
sudo make install
sudo service lwrfd start
sudo update-rc.d lwrfd defaults

LWRF plugs can be controlled by publishing to 'lwrf' MQTT topic.

The message format is `<channel> <command> [<level>]`, where channel is 1-16, command is 0-2 (2 means mood), and level is 0-31 (used for dimmers).

E.g publishing “1 1” to 'lwrf' topic turns channel 1 on and “1 0” turns it off.

Plugs can be paired with the emonPi in the usual LightwaveRF way: Either press and hold pairing button (if button exists) or turn on the plug from main power and send 'on' command. Most LightWaveRF plugs allow multiple (up to 6) control devices to be paired.

To reset the plug and delete all pairing, press and hold the pairing button to enter pairing mode, then press and hold again to erase memory. Then press (don't hold) once to confirm. For plugs without a pairing button, turn on the plug from the mains power, then in the first few seconds, press the 'all off' button on the RF remote.

**Emulate Remote**

The LightWaveRF Pi MQTT emulates a LightWaveRF remote with the following default ID: `byte id[] = {0x6f,0xed,0xbb,0xdb,0x7b,0xee};`. If you want to be able to control your plugs with either YOUR LightWaveRF remote or the emonPi you will need to capture the unique ID of your remote. To do this you will need an [OOK receiver module](http://uk.rs-online.com/web/p/lower-power-rf-modules/6172044) and an Arduino running the [lwrf receive sketch](https://github.com/lawrie/LightwaveRF/tree/master/examples/lwreceive). The ID is the last 6 bytes of the transmission. Once captured replace the ID in [mqrfmqtt.c](https://github.com/lawrie/LightwaveRF/tree/master/examples/lwreceive) with your remote's ID then recompile (make, sudo make install).

39 changes: 39 additions & 0 deletions docs/north-america.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Use in North America

The emonPi / emonTx hardware units are designed for use on single-phase systems. However, the they can be used on a North American Split-Phase system with the following considerations:

## 1. Ensure clip-on CT sensor will fit your conductors

Typical residential Service Entrance Wires are AWG 2/0 Copper or AWG 4/0 Aluminium. The opening in the [standard clip-on CT sensor sold in the OpenEnergyMonitor shop](http://shop.openenergymonitor.com/100a-max-clip-on-current-sensor-ct/) is **13mm**, and hence can accommodate a maximum wire size of **AWG 1/0**. Therefore, we recommend you measure the diameter of your feeders before purchasing a CT sensor.

If the standard CT sensor does not fit your conductors there are two options:

1. Use an [Optical Pulse Sensor](https://shop.openenergymonitor.com/optical-utility-meter-led-pulse-sensor/) instead of CT sensor to interface directly with a utility meter. This will give an accurate reading of energy consumed (kWh) but will not provide a real-time power reading (W).

2. Use an alternative larger CT sensor: It's possible to obtain larger CT sensors. However, using an alternative CT will usually require re-calibration and possibly, hardware modification (burden resistor may need replacement). See [Learn > emonTx in North America](../electricity-monitoring/ac-power-theory/use-in-north-america.md) for more info. Please search / post on the [community forums](https://community.openenergymonitor.org) for further assistance.

```{warning}
Installing clip-on CT sensors on USA electrical systems should only by undertaken by a professional electrician. In a typical residential installation, even if the main breaker is switched off, the load center Service Entrance Wires and bus bars are always live.
```

## 2. Use USA AC-AC Adapter

Use the [USA AC-AC voltage sensor adapter sold via the OpenEnergyMonitor Shop](http://shop.openenergymonitor.com/ac-ac-power-supply-adapter-ac-voltage-sensor-us-plug). The system has been calibrated to work with this adapter. Using any other adapter will usually require re-calibration.

## 3. Software Calibration

a) emonPi: Set EmonHub USA Calibration in the `[[RFM2Pi]]` interfacer section of `emonhub.conf` set: `calibration=110v`.

`emonhub.conf` can be edited directly in local Emoncms as described in [EmonHub > Overview](../emonhub/overview.md). See [[[RFM2Pi]] section of emonHub configuration guide](../emonhub/configuration.md) for advanced emonhub config info.

b) emonTx: Enable USA calibration using [on-board DIP switch](../emontx3/configuration.md)

## 4. Sum power values

If monitoring a split-phase system the power values from each leg can be summed in Emoncms to calculate the total power.

The emonPi by default reports `power1_plus_power2`, this input will need to be logged to a feed. See [Setup > Logging Locally](../emoncms/intro-rpi.md).

If using emonTx then the power values from multiple CT inputs can be summed in Emoncms using `+ feed` Input Processor.

See [Learn > emonTx in North America](../electricity-monitoring/ac-power-theory/use-in-north-america.md) for further technical info about the USA system.
61 changes: 61 additions & 0 deletions docs/pulse_counting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Pulse counting

![img/optical_pulse.jpg](img/optical_pulse.jpg)

Many meters, including single phase, 3-phase, import and export electricity meters, gas meters, water meters and heat meters, have pulse outputs. The pulse output may be a flashing LED or a relay (typically solid state) or both.

Using an Optical Pulse Sensor it is possible to detect the LED / IR 'pulse' output from a utility meters. Meters with wired pulse outputs can be connected directly with two wires and usually switch a voltage provided by the monitoring hardware.

In the case of an electricity meter, a pulse output corresponds to a certain amount of energy passing through the meter (kWh/Wh). For single-phase domestic electricity meters e.g. Elster A100c, each pulse typically corresponds to 1 Wh (1000 pulses per kWh). Water and gas meters will usually be marked to show the quantity of water (litres/gallons) or gas (cubic meters/cubic feet) that each pulse represents.

- The emonPi has one spare interrupt pulse input as standard (IRQ 1, Dig3) which can be used for pulse counting.
- This pulse input is accessible via the RJ45 socket.

Unlike clip-on CT based monitoring, pulse counting is measuring exactly what the utility meter is measuring i.e. what you get billed for. Pulse counting cannot provide an instantaneous power reading like clip on CT sensors can. It is often worthwhile using pulse counting in conjunction with clip on CT sensors to get the best of both techniques.

The emonPi can simultaneously perform pulse counting and CT based monitoring.

```{note}
Some meters are configured to pulse on both import and export. If your meter is, and you use it for both (e.g. an import meter on a property with grid-connected Solar PV) then you will have difficulty making good use of an optical pulse sensor, as it will not agree with either the meter reading or any CT sensor measurement.
One possibility is to use the sign (positive or negative) of the output of a CT sensor attached to the meter's input (or output) to distinguish between positive and negative pulses. You can then either reject negative pulses, or count them separately if you wish.
<a href="https://community.openenergymonitor.org/t/large-discrepancy-between-pulse-counter-and-ct/10561">This community forum discussion</a> contains more information on how to do this.
```

## Option 1: Using an Optical pulse sensor

![optical_pulse_emonpi.png](img/optical_pulse_emonpi.jpg)

```{warning}
It is advisable to shield the sensor and the meter from bright light as this can adversely affect readings.
```

1. Identify your utility meter's pulse output, usually a red flashing LED marked 'kWh'. Stick the sensor over the LED, carefully aligning the hole so the flashing LED shines through clearly. Be sure to clean any dust from the meter face before attaching the sensor.

2. Plug sensors RJ45 connector into emonPi / emonTx RJ45 socket.

```{warning}
Ensure the sensor is plugged into the RJ45 socket on the emonPi on the same side as the CT connection jack-plug sockets NOT the Etherent socket.
```

If installed correctly when the emonPi / emonTx is powered up the pulse sensor LED should flash in sync with the utility meter LED. See video clip:

*You may need to switch on a large electrical load e.g. kettle to generate some pulses*

<div class='videoWrapper'>
<iframe width="560" height="315" src="https://www.youtube.com/embed/vq5EmMRrOY0" frameborder="0" allowfullscreen></iframe>
</div>

*Note: If the pulsecount value in emoncms does not increase in line with LED flashes, it maybe that there is light from another source interfering with the pulse detection. Some meters have a plastic cover that makes it quite hard to keep external light away from the pulse sensor. See forum thread [here](https://community.openenergymonitor.org/t/first-try-with-emonpi-pulsecount-stuck-at-1/7375) for more details.*

## Option 2: Wired pulse counting

To connect to a meter with a wired pulse output it's possible to either wire the pulse output cable directly to a RJ45 passthrough connector or to a RJ45 to terminal block adapter. The screenshot below shows an example with a simple RJ45 passthrough connector.

**RJ45 Pinout**<br>
The RJ45 implements a standard pinout used by other manufacturers of DS18B20 temperate sensing hardware such as Sheepwalk Electronics.

![RJ45-Pin-out.png](img/RJ45-Pin-out.png)

![emonpi_wired_pulse_input.jpg](img/emonpi_wired_pulse_input.jpg)
95 changes: 95 additions & 0 deletions docs/technical.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# emonPi Technical Overview

The emonPi is an all-in-one Raspberry Pi based energy monitoring unit making for a simple installation where Ethernet or WiFi is available at the meter location.

The emonPi can monitor two single-phase AC circuits using clip-on CT sensors. The emonPi can also monitor temperature, and interface directly with a utility meter via an optical pulse sensor.

![emonpi](img/emonPi_shop_photo.png)

**Features:**

- 2x CT Sensor inputs for single-phase AC electricity monitoring designed for use with the [100A SCT-013-000 CT sensor](https://shop.openenergymonitor.com/100a-max-clip-on-current-sensor-ct/)
- 1x AC voltage measurement using plug-in AC-AC adapter for real power calculation alongside current measurement from CT sensors. Designed for use with a [9V AC output voltage adapter](https://shop.openenergymonitor.com/ac-ac-power-supply-adapter-ac-voltage-sensor-uk-plug/)
- Support for multiple wired one-wire DS18B20 temperature sensors via RJ45 socket
- Support for pulse counting either wired or via Optical Pulse Sensor
- 433 MHz RFM69 radio transceiver for receiving data from additional energy monitoring or temperature and humidity nodes.
- The emonPi measurement board is based on Arduino (Atmega328). This talks to an integrated Raspberry Pi running our emonSD software stack on it's SD card.
- Full local data logging and visualisation capability using the emonSD Emoncms software stack. Data can also be sent to a remote emoncms server such as emoncms.org.
- Network connectivity via either Ethernet or WiFi.
- **LCD Display:** for easier setup, displays network IP address and sensor status.
- **Push button:** for shutdown and enabling/disabling SSH access.

## emonPi Internals

The emonPi is based on a RaspberryPi + emonPi measurement board. The emonPi measurement board is based on an ATmega328p 8-bit microcontroller running Arduino based firmware. The following video gives a good overview of what is inside an emonPi. Note that we currently ship RaspberryPi version 3b+ which has WiFi onboard rather than the older version featured in this video.

<div class='videoWrapper'>
<iframe width="560" height="315" src="https://www.youtube.com/embed/lc2LzCZnySo" frameborder="0" allowfullscreen></iframe>
</div>

## System Overview

The following system diagram shows the main hardware and software components that make up the emonPi. On the left we have the emonPi measurement board based on the ATmega328 microcontroller with inputs from the different sensors, RFM69 433 MHz transceiver, button and I2C connection to the LCD.

The Atmega328 microprocessor communicates with the Raspberry Pi via the internal UART serial port (/dev/ttyAMA0).

![emonPi system diagram](img/emonPi_System_Diagram.png)

### RF

The emonPi uses the HopeRF RFM69CW RF module to receive data from other wireless nodes (emonTx, emonTH etc) using 433 MHz. We use the [JeeLib packet format](http://jeelabs.org/2011/06/09/rf12-packet-format-and-design/). Each RF node has a unique node ID but common network group (default 210). The ATmega328 runs a modified version of [JeeLabs RFM12Demo Sketch](https://github.com/jeelabs/jeelib/blob/master/examples/RF12/RF12demo/RF12demo.ino) to receive the data from radio nodes. Received radio packets are forwarded over serial and decoded on the RaspberryPi using EmonHub.

### Energy Monitoring

The emonPi measurement board includes input circuitry that converts the outputs from the ACAC adapter and CT sensors into signals that are compatible with the Analog to Digital converter (ADC). The ATmega328's 10-bit ADC samples the voltage and current channels sequentially. The Firmware running on the ATmega328 calculates real power, apparent power, power factor, Vrms and Irms of each channel. The real power reading is then pushed every 5s to the RaspberryPi for logging and visualisation.

To learn more about how the electricity monitoring works, see our Learn site here:

- [Learn: AC Power Theory](https://learn.openenergymonitor.org/electricity-monitoring/ac-power-theory/introduction)
- [Learn: CT Sensors, interfacing with an Arduino](https://learn.openenergymonitor.org/electricity-monitoring/ct-sensors/interface-with-arduino)
- [Learn: Measuring AC Voltage with an AC to AC power adapter](https://learn.openenergymonitor.org/electricity-monitoring/voltage-sensing/measuring-voltage-with-an-acac-power-adapter)

The full emonPi measurement board firmware can be accessed and downloaded here:

- [emonPi Discrete Sampling Firmware](https://github.com/openenergymonitor/emonpi/tree/master/firmware)
- The firmware uses the [EmonLib Discrete Sampling Library](https://github.com/openenergymonitor/EmonLib/)

The CT input's are designed for use with the [100A SCT-013-000 CT sensor](https://shop.openenergymonitor.com/100a-max-clip-on-current-sensor-ct/). This sensor has 2000 turns, which means that the current in the secondary is 2000 less than the current in the mains wire primary. The emonPi has a fixed sized burden resistor specified to match this sensor at 22 Ohms. It is possible to change this burden resistor if you wish to use a CT with a different current range or number of turns.

### Pulse Counting

Pulse counting on the emonPi uses the hardware interrupt IRQ1 on the ATmega328. The first hardware interrupt IRQ0 is used by the RFM69CW. Only one pulse counter input is possible per emonTx/emonPi. See guide [+ Add Optical Pulse Sensor](pulse_counting.md) for more information on the optical pulse sensor.

The emonPi firmware implements a check for a minimum pulse width, this can be shortened on systems with more frequent pulses, see line: [https://github.com/openenergymonitor/emonpi/blob/master/firmware/emonPi_DS_jeelib_classic/main.ino#L96](https://github.com/openenergymonitor/emonpi/blob/master/firmware/emonPi_DS_jeelib_classic/main.ino#L96).

## RaspberryPi and emonSD

The emonPi Raspberry Pi runs our emonSD software stack which is based on [Raspbian Buster Lite](https://www.raspberrypi.org/downloads/raspbian/). The pre-built emonSD image is available to [purchase](https://shop.openenergymonitor.com/emonsd-pre-loaded-raspberry-pi-sd-card/) or [download](../emonsd/download.md) or it is possible to built the image yourself using our automated build script, see [EmonScripts](https://github.com/openenergymonitor/EmonScripts).

EmonSD includes [emonHub](https://github.com/openenergymonitor/emonhub) which reads in the serial data from the emonPi measurement board and acts as a broker forwarding this data on to the local installation of emoncms via MQTT or to a remote server such as emoncms.org via HTTP.

[Emoncms](https://github.com/emoncms/emoncms) is our open source web application for processing, logging and visualising energy, temperature and other environmental data. It is installed as part of the emonSD software stack and provides full local data logging and visualisation capabilities.

## Open Source

**emonPi Firmware** (see [Firmware Modification](../electricity-monitoring/platformio/index.md)<br>
[emonPi Discrete Sampling Firmware](https://github.com/openenergymonitor/emonpi/tree/master/firmware)

**emonPi Schematic and Board files:**<br> [https://github.com/openenergymonitor/emonpi/tree/master/hardware/emonpi/emonpi_V1_6](https://github.com/openenergymonitor/emonpi/tree/master/hardware/emonpi/emonpi_V1_6)

---

## emonPi Specification

| Attribute | Parameter | Link |
|---|---|---|
| Error due to component and sensor tolerances | <11% | [Further info](https://openenergymonitor.org/emon/buildingblocks/emontx-error-sources)
| Measuring Current (CT) |50mA-96A | [Further info](https://openenergymonitor.org/emon/buildingblocks/ct-sensors-interface)
| Measuring Voltage (AC-AC) | 1st: 110VAC-254VAC / 2nd: 9VAC-12VAC| [Further info](https://openenergymonitor.org/emon/buildingblocks/measuring-voltage-with-an-acac-power-adapter)
| Sample period | 5s | [Discrete sampling](https://github.com/openenergymonitor/emonpi/blob/master/firmware/firmware/firmware.ino)
| Frequency | 433Mhz | [Identify RF module](https://openenergymonitor.org/emon/buildingblocks/which-radio-module)
| RF range | 40m-100m | [Antenna testing](https://blog.openenergymonitor.org/2014/03/emontx-v3-antenna-testing/)
| Power Consumption | 1.5W-2.5W RasPi2 / 2W-4W RasPi3 |
| Operating temperature | -25 to +80 DegC | [Further info](https://www.raspberrypi.org/help/faqs/#performanceOperatingTemperature)
| Physical Dimensions | 10cm x 8.5cm x 10cm |

25 changes: 25 additions & 0 deletions docs/temperature_sensing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Temperature sensing

The emonPi supports temperature sensing using DS18B20 one-wire digital temperature sensors. The standard firmware on the emonPi supports up to 6x temperature sensors.

The emonPi has a special RJ45 socket to which either a single RJ45 DS18B20 temperature sensor can be connected directly or multiple sensors can be connected via either a RJ45 breakout board or terminal block breakout board.

## Example: 4x temperature sensors and a RJ45 breakout

![800px-Emonpi_ds18b20_rj45.JPG](img/800px-Emonpi_ds18b20_rj45.JPG)

- [Shop: RJ45 Encapsulated DS18B20 temperature sensor](http://shop.openenergymonitor.com/rj45-encapsulated-ds18b20-temperature-sensor/)
- [Shop: emonPi / emonTx RJ45 Expander for DS18B20 & Pulse Sensors](https://shop.openenergymonitor.com/rj45-expander-for-ds18b20-pulse-sensors/)
- [An RJ45 coupler can be used to extend RJ45 sensor cables.](http://www.sheepwalkelectronics.co.uk/product_info.php?cPath=26&products_id=36)

## RJ45 Pinout

The RJ45 implements a standard pinout used by other manufacturers of DS18B20 temperate sensing hardware such as Sheepwalk Electronics.

![RJ45-Pin-out.png](img/RJ45-Pin-out.png)

*Note: The RJ45 socket does not support power supply switching via Dig19 (ADC5) as described above.*

## Further reading

If you are using temperature sensors with heating systems such as heat pumps the following blog post by John Cantor provides a number of useful mounting suggestions: [John Cantor's Blog: Temperature sensors for monitoring heat pumps](https://heatpumps.co.uk/2015/06/08/temperature-sensing-with-openenergymonitor)
9 changes: 6 additions & 3 deletions emoncms-setup/hello.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,12 @@ function draw_network_list()
networks[ssid].enabled = true;
networks_to_save[ssid] = networks[ssid];

$.ajax({type: 'POST', url: path+"setup/setwifi?mode=client", dataType: 'text', async: true });

$.ajax({type: 'POST', url: path+"wifi/setconfig", data: "networks="+JSON.stringify(networks_to_save)+"&country="+country, dataType: 'text', async: true });
$.ajax({type: 'POST', url: path+"setup/setwifi?mode=client", dataType: 'text', async: true, success: function(result) {
console.log(result);
$.ajax({type: 'POST', url: path+"wifi/setconfig", data: "networks="+JSON.stringify(networks_to_save)+"&country="+country, dataType: 'text', async: true, success: function(result) {
console.log(result);
}});
}});
});

function wifi_scan()
Expand Down
2 changes: 1 addition & 1 deletion emoncms-setup/setup_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function setup_controller()

else if ($route->action=="wlan0-status" && $setup_access) {
$route->format = "text";
$result = exec("/sys/class/net/wlan0/operstate");
$result = exec("cat /sys/class/net/wlan0/operstate");
if ($result=="down") $result = "false";
}

Expand Down
18 changes: 10 additions & 8 deletions emoncms_wifiscan.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@

$log = new EmonLogger(__FILE__);

if ($redis_enabled) {
if ($settings['redis']['enabled']) {
$redis = new Redis();
if (!$redis->connect($redis_server['host'], $redis_server['port'])) {
$log->error("Cannot connect to redis at ".$redis_server['host'].":".$redis_server['port']); die('Check log\n');
}
if (!empty($redis_server['prefix'])) $redis->setOption(Redis::OPT_PREFIX, $redis_server['prefix']);
if (!empty($redis_server['auth'])) {
if (!$redis->auth($redis_server['auth'])) {
$log->error("Cannot connect to redis at ".$redis_server['host'].", autentication failed"); die('Check log\n');
$connected = $redis->connect($settings['redis']['host'], $settings['redis']['port']);
if (!$connected) { echo "Can't connect to redis at ".$settings['redis']['host'].":".$settings['redis']['port']." , it may be that redis-server is not installed or started see readme for redis installation"; die; }
if (!empty($settings['redis']['prefix'])) $redis->setOption(Redis::OPT_PREFIX, $settings['redis']['prefix']);
if (!empty($settings['redis']['auth'])) {
if (!$redis->auth($settings['redis']['auth'])) {
echo "Can't connect to redis at ".$settings['redis']['host'].", autentication failed"; die;
}
}
if (!empty($settings['redis']['dbnum'])) {
$redis->select($settings['redis']['dbnum']);
}
} else {
$redis = false;
}
Expand Down
14 changes: 14 additions & 0 deletions emoncmsdbupdate_old.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

// Update Emoncms database

$applychanges = true;

define('EMONCMS_EXEC', 1);
chdir("/var/www/emoncms");
require "process_settings.php";
require "core.php";
$mysqli = @new mysqli($server,$username,$password,$database);

require_once "Lib/dbschemasetup.php";
print json_encode(db_schema_setup($mysqli,load_db_schema(),$applychanges))."\n";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 0 additions & 12 deletions firmware/compile.sh

This file was deleted.

1,165 changes: 0 additions & 1,165 deletions firmware/compiled/archive/emonPi_V1.1.hex

This file was deleted.

1,025 changes: 0 additions & 1,025 deletions firmware/compiled/archive/emonPi_V1.1_Bootloader.hex

This file was deleted.

1,179 changes: 0 additions & 1,179 deletions firmware/compiled/archive/emonPi_V1.2.1.hex

This file was deleted.

1,179 changes: 0 additions & 1,179 deletions firmware/compiled/archive/emonPi_V1.2.hex

This file was deleted.

1,025 changes: 0 additions & 1,025 deletions firmware/compiled/archive/emonPi_V1.2_Bootloader.hex

This file was deleted.

1,188 changes: 0 additions & 1,188 deletions firmware/compiled/archive/emonPi_V1.3.hex

This file was deleted.

1,025 changes: 0 additions & 1,025 deletions firmware/compiled/archive/emonPi_V1.3_bootloader.hex

This file was deleted.

1,025 changes: 0 additions & 1,025 deletions firmware/compiled/archive/emonPi_V1.4_bootloader.hex

This file was deleted.

1,192 changes: 0 additions & 1,192 deletions firmware/compiled/archive/emonPi_V1.5.hex

This file was deleted.

1,025 changes: 0 additions & 1,025 deletions firmware/compiled/archive/emonPi_V1.5_bootloader.hex

This file was deleted.

1,197 changes: 0 additions & 1,197 deletions firmware/compiled/archive/emonPi_V1.6.hex

This file was deleted.

1,196 changes: 0 additions & 1,196 deletions firmware/compiled/archive/emonPi_V1.7.hex

This file was deleted.

1,196 changes: 0 additions & 1,196 deletions firmware/compiled/archive/emonPi_V1.8.hex

This file was deleted.

1,025 changes: 0 additions & 1,025 deletions firmware/compiled/archive/emonPi_V1_Bootloader.hex

This file was deleted.

1,194 changes: 0 additions & 1,194 deletions firmware/compiled/archive/emonPi_V2.0.hex

This file was deleted.

1,025 changes: 0 additions & 1,025 deletions firmware/compiled/archive/emonPi_V2.0_bootloader.hex

This file was deleted.

1,213 changes: 0 additions & 1,213 deletions firmware/compiled/archive/emonPi_V2.2.hex

This file was deleted.

1,213 changes: 0 additions & 1,213 deletions firmware/compiled/archive/emonPi_V2.3.hex

This file was deleted.

1,220 changes: 0 additions & 1,220 deletions firmware/compiled/archive/emonPi_V2.4.hex

This file was deleted.

1,224 changes: 0 additions & 1,224 deletions firmware/compiled/archive/emonPi_V2.5.hex

This file was deleted.

1,214 changes: 0 additions & 1,214 deletions firmware/compiled/archive/emonPi_V2.6.hex

This file was deleted.

1,195 changes: 0 additions & 1,195 deletions firmware/compiled/archive/emonPi_V2.7.hex

This file was deleted.

1,102 changes: 0 additions & 1,102 deletions firmware/compiled/archive/emonPi_V2.8.1.hex

This file was deleted.

1,120 changes: 0 additions & 1,120 deletions firmware/compiled/archive/emonPi_V2.8.2.hex

This file was deleted.

1,123 changes: 0 additions & 1,123 deletions firmware/compiled/archive/emonPi_V2.8.4.hex

This file was deleted.

1,194 changes: 0 additions & 1,194 deletions firmware/compiled/archive/emonPi_V2.8.hex

This file was deleted.

1,120 changes: 0 additions & 1,120 deletions firmware/compiled/archive/emonPi_V2.9.0.hex

This file was deleted.

1,120 changes: 0 additions & 1,120 deletions firmware/compiled/latest.hex

This file was deleted.

1,248 changes: 0 additions & 1,248 deletions firmware/compiled/latest_bootloader.hex

This file was deleted.

21 changes: 0 additions & 21 deletions firmware/compiled/readme.md

This file was deleted.

17 changes: 0 additions & 17 deletions firmware/compiled/reset

This file was deleted.

7 changes: 0 additions & 7 deletions firmware/compiled/update

This file was deleted.

630 changes: 630 additions & 0 deletions firmware/emonPi_CM/emonPi_CM.ino

Large diffs are not rendered by default.

586 changes: 586 additions & 0 deletions firmware/emonPi_CM/emonPi_CM_config.ino

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions firmware/emonPi_CM/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[platformio]
default_envs = default
src_dir = .
#lib_dir = ../libraries

[env:default]
platform = atmelavr
framework = arduino
board = uno
monitor_speed = 115200
lib_deps =
OneWire
DallasTemperature
https://github.com/openenergymonitor/EmonLibCM
https://github.com/openenergymonitor/RFM69_LPL
https://github.com/openenergymonitor/RFM69_JeeLib#atmega
https://github.com/openenergymonitor/emonEProm
https://github.com/openenergymonitor/LiquidCrystal_I2C
4 changes: 4 additions & 0 deletions firmware/emonPi_CM/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# emonPi_CM

**New 16th Feb 2023:** This firmware provides higher accuracy continuous monitoring. Continuous monitoring means that the power readings are representative of the full 10s period that they represent rather than a short snapshot. Support for radio formats: JeeLib Native and **LowPowerLabs (recommended)**.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ LiquidCrystal_I2C lcd(0,0,0);

//----------------------------emonPi Firmware Version---------------------------------------------------------------------------------------------------------------
// Changelog: https://github.com/openenergymonitor/emonpi/blob/master/firmware/readme.md
const int firmware_version = 290; //firmware version x 100 e.g 100 = V1.00
const int firmware_version = 293; //firmware version x 100 e.g 100 = V1.00

//----------------------------emonPi Settings---------------------------------------------------------------------------------------------------------------
bool debug = true;
Expand Down Expand Up @@ -268,6 +268,7 @@ void loop()

if ((now - last_rf_rest) > RF_RESET_PERIOD) {
rf12_initialize(nodeID, RF_freq, networkGroup); // Periodically reset RFM69CW to keep it alive :-(
last_rf_rest = now;
}

}
Expand Down Expand Up @@ -317,6 +318,7 @@ void loop()
if (DS18B20_STATUS==1)
{
sensors.requestTemperatures(); // Send the command to get temperatures
delay(750); //Wait longer for temperature conversion, required for new 20201 batch of RJ45 sensors
for(byte j=0;j<numSensors;j++) emonPi.temp[j]=get_temperature(j);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
# targets = upload

[platformio]
env_default = emonpi
default_envs = emonpi
src_dir = .

# USE BASH SCRIPT TO MAKE FS RW INSTEAD, see ./compile
# ~on emonPi use RW data partition~
Expand All @@ -27,14 +28,14 @@ env_default = emonpi
# libdeps_dir = ~/data/.piolibdeps

[common]
build_flags = -D BUILD_TAG=2.8.0
build_flags = -D BUILD_TAG=2.9.5
monitor_speed = 38400

# http://docs.platformio.org/en/stable/projectconf.html#lib-deps
lib_deps_external =
DallasTemperature@3.7.7
DallasTemperature@3.9.1
EmonLib
LiquidCrystal_I2C@1.1.2
https://github.com/openenergymonitor/LiquidCrystal_I2C
https://github.com/jcw/jeelib.git#f097c0039c926881d80a74bec7a7aa020de610ee
https://github.com/jbechter/arduino-onewire-DS2438.git

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
# Change Log - emonPi Discrete Sampling Firmware
# emonPi_DS_jeelib_classic

**See continuous-sampling branch for continuous sampling**
The original emonPi firmware, this performs power measurement in short discreet snapshots ~300ms long per CT channel at 50Hz per 10s period. Compatible with the original jeelib classic radio format.

# V2.9.0 (16/01/18)
## Change Log - emonPi Discrete Sampling Firmware

Compile using PlatformIO: https://guide.openenergymonitor.org/technical/compiling/

### V2.9.3 (05/01/21)

- Wait longer for DS18B20 conversion, require for new batch of RJ45 temp sensors

### V2.9.2 (17/11/19)

- Fix RFM init

https://community.openenergymonitor.org/t/emonpi-firmware-build/12428/45

```
RAM: [===== ] 52.9% (used 1083 bytes from 2048 bytes)
Flash: [====== ] 60.3% (used 18526 bytes from 30720 bytes)
```

### V2.9.0 (16/01/18)

- Allow CT's to be plugged in after unit has powered up. CT input will read zero if no CT is connected.

Expand All @@ -14,9 +33,9 @@ Data: 1048 bytes (51.2% Full)
(.data + .bss + .noinit)
```

# V2.8.4 (21/12/17)
### V2.8.4 (21/12/17)

- Correct USA voltage for apparent power sampling to 120V. Only affects battery / DC USB 5V operation. Does not effect when powering unit vi AC-AC adaptor.
- Correct USA voltage for apparent power sampling to 120V. Only affects battery / DC USB 5V operation. Does not effect when powering unit via AC-AC adaptor.

```
Program: 17942 bytes (54.8% Full)
Expand All @@ -26,12 +45,12 @@ Data: 1034 bytes (50.5% Full)
(.data + .bss + .noinit)
```

# V2.8.3 (07/04/17)
### V2.8.3 (07/04/17)

- Reduce min pulse width to 60ms


# V2.8.2 (07/04/17)
### V2.8.2 (07/04/17)

* Reduce min pulse width to 60ms

Expand All @@ -42,7 +61,7 @@ Data: 1022 bytes (49.9% Full)
(.data + .bss + .noinit)
```

# V2.8.2 (10/12/16)
### V2.8.2 (10/12/16)

* Autodetect LCD on I2C address `0x27` or `0x3f`

Expand All @@ -53,7 +72,7 @@ Data: 1026 bytes (50.1% Full)
(.data + .bss + .noinit)
```

# V2.8.1 (21/11/16)
### V2.8.1 (21/11/16)

* Reintroduces "quiet mode" feature as seen in the RFM2Pi firmwares to allow improved RF debugging.

Expand All @@ -66,7 +85,7 @@ Data: 953 bytes (46.5% Full)
(.data + .bss + .noinit)
```

# V2.8 (18/11/16)
### V2.8 (18/11/16)

* Compiled using platformIO with [JeeLib 10th Nov 2015 (f097c0039c)](https://github.com/jcw/jeelib/tree/f097c0039c926881d80a74bec7a7aa020de610ee)
* Fixes emonTx drop off [forum discussion](https://community.openenergymonitor.org/t/emon-txs-not-updating-after-emonpi-update/2233/10)
Expand All @@ -79,7 +98,7 @@ Data: 951 bytes (46.4% Full)
(.data + .bss + .noinit)
```

# V2.7 (16/11/16)
### V2.7 (16/11/16)

* Compiled using platformIO with latest JeeLib (7fc95a72ec)
* Consistency with github releases
Expand All @@ -94,55 +113,55 @@ Data: 951 bytes (46.4% Full)
(.data + .bss + .noinit)
```

# V2.6 (15/04/16)
### V2.6 (15/04/16)
* [Update to latest JeeLib with RF Fixes ](https://github.com/jcw/jeelib/issues/92) [68f6e42]~~
* Remove RF keep alive introduced in V2.5~
Compiled with Arduino 1.6.8 | Hex size: 54.8kB | Sketch uses 19,400 bytes (60%) | Global variables: 947 bytes (46%)~~

**(10/05/16) - Temporarily restored to V2.5 to fix emonTx RF dropping issue [thread [[1]](https://community.openenergymonitor.org/t/emonsd-03may16-release/145/40) [[2]](https://openenergymonitor.org/emon/node/12593)**

# V2.5 (18/03/16)
### V2.5 (18/03/16)
* Soft reset RFM69CW ever 60s to ensure its kept alive

Compiled with Arduino 1.6.8 | Hex size: 55kB | Sketch uses 19,554 bytes | Global variables: 946 bytes

# V2.4 (8/03/16)
### V2.4 (8/03/16)
* Adjust Vcal_EU to improve VRMS voltage reading accuracy when using UK/EU AC-AC
* Compile with Arduino 1.6.7 with JeeLib 10th Sep 2015 f097c0039c926881d80a74bec7a7aa020de610ee
* Updated OneWire library to V2.3.2 & updated sensors.getAddress function

Compiled with Arduino 1.6.8 | Hex size: 54.8kB | Sketch uses 19,460 bytes | Global variables: 941 bytes

# V2.3 (20/02/16)
### V2.3 (20/02/16)
* Fix VRMS reading bug
* Compile with Arduino 1.6.7

# V2.2 (30/01/16)
### V2.2 (30/01/16)
* Reduction in SRAM memory usage thanks to F-macro serial string implementation
* Display "Raspberry Pi Booting" message on LCD at startup
* Only sample from CT channels when CT is connected to that channel (fix noise readings when no CT connected)

# V2.1 (20/1/16)
### V2.1 (20/1/16)
* Allow use of group 0

# V2.0 (17/11/15)
### V2.0 (17/11/15)
* Don't print ACK's to serial

# V1.9 (16/11/15)
### V1.9 (16/11/15)
* Fix counting pulses faster than 110ms, strobed meter LED http://openenergymonitor.org/emon/node/11490

# V1.8 (30/10/15)
### V1.8 (30/10/15)
* Enable pulse count INT1 internal pull-up to fix spurious pulse count readings

# V1.7 (12/06/15)
### V1.7 (12/06/15)
* Fix bug which stopped USA AC-AC Vcal from being applied at runtime

# V1.6 (12/06/15)
### V1.6 (12/06/15)
* Fix interrupt pulse debouce issue by limiting pulse width to 52ms min (50ms is default for LED pulse output meters)
* Compile with latest JeeLib with fix for RF hang, remove RF reset added in V1.3 (bf179057ee1abc2cfa2965b454421203ac52c6c3)
* Enable simultaneous pulse counting and temperature monitoring on single RJ45 using breakout

# V1.5 (27/05/15)
### V1.5 (27/05/15)
* Change pulse count to be stored as unsigned long datatype
* Add new variable power 1 + power 2 as third item in the node struct. This will be useful for US installs and Solar PV type 2 installations to provide a feed for consumption (solar PV + grid import / export)

Expand All @@ -161,21 +180,21 @@ After this update a manual change will be required to emonhub.conf, copy and pas
```
https://github.com/openenergymonitor/emonpi/commit/c427cd2bdfce7b3c535388d1ee53cc45183edf9c

# V1.4 (27/05/15)
### V1.4 (27/05/15)
Make firmware version return command 'v' return firmware version and RFM setting all on one line
https://github.com/openenergymonitor/emonpi/commit/fa4474571cffa45d03483ce9da32f021dd2df91a

# V1.3 (21/05/15)
### V1.3 (21/05/15)
1.3 firmware dev, add RF init ever 10min to keep RF alive
https://github.com/openenergymonitor/emonpi/commit/96b59c38c045a44e6dea3c1a5e048d038380e88a

# V1.2 (13/05/15)
### V1.2 (13/05/15)
Fix AC wave detect and improve AC calibration calibration
https://github.com/openenergymonitor/emonpi/commit/41987f1e21b3687b8b0ac6b9f5f5160cdfb808a4

# V1.1 (11/05/15)
### V1.1 (11/05/15)
Add sample from both CT's as default and set 110V VRMS for apparent power when US calibration is set e.g '2p'
https://github.com/openenergymonitor/emonpi/commit/2565eb3663847c22bfb62b0d1258f8cbc5fea224

# V1.0
### V1.0
First release
File renamed without changes.
File renamed without changes.
File renamed without changes.
73 changes: 0 additions & 73 deletions firmware/platformio.md

This file was deleted.

21 changes: 0 additions & 21 deletions firmware/upload.sh

This file was deleted.

2 changes: 2 additions & 0 deletions firstbootupdate
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

# NOT USED ANYMORE REPLACED BY: https://github.com/openenergymonitor/EmonScripts/blob/master/update/firstbootupdate

# Script to update new emonPi's to latest firmware and software the fist time they are booted up in the factory
# Looks to see if /home/pi/data/emonpiupdate.log exists or LCD push button (GPIO 23) is pressed (high when pressed)

Expand Down
2 changes: 0 additions & 2 deletions hardware/emonpi/emonpi_V1_5/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

**Raspberry Pi Energy Monitoring Shield**

Technical Documentation: [http://wiki.openenergymonitor.org/index.php?title=EmonPi](http://wiki.openenergymonitor.org/index.php?title=EmonPi)

![photo.png](photo.png)


Expand Down
Binary file added hardware/emonpi/emonpi_V1_6/EmonPi_GPIO.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 77 additions & 7 deletions hardware/emonpi/emonpi_V1_6/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,93 @@

**Raspberry Pi Energy Monitoring Shield**

Technical Documentation: [http://wiki.openenergymonitor.org/index.php?title=EmonPi](http://wiki.openenergymonitor.org/index.php?title=EmonPi)
<img src="photo.png" width="900">

emonPi Hardware Change Log: [http://wiki.openenergymonitor.org/index.php?title=EmonPi#Hardware_Change_Log](http://wiki.openenergymonitor.org/index.php?title=EmonPi#Hardware_Change_Log)
### Schematic

![emonPi_V1.6_sch.png](emonPi_V1.6_sch.png)

### Board

<img src="photo.png" width="900">
![emonPi_V1.6_brd.png](emonPi_V1.6_brd.png)

### Port Map

| Arduino Pin | AVR Special Function | emonPi V1.6 Atmega 328 | Raspberry Pi |
|----------------|-----------------------|--------------------------------------|-------------------|
| Analog 0 (D14) | | AC Voltage | |
| Analog 1 (D15) | | CT1 | |
| Analog 2 (D16) | | CT2 | |
| Analog 3 (D17) | | | |
| Analog 4 (D18) | (SDA) | | |
| Analog 5 (D19) | (SCL) | | |
| Analog 6 (D20) | | RJ45 pin 8 – ADC6 / Dig20 | |
| Analog 7 (D21) | | | |
| Digital 0 | (RXD) | FTDI Tx | GPIO 14 / pin 8 |
| Digital 1 | (TXD) | FTDI Rx | GPIO 15 / pin 10 |
| Digital 2 | (int0) PWM | RFM12B/69CW INT / (JP5 – RJ45 pin 7) | |
| Digital 3 | (int1) PWM | RJ45 pin 6 – Pulse counter | |
| Digital 4 | | RJ45 pin 4 – one-wire DS18B20 | |
| Digital 5 | PWM | Raspi GPIO 17 / Pin 11 | GPIO 17 / Pin 11 |
| Digital 6 | PWM | OOK Tx / (GPIO 18 -Pin 12) V1.6 | |
| Digital 7 | | | |
| Digital 8 | | Shutdown PTM Button | |
| Digital 9 | PWM | emonPi PCB LED | |
| Digital 10 | (SS) PWM | RFM69CW SEL | |
| Digital 11 | (MOSI) PWM | RFM69CW SDI | |
| Digital 12 | (MISO) | RFM69CW SDO | |
| Digital 13 | (SCK) | RFM69CW SCK | |

### Schematic

![emonPi_V1.6_sch.png](emonPi_V1.6_sch.png)
### Raspberry Pi GPIO

### Board
| Raspberry Pi GPIO | RasPi Function | emonPi V1.6 ATmega328 |
|--------------------|-----------------|------------------------------------------|
| 2 (0 REV1) | I2C | SDA I2C LCD |
| 3 (1 REV 1) | I2C | SCL I2C LCD |
| 4 (pin 7) | | ATmega328 reset |
| 7 | SPI CS | |
| 8 | SPI CS | |
| 9 | SPI | |
| 10 | SPI | |
| 11 | SPI | |
| 14 | UART Tx | Dig 0 /Rx |
| 15 | UART Rx | Dig 1 / Tx |
| 17 (pin 11) | | Atmega Dig 5 – shutdown signal |
| 18 (pin 12) | | OOK Tx (V1.6) |
| 22 | | |
| 23 (pin 16) | | LCD PTM push button (High when pressed) |
| 24 | | |
| 25 | | |
| 27 (21 REV 1) | | |

![emonPi_V1.6_brd.png](emonPi_V1.6_brd.png)
Red dots mark GPIO used by the emonPi:

![](EmonPi_GPIO.png)

### Enclosure CAD Design

![](EmonPi_case_CAD_drawing.png)


### Dimensions

PCB: 99.2mm x 76.1mm

Enclosure: 103mm x 85mm x 99mm

Enclosure Screws: Torx T20

Raspberry Pi fixing kit (Rapid Rapid numbers):

- 4 x 15mm spacer: 33-2040
- 4 x M3 screw: 33-2300

LCD fixing kit (Rapid Rapid numbers):

- 4 x 6mm spacer: 33-2034
- 4 x M3 lock Nut: 33-4402
- 4 x M3 12mm countersunk screw: 33-2955

### Open Hardware

Expand Down
27 changes: 0 additions & 27 deletions install/apache.sh

This file was deleted.

3 changes: 0 additions & 3 deletions install/base.sh

This file was deleted.

65 changes: 0 additions & 65 deletions install/config.ini

This file was deleted.

182 changes: 0 additions & 182 deletions install/default.settings.php

This file was deleted.

79 changes: 0 additions & 79 deletions install/emoncms_core.sh

This file was deleted.

76 changes: 0 additions & 76 deletions install/emoncms_modules.sh

This file was deleted.

26 changes: 0 additions & 26 deletions install/emonhub.sh

This file was deleted.

58 changes: 0 additions & 58 deletions install/emonsd.sh

This file was deleted.

20 changes: 0 additions & 20 deletions install/firmware.sh

This file was deleted.

19 changes: 0 additions & 19 deletions install/init.sh

This file was deleted.

73 changes: 0 additions & 73 deletions install/main.sh

This file was deleted.

26 changes: 0 additions & 26 deletions install/mosquitto.sh

This file was deleted.

16 changes: 0 additions & 16 deletions install/mysql.sh

This file was deleted.

68 changes: 0 additions & 68 deletions install/readme.md

This file was deleted.

19 changes: 0 additions & 19 deletions install/redis.sh

This file was deleted.

107 changes: 0 additions & 107 deletions install/wifiap.sh

This file was deleted.

39 changes: 18 additions & 21 deletions lcd/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# HD44780 LCD with PCF8574 I2c
# HD44780 LCD with PCF8574 I2c

I2C Address: 0x27
I2C Address: 0x27 or 0x3f


# Enabling The I2C Port

**Tested on Raspbian Jessie and Stretch**
**Tested on Raspbian**

The I2C ports need to be enabled in Raspbian before they can be used.

Expand All @@ -15,20 +15,19 @@ Un-comment / add the line

dtparam=i2c_arm=on

Edit kernal modules file:

$ sudo nano /etc/modules
Edit kernel modules file:

Add these line:
$ sudo nano /etc/modules

Add this line:

i2c-dev

Exit and save the file.

​
## Install the I2C utilities:

Usally pre-installed
Usually pre-installed

$ sudo apt-get install python-smbus i2c-tools

Expand All @@ -37,9 +36,9 @@ Enter "sudo reboot" to restart the pi and now the I2C pins will be available to

## Detect LCD on I2C bus and find out address

$ sudo i2cdetect -y 1
$ sudo i2cdetect -y 1

Expected output LCD is detect is `0x27` or `0x3F` e.g
Expected output is `0x27` or `0x3F` e.g.

```
pi@emonpi:~ $ sudo i2cdetect -y 1
Expand All @@ -54,21 +53,19 @@ pi@emonpi:~ $ sudo i2cdetect -y 1
70: -- -- -- -- -- -- -- --
```

Use port 0 for very olde 256Mb RAM pi (rev1) - not recomended to use this pi vesion
Use port 0 for very old 256Mb RAM pi (rev1) - not recommended to use this pi version

# Install emonPiLCD python script

```
sudo apt-get update
sudo apt-get install python-smbus i2c-tools python-rpi.gpio python-pip redis-server python-gpiozero -y
sudo pip install redis paho-mqtt xmltodict requests
sudo apt-get install python3-smbus i2c-tools python3-rpi.gpio python3-pip redis-server python3-gpiozero -y
sudo pip3 install redis paho-mqtt xmltodict requests
```

## Run as service

sudo ln -s /home/pi/emonpi/lcd/ /usr/share/emonPiLCD
sudo ln -s /home/pi/emonpi/lcd/emonPiLCD /etc/init.d/emonPiLCD

# Run at startup
## Run as service

sudo update-rc.d emonPiLCD defaults
Run the shell script
```
./install.sh
```
2 changes: 0 additions & 2 deletions lcd/disablessh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@
# Disable SSH
sudo update-rc.d ssh disable
sudo invoke-rc.d ssh stop

exit
8 changes: 6 additions & 2 deletions lcd/emonPiLCD.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[general]
uselogfile = True

# LCD backlight timeout in seconds 0: always on, 300: off after 5 min
# LCD backlight timeout in seconds 0: always on, 600: off after 140 min
# as the emonpi could be installed in a dark place, keep the backlight on, eh ?
backlight_timeout = 0
backlight_timeout = 600

#How often the LCD is updated when a button is not pressed
lcd_update_sec = 30
Expand All @@ -23,6 +23,10 @@ mqtt_passwd = emonpimqtt2016
mqtt_host = 127.0.0.1
mqtt_port = 1883
mqtt_emonpi_topic = emonhub/rx/5/values
mqtt_temp1_topic = emon/emonpi/t1
mqtt_temp2_topic = emon/emonpi/t2
mqtt_vrms_topic = emon/emonpi/vrms
mqtt_pulse_topic = emon/emonpi/pulsecount
mqtt_feed1_topic = emon/emonpi/power1
mqtt_feed2_topic = emon/emonpi/power2

Expand Down
572 changes: 18 additions & 554 deletions lcd/emonPiLCD.py

Large diffs are not rendered by default.

37 changes: 11 additions & 26 deletions lcd/emonPiLCD.service
Original file line number Diff line number Diff line change
@@ -1,40 +1,25 @@
# Systemd unit file for emonPiLCD script

# INSTALL:
# sudo ln -s /usr/share/emonPiLCD/emonPiLCD.service /lib/systemd/system

# RUN AT STARTUP
# sudo systemctl daemon-reload
# sudo systemctl enable emonPiLCD.service

# START / STOP With:
# sudo systemctl start emonPiLCD
# sudo systemctl stop emonPiLCD

# installation is done via the install.sh script in the same folder
# VIEW STATUS
# systemctl status emonPiLCD
# VIEW LOG
# journalctl -f -u emonPiLCD

[Unit]
Description=emonPiLCD Script
Wants=mosquitto.service
Description=emonPi LCD driver
After=mosquitto.service

[Service]
Type=idle
ExecStart=/usr/bin/python /usr/share/emonPiLCD/emonPiLCD.py
User=pi

# Restart script if stopped on a failure. Will not restart if not configured correctly
Restart=on-failure
# Wait 60s before restart
RestartSec=60

# Tag things in the log
# If you want to use the journal instead of the file above, uncomment SyslogIdentifier below
# View with: sudo journalctl -f -u emonPiLCD -o cat
SyslogIdentifier=emonPiLCD
PIDFile=/var/run/emonpilcd.pid
Environment='LOG_PATH=/var/log/emonpilcd'
ExecStart=/usr/bin/python3 /opt/openenergymonitor/emonpi/lcd/emonPiLCD.py --logfile=${LOG_PATH}/emonpilcd.log
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p ${LOG_PATH}/
ExecStartPre=/bin/chgrp -R pi ${LOG_PATH}/
ExecStartPre=/bin/chmod 775 ${LOG_PATH}/
Type=simple
Restart=always

[Install]
WantedBy=multi-user.target
Loading