Skip to content

Commit

Permalink
Merge branch 'stable' of github.com:OpenEVSE/ESP8266_WiFi_v2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
glynhudson committed Oct 23, 2017
2 parents fee3ced + 4b2aa58 commit 53443e2
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 59 deletions.
Binary file added docs/main2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ data_dir = src/data
env_default = openevse

[common]
version = -DBUILD_TAG=2.4.1
version = -DBUILD_TAG=2.4.2
lib_deps = [email protected], [email protected]
extra_scripts = scripts/extra_script.py
debug_flags = -DENABLE_DEBUG -DENABLE_PROFILE -DDEBUG_PORT=Serial1
Expand Down Expand Up @@ -77,10 +77,22 @@ monitor_baud = 115200
extra_scripts = ${common.extra_scripts}

# http://docs.platformio.org/en/latest/platforms/espressif8266.html#using-arduino-framework-with-staging-version
# Staging Arduino framework and common lib version
[env:openevse_staging]
platform = espressif8266_stage
board = esp12e
framework = arduino
lib_deps = ${common.lib_deps}
src_build_flags = ${common.version} ${common.ota_flags} ${common.debug_flags} -DENABLE_ASYNC_WIFI_SCAN
upload_port = openevse.local
monitor_baud = 115200
extra_scripts = ${common.extra_scripts}

# staging Arduino framwork and latest libs
[env:openevse_staging_libs]
platform = espressif8266_stage
board = esp12e
framework = arduino
lib_deps = https://github.com/knolleary/pubsubclient, https://github.com/me-no-dev/ESPAsyncWebServer.git, https://github.com/me-no-dev/ESPAsyncTCP.git
src_build_flags = ${common.version} ${common.ota_flags} ${common.debug_flags} -DENABLE_ASYNC_WIFI_SCAN
upload_port = openevse.local
Expand Down
120 changes: 63 additions & 57 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# OpenEVSE WiFi Gateway

[![Build Status](https://travis-ci.org/jeremypoulter/ESP8266_WiFi_v2.x.svg?branch=master)](https://travis-ci.org/jeremypoulter/ESP8266_WiFi_v2.x)
[![Build Status](https://travis-ci.org/OpenEVSE/ESP8266_WiFi_v2.x.svg?branch=master)](https://travis-ci.org/OpenEVSE/ESP8266_WiFi_v2.x)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/640ec33a27b24f6fb4fb1d7e74c7334c)](https://www.codacy.com/app/jeremy_poulter/ESP8266_WiFi_v2.x?utm_source=github.com&utm_medium=referral&utm_content=jeremypoulter/ESP8266_WiFi_v2.x&utm_campaign=Badge_Grade)

![mobile](docs/mobile-render.png)
![main](docs/main2.png)

![main](docs/main.png)



The WiFi gateway uses an ESP8266 (ESP-12) to communcate to the OpenEVSE controller via serial utilizing the existing RAPI serial interface. The web interface is served directly from the ESP8266 and can be controlled via a connected device over a local network.
The WiFi gateway uses an ESP8266 (ESP-12) to communicate to the OpenEVSE controller via serial utilizing the existing RAPI serial interface. The web interface is served directly from the ESP8266 and can be controlled via a connected device over a local network.

## Features

Expand All @@ -22,7 +18,21 @@ The WiFi gateway uses an ESP8266 (ESP-12) to communcate to the OpenEVSE controll
- MQTT status & control
- Log to Emoncms server e.g [data.openevse.org](http://data.openevse.org) or [emoncms.org](https://emoncms.org)
- 'Eco' mode: automatically adjust charging current based on availability of power from solar PV or grid export
- Ohmconnect integration (California USA only)
- OhmConnect integration (California USA only)

## Requirements

### OpenEVSE charging station
- Purchase via: [OpenEVSE Store (USA/Canda)](https://store.openevse.com) | [OpenEnergyMonitor (UK / EU)](https://shop.openenergymonitor.com/openevse-deluxe-ev-charge-controller-kit/)
- OpenEVSE FW [V4.8.0 recommended](https://github.com/OpenEVSE/open_evse/releases/tag/v4.8.0)
- All new OpenEVSE units are shipped with V4.8.0 pre-loaded (October 2017 onwards)
- OpenEVSE FW V3.10.4 will work with latest WiFi FW with some minor issues e.g. LCD text corruption

### WiFi Module

- ESP8266 (ESP-12) e.g Adafruit Huzzah
- Purchase via: [OpenEVSE Store (USA/Canda)](https://store.openevse.com/collections/frontpage/products/openevse-wifi-kit) | [OpenEnergyMonitor (UK / EU)](http://shop.openenergymonitor.com/openevse-wifi-kit/)
- See [OpenEVSE WiFi setup guide](https://openevse.dozuki.com/Guide/OpenEVSE+WiFi+%28Beta%29/14) for WiFi module connection instructions

***

Expand All @@ -39,7 +49,7 @@ The WiFi gateway uses an ESP8266 (ESP-12) to communcate to the OpenEVSE controll
* [RAPI via web interface](#rapi-via-web-interface)
* [RAPI over MQTT](#rapi-over-mqtt)
* [RAPI over HTTP](#rapi-over-http)
* [Ohmconnect](#ohmconnect)
* [OhmConnect](#ohmconnect)
* [System](#system)
* [Authentication](#authentication)
* [Firmware update](#firmware-update)
Expand Down Expand Up @@ -67,26 +77,26 @@ The WiFi gateway uses an ESP8266 (ESP-12) to communcate to the OpenEVSE controll

On first boot, OpenEVSE should broadcast a WiFI AP `OpenEVSE_XXX`. Connect to this AP (default password: `openevse`) and the [captive portal](https://en.wikipedia.org/wiki/Captive_portal) should forward you to the log-in page. If this does not happen navigate to [http://openevse](http://openevse), [http://openevse.local](http://openevse.local) or [http://192.168.4.1](http://192.168.4.1)

*Note: You may need to disable mobile data if connecting via a Android device*
*Note: You may need to disable mobile data if connecting via an Android device*

![Wifi connect](docs/wifi-connect.png) ![Wifi setup](docs/wifi-scan.png)


- Select your WiFi network from list of available networks
- Enter WiFi PSK key then click `Connect`

- OpenEVSE should now connect to local wifi network
- Re-connect device to home WiFi network and connect OpenEVSE using [http://openevse.local](http://openevse.local), [http://openevse](http://openevse) or local IP address.
- OpenEVSE should now connect to local WiFi network
- Re-connect device to home WiFi network and connect to OpenEVSE using [http://openevse.local](http://openevse.local), [http://openevse](http://openevse) or local IP address.

**If connection / re-connection fails (e.g. network cannot be found or password is incorrect) the OpenEVSE will automatically revert back to WiFi access point mode after a short while to allow a new network to be re-configued if required. Re-connection to existing network will be attempted every 5min.**
**If connection / re-connection fails (e.g. network cannot be found or password is incorrect) the OpenEVSE will automatically revert back to WiFi access point mode after a short while to allow a new network to be re-configured if required. Re-connection to existing network will be attempted every 5 minutes.**

*Holding the `boot` button on the ESP8266 module at startup (for about 10's) will force Wifi access point mode. This is useful when trying to connect the unit to a new WiFi network.*
*Holding the `boot` button on the ESP8266 module at startup (for about 10s) will force WiFi access point mode. This is useful when trying to connect the unit to a new WiFi network.*

***

## OpenEVSE Web Interface

All functions of the OpenEVSE can be viewed and controlled via the web interface. Here is a screen grab showing 'advanecd' display mode:
All functions of the OpenEVSE can be viewed and controlled via the web interface. Here is a screen grab showing the 'advanced' display mode:

![advanced](docs/adv.png)

Expand All @@ -107,41 +117,41 @@ This is best illustrated using an Emoncms graph. The solar generation is shown i

![divert](docs/divert.png)

- OpenEVSE is initally sleeping with EV connected
- Once solar PV generation reaches 6A (1.5kW @ 240V) the OpenEVSE starts charged
- OpenEVSE is initially sleeping with an EV connected
- Once solar PV generation reaches 6A (1.5kW @ 240V) the OpenEVSE initiates charging
- Charging current is adjusted based on available solar PV generation
- Once the charge is started even if generation drops below 6A this EV will continue to charge*
- Once charging has begun, even if generation drops below 6A, the EV will continue to charge*

**The decision was made not to pause charging if generation current drops below 6A since repeatedly starting / stoppping a charge causes excess wear to the OpenEVSE relay contactor.*
**The decision was made not to pause charging if generation current drops below 6A since repeatedly starting / stopping a charge causes excess wear to the OpenEVSE relay contactor.*

If a Grid +I/-E (positive import / negative export) feed was used the OpenEVSE would adjust it's charging rate based on *excess* power that would be exported to the grid e.g. If solar PV was producting 4kW and 1kW was being used on-site the OpenEVSE would charge at 3kW, grid export would be 0kW. If on-site consumption increases to 2kW OpenEVSE would reduce it's chargin rate to 2kW.
If a Grid +I/-E (positive import / negative export) feed was used the OpenEVSE would adjust its charging rate based on *excess* power that would be exported to the grid; for example, if solar PV was producing 4kW and 1kW was being used on-site, the OpenEVSE would charge at 3kW and the amount exported to the grid would be 0kW. If on-site consumption increases to 2kW the OpenEVSE would reduce its charging rate to 2kW.

An [OpenEnergyMonitor solar PV energy monitor](https://guide.openenergymonitor.org/applications/solar-pv/) with an AC-AC voltage sensor adaptor is required to monitor direction of current flow.

### Setup

- To use Eco charging mode MQTT must be enabled 'Solar PV divert' MQTT topics must be entered.
- Integration with OpenEnergyMonitor emonPi is strightforward:
- To use 'Eco' charging mode MQTT must be enabled and 'Solar PV divert' MQTT topics must be entered.
- Integration with an OpenEnergyMonitor emonPi is straightforward:
- Connect to emonPi MQTT server, [emonPi MQTT credentials](https://guide.openenergymonitor.org/technical/credentials/#mqtt) should be pre-populated
- Enter solar PV generation / Grid (+I/-E) MQTT topic e.g. if solar PV is being monitored by emonPi CT channel 1 enter `emon/emonpi/power1`
- [MQTT lens Chrome extension](https://chrome.google.com/webstore/detail/mqttlens/hemojaaeigabkbcookmlgmdigohjobjm?hl=en) can be used to view MQTT data e.g. subscribe to `emon/#` for all OpenEnergyMonitor MQTT data. To lean more about MQTT see [MQTT section of OpenEnergyMonitor user guide](https://guide.openenergymonitor.org/technical/mqtt/)
- If using Grid +I/-E (positive import / negative export) MQTT feed ensure the notation positive import / negative export is correct, CT sensor can be pyhsically reversed on the cable to invert the reading.
- If using Grid +I/-E (positive import / negative export) MQTT feed ensure the notation positive import / negative export is correct, CT sensor can be physically reversed on the cable to invert the reading.

### Opperation
### Operation

To enable 'Eco' mode charging
To enable 'Eco' mode charging:

* Connect EV and ensure EV's internal charging timmer is switched off
* Pause charge, OpenEVSE should display 'sleeping'
* Enable Eco mode using web interface or via MQTT
* EV will not begin charging when genaration / excess current reaches 6A (1.4kW @ 240V)
- Connect EV and ensure EV's internal charging timer is switched off
- Pause charge; OpenEVSE should display 'sleeping'
- Enable 'Eco' mode using web interface or via MQTT
- EV will not begin charging when generation / excess current reaches 6A (1.4kW @ 240V)

* During 'Eco' charing changes to charging current are temporary (not saved to EEPROM)
* After an 'Eco mode' charge the OpenEVSE will revert to 'Normal' when EV is disconnected
* Current is adjusted in 1A increments between 6A (1.5kW @ 240V) > max charging current (as set in OpenEVSE setup)
* 6A is the lowest supported charging current that SAE J1772 EV charging protocol supports
* The OpenEVSE does not adjust the current itself but rather request that the EV adjusts its charging current by varying the duty cycle of the pilot signal, see [theory of opperation](https://openev.freshdesk.com/support/solutions/articles/6000052070-theory-of-operation) and [Basics of SAE J1772](https://openev.freshdesk.com/support/solutions/articles/6000052074-basics-of-sae-j1772).
* Charging mode can be viewed and set via MQTT: `{base-topic}/divertmode/set`. (1 = normal, 2 = eco)
- During 'Eco' charging changes to charging current are temporary (not saved to EEPROM)
- After an 'Eco mode' charge the OpenEVSE will revert to 'Normal' when EV is disconnected
- Current is adjusted in 1A increments between 6A (1.5kW @ 240V) > max charging current (as set in OpenEVSE setup)
- 6A is the lowest supported charging current that SAE J1772 EV charging protocol supports
- The OpenEVSE does not adjust the current itself but rather request that the EV adjusts its charging current by varying the duty cycle of the pilot signal, see [theory of operation](https://openev.freshdesk.com/support/solutions/articles/6000052070-theory-of-operation) and [Basics of SAE J1772](https://openev.freshdesk.com/support/solutions/articles/6000052074-basics-of-sae-j1772).
- Charging mode can be viewed and set via MQTT: `{base-topic}/divertmode/set` (1 = normal, 2 = eco).

***

Expand All @@ -153,7 +163,7 @@ To enable 'Eco' mode charging

OpenEVSE can post its status values (e.g amp, temp1, temp2, temp3, pilot, status) to [emoncms.org](https://emoncms.org) or any other Emoncms server (e.g. emonPi) using [Emoncms API](https://emoncms.org/site/api#input). Data will be posted every 30s.

Data can be posted using HTTP or HTTPS. For HTTPS the Emoncms server must support HTTPS (emoncms.org does, emonPi does not).Due to the limited resources on the ESP the SSL SHA-1 fingerprint for the Emoncms server must be manually entered and regularly updated.
Data can be posted using HTTP or HTTPS. For HTTPS the Emoncms server must support HTTPS (emoncms.org does, the emonPi does not).Due to the limited resources on the ESP the SSL SHA-1 fingerprint for the Emoncms server must be manually entered and regularly updated.

*Note: the emoncms.org fingerprint will change every 90 days when the SSL certificate is renewed.*

Expand All @@ -177,27 +187,29 @@ MQTT can also be used to control the OpenEVSE, see RAPI MQTT below.

#### RAPI

RAPI commands can be used to control and check the status of all OpenEVSE functions. A full list of RAPI commands can be found in the [OpenEVSE plus source code](https://github.com/lincomatic/open_evse/blob/stable/rapi_proc.h). RAPI commands can be issued via the web-interface, HTTP and MQTT.
RAPI commands can be used to control and check the status of all OpenEVSE functions. RAPI commands can be issued via the direct serial, web-interface, HTTP and MQTT. We recommend using RAPI over MQTT.

**A full list of RAPI commands can be found in the [OpenEVSE plus source code](https://github.com/OpenEVSE/open_evse/blob/stable/firmware/open_evse/src/rapi_proc.h).**

#### RAPI via web interface

Enter RAPI commands directly into to web interface (dev mode must be enabled), RAPI responce is printed in return:
Enter RAPI commands directly into to web interface (dev mode must be enabled), RAPI response is printed in return:

#### RAPI over MQTT

RAPI commands can be issued via MQTT messages. The RAPI command should be published to the following MQTT:

`<base-topic>/rapi/in/<$ rapi-command> payload`

e.g assuming base-topic of `openevse` to following command will set current to 13A:
e.g assuming base-topic of `openevse` the following command will set current to 13A:

`openevse/rapi/in/$SC 13`

The payload can be left blank if the RAPI command does not require a payload e.g.

`openevse/rapi/in/$GC`

The responce from the RAPI command is published by the OpenEVSE back to the same sub-topic and can be received by subscribing to:
The response from the RAPI command is published by the OpenEVSE back to the same sub-topic and can be received by subscribing to:

`<base-topic>/rapi/out/#`

Expand Down Expand Up @@ -226,7 +238,7 @@ To enable (start / resume a charge) issue RAPI command `$FE`

There is also an [OpenEVSE RAPI command python library](https://github.com/tiramiseb/python-openevse).

### Ohmconnect
### OhmConnect

**TBC**

Expand All @@ -238,7 +250,7 @@ There is also an [OpenEVSE RAPI command python library](https://github.com/tiram

### Authentication

Admin HTTP Authentication (highly recomended) can be enabled by saving admin config by default username and password.
Admin HTTP Authentication (highly recommended) can be enabled by saving admin config by default username and password.

**HTTP authentication is required for all HTTP requests including input API**

Expand All @@ -258,21 +270,21 @@ Pre-compiled .bin's can be uploaded via the web interface, see [OpenEVSE Wifi re

If required firmware can also be uploaded via serial using USB to UART cable.

The code for the ESP8266 can be compiled and uploaded using PlatformIO or Arduino IDE. IMO PlatformIO is the easiest..
The code for the ESP8266 can be compiled and uploaded using PlatformIO or Arduino IDE. We recommend PlatformIO for its ease of use.

### Using PlatformIO

For more detailed ESP8266 Arduino core specific PlatfomIO notes see: https://github.com/esp8266/Arduino#using-platformio

#### a. Install PlatformIO command line

The easiest way if running Linux is to install use the install script, this installed pio via python pip and installs pip if not present. See [PlatformIO installation docs](http://docs.platformio.org/en/latest/installation.html#installer-script). Or PlatformIO IDE can be used :
The easiest way if running Linux is to install using the install script. See [PlatformIO installation docs](http://docs.platformio.org/en/latest/installation.html#installer-script). Or PlatformIO IDE can be used :

`$ sudo python -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)"`

#### b. And / Or use PlatformIO IDE

Standalone built on GitHub Atom IDE, or use PlatformIO Atom IDE plug-in if you already have Atom installed. The IDE is nice, easy and self-explanitory.
Standalone built on GitHub Atom IDE, or use PlatformIO Atom IDE plug-in if you already have Atom installed. The IDE is nice, easy and self-explanatory.

[Download PlatfomIO IDE](http://platformio.org/platformio-ide)

Expand All @@ -283,19 +295,12 @@ Standalone built on GitHub Atom IDE, or use PlatformIO Atom IDE plug-in if you a

#### 2. Compile & upload


- Put ESP into bootloader mode
- On other ESP boards (Adafruit HUZZAH) press and hold `boot` button then press `reset`, red LED should light dimly to indicate bootloader mode.
- On other ESP boards (Adafruit HUZZAH) press and hold `boot` button then press `reset`, red LED should light dimly to indicate bootloader mode.

```
$ cd ESP8266_WiFi_v2.x
$ pio run
$ pio run -t upload
```


*Note: uploading SPIFFS is no longet requires since web resources are [now embedded in the firmware](https://github.com/OpenEVSE/ESP8266_WiFi_v2.x/pull/87)
*To enable to OTA upload first upload via serial using the dev environment, this enables to OTA enable build flag. See `platformio.ino*

*Note: uploading SPIFFS is no longer required since web resources are [now embedded in the firmware](https://github.com/OpenEVSE/ESP8266_WiFi_v2.x/pull/87)

***

Expand Down Expand Up @@ -324,7 +329,7 @@ Starting with 1.6.4, Arduino allows installation of third-party platform package

#### Erase Flash

If you are experiancing ESP hanging in a reboot loop after upload it may be that the ESP flash has remnants of previous code (which may have the used the ESP memory in a different way). The ESP flash can be fully erased using [esptool](https://github.com/themadinventor/esptool). With the unit in bootloder mode run:
If you are experiencing ESP hanging in a reboot loop after upload it may be that the ESP flash has remnants of previous code (which may have the used the ESP memory in a different way). The ESP flash can be fully erased using [esptool](https://github.com/themadinventor/esptool). With the unit in bootloder mode run:

`$ esptool.py erase_flash`

Expand All @@ -342,7 +347,7 @@ Erase took 8.0 seconds

#### Fully erase ESP

To fully erase all memory locations on an ESP-12 (4Mb) we neeed to upload a blank file to each memory location
To fully erase all memory locations on an ESP-12 (4Mb) we need to upload a blank file to each memory location

`esptool.py write_flash 0x000000 blank_1MB.bin 0x100000 blank_1MB.bin 0x200000 blank_1MB.bin 0x300000 blank_1MB.bin`

Expand All @@ -353,6 +358,7 @@ To fully erase all memory locations on an ESP-12 (4Mb) we neeed to upload a blan
Collaboration of [OpenEnegyMonitor](http://openenergymonitor.org) and [OpenEVSE](https://openevse.com).

Contributions by:

- @glynhudson
- @chris1howell
- @trystanlea
Expand Down
Loading

0 comments on commit 53443e2

Please sign in to comment.