I use Domoticz to improve my PV ownconsumtion and charge our new EV car (Nissan Leaf ZE1) with photovoltaic power.
A raspberry pi3, a Razberry board, some z-wave plugs and a TCP/IP controllable EV wallbox (with a Phoenix Contact EM-CP-PP-ETH charge control) is my hardware setup. I read data from the Fronius inverter with http requests (LUA Script) and control the EV wallbox also with a short LUA script to send TCP modbus commands. Charging power can be set from 6A (1,4kW) to 20A (4,6kW) in 2A steps. Since march we charged 270kWh green energy into the Leaf.
EV car charge with PV
Moderator: leecollings
- mgerhard74
- Posts: 48
- Joined: Friday 28 July 2017 18:28
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.7
- Location: Austria, Upperaustria
- Contact:
EV car charge with PV
Domoticz improves my photovoltaik ownconsumption (Rpi3, wifi plugs) - PV 6,5kWp (Fronius Symo inverter) - 10kWh PV batterie - Nissan Leaf2 (40kWh) and Kia eNiro (64kWh)
-
- Posts: 744
- Joined: Saturday 30 May 2015 22:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Contact:
Re: EV car charge with PV
Interesting. Can you see how effectively you harvest your pv energy in your car? Can you keep the energy pull from the grid close to zero during charging?
- mgerhard74
- Posts: 48
- Joined: Friday 28 July 2017 18:28
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.7
- Location: Austria, Upperaustria
- Contact:
Re: EV car charge with PV
Hello Jake, difficult to answer, because some other devices are taking enery of PV: fridge, pool pump, washing machine, wifi routers, cooking,....
In fact, the LUA script can react on taking enery from the grid. In my case, i decrease charging current on power consumption is greater than 200 watt. Easy to change this value to 0. So no grid power will charge the car.
Our PV ownconsumtion rate decrease from about 33% to 42% in april and 55% in may. Every kilometer of our Nissan Leaf is free. (and of course free of fuel and co2)
Gerhard
And a picture of our Nissan Leaf:
In fact, the LUA script can react on taking enery from the grid. In my case, i decrease charging current on power consumption is greater than 200 watt. Easy to change this value to 0. So no grid power will charge the car.
Our PV ownconsumtion rate decrease from about 33% to 42% in april and 55% in may. Every kilometer of our Nissan Leaf is free. (and of course free of fuel and co2)
Gerhard
Code: Select all
-- ---------------------------------------------------------------------
-- Control of EV Wallbox with Phoenix Contact EM-CP-PP-ETH
-- How to install mbtget: https://github.com/sourceperl/mbtget
-- IP-address of Phoenix Contact EM-CP-PP-ETH: 10.0.0.150
-- Turn charge on or off; change current from 6 to 20 ampere
-- (c) 2018, Ing. Gerhard Mitterbaur
-- ---------------------------------------------------------------------
local nSmartmeter = 0
Debug = "YES" -- turn debugging on "YES" or off "NO"
commandArray = {}
nSmartmeter= tonumber(otherdevices_svalues['Smartmeter'])
if (otherdevices['7 Wallbox'] == 'On') then
if Debug=="YES" then
print ("Smartmeter: " ..tostring(nSmartmeter))
end
-- Very high photovoltaic power
if (nSmartmeter < -1300) then
if (uservariables["WallboxOn"] == 0) then
-- Start charge EV
os.execute("mbtget -a 400 -u 180 -w5 1 10.0.0.150")
-- Current 6A (1400 Watt)
os.execute("mbtget -a 300 -u 180 -w6 6 10.0.0.150")
commandArray['Variable:WallboxOn'] = "1"
commandArray['Variable:WallboxAmpere'] = "6"
commandArray['Variable:WallboxOffCount'] = "0"
end
end
-- high photovoltaic power, Wallbox is still "on", increase charge
if (nSmartmeter < -400) then
if (uservariables["WallboxOn"] == 1) then
-- Start charge EV
os.execute("mbtget -a 400 -u 180 -w5 1 10.0.0.150")
commandArray['Variable:WallboxOffCount'] = "0"
if (uservariables["WallboxAmpere"] == 6) then
-- Current 8A
os.execute("mbtget -a 300 -u 180 -w6 8 10.0.0.150")
commandArray['Variable:WallboxAmpere'] = "8"
elseif (uservariables["WallboxAmpere"] == 8) then
-- Current 10A
os.execute("mbtget -a 300 -u 180 -w6 10 10.0.0.150")
commandArray['Variable:WallboxAmpere'] = "10"
elseif (uservariables["WallboxAmpere"] == 10) then
-- Current 12A
os.execute("mbtget -a 300 -u 180 -w6 12 10.0.0.150")
commandArray['Variable:WallboxAmpere'] = "12"
elseif (uservariables["WallboxAmpere"] == 12) then
-- Current 14A
os.execute("mbtget -a 300 -u 180 -w6 14 10.0.0.150")
commandArray['Variable:WallboxAmpere'] = "14"
elseif (uservariables["WallboxAmpere"] == 14) then
-- Current 16A
os.execute("mbtget -a 300 -u 180 -w6 16 10.0.0.150")
commandArray['Variable:WallboxAmpere'] = "16"
elseif (uservariables["WallboxAmpere"] == 16) then
-- Current 18A
os.execute("mbtget -a 300 -u 180 -w6 18 10.0.0.150")
commandArray['Variable:WallboxAmpere'] = "18"
end
elseif (uservariables["WallboxAmpere"] == 18) then
-- Current 20A
os.execute("mbtget -a 300 -u 180 -w6 20 10.0.0.150")
commandArray['Variable:WallboxAmpere'] = "20"
end
end
end
-- low photovoltaic power, decrease charge
if (nSmartmeter > 200) then
if (uservariables["WallboxOn"] == 1) then
if (uservariables["WallboxAmpere"] == 20) then
-- Current 18A
os.execute("mbtget -a 300 -u 180 -w6 18 10.0.0.150")
commandArray['Variable:WallboxAmpere'] = "18"
elseif (uservariables["WallboxAmpere"] == 18) then
-- Current 16A
os.execute("mbtget -a 300 -u 180 -w6 16 10.0.0.150")
commandArray['Variable:WallboxAmpere'] = "16"
elseif (uservariables["WallboxAmpere"] == 16) then
-- Current 14A
os.execute("mbtget -a 300 -u 180 -w6 14 10.0.0.150")
commandArray['Variable:WallboxAmpere'] = "14"
elseif (uservariables["WallboxAmpere"] == 14) then
-- Current 12A
os.execute("mbtget -a 300 -u 180 -w6 12 10.0.0.150")
commandArray['Variable:WallboxAmpere'] = "12"
elseif (uservariables["WallboxAmpere"] == 12) then
-- Current 10A
os.execute("mbtget -a 300 -u 180 -w6 10 10.0.0.150")
commandArray['Variable:WallboxAmpere'] = "10"
elseif (uservariables["WallboxAmpere"] == 10) then
-- Current 8A
os.execute("mbtget -a 300 -u 180 -w6 8 10.0.0.150")
commandArray['Variable:WallboxAmpere'] = "8"
elseif (uservariables["WallboxAmpere"] == 8) then
-- Current 6A
os.execute("mbtget -a 300 -u 180 -w6 6 10.0.0.150")
commandArray['Variable:WallboxAmpere'] = "6"
end
end
end
-- very low photovoltaic power, stop charge
if (nSmartmeter > 500) then
if (uservariables["WallboxOn"] == 1) then
if (uservariables["WallboxAmpere"] == 6) then
-- Count to 5 before turn off charging
if (uservariables["WallboxOffCount"] == 0) then
commandArray['Variable:WallboxOffCount'] = "1"
elseif (uservariables["WallboxOffCount"] == 1) then
commandArray['Variable:WallboxOffCount'] = "2"
elseif (uservariables["WallboxOffCount"] == 2) then
commandArray['Variable:WallboxOffCount'] = "3"
elseif (uservariables["WallboxOffCount"] == 3) then
commandArray['Variable:WallboxOffCount'] = "4"
elseif (uservariables["WallboxOffCount"] == 4) then
commandArray['Variable:WallboxOffCount'] = "5"
elseif (uservariables["WallboxOffCount"] == 5) then
-- Stop charge EV
os.execute("mbtget -a 400 -u 180 -w5 0 10.0.0.150")
commandArray['Variable:WallboxAmpere'] = "0"
commandArray['Variable:WallboxOn'] = "0"
commandArray['Variable:WallboxOffCount'] = "0"
end
end
end
end
else
-- Current 16A
os.execute("mbtget -a 300 -u 180 -w6 16 10.0.0.150")
-- Switch Wallbox to OFF: stop charge
os.execute("mbtget -a 400 -u 180 -w5 0 10.0.0.150")
commandArray['Variable:WallboxAmpere'] = "0"
commandArray['Variable:WallboxOn'] = "0"
commandArray['Variable:WallboxOffCount'] = "0"
end
if Debug=="YES" then
print ("Wallbox on/off " .. uservariables["WallboxOn"])
print ("Wallbox Ampere " .. uservariables["WallboxAmpere"])
print ("Wallbox Off Count " .. uservariables["WallboxOffCount"])
end
return commandArray
Domoticz improves my photovoltaik ownconsumption (Rpi3, wifi plugs) - PV 6,5kWp (Fronius Symo inverter) - 10kWh PV batterie - Nissan Leaf2 (40kWh) and Kia eNiro (64kWh)
-
- Posts: 660
- Joined: Thursday 10 November 2016 9:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: EV car charge with PV
Hello,
A few years ago, PV was indeed considered such a waste that it was only considered to electrify areas that could not be wired easily to the public electric network! Now governments give money for equipments that will struggle for decades to just give back the energy that was needed to manufacture them, provided you don't have an heavy wind or hail period that'll break everything. As well as for electric cars that overweight their fuel counterparts by 30% in average.
This is just crazy.
If you consider a french Renault Zoe (maybe the most successful electric car in Fra,ce: A city car weighting 1450kg!) compared to a suzuki swift (another city car, with current generation at 900kg in average after loosing 150kg since last generation), that can be up to 60% overweight for the electric version that will only allow you to drive 200/300km!
=> With current PV and battery tech, it's everything but CO2 free.
The only interest is money: Buying your next 2 decades electricity once now (if you're lucky), at current energy cost that drive PV panels/battery manufacturing costs. As energy will cost more and more, you main save money.
But in the end, if everyone does the same, this will just accelerate our current problems.
An effort on current average car weight and aerodynamics (forget SUV's and such small dick compensators, as marketing guys qualify them in the automotive industry!) with current engine technology could do the job of an electric counterpart for half the weight at 3 to 5l/100km fuel consumption.
The miracle electric battery tech, we still wait for it since the very first electric car, named "Jamais Contente" (="Never Happy"!):
https://fr.wikipedia.org/wiki/La_Jamais_contente
Well, as usual, free until you consider all the energy that was used for battery manufacturing and needed ore extraction... Same for PV panels: several 10's of sq-meters resulting from another heavy energy eater, silicon foundry. Lets' not speak about recycling side.mgerhard74 wrote: ↑Sunday 20 May 2018 17:21 Our PV ownconsumtion rate decrease from about 33% to 42% in april and 55% in may. Every kilometer of our Nissan Leaf is free. (and of course free of fuel and co2)
A few years ago, PV was indeed considered such a waste that it was only considered to electrify areas that could not be wired easily to the public electric network! Now governments give money for equipments that will struggle for decades to just give back the energy that was needed to manufacture them, provided you don't have an heavy wind or hail period that'll break everything. As well as for electric cars that overweight their fuel counterparts by 30% in average.
This is just crazy.
If you consider a french Renault Zoe (maybe the most successful electric car in Fra,ce: A city car weighting 1450kg!) compared to a suzuki swift (another city car, with current generation at 900kg in average after loosing 150kg since last generation), that can be up to 60% overweight for the electric version that will only allow you to drive 200/300km!
=> With current PV and battery tech, it's everything but CO2 free.
The only interest is money: Buying your next 2 decades electricity once now (if you're lucky), at current energy cost that drive PV panels/battery manufacturing costs. As energy will cost more and more, you main save money.
But in the end, if everyone does the same, this will just accelerate our current problems.
An effort on current average car weight and aerodynamics (forget SUV's and such small dick compensators, as marketing guys qualify them in the automotive industry!) with current engine technology could do the job of an electric counterpart for half the weight at 3 to 5l/100km fuel consumption.
The miracle electric battery tech, we still wait for it since the very first electric car, named "Jamais Contente" (="Never Happy"!):
https://fr.wikipedia.org/wiki/La_Jamais_contente
- psubiaco
- Posts: 222
- Joined: Monday 20 August 2018 9:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Italy
- Contact:
Re: EV car charge with PV
Hi Gerhard,
well done!
Can you suggest a cheap and powerful wallbox that can be controlled by UDP/IP or TCP/IP ?
I have to do the same as you, already have energy meter measuring the import/export power from grid, and want to charge the BEV car (Kia e-Niro) with max 5-7kW power, monophase.
Thanks a lot.
Paolo
well done!
Can you suggest a cheap and powerful wallbox that can be controlled by UDP/IP or TCP/IP ?
I have to do the same as you, already have energy meter measuring the import/export power from grid, and want to charge the BEV car (Kia e-Niro) with max 5-7kW power, monophase.
Thanks a lot.
Paolo
Paolo
--
I use DomBus modules to charge EV car, get a full alarm system, control heat pump, fire alarm detection, lights and much more. Video
Facebook page - Youtube channel
--
I use DomBus modules to charge EV car, get a full alarm system, control heat pump, fire alarm detection, lights and much more. Video
Facebook page - Youtube channel
- mgerhard74
- Posts: 48
- Joined: Friday 28 July 2017 18:28
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.7
- Location: Austria, Upperaustria
- Contact:
Re: EV car charge with PV
Hi Paolo,
Sorry for the delay. I use a simple wallbox from a local company. The main part is a Phoenix Contact EM-CP-PP-ETH charge control, a power meter is optional, a residual current circuit breaker and a 3-phase relay. A key switch can start charge manualy. Some Leds at the front. (Charge, connect, failure)
In Domoticz:
Install mbtget: https://github.com/sourceperl/mbtget
Ip of my charge control is 10.0.0.150
Lua Script to start charge at 1400Watt:
os.execute("mbtget -a 400 -u 180 -w5 1 10.0.0.150")
os.execute("mbtget -a 300 -u 180 -w6 6 10.0.0.150")
Switch to 8A:
os.execute("mbtget -a 300 -u 180 -w6 8 10.0.0.150")
Stop charge:
os.execute("mbtget -a 400 -u 180 -w5 0 10.0.0.150")
Gerhard
Sorry for the delay. I use a simple wallbox from a local company. The main part is a Phoenix Contact EM-CP-PP-ETH charge control, a power meter is optional, a residual current circuit breaker and a 3-phase relay. A key switch can start charge manualy. Some Leds at the front. (Charge, connect, failure)
In Domoticz:
Install mbtget: https://github.com/sourceperl/mbtget
Ip of my charge control is 10.0.0.150
Lua Script to start charge at 1400Watt:
os.execute("mbtget -a 400 -u 180 -w5 1 10.0.0.150")
os.execute("mbtget -a 300 -u 180 -w6 6 10.0.0.150")
Switch to 8A:
os.execute("mbtget -a 300 -u 180 -w6 8 10.0.0.150")
Stop charge:
os.execute("mbtget -a 400 -u 180 -w5 0 10.0.0.150")
Gerhard
Domoticz improves my photovoltaik ownconsumption (Rpi3, wifi plugs) - PV 6,5kWp (Fronius Symo inverter) - 10kWh PV batterie - Nissan Leaf2 (40kWh) and Kia eNiro (64kWh)
-
- Posts: 24
- Joined: Sunday 10 February 2019 16:22
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: EV car charge with PV
Hi and thanks for this topic!
Even quite old, I am really interested in it! It is quite an anticipation as: 1° I do not yet have my EV Leaf and 2° I do not have my photovoltaic power (kind of delay due to a virus, you might have heard about that
)
The first step I am trying to clarify is the hardware part: why are you talking about RPI2, Razberry etc in the first topic? Because in your last post, seems like the only needed hardware is the charge control, no?
And what's the soft config? Only the LUA Script you provided (with mbtget) or is there anything to add?
To share my actual project: I would like to adapt my EVBOX Elvi power according the house consumption at a very first step (in order to avoid consumming to much power for charging the car if the air conditionner is on, for example). Then, once my photovoltaic power will be installed, I will do the same, but adding the photovoltaic power as another variable to be considered in the EVBOX power delivered.
Thanks in advance for your help and clarification
Even quite old, I am really interested in it! It is quite an anticipation as: 1° I do not yet have my EV Leaf and 2° I do not have my photovoltaic power (kind of delay due to a virus, you might have heard about that

The first step I am trying to clarify is the hardware part: why are you talking about RPI2, Razberry etc in the first topic? Because in your last post, seems like the only needed hardware is the charge control, no?
And what's the soft config? Only the LUA Script you provided (with mbtget) or is there anything to add?
To share my actual project: I would like to adapt my EVBOX Elvi power according the house consumption at a very first step (in order to avoid consumming to much power for charging the car if the air conditionner is on, for example). Then, once my photovoltaic power will be installed, I will do the same, but adding the photovoltaic power as another variable to be considered in the EVBOX power delivered.
Thanks in advance for your help and clarification

- mgerhard74
- Posts: 48
- Joined: Friday 28 July 2017 18:28
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.7
- Location: Austria, Upperaustria
- Contact:
Re: EV car charge with PV
Hi, i use a RPI3. The razberry board is only neccessary to control z-wave devices. (plugs, thermostats,....)
So you need a RPI3, you must have the smartmeter value or PV energy value to control the EV charge unit. The main part of the charge unit is a Phoenix Contact EM-CP-PP-ETH charge control.
So you need a RPI3, you must have the smartmeter value or PV energy value to control the EV charge unit. The main part of the charge unit is a Phoenix Contact EM-CP-PP-ETH charge control.
Domoticz improves my photovoltaik ownconsumption (Rpi3, wifi plugs) - PV 6,5kWp (Fronius Symo inverter) - 10kWh PV batterie - Nissan Leaf2 (40kWh) and Kia eNiro (64kWh)
Who is online
Users browsing this forum: No registered users and 1 guest