OpenEVSE / ESP8266_WiFi_v2.x

ESP8266 WiFi for OpenEVSE Version 2.x
https://openevse.openenergymonitor.org
76 stars 46 forks source link
emoncms esp8266 evse mqtt-client openenergymonitor openevse wifi

OpenEVSE WiFi Gateway

OpenEVSE WiFi V2.x is now archived, the current version is OpenEVSE V4.x , upgrading from V2.x to V4.x requires a WiFi module hardware upgrade to ESP32.

main

The WiFi gateway uses an ESP8266 (ESP-12) which communicates with the OpenEVSE controller via serial utilizing the existing RAPI API serial interface. The web interface UI is served directly from the ESP8266 web server and can be controlled via a connected device over the network.

Live demo: https://openevse.openenergymonitor.org

Features

Requirements

OpenEVSE charging station

WiFi Module


Contents


User Guide

WiFi Setup

On first boot, OpenEVSE should broadcast a WiFI access point (AP) OpenEVSE_XXX. Connect to this AP (default password: openevse) and the captive portal should forward you to the log-in page. If this does not happen navigate to http://openevse, http://openevse.local or http://192.168.4.1

Note: You may need to disable mobile data if connecting via a mobile

Note: Use of Internet Explorer 11 or earlier is not recommended

Wifi connect Wifi setup

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 (AP) 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 / GPIO0 button on the ESP8266 module for about 5s will force WiFi access point mode. This is useful when trying to connect the unit to a new WiFi network. If the unit cannot connect t0 a WiFi network it will resturn to AP more before retrying to connect


OpenEVSE Web Interface

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

The interface has been optimised to work well for both desktop and mobile. Here is an example setting a charging delay timer using an Android device:

android-clock

Charging Mode: Eco

'Eco' charge mode allows the OpenEVSE to adjust the charging current automatically based on an MQTT feed. This feed could be the amount of solar PV generation or the amount of excess power (grid export). 'Normal' charge mode charges the EV at the maximum rate set.

Solar PV Divert Example

This is best illustrated using an Emoncms MySolar graph. The solar generation is shown in yellow and OpenEVSE power consumption in blue:

divert

*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 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 with an AC-AC voltage sensor adaptor is required to monitor direction of current flow.

Setup

eco

Operation

To enable 'Eco' mode charging:

* OpenEVSE controller firmware V4.8.0 has a bug which restricts the lowest charging current to 10A. The J1772 protocol can go down to 6A. This will has be fixed with a firmware update. See OpenEnergyMonitor OpenEVSE FW releases. A ISP programmer is required to update openevse controler FW.


Services

services

Emoncms data logging

OpenEVSE can post its status values (e.g amp, temp1, temp2, temp3, pilot, status) to emoncms.org or any other Emoncms server (e.g. emonPi) using Emoncms API. 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, 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.

MQTT

OpenEVSE Status via MQTT

OpenEVSE can post its status values (e.g. amp, wh, temp1, temp2, temp3, pilot, status) to an MQTT server. Data will be published as a sub-topic of base topic.E.g <base-topic>/amp. Data is published to MQTT every 30s.

MQTT setup is pre-populated with OpenEnergyMonitor emonPi default MQTT server credentials.

Note: emon/xxxx should be used as the base-topic if posting to emonPi MQTT server if you want the data to appear in emonPi Emoncms. See emonPi MQTT docs.

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. 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.

RAPI via web interface

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

enable-rapi

rapi-web

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 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 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/#

e.g. $OK

See video demo of RAPI over MQTT

RAPI over HTTP

RAPI (rapid API) commands can also be issued directly via a single HTTP request.

Assuming 192.168.0.108 is the local IP address of the OpenEVSE ESP.

Eg.the RAPI command to set charging rate to 13A:

http://192.168.0.108/r?rapi=%24SC+13

To sleep (pause a charge) issue RAPI command $FS

http://192.168.0.108/r?rapi=%24FS

To enable (start / resume a charge) issue RAPI command $FE

http://192.168.0.108/r?rapi=%24FE

There is also an OpenEVSE RAPI command python library.

OhmConnect

USA California only Join here

Video - How does it Work https://player.vimeo.com/video/119419875

-Sign Up -Enter Ohm Key

Ohm Key can be obtained by logging in to OhmConnect, enter Settings and locate the link in "Open Source Projects" Example: https://login.ohmconnect.com/verify-ohm-hour/OpnEoVse Key: OpnEoVse

System

system

Authentication

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

Firmware update

Pre-compiled .bin's can be uploaded via the web interface, see OpenEVSE Wifi releases for latest updates.

Hardware reset

A Hardware reset can be made (all wifi and services config lost) by pressing and holding GPIO0 hardware button (on the Huzzah WiFi module) for 10s.

Note: Holding the GPIO0 button for 5s will but the WiFi unit into AP (access point) mode to allow the WiFi network to be changed without loosing all the service config


Upload pre-compiled firmware

esptool.py write_flash 0x000000 firmware.bin

Firmware Compile & Upload

The ESP should be shipped with latest firmware pre-installed, firmware can be updated via the HTTP web interface.

**Updating from V1: it's possible to update from V1 to V2 firmware using the HTTP web interface uploader, just upload the latest .bin pre-compiled firmware release.***

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. We recommend PlatformIO for its ease of use.

Compile & Upload 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 using the install script. See PlatformIO installation docs. 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-explanatory.

Download PlatfomIO IDE

1. Clone this repo

$ git clone https://github.com/OpenEVSE/ESP8266_WiFi_v2.x

2. Compile & upload

pio run -t upload

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

Building the GUI

The GUI files are minified and compiled into the firmware using a combination of Webpack and a custom build script. You will also need Node.JS and NPM installed.

In addition the GUI is now maintained in a separate repository and included as a Git submodule. If the gui directory is empty use the following to retrieve the GUI source and fetch the dependencies.

git submodule update --init
cd gui
npm install

To 'build' the GUI use the following:

cd gui
npm run build

You can then just compile and upload as above.

For more details see the GUI documentation


Compile & Upload Using Arduino IDE

1. Install ESP for Arduino with Boards Manager

From: https://github.com/esp8266/Arduino

Starting with 1.6.4, Arduino allows installation of third-party platform packages using Boards Manager. ESP Arduino packages are available for Windows, Mac OS, and Linux (32 and 64 bit).

2. Compile and Upload


Troubleshooting

WiFi Connection issues

It's been reported that the OpenEVSE WiFi has issues with non standard MTU settings, we recomend using the standard 1500 bytes for router MTU setting

Uploading issues

$ esptool.py erase_flash

Output:

esptool.py v1.2-dev
Connecting...
Running Cesanta flasher stub...
Erasing flash (this may take a while)...
Erase took 8.0 seconds

Fully erase ESP

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

View serial debug

To help debug it may be useful to enable serial debug output. To do this upload using openevse_dev environment e.g.

pio run -t upload -eopenevse_dev

The default is to enable serial debug on serial1 the ESP's 2nd serial port. You will need to connect a debugger to the ESP serial1 Tx pin (GPIO2).

To change to use serial0 (the main ESP's serial port) change -DDEBUG_PORT=Serial1 to -DDEBUG_PORT=Serial in platformio.ini. Note that using serial 0 will adversely effect RAPI communication with the openevse controller.


About

Collaboration of OpenEnergyMonitor and OpenEVSE.

Contributions by:

Licence

GNU General Public License (GPL) V3