Coder Social home page Coder Social logo

openevse / openevse_esp32_firmware Goto Github PK

View Code? Open in Web Editor NEW
151.0 151.0 106.0 22.42 MB

OpenEVSE V4 WiFi gateway using ESP32

Shell 0.04% Python 1.43% JavaScript 0.28% C++ 24.24% C 73.74% Makefile 0.10% HTML 0.16% Dockerfile 0.01% CSS 0.01%
emoncms mqtt openevse

openevse_esp32_firmware's People

Contributors

alsavage avatar arjanmels avatar billatq avatar capnbry avatar chris1howell avatar d3wy avatar dependabot[bot] avatar dicion avatar glynhudson avatar ianrrees avatar jdgarcia99 avatar jeremypoulter avatar jketcham avatar joverbee avatar kipk avatar kronenpj avatar lincomatic avatar mathieucarbou avatar matth-x avatar mikebaz avatar moeabm avatar rbray89 avatar realdesilets47 avatar sandeen avatar slyremarks avatar suriv avatar toofishes avatar toulbar2 avatar yoavl avatar zymurgic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openevse_esp32_firmware's Issues

Hostname XMLHttpRequest blocked by CORS policy

Using hostname lookup in a desktop browser e.g http://openevse.local results in the following errors. These errors result in some parameters not being displayed e.g max current

Access to XMLHttpRequest at 'http://192.168.86.20/r?json=1&rapi=$GH' from origin 'http://openevse.local' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Using hostname access:

Screenshot 2019-09-22 at 19 06 09

Using direct IP address (no errors):

Screenshot 2019-09-22 at 19 06 20

Implement schedules for days / times?

I apologize if this request is being worked on already, but if so, I couldn't find it.

I'd like the ability to set schedules for charging by day, and time, multiple times per day (if possible).

I have time-of-use billing and I would rather have the schedule of cheap rates (mostly at night) done on my OpenEVSE rather than my 2014 Volt. I know that right now I can set a daily schedule, but that doesn't help me when my weekend rates are the same as my nightly rates during the week :)

Add Certificate Management

  • Disable root certificate validation per client
  • Update root certificates
  • HTTPS server certificate/private key (GUI)
  • MQTT client certificate/private key

Web server HTTPS

Enable HTTPS support for the webserver, including changing the certificate and private key.

A single base topic?

This is another un-important possible change...

At the moment messages are posted to

<base topic>/

which by default is

openevse-XXXX/

but announce messages are posted to (irregardless of base topic):

openevse/announce/XXXX

(although that may change soon toopenevse/announce).

For consistency does it make sense to have a separate base topic , so messages would be posted too:

openevse/<base topic>

which would then by default be:

openevse/openevse-XXXX

I guess the problem with this is that it isnt backward compatible?

Personally I dont have strong feelings about this. But I thought it would be worth raising it.

WiFi Scan Improvements

In order of priority:

  • Don't scan until the user clicks a 'Scan' button, this will avoid scanning for networks if a user wants to continue in standalone mode
  • Only scan once, this will avoid the list changing in size while the user is trying to enter their passkey
  • Sort SSID'S by RSSI in descending order (less negative RSSI = stronger signal = display first)
  • Don't display very weak networks

These seemingly minor tweaks are actually very important, it took many attempts to setup a WiFi in a location with 100's of WiFi networks since the wifi network scan table kept jumping around in size while trying to enter a complex PSK. Most of the WiFi networks where very weak and should not have been displayed. Also if a user wants use to use stand-alone more it's frustrating to have to wait for a wifi scan that is not needed.

Hardware info

We should add some hardware info to the config so we can distinguish between the ESP8622 and ESP32

ESP32: non-blocking RAPI & "controller not found message"

If possible the RAPI loop should be non-blocking and if the open evse controller is not detected a message should be displayed:

"OpenEVSE controller not detected, please check connections"

  • RAPI comms non-blocking
  • Display message in UI when OpenEVSE is not connected

HTTP update not working

Trying to update via HTTP web interface results in ESP32 rebooting but update is no applied. The firmware file does not seem to uploading correctly. Browser does not register a file upload:

Screenshot 2019-09-22 at 19 16 30

Here is the debug log showing the update process starting them immediately rebooting

Free: 250504
Free: 251192
Free: 251652
Free: 251652
Free: 251652
Update Start: firmware.bin
Update: 0%

0:32
Got 'emonpi' 144 == 144 @ 282:32
Got 'emonpimqtt2016' 137 == 137 @ 314:64
Got 'emon/emontx3/power2' 242 == 242 @ 378:30
Got '' 128 == 128 @ 408:30
Got '' 255 == 128 @ 498:15
Using default ''

Cannot compile (python 3?)

I can't seem to compile the latest mater branch. I think the issue could be due to changing the build script to use python3. What are the steps I need to tell Pio to use Python3? I've got python 3.6.8 installed on my machine which in invoked by $ python3 just $python invokes python 2.7.15

Make each OpenEVSE unique and discoverable

We should make each OpenEVSE unique, this will fix the issues of conflicting devices on a single network and help with integration with services that require unique ID e.g home assistant auto config etc. Each device should have a name consisting of openevse- followed by 4 chars representing the 'chip ID`

openevse-<chipID>
openevse-1234

The <chipID> should be the base64 encoded version of the NIC specific part of the MAC address/Chip ID. Each char in Base64 encodes 6 bits, 6x4=24 which just happens to be the number of chars that should be easy to remember and the number of bits of the MAC NIC.

Note: Even though Base64 is case sensitive and some of the context that it will be used (eg host name) are not, it still should be sufficiently unique. Also need to consider the mapping of the '62' and '63'.

We should append ESP Chip ID to the following default strings:

  • Wifi AP SSID, currently uses chip-ID but should be reduced to 4 characters for consistency?
  • hostname
  • MQTT base-topic
  • Emoncms node name

In order for other services to discover the openevse and determine the unique ID the MQTT initial connection message and LWT (last will testament) should be published to a fixed topic e.g

  • MQTT initial connection message to openevse/announce/<chip ID> topic. The message will be a JSON block of the format:
{
  "state":"connected",
  "name":"openevse-<chipID>",
  "mqtt":"<MQTT base topic>",
  "http":"<HTTP endpoint>"
}
  • MQTT LWT (last will testament) disconnection message to openevse/announce/<chip ID> topic
    The message will be a JSON block of the format:
{
  "state":"disconnected",
  "name":"openevse-<chipID>"
}

Both the initial connection message and LWT should have MQTT retain flag set

temp1 has moved to temp3

The 'pilot' and 'temp' metrics posted to Emoncms / MQTT are incorrect on the ESP32. The values for these metrics shown on the webpage are correct.

Temp1 should be the internal temperature sensor. Temp2/3 are not used on the standard OpenEVSE and should be large negative numbers.

Screenshot_2019-09-08_00-08-50

Octopus Agile / Smart Tariff Schedule Integration (demandshaper)

Demand shaper uses a day ahead power availability forecast to schedules charging sessions at the lowest cost Octopus Agile / carbon time. The forecast could be grid carbon intensity, of cost e.g Octopus API OpenEVSE/ESP8266_WiFi_v2.x#175

Demand shaper module is available for Emoncms, it would be preferable to run it locally on the ESP: https://github.com/emoncms/demandshaper

  • DSR event could be entered into the schedule be setting the forecast signal to a very high cost level for the DSR period
  • Multiple forecast signals could be combined e.g grid carbon / cost + DSR event
  • EV state of charge could be provided by a MQTT topic or from OVMS #emoncms/demandshaper#7
  • Amount of kWh input could be specified with converter to miles

NPM Audit screaming about handlebars security problem

When using on a Raspberry Pi Zero W (which is a pain to get Node.js running on anyway as Pi Zero is armv6. But it's plenty fast for talking serial to the OpenEVSE over Rapi. At any rate...

Node V11.5.0
NPM V 6.4.1

Here's the report...which may entirely be my fault, so feel free to shout me down, call me an idiot and kick-ban me for life. But this is what the freshest of fresh installs yielded.

                      === npm audit security report ===                        
                                                                                
# Run  npm update handlebars --depth 3  to resolve 4 vulnerabilities
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ ModerateDenial of Service                                            │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ handlebars                                                   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ nyc [dev]                                                    │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ nyc > istanbul-reports > handlebars                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/1300                      │
└───────────────┴──────────────────────────────────────────────────────────────┘


┌───────────────┬──────────────────────────────────────────────────────────────┐
│ HighArbitrary Code Execution                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ handlebars                                                   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ nyc [dev]                                                    │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ nyc > istanbul-reports > handlebars                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/1316                      │
└───────────────┴──────────────────────────────────────────────────────────────┘


┌───────────────┬──────────────────────────────────────────────────────────────┐
│ HighArbitrary Code Execution                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ handlebars                                                   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ nyc [dev]                                                    │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ nyc > istanbul-reports > handlebars                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/1324                      │
└───────────────┴──────────────────────────────────────────────────────────────┘


┌───────────────┬──────────────────────────────────────────────────────────────┐
│ HighPrototype Pollution                                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ handlebars                                                   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ nyc [dev]                                                    │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ nyc > istanbul-reports > handlebars                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/1325                      │
└───────────────┴──────────────────────────────────────────────────────────────┘

Emoncms http posting incorrectly reports "connected: no"

Posting to Emoncms (emonPi) via http / https works great but even when successfully posting the interface still reports Connected: No and debug log reports Emoncms error: {" success": true}

Screenshot 2019-09-07 at 14 23 13

Screenshot 2019-09-07 at 14 25 50

Currently, I'm posting to an emonPi which does not support https, is https only enabled for emoncms.org and data.openevse?

OTA upload not working

I can't see to get OTA upload to work either am I missing something? I checked that ENABLE_OTA was enabled in the build flags.

Uploading .pioenvs/openevse_huzzah32/firmware.bin
19:34:15 [DEBUG]: Options: {'timeout': 10, 'esp_ip': '192.168.86.20', 'host_port': 33428, 'image': '.pioenvs/openevse_huzzah32/firmware.bin', 'host_ip': '0.0.0.0', 'auth': '', 'esp_port': 8266, 'spiffs': False, 'debug': True, 'progress': True}
19:34:15 [INFO]: Starting on 0.0.0.0:33428
19:34:15 [INFO]: Upload size: 1295600
Sending invitation to 192.168.86.20 ..........
19:35:55 [ERROR]: No response from the ESP
*** [upload] Error 1

Sending empty RAPI commands over MQTT causes crash

mosquitto_pub -h home.lan -u emonpi -P emonpimqtt2016 -n -t 'emon/openevse-a7d4/rapi/in/$FS'
MQTT received:
Topic: emon/openevse-a7d4/rapi/in
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC      : 0x4000c3f0  PS      : 0x00060a30  A0      : 0x800e8181  A1      : 0x3ffb1b90  
A2      : 0x3ffc15e0  A3      : 0x00000000  A4      : 0x00000001  A5      : 0x3ffcfd52  
A6      : 0x0000006e  A7      : 0x00000000  A8      : 0x00000000  A9      : 0x00000000  
A10     : 0x3ffb1c18  A11     : 0x00000000  A12     : 0x00000002  A13     : 0x0000ff00  
A14     : 0x00ff0000  A15     : 0xff000000  SAR     : 0x00000008  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000000  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xffffffff  

Backtrace: 0x4000c3f0:0x3ffb1b90 0x400e817e:0x3ffb1bb0 0x400e829a:0x3ffb1bd0 0x400d6999:0x3ffb1bf0 0x4017eba1:0x3ffb1c70 0x400deee7:0x3ffb1c90 0x400def02:0x3ffb1cf0 0x400e4c99:0x3ffb1d10 0x400e2c82:0x3ffb1dd0 0x400e3e65:0x3ffb1e00 0x400e42a7:0x3ffb1e60 0x400e45c6:0x3ffb1ec0 0x4017f085:0x3ffb1f20 0x400de06f:0x3ffb1f40 0x400d6402:0x3ffb1f60 0x400e9b81:0x3ffb1fb0 0x40088f69:0x3ffb1fd0
0x400e817e: String::move(String&) at /home/jeremy/.platformio/packages/framework-arduinoespressif32/cores/esp32/WString.cpp:857

0x400e829a: String::operator=(String&&) at /home/jeremy/.platformio/packages/framework-arduinoespressif32/cores/esp32/WString.cpp:857

0x400d6999: mqttmsg_callback(MongooseString, MongooseString) at /home/jeremy/Dev/JeremyPoulter/ESP8266_WiFi_v2.x.mongoose/.pio/libdeps/openevse_esp-wrover-kit/ArduinoJson_ID64/src/ArduinoJson/Json/JsonSerializer.hpp:80

0x4017eba1: std::_Function_handler<void (MongooseString, MongooseString), void (*)(MongooseString, MongooseString)>::_M_invoke(std::_Any_data const&, MongooseString&&, MongooseString&&) at /home/jeremy/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/5.2.0/functional:1871

0x400deee7: std::function<void (MongooseString, MongooseString)>::operator()(MongooseString, MongooseString) const at /home/jeremy/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/5.2.0/functional:2271
 (inlined by) MongooseMqttClient::eventHandler(mg_connection*, int, void*) at /home/jeremy/Dev/JeremyPoulter/ArduinoMongoose/src/MongooseMqttClient.cpp:96

0x400def02: MongooseMqttClient::eventHandler(mg_connection*, int, void*, void*) at /home/jeremy/Dev/JeremyPoulter/ArduinoMongoose/src/MongooseMqttClient.cpp:34

0x400e4c99: mqtt_handler at /home/jeremy/Dev/JeremyPoulter/ArduinoMongoose/src/mongoose.c:3529

0x400e2c82: mg_call at /home/jeremy/Dev/JeremyPoulter/ArduinoMongoose/src/mongoose.c:3529

0x400e3e65: mg_recv_tcp at /home/jeremy/Dev/JeremyPoulter/ArduinoMongoose/src/mongoose.c:3529
 (inlined by) mg_do_recv at /home/jeremy/Dev/JeremyPoulter/ArduinoMongoose/src/mongoose.c:2965

0x400e42a7: mg_if_can_recv_cb at /home/jeremy/Dev/JeremyPoulter/ArduinoMongoose/src/mongoose.c:3529
 (inlined by) mg_mgr_handle_conn at /home/jeremy/Dev/JeremyPoulter/ArduinoMongoose/src/mongoose.c:4080

0x400e45c6: mg_socket_if_poll at /home/jeremy/Dev/JeremyPoulter/ArduinoMongoose/src/mongoose.c:3529

0x4017f085: mg_mgr_poll at /home/jeremy/Dev/JeremyPoulter/ArduinoMongoose/src/mongoose.c:3529

0x400de06f: MongooseCore::poll(int) at /home/jeremy/Dev/JeremyPoulter/ArduinoMongoose/src/MongooseCore.cpp:38

0x400d6402: loop() at /home/jeremy/Dev/JeremyPoulter/ESP8266_WiFi_v2.x.mongoose/src/main.cpp:110

0x400e9b81: loopTask(void*) at /home/jeremy/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:19

0x40088f69: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:355 (discriminator 1)

Use Mongoose as a replacement for AsyncWebServer

Based on discussion here: me-no-dev/ESPAsyncWebServer#324 (comment) we are moving the ESP32 port to use the Mongoose via ArduinoMongoose

  • Web server
  • WiFi - needed for OpenEVSE/ESP8266_WiFi_v2.x#182
    • WiFi events
    • Hidden SSIDs ?
    • Set hostname
  • HTTP(S) clients
    • EmonCMS HTTPS client
    • OhmConnect HTTPS client
  • MQTT client
  • Certificate Management
    • Update root certificates
    • Disable root certificate validation per client
  • OTA update
    • Upload firmware via Webserver
    • Upload firmware via Arduino IDE/Platform IO
    • Check for updates and download from GitHub releases?
  • Board support - needed for OpenEVSE/ESP8266_WiFi_v2.x#182
  • Release
    • New Repository
      or
    • ESP8266 support
  • Misc
    • Async Serial read, report when not connected to OpenEVSE, #1

emoncms HTTPS posting UI

HTTPS is already supported for ESP32 however the UI needs updating to reflect this:

  • Create dropdown box to select protocol HTTP/HTTPS
  • Remove SHA1 fingerprint field as this is no longer required. This can can also be removed from EEPROM

Not plugged in notification

A few times recently I have even noticing the car or is not properly being plugged in so in the morning the car has not been charged.

It would be really good if a notification could be sent if the car is not plugged in at some specific time, eg overnight.

Some possible options could be email, SMS, Slack or other web service.

Move timer functions to WiFi module to remove the need for RTC hardware

WiFi to control sleep and charging with RAPI commands while on timers and eliminate the RTC chip. The chip and parts add significant cost to every batch of LCDs we make. Also timer functions take up considerable code space on the open_evse controller.

Time could be updated automatically via NTP and held in memory.

Add Support for RAPI 5.0.0

I added hooks to facilitate support of OCPP. In the process, RAPI got altered a bit, and became incompatible with existing code. The changes are as follows:

  1. $ST async notification replaced with $AT, which has more parameters
  2. $AB async notification is now sent on boot
  3. $GS has 2 new parameters added to it. Also, the first parameter, state, is now in hexadecimal, instead of decimal, to make it consistent with $AT (and the now deprecated $ST)
    going forwards all async new async notifications will be of form $Ax.

I was going to create a pull request, but then realized that I don't understand your code well enough to fully test it. I've put some changes into the following commit in my own branch:

lincomatic/ESP8266_WiFi_v2.x@da56fea

Please review them, and alter as needed, at your convenience.

Periodically post MQTT announce message and use bare announce/ topic

Building upon #15 it would be useful for Home Assistant integration for the Carbon Coop OpenDSR project that @beaylott is leading if:

  • The OpenEVSE Announce message was periodically published to the announce topic (every 30s) and

  • The announce message was published to the bare announce topic e.g openevse/announce rather than an ID sub topic e.g openevse/announce/<id>

What are your thoughts @jeremypoulter? I'm happy to make both these changes, I think it would make it easier for any service to integrate with OpenEVSE MQTT.

Memory leak

The free heap seems to be reducing linearly! After being running for about 24hrs the unit required a rest to become responsive. Since then, I've setup better logging to capture the freeheap to see what value resulted in a crash. I will continue to monitor

Selection_240

LCD Energy Savings (backlight off)

Add basic energy savings.

Add ability to turn of LCD back light after x minutes of inactivity with the RAPI command $FB 0.

back light will turn back on automatically with any state change.

ESP32 port

Port to the ESP32, primerially targeting the NodeMCU ESP-32S.

Suggestions: RAPI command to set over-current threshold/timeout

As far as I understand a common problem in older Nissan Leafs is that the car charger's firmware might not be fully compliant with SAE J1772. Upgrading that firmware might pose challenges as I've discovered; there seems to be not much interest from dealers and it's also not a high priority for others offering services that dealers do not offer.

It would be great if OpenEVSE would have a RAPI command that changes the default overcurrent threshold and timeout.

#define OVERCURRENT_THRESHOLD 5 // A
​#define OVERCURRENT_TIMEOUT 5000UL // ms

Use NTP to set time on OpenEVSE controller

As a first step towards #5 and negating the need for a hardware RTC, NTP time from the ESP could be used to automatically set the time on the OpenEVSE controller.

We should keep the option to "sync" the time from a web browser for the use case where no web connection is present.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.