logo elektroda
logo elektroda
X
logo elektroda

Sharing EV Chargers using OpenBeken - charging limiter - detailed explanation and autoexec script

Zogdan 3174 3

TL;DR

  • OpenBeken’s ChargingLimit driver can turn a Tuya-based power meter into a shared EV-charger limiter for apartment, guest, or business charging scenarios.
  • The setup keeps the charger unchanged and places an OBK-enabled meter in front of it, then uses `chSetupLimit` and autoexec scripting to start, stop, and publish session status.
  • The example targets OpenBeken release 1.17.213 and limits channel 5 to 5000 Wh or 3600 seconds with `POWER OFF`.
  • Presets for guests, friends, and tests show how to offer fixed charging packages, but load balancing remains a major challenge on limited supply like 5.7 kW.
  • Installation, protections, and compliance still require a qualified installer.
Generated by the language model.
ADVERTISEMENT
📢 Listen (AI):
  • Sharing EV Chargers using OpenBeken - charging limiter

    Electric cars connected to chargers in front of a building.


    The use of Electric Vehicles (EVs) is increasing rapidly. However, this growth comes with challenges related to charging infrastructure and battery limitations.

    The worst nightmare for owners of electric vehicles is being left without power. Wouldn't it be nice if people were willing to share some electricity for those in need?

    Private charging stations, while convenient, have their drawbacks. They often require a high upfront cost (including installation), and for individuals living in apartments or without private parking, installing a home charger is not an option.

    You might consider purchasing a larger battery to extend driving range, but this will increase weight and cost.

    Shared EV chargers can provide a small contribution to creating a more accessible charging infrastructure.

    Electrical Situation and types of chargers

    Let's consider a regular situation with a single-phase installation. In this scenario, "slow charging" typically occurs with a level 2 charger that uses AC power. The charger is integrated within the vehicle, while the charge controller determines the maximum power that can be drawn. The maximum current is usually set between 10 and 32 A, resulting in a charging power starting at 3.7 kW. To manage the operation of the charger, and to manage the PWM signal to indicate the maximum power, controllers like the EKEPC2-C/S are often used.

    However, a controller alone is insufficient as you also need features like galvanic disconnect, current measurement, leak current protection, and overcurrent protection. That is why I would refrain from building one yourself. Getting all parts and certification ( insurance ) would be expensive as well.

    Chargers are often expensive due to their "smart" features, such as an LCD screen, a (privacy invading) mobile app, bluetooth, Wi-Fi, NFC, and a ( closed down, yet another dependency) cloud-based platform for charger management and tracking sessions. These smart chargers can easily cost around 1000 euros.

    On the other hand, there are also more reasonable chargers like those made by doktorvolt.pl, which come fully assembled with all required protections and the corresponding controller built in. These types of chargers are easy in operation and have no more than a start/stop button, an indicator LED, and a socket for the charging cable.

    Apart from that we should consider the right to repair and the e-waste : a fully packed custom board leaves us with no other option than to replace the whole charger. Using standard DIN components is really a better choice.
    Internal view of an electrical box with a controller.


    While you may opt for a "smart" charger promising flawless global sharing, there are numerous suppliers offering peer-to-peer EV charging, but as this market gets saturated, there will likely be a major consolidation. Betting on the right platform is not easy, and even promised interoperability through OCPP or the new IEC 63110 protocol does not mean that operation or integration will be easy.

    What we are looking for is a simple way to limit the use of a shared resource.

    Sharing the charger

    If you intend to share your charger, you might think of the following scenarios:

    1. Sharing with someone you know and establishing an agreement about the costs.
    2. Sharing with visiting guests, friends, or family.
    3. Sharing with clients in exchange for expenditures at your business, such as a café or hotel.

    Scenario 1 may involve some hassle and requires a level of trust, but it is completely feasible. For instance, you could use two energy meters that can be switched between users.

    Scenario 2 promotes friendly and social behavior, but you don't want to bankrupt yourself over it.

    Scenario 3 would also require some form of limitation, as charging 10 kWh for a single cup of coffee can quickly undermine your business model.

    Using OBK

    Openbeken (OBK) is an alternative firmware for smart IOT devices.

    Let's assume you have an OBK-enabled Tuya-based Power Meter / Switch / Protector like the Tomzn TOML-VA (Link), providing access to total power data through a Tuya channel.

    Further we assume that your minimal version is OpenBeken release 1.17.213, where the chargingLimit driver was introduced. See the code

    As a charger we assume you have a Single phase charger (max 32 A , 7.3 kW) . We do not modify the charger. The power meter is installed in front of the charger. You can set the built in protections from the meter.

    (Warning / Disclaimer: You must follow all regulations, permissions, contractual obligations, warranty, and safety procedures specific to your situation. Chargers should be installed and checked by a qualified installer.)

    For scenario 1, scripting an OBK-enabled meter with different users can be an option. OBK would post the totals of each charging session, along with the "userid" variable, to a web-based data collection endpoint. This would also allow for registering different tariffs, although I have not found an existing script to fulfill this functionality yet.

    For scenario 2, the "ChargeLimit" driver in OBK can be used. It enables setting a maximum power limit and/or time window for supplying power to the charger. For example, you can restrict the charging time to a maximum of 60 minutes and the power to a maximum of 10 kWh. If either limit is reached, the charging session automatically stops by disconnecting the power to the charger.

    In both scenarios, when starting the charging session either via MQTT or the OBK GUI, the person wishing to charge would simply connect the cable between their vehicle and the charger to initiate charging.

    For scenario 3, the "ChargeLimit" driver can also be employed. Presets can be easily set up with scripting in OBK, such as an "electrical step" that requires more time but less power, or a "small client" preset that allows for a maximum of 30 minutes and 5 kWh. If you want to charge, you can select a preset like "20 kWh, 2 hours charge (10 EUR)".

    At any time, you can remotely stop the charging session or monitor how much power and time remain.

    Setting up OBK

    The minimal setup would look like this :

    
    // start the Chargginglimit driver
    startDriver ChargingLimit
    
    // set up the limit 
    // suppose the total power is measured in channel 5
    // chSetupLimit (channel to watch)  (max power) (max time) action to perform
    chSetupLimit 5 5000 3600 "POWER OFF"
    


    In this case it would mean we monitor channel 5 for power, and allow maximum 5000 Wh = 5KWh or maximum 3600 seconds (1 hour)
    You can find more at github

    An example of how that would look (with presets via scripting) :

    OpenBeken EV charger user interface with charging mode and power limit settings.


    (1) re(start) charging session
    (2) enable/disable charger mode
    (3) set maximum power for the session
    (4) set maximum time for the session
    (5) or select a preset
    (6) current status of the session, how much power or time is left

    Possible Improvements

    One significant challenge is load balancing. If your total system has a hard limit, such as an electricity contract allowing 5.7 kW (25A) maximum, but you want to provide the maximum power available for charging when no other users (e.g., water boiler) are consuming power, you will need two power meters and a way to communicate the maximum allowed current to the controller. Some smart chargers offer an RS485 current meter that communicates with the charger, but this needs to be done fast (reading every second) to prevent tripping the main fuse.

    Summary

    Using OBK provides a low-tech (or more appropriately, appropriate tech) option for sharing your EV charger. With its powerful scripting capabilities and flexible driver system, OBK serves as a good starting point for adding additional functionality to your charger. Moreover, since the limits you set can be assigned to a non-power metering Tuya channel, this functionality can be extended to limit other sensor values as well.

    Any suggestion or improvement is welcome.

    Thanks to openshwprojects

    Autoexec.bat :

    startDriver httpButtons
    startDriver TuyaMCU
    startDriver NTP
    
    linkTuyaMCUOutputToChannel 16 1 1
    setChannelType 1 toggle
    
    setChannelType 2 Voltage_div10
    
    setChannelType 3 Power
    
    setChannelType 4 Current_div1000
    
    linkTuyaMCUOutputToChannel 1 0 5
    setChannelType 5 EnergyTotal_kWh_div100
    
    linkTuyaMCUOutputToChannel 6 RAW_TAC2121C_VCP
    
    linkTuyaMCUOutputToChannel 101 0 6
    setChannelType 6 Temperature_div10
    
    setChannelType 7 Error
    
    
    // *******************************
    // Charger setup 
    
    // We use toggle 29 to enable/disable the charger mode
    // while enabling, we start a new cycle immediately
    
    setChannelType 29 Toggle
    SetChannelLabel 29 "Charger mode"
    addChangeHandler Channel29 == 1 startchargermode
    addChangeHandler Channel29 == 0 stopchargermode
    
    // disable driver by default after restart 
    SetChannel 29 0
    
    // (re)start session when toggled
    addChangeHandler Channel1 == 1 startsession  
    addChangeHandler Channel1 == 0 stopsession
    
    // disable output by default after restart 
    setChannel 1 0
    
    // we keep the maximum time in channel 30 ( $CH30)
    setChannelType 30 TextField
    SetChannelLabel 30 "30 : Max Power (Wh)"
    setChannel 30 2
    
    // we keep the maximum time in channel 31 ( $CH31)
    setChannelType 31 TextField
    SetChannelLabel 31 "31 : Max Time (Seconds)"
    setChannel 31 60
    
    // chargermode
    
    alias startchargermode backlog startDriver ChargingLimit; publish charging/driver "started";  startsession; 
    alias stopchargermode backlog stopDriver ChargingLimit; publish charging/driver "stopped"; stopsession;
    
    // charging sessions
    
    alias startsession backlog setChannel 1 1; chSetupLimit 3 $CH30 $CH31 "POWER OFF"; publish charging/status "started" ; publish charging/status/starthour $hour ; publish charging/status/startminute $minute ; publish charging/status/stophour 0; publish charging/status/stopminute 0;
    
    alias stopsession backlog setChannel 1 0; publish charging/status "stopped"; publish charging/status/stophour $hour; publish charging/status/stopminute $minute;
    // todo : timestamp instead of hour minute
    
    // some presets 
    alias presetguests backlog setChannel 30 5000; setChannel 31 3600;
    alias presetfriends backlog setChannel 30 10000; setChannel 31 7200;
    alias presettest backlog setChannel 30 2; setChannel 31 10;
    
    setButtonEnabled 0 1
    setButtonLabel 0 "Preset guests 5 KWh / 1 Hour" 
    setButtonCommand 0 presetguests
    setButtonColor 0 "#56b08f"
    
    setButtonEnabled 1 1
    setButtonLabel 1 "Preset Friends 10 KWh / 2 Hours" 
    setButtonCommand 1 presetfriends
    setButtonColor 1 "#56b08f"
    
    setButtonEnabled 2 1
    setButtonLabel 2 "Preset Test 2 Wh / 10 sec" 
    SetButtonCommand 2 presettest
    setButtonColor 2 "#56b08f"
    

    Cool? Ranking DIY
    About Author
    Zogdan
    Level 10  
    Offline 
    Zogdan wrote 25 posts with rating 13, helped 6 times. Been with us since 2023 year.
  • ADVERTISEMENT
  • #2 20699074
    metalMANiu
    Level 21  
    Posts: 619
    Help: 11
    Rate: 241
    It would be better to post the article in the original language - English.

    The machine-translated one requires knowledge of both Polish and English (to be able to "decode" the original word and make the correct translation yourself).

    If this article is aimed at thousands of people and you can't find one person to translate (or at least correct the blatant nonsense produced in the translation), then I don't know...
  • ADVERTISEMENT
  • #3 20699277
    gulson
    System Administrator
    Posts: 29343
    Help: 148
    Rate: 6023
    You're right, the original is here:
    https://www.elektroda.com/rtvforum/topic3996220.html
    I like the idea of sharing and sharing the electrical installation for the EV charger.
    If you can do simple management with Tuya, so much the better.
  • #4 20707762
    tda123
    Level 11  
    Posts: 26
    Help: 1
    Rate: 2
    Everything is fine, but now rather work is being carried out on how to prevent charging electricians from sources other than those indicated. In short, now a bigger part of the price of petrol is tax and the idea is to get a similar effect with electrics. So your chargers and charging with photovoltaics is be. Maybe it's a conspiracy theory, but I think that's what it will look like in the end.
📢 Listen (AI):

FAQ

TL;DR: A shared EV charger can be capped at 5 kWh or 3,600 seconds, and the core idea is simple: "limit the use of a shared resource." This FAQ is for people using OpenBeken with a Tuya meter to share a single-phase charger safely, cheaply, and without cloud dependence. [#20696047]

Why it matters: It shows how to turn a basic EV charger into a controllable shared charger for guests, friends, or small-business customers without modifying the charger itself.

Option Main features Typical complexity Cost signal from thread Best fit
Basic DIN-rail charger Start/stop, LED, cable socket, built-in protections Low More reasonable Home or simple shared use
Smart charger LCD, app, Bluetooth, Wi‑Fi, NFC, cloud platform High Around 1000 euros Remote ecosystem features
OBK + Tuya meter Session caps by kWh and time, presets, MQTT/GUI control Medium Reuses existing meter/switch Guest, friend, or café-style sharing

Key insight: OpenBeken does not make the charger smarter; it makes the session controllable. The thread’s practical win is simple session limiting by energy and time, not full load balancing or roaming-platform integration. [#20696047]

Quick Facts

  • The example setup targets a single-phase charger up to 32 A and 7.3 kW, with the power meter installed in front of the charger and no charger hardware modification required. [#20696047]
  • The minimum stated firmware is OpenBeken 1.17.213, because that release introduced the ChargingLimit driver used for session caps. [#20696047]
  • The minimal command example uses chSetupLimit 5 5000 3600 "POWER OFF", which means a hard stop after 5000 Wh or 3600 s. [#20696047]
  • The sample presets are Guests: 5 kWh / 1 hour, Friends: 10 kWh / 2 hours, and Test: 2 Wh / 10 s. [#20696047]
  • The thread contrasts simple chargers with cloud-heavy models that can cost around 1000 euros and add app, Wi‑Fi, Bluetooth, NFC, and platform dependencies. [#20696047]

How does the OpenBeken ChargingLimit driver work for sharing an EV charger with power and time limits?

It watches a selected measurement channel and stops the charging session when either the energy cap or the time cap is reached. The thread’s example sets a limit of 5000 Wh or 3600 seconds, then issues "POWER OFF" automatically. That makes it suitable for guest charging, friend sharing, or small-business presets without modifying the charger electronics. [#20696047]

What is OpenBeken (OBK), and why would someone use it with a Tuya-based EV charging setup?

"OpenBeken is alternative firmware that replaces stock software on supported smart IoT devices, adds local control, and exposes scripting, drivers, and channel logic." In this setup, OBK lets a Tuya-based meter or switch enforce charging limits, publish status by MQTT, and avoid dependence on cloud apps. The thread names release 1.17.213 as the minimum for ChargingLimit support. [#20696047]

What is OCPP, and how is it different from a simple OpenBeken-based shared EV charger setup?

"OCPP is a charger communication protocol that connects EV charge points to management software, with interoperability as its main goal." The thread treats OCPP as part of full smart-charger ecosystems, while the OBK approach only limits a local shared resource by time or energy. OBK is simpler, cheaper, and more direct, but it does not promise effortless platform integration. [#20696047]

How do I set up OpenBeken autoexec.bat to limit an EV charging session by kWh and time?

Use three steps. 1. Start the needed drivers: httpButtons, TuyaMCU, NTP, and ChargingLimit when charger mode is enabled. 2. Map the meter channels and store limits in channels 30 and 31. 3. In startsession, call chSetupLimit 3 $CH30 $CH31 "POWER OFF". The sample presets then set 5000 Wh and 3600 s, or 10000 Wh and 7200 s. [#20696047]

Which Tuya power meter models like the Tomzn TOML-VA are suitable for an OpenBeken EV charger limiter project?

The thread explicitly assumes an OBK-enabled Tuya-based power meter, switch, or protector, and gives the Tomzn TOML-VA as the concrete example. The practical requirement is access to total power or energy data through a Tuya channel that OBK can map. If the device exposes usable measurement channels, it fits the project model described there. [#20696047]

Why does the example OBK script use chSetupLimit with channel 3 in autoexec, while the article earlier mentions monitoring channel 5?

The two examples track different measurements. The short setup example says channel 5 is total energy in kWh, but the full autoexec.bat maps channel 3 as Power and channel 5 as EnergyTotal_kWh_div100. That means the script likely evolved, and a wrong channel mapping is a real failure case if the charger does not stop as expected. [#20696047]

What are the practical differences between a basic DIN-rail EV charger and a 'smart' charger with cloud, app, Wi-Fi, and NFC features?

A basic DIN-rail charger focuses on charging, protection, and repairability, while a smart charger adds screens, apps, Bluetooth, Wi‑Fi, NFC, and cloud services. The thread says smart models can cost around 1000 euros and may create privacy and platform dependencies. It argues that standard DIN components are easier to repair and produce less e-waste than packed custom boards. [#20696047]

How can I create guest and friend charging presets in OpenBeken for different EV charging limits like 5 kWh per hour or 10 kWh over 2 hours?

Create aliases that write preset values into the limit channels, then bind them to buttons. The sample uses presetguests for 5000 Wh and 3600 s, and presetfriends for 10000 Wh and 7200 s. Buttons 0 and 1 are labeled for those presets, colored #56b08f, and can be launched from the OBK web UI. [#20696047]

What safety protections are still required when using OpenBeken with an EV charger, even if the charger itself is not modified?

You still need the charger’s normal safety functions, because OBK only adds session control. The thread names galvanic disconnect, current measurement, leak-current protection, and overcurrent protection as required features, and it warns against building the charger yourself. It also says installation and checking should be done by a qualified installer. [#20696047]

How do I monitor remaining charging time and energy in OpenBeken during a shared EV charging session?

Monitor the session status channels and the watched meter channel in the OBK GUI or via MQTT. The thread’s interface shows current session status plus how much power or time is left, and the script publishes charging/status with start and stop hour and minute fields. That gives live visibility without needing a separate cloud dashboard. [#20696047]

Why is load balancing harder than simple session limiting when sharing a single-phase EV charger?

Load balancing must react to total site consumption, not just one charging session. The thread gives a concrete case: a 5.7 kW contract limit, equivalent to 25 A, where a boiler can suddenly consume power. It says you need two power meters and fast communication of allowable current, with updates around every second to avoid tripping the main fuse. [#20696047]

What is IEC 63110, and why might interoperability still be difficult even if a charger claims support for it?

"IEC 63110 is a communication standard for EV charging management that aims to improve interoperability between chargers and software systems." The thread still warns that support for OCPP or IEC 63110 does not guarantee easy operation or integration. Its point is practical: protocol support alone does not remove vendor complexity, market fragmentation, or setup effort. [#20696047]

How could I log separate EV charging sessions and user IDs from OpenBeken to a web endpoint for cost sharing or billing?

Use OBK scripting to post each session total together with a userid variable to a web-based collection endpoint. The thread proposes this for cost sharing in scenario 1 and notes it could also support different tariffs. It presents the idea as feasible, but it also says no existing script was found there that already implements the full billing workflow. [#20696047]

What troubleshooting steps should I take if an OpenBeken-controlled charger does not stop after reaching the configured kWh or time limit?

Check three things first. 1. Verify the watched channel is correct, because the thread shows channel 5 in one example and channel 3 in autoexec.bat. 2. Confirm ChargingLimit actually starts when channel 29 enables charger mode. 3. Make sure the stop action is exactly "POWER OFF" and that channel 1 really controls output. A bad channel map is the most obvious edge case here. [#20696047]

How does an OpenBeken plus Tuya meter solution compare with buying a commercial smart EV charger for small business or guest charging scenarios?

The OBK plus Tuya approach gives enough control for guest, friend, or café-style charging without paying for a full smart-charger platform. The thread positions it as appropriate tech: local, scriptable, and able to sell simple packages like 20 kWh or 2 hours. Commercial smart chargers add richer ecosystem features, but they also add higher cost, cloud dependence, and more integration uncertainty. [#20696047]
Generated by the language model.
ADVERTISEMENT