Start a new topic

How to link OpenEVSE v4 to Arduino Uno?


Good day! I have OpenEVSE v4. Is it possible to additionally connect Arduino (UNO) and arrange data exchange between them? The garage where I charge the car is outside the WiFI network, so I want to connect the GSM module to the Arduino UNO and control the charging process via mobile communication. Is it possible? I need to know exactly the possibility of connecting OpenEVSE and Arduino. Thank you in advance for your cooperation!


If the RAPI commands are enough to do the controls you need, the arduino will communicate using the TX/RX pins.  The arduino can be powered by the OE 12 volt supply also.

I was looking through this example: https://store.openevse.com/blogs/news/15753588-openevse-remote-api-examples to try and figure out how I can get communication going between the OpenEVSE controller and an Arduino. It's not clear from the Arduino file what commands are used to get information from the EVSE controller. The Arduino seems to be waiting for the controller to send data. Is the controller constantly broadcasting information?

Most commands are initiated by the remote device. There are some asymmetric commands, sent by OpenEVSE when a state changes.


The full description of the RAPI is here:

https://github.com/lincomatic/open_evse/blob/development/firmware/open_evse/rapi_proc.h



Current version pasted below


**** RAPI protocol ****
Fx - function
Sx - set parameter
Gx - get parameter


command formats
1. with XOR checksum (recommended)
$cc pp pp ...^xk\r
2. with additive checksum (legacy)
$cc pp pp ...*ck\r
3. no checksum (FOR TESTING ONLY! DON'T USE FOR APPS)
$cc pp pp ...\r
4. checksum + sequence id (v3.0.0+)
$cc pp pp .. :ss^xk\r
\r = carriage return = 13d = 0x0D
cc = 2-letter command
pp = parameters
xk = 2-hex-digit checksum - 8-bit XOR of all characters before '^'
ck = 2-hex-digit checksum - 8-bit sum of all characters before '*'
ss = optional 2-hex-digit sequence id - response will echo the sequence id
     so that receiver can verify that the response matches the command
     ss CANNOT be 00, which is reserved as an invalid value


response format (v1.0.3-)
$OK [optional parameters]\r - success
$NK [optional parameters]\r - failure


response format (v2.0.0+)
$OK [optional parameters]^xk\r - success
$NK [optional parameters]^xk\r - failure
xk = 2-hex-digit checksum - 8-bit XOR of all characters before '^'


response format (v3.0.0+)
$OK [optional parameters] [:ss]^xk\r - success
$NK [optional parameters] [:ss]^xk\r - failure
xk = 2-hex-digit checksum - 8-bit XOR of all characters before '^'
ss = optional 2-hex-digit sequence ID which was sent with the command
     only present if a sequence ID was send with the command


asynchronous notification messages
$ST state\r - EVSE state transition - sent whenever EVSE state changes
 state: EVSE_STATE_xxx
$WF mode\r - Request client WiFi mode
 mode: WIFI_MODE_XXX
 (currently very long press (10 sec) of menu btn on OpenEVSE will send WIFI_MODE_AP_DEFAULT
v2.0.1+: 2-hex-digit XOR checksum appended to asynchronous messages


commands
F0 {1|0}- enable/disable display updates
     enables/disables g_OBD.Update()
 $F0 1^43 - enable display updates and call g_OBD.Update()
 $F0 0^42 - disable display updates
FB color - set LCD backlight color
colors:
 OFF 0
 RED 1
 YELLOW 3
 GREEN 2
 TEAL 6
 BLUE 4
 VIOLET 5
 WHITE 7
 $FB 7*03 - set backlight to white
FD - disable EVSE
 $FD*AE
FE - enable EVSE
 $FE*AF
FP x y text - print text on lcd display
FR - restart EVSE
 $FR*BC
FS - sleep EVSE
 $FS*BD
FF - enable/disable feature
 $FF feature_id 0|1
 0|1 0=disable 1=enable
 feature_id:
  D = Diode check
  E = command Echo
   use this for interactive terminal sessions with RAPI.
   RAPI will echo back characters as they are typed, and add a <LF> character
   after its replies. Valid only over a serial connection, DO NOT USE on I2C
  F = GFI self test
  G = Ground check
  R = stuck Relay check
  T = temperature monitoring
  V = Vent required check
 $FF D 0 - disable diode check
 $FF G 1 - enable ground check
S0 0|1 - set LCD type
 $S0 0*F7 = monochrome backlight
 $S0 1*F8 = RGB backlight
S1 yr mo day hr min sec - set clock (RTC) yr=2-digit year
S2 0|1 - disable/enable ammeter calibration mode - ammeter is read even when not charging
 $S2 0*F9
 $S2 1*FA
S3 cnt - set charge time limit to cnt*15 minutes (0=disable, max=255)
 NOTES:
  - allowed only when EV connected in State B or C
  - temporarily disables delay timer until EV disconnected or limit reached
  - actually *extends* the current charging session. So if current session
    has already charged for 2hrs, then $S3 2 ends charging after total 2:30
 response:
  $OK - accepted
  $NK - invalid EVSE state
S4 0|1 - set auth lock (needs AUTH_LOCK defined and AUTH_LOCK_REG undefined)
   0 = unlocked
   1 = locked - EVSE won't charge until unlocked
   when auth lock is on, will not transition to State C and a lock icon is
   displayed in States A & B.
SA currentscalefactor currentoffset - set ammeter settings
SC amps [V]- set current capacity
 response:
   if amps < minimum current capacity, will set to minimum and return $NK amps
   if amps > maximum current capacity, will set to maximum and return $NK amps
   otherwise return $OK amps
   default action is to save new current capacity to EEPROM.
   if V is specified, then new current capacity is volatile, and will be
     reset to previous value at next reboot
(DEPRECATED) SD 0|1 - disable/enable diode check
 $SD 0*0B
 $SD 1*0C
(DEPRECATED) SE 0|1 - disable/enable command echo
 $SE 0*0C
 $SE 1*0D
 use this for interactive terminal sessions with RAPI.
 RAPI will echo back characters as they are typed, and add a <LF> character
 after its replies. Valid only over a serial connection, DO NOT USE on I2C
(DEPRECATED) SF 0|1 - disable/enable GFI self test
 $SF 0*0D
 $SF 1*0E
(DEPRECATED) SG 0|1 - disable/enable ground check
 $SG 0*0E
 $SG 1*0F
SH kWh - set cHarge limit to kWh
 NOTES:
  - allowed only when EV connected in State B or C
  - temporarily disables delay timer until EV disconnected or limit reached
  - actually *extends* the charge to the limit. So say, current session has
    already charged 10kWh, $SH 5 will charge until 15kWh
 response:
  $OK - accepted
  $NK - invalid EVSE state
SK - set accumulated Wh (v1.0.3+)
 $SK 0*12 - set accumulated Wh to 0
SL 1|2|A  - set service level L1/L2/Auto
 $SL 1*14
 $SL 2*15
 $SL A*24
SM voltscalefactor voltoffset - set voltMeter settings
(DEPRECATED) SR 0|1 - disable/enable stuck relay check
 $SR 0*19
 $SR 1*1A
ST starthr startmin endhr endmin - set timer
 $ST 0 0 0 0*0B - cancel timer
(DEPRECATED)SV 0|1 - disable/enable vent required
 $SV 0*1D
 $SV 1*1E
G0 - get EV connect state
 response: $OK connectstate
 connectstate: 0=not connected, 1=connected, 2=unknown
 -> connectstate is unknown when EVSE pilot is -12VDC
G3 - get time limit
 response: $OK cnt
 cnt*15 = minutes
        = 0 = no time limit
G4 - get auth lock (needs AUTH_LOCK defined and AUTH_LOCK_REG undefined)
 response: $OK lockstate
  lockstate = 0=unlocked, =1=locked
GA - get ammeter settings
 response: $OK currentscalefactor currentoffset
 $GA*AC
GC - get current capacity range in amps
 response: $OK minamps maxamps
 $GC*AE
GD - get Delay timer
 response: $OK starthr startmin endhr endmin
   all values decimal
   if timer disabled, starthr=startmin=endhr=endmin=0
GE - get settings
 response: $OK amps(decimal) flags(hex)
 $GE*B0
GF - get fault counters
 response: $OK gfitripcnt nogndtripcnt stuckrelaytripcnt (all values hex)
 maximum trip count = 0xFF for any counter
 $GF*B1
GG - get charging current and voltage
 response: $OK milliamps millivolts
 AMMETER must be defined in order to get amps, otherwise returns -1 amps
 VOLTMETER must be defined in order to get voltage, otherwise returns -1 volts
 $GG*B2
GH - get cHarge limit
 response: $OK kWh
 kWh = 0 = no charge limit
GM - get voltMeter settings
 response: $OK voltcalefactor voltoffset
 $GM^2E
GO get Overtemperature thresholds
 response: $OK ambientthresh irthresh
 thresholds are in 10ths of a degree Celcius
 $GO^2C
GP - get temPerature (v1.0.3+)
 $GP*BB
 response: $OK ds3231temp mcp9808temp tmp007temp
 ds3231temp - temperature from DS3231 RTC
 mcp9808temp - temperature from MCP9808
 tmp007temp - temperature from TMP007
 all temperatures are in 10th's of a degree Celcius
 if any temperature sensor is not installed, its return value is -2560
GS - get state
 response: $OK evsestate elapsed
 evsestate(dec): EVSE_STATE_xxx
 elapsed(dec): elapsed charge time in seconds of current or last charging session
 $GS*BE
GT - get time (RTC)
 response: $OK yr mo day hr min sec       yr=2-digit year
 $GT*BF
GU - get energy usage (v1.0.3+)
 $GU*C0
 response: $OK Wattseconds Whacc
 Wattseconds - Watt-seconds used this charging session, note you'll divide Wattseconds by 3600 to get Wh
 Whacc - total Wh accumulated over all charging sessions, note you'll divide Wh by 1000 to get kWh
GV - get version
 response: $OK firmware_version protocol_version
 $GV*C1
T commands for debugging only #define RAPI_T_COMMMANDS
T0 amps - set fake charging current
 response: $OK
 $T0 75
 *

Chris, thanks for the quick reply. If you look at this code: https://github.com/chris1howell/OpenEVSE_RAPI_Neo/blob/master/OpenEVSE_neo_RAPI.ino

where does the Arduino initiate the communication with the OpenEVSE controller?

That was a display only, so it was just waiting for state changes and updating the display.

OK, got it! How were they wired? Arduino's RX and TX pins? To which pins on the OpenEVSE board?

Hi Chris,


I finally got my EVSE Controller and have been trying to establish serial communication with my Arduino Uno. I'm almost there, but I am having a little bit of trouble. Here is my setup: Arduino RX -> OpenEVSE TX, Arduino TX -> OpenEVSE RX, Arduino 5V - OpenEVSE 5V, Arduino GND - OpenEVSE GND. My Arduino is connected to my computer via USB.


This is the Arduino code I wrote: 


#include <SoftwareSerial.h>

 

SoftwareSerial mySerial(12,13);

int incomingStuff[15];

 

void setup() {

  Serial.begin(9600);

 

}

 

void loop() {

  mySerial.begin(115200);

  mySerial.println("$G0");

  for(int i=0; i<15; i++){

    incomingStuff[i] = mySerial.read();

    Serial.print(incomingStuff[i]);Serial.print(" i:");

    Serial.println(i);

  }

 

}


I read the following on my serial monitor: 


36 i:1

79 i:2

75 i:3

32 i:4

156 i:5

175 i:6

51 i:7

49 i:8

13 i:9


I know that the decimal equivalent of '$' = 36, 'O'=79, 'K'=75, ' '=32 , so I am getting the first part of the response: "$OK", but I don't understand the values I am getting after that part. I was just expecting a 0,1,or 2 since I sent the G0 command. 


Thanks in advance for your help



It looks like the problem was because the software serial is at its limit at 115200 bps. I switched to Arduino Mega which has additional hardware serial ports, and it seems to be working fine.

Login or Signup to post a comment