Getting Started

This quick 'Getting Started' guide should help you setup a complete development environment. Once finished you will have a working instance of OpenEMS Edge, with simulated energy storage and photovoltaic system, as well as an OpenEMS UI for monitoring the simulator inside your web browser. Finally OpenEMS Backend is added to simulate a cloud backend that connects UI and Edge.

1. Download the source code

  1. Download any git client and install it. Our recommendation is Sourcetree by Atlassian

  2. Clone the OpenEMS git repository

    1. In Sourcetree:

      1. press FileClone

      2. enter the git repository path https://github.com/OpenEMS/openems.git

      3. select a target directory, for example C:\Users\your.user\git\openems

      4. and press Clone.

        Cloning the git repository using Sourcetree
        Figure 1. Cloning the git repository using Sourcetree
    2. Alternatively: with the git command line utility

      1. open a console

      2. change to the target directory

      3. execute git clone https://github.com/OpenEMS/openems.git

  3. Git is downloading the complete source code for you.

OpenEMS uses the git version control system via the popular GitHub platform. It’s worth learning some basic git commands and workflows. If you want to start with your own OpenEMS developments, just create a copy using the GitHub fork a repo feature, and create a pull request to get feedback on your work and contribute to the project.

2. Setup Eclipse IDE for OpenEMS Edge and Backend

  1. Prepare Eclipse IDE

    1. Download Java Development Kit (JDK) 11 and install it. We recommend the OpenJDK Temurin builds by the Adoptium project

    2. Download Eclipse for Java , install and start it

    3. On first start you will get asked to create a workspace. Select your source code directory (C:\Users\your.user\git\openems in our example) and press Launch.

      Creating a workspace in Eclipse IDE
      Figure 2. Creating a workspace in Eclipse IDE
    4. Install BndTools in Eclipse:

      Menu: HelpEclipse Marketplace…​Find: → enter Bndtools → press Install

    5. Configure Eclipse IDE to use JDK 11.

      • In the Menu select WindowsPreferences

      • Select Java - Installed JREs in the navigation tree

      • Press the Add…​ button

      • Keep Standard VM selected and press Next >

      • Press the Directory…​ button and select the folder of the installed JDK (e.g. C:\Program Files\Eclipse Adoptium\jdk-11.0.13.8-hotspot)

      • Press the Finish button

      • Back in the Preferences window, tick the newly added JDK 11 and press Apply and Close

        Set the Java Development Kit in Eclipse IDE
        Figure 3. Creating a workspace in Eclipse IDE
  2. Import OpenEMS component projects (OSGi bundles):

    Menu: FileImport…​BndtoolsExisting Bnd Workspace → your source code directory should have been selected as Root Directory automatically → Finish → "Switch to Bndtools perspective?" Yes

  3. Eclipse will now spend some time importing and building OpenEMS Edge and Backend. Close the Welcome window to follow the progress till you eventually see the full tree of OpenEMS projects (or bundles) in the Bndtools Explorer and all errors and warnings in the Problems tab disappear.

3. Run OpenEMS Edge and start Simulator

  1. Run OpenEMS Edge

    1. In Eclipse IDE open the project io.openems.edge.application and double click on EdgeApp.bndrun.

      io.openems.edge.application project in Eclipse IDE
      Figure 4. io.openems.edge.application project in Eclipse IDE
    2. Click on Run OSGi to run OpenEMS Edge. You should see log outputs in the Console tab inside Eclipse IDE.

      OpenEMS Edge initial log output
      Figure 5. OpenEMS Edge initial log output
  2. Configure and start the Simulator

    1. Open the Apache Felix Web Console Configuration

      Login with username admin and password admin.

      Apache Felix Web Console Configuration
      Figure 6. Apache Felix Web Console Configuration
    2. Configure a Scheduler

      The Scheduler is responsible for executing the control algorithms (Controllers) and defines the OpenEMS Edge application cycle
      1. Click on Scheduler All Alphabetically

        Configuration of All Alphabetically Scheduler
        Figure 7. Configuration of All Alphabetically Scheduler
      2. Accept the default values and click Save

      3. You created your first instance of an OpenEMS Component with ID "scheduler0". The log shows:

        INFO  [onent.AbstractOpenemsComponent] [scheduler0] Activate Scheduler.AllAlphabetically

        Add any other OpenEMS Components in the same way:

    3. Configure debug outputs on the console: Controller Debug Log. The default values can be accepted without changes.

      Configuration of Controller Debug Log
      Figure 8. Configuration of Controller Debug Log

      The log shows:

      INFO  [onent.AbstractOpenemsComponent] [ctrlDebugLog0] Activate Controller.Debug.Log

      followed once per second by

      INFO  [ntroller.debuglog.DebugLogImpl] [ctrlDebugLog0] _sum[State:Ok]
      It is 'once per second', because the Cycle-Time is defined as "1000 ms" by default. Adjust the setting in the Core Cycle (Core.Cycle) component to change this.
    4. Configure a simulated standard-load-profile datasource using Simulator DataSource: CSV Predefined. Select H0_HOUSEHOLD_SUMMER_WEEKDAY_STANDARD_LOAD_PROFILE as the Source.

      Configuration of Simulator DataSource: CSV Predefined as standard load profile datasource
      Figure 9. Configuration of Simulator DataSource: CSV Predefined as standard load profile datasource

      The log shows:

      INFO  [onent.AbstractOpenemsComponent] [datasource0] Activate Simulator.Datasource.CSV.Predefined
      The data source was configured with the OpenEMS Component ID datasource0 which will be used in the next step as the Datasource-ID reference.
    5. Configure a simulated grid meter: Simulator GridMeter Acting. Configure the Datasource-ID 'datasource0' to refer to the data source configured above.

      Configuration of Simulator GridMeter Acting
      Figure 10. Configuration of Simulator GridMeter Acting

      This time some more logs will show up. Most importantly they show, that the Grid meter now shows a power value and the Consumption is derived directly from this value, because no PV system or energy storage system is configured yet.

      INFO  [onent.AbstractOpenemsComponent] [meter0] Activate Simulator.GridMeter.Acting
      INFO  [onent.AbstractOpenemsComponent] [meter0] Deactivate Simulator.GridMeter.Acting
      INFO  [onent.AbstractOpenemsComponent] [meter0] Activate Simulator.GridMeter.Acting
      INFO  [ntroller.debuglog.DebugLogImpl] [ctrlDebugLog0] _sum[State:Ok Grid:1336 W Consumption:1336 W] meter0[1336 W]
      This setup causes the simulated grid-meter to take the standardized load-profiles data as input parameter.
      'Acting' in the name 'Simulator GridMeter Acting' refers to the fact, that this meter actively provides data - in opposite to a 'Reacting' simulated device that is reacting on other components: for example the 'Simulator.EssSymmetric.Reacting' configured below.
    6. Configure a simulated reacting energy storage system: Simulator EssSymmetric Reacting. The default values can be accepted without changes. (If you choose an other setup as the one described here you may have to create a new Datasource-Component and provide its ID here. The actual data is ignored, but the Datasource’s Time-Delta value is required to calculate values with time-dependant units.)

      Configuration of Simulator EssSymmetric Reacting
      Figure 11. Configuration of Simulator EssSymmetric Reacting

      The log shows:

      INFO  [onent.AbstractOpenemsComponent] [ess0] Activate Simulator.EssSymmetric.Reacting
      INFO  [ntroller.debuglog.DebugLogImpl] [ctrlDebugLog0] _sum[State:Ok Ess SoC:50 % Grid:1560 W Consumption:1560 W] ess0[SoC:50 %|L:UNDEFINED] meter0[1560 W]
      INFO  [ntroller.debuglog.DebugLogImpl] [ctrlDebugLog0] _sum[State:Ok Ess SoC:50 %|L:0 W Grid:1502 W Consumption:1502 W] ess0[SoC:50 %|L:0 W] meter0[1502 W]
      The debug log now shows data for the battery, but the charge/discharge power stays at "0 W" and the state of charge stays at "50 %" as configured. Next step is to configure a control algorithm that tells the battery to charge or discharge depending on the power measured by the simulated grid meter.
    7. Configure the self-consumption optimization algorithm: Controller Balancing Symmetric. Configure the Ess-ID 'ess0' and Grid-Meter-ID 'meter0' to refer to the components configured above.

      Configuration of Symmetric Balancing Controller
      Figure 12. Configuration of Symmetric Balancing Controller

      The log shows:

      INFO  [onent.AbstractOpenemsComponent] [ctrlBalancing0] Activate Controller.Symmetric.Balancing
      ...
      INFO  [ntroller.debuglog.DebugLogImpl] [ctrlDebugLog0] _sum[State:Ok Ess SoC:50 %|L:593 W Grid:15 W Consumption:608 W] ess0[SoC:49 %|L:593 W|DebugSetActivePower:593 W] meter0[15 W]
      Values will differ slightly for you, but note how the Controller now tells the battery to discharge (Ess SoC:49 %|L:593 W), trying to balance the Grid power to "0 W" (Grid L:15 W):
    8. Configure the websocket Api Controller: Controller Api Websocket. The default values can be accepted without changes.

      Configuration of Controller Api Websocket
      Figure 13. Configuration of Controller Api Websocket

      The log shows:

      INFO  [onent.AbstractOpenemsComponent] [ctrlApiWebsocket0] Activate Controller.Api.Websocket
      INFO  [socket.AbstractWebsocketServer] Starting [Websocket Api] websocket server [port=8085]
      The Controller Api Websocket is required so that OpenEMS UI can connect to OpenEMS Edge locally.

4. Setup Visual Studio Code for OpenEMS UI

  1. Download node.js LTS and install it.

  2. Download Visual Studio Code , install and start it.

  3. Open OpenEMS UI source code in Visual Studio Code:

    Menu: FileOpen Folder…​ → Select the ui directory inside the downloaded source code (for example C:\Users\your.user\git\openems\ui) → Select directory

  4. Open the integrated terminal:

    Menu: TerminalNew Terminal

  5. Install Angular CLI :

    npm install -g @angular/cli

    If you receive an error message that the command npm could not be found, make sure that node.js is installed and restart Visual Studio Code.
  6. Resolve and download dependencies:

    npm install

5. Run OpenEMS UI

  1. In Visual Studios integrated terminal type…​

    ng serve -c openems-edge-dev

    If you receive an error message, that you have no rights to execute "ng serve", set Set-ExecutionPolicy RemoteSigned -Scope CurrentUser.

    The log shows:

    NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/
  2. Open a browser at http://localhost:4200

  3. You should see OpenEMS UI. Log in as user "guest" by leaving the standard password and clicking the login button. Alternatively type "admin" in the password field to log in with extended permissions.

    OpenEMS UI Login screen
    Figure 14. OpenEMS UI Login screen
  4. You should see the Energymonitor showing the same data as the DebugLog output on the console.

    OpenEMS UI Energymonitor screen
    Figure 15. OpenEMS UI Energymonitor screen

6. Integrate OpenEMS Backend

Instead of having Edge and UI talk to each other directly, the communication can also be proxied via Backend.

6.1. Run and configure OpenEMS Backend

  1. In Eclipse IDE open the project io.openems.backend.application and double click on BackendApp.bndrun.

    io.openems.backend.application project in Eclipse IDE
    Figure 16. io.openems.backend.application project in Eclipse IDE
  2. Click on Run OSGi to run OpenEMS Backend. You should see log outputs on the console inside Eclipse IDE.

    OpenEMS Backend initial log output
    Figure 17. OpenEMS Backend initial log output
    Disable the two icon buttons "Show Console When Standard Out changes" and "Show Console When Standard Error changes" next to the Console tab to avoid constant switching between the output of OpenEMS Edge and OpenEMS Backend.
  3. Configure the Backend

    1. Open the Apache Felix Web Console Configuration .

      Apache Felix Web Console for OpenEMS Backend is started on port 8079 by default. This is configured using the org.osgi.service.http.port setting in BackendApp.bndrun.

      Login with username admin and password admin.

      Apache Felix Web Console Configuration for OpenEMS Backend
      Figure 18. Apache Felix Web Console Configuration for OpenEMS Backend
    2. Configure Edge.Websocket

      The Edge.Websocket service is responsible for the communication between OpenEMS Backend and OpenEMS Edge.

      In the example we are configuring the Port '8081'. This port needs to match with what we configure later in OpenEMS Edge.

      Configuration of Backend Edge.Websocket
      Figure 19. Configuration of Backend Edge.Websocket
    3. Configure Ui.Websocket

      The Ui.Websocket service is responsible for the communication between OpenEMS Backend and OpenEMS UI.

      In the example we are configuring the Port '8082'. This port needs to match with what we configure later in the OpenEMS UI environment file.

      Configuration of Backend Ui.Websocket
      Figure 20. Configuration of Backend Ui.Websocket
    4. Configure Timedata

      The Timedata service provider is responsible for holding the current and historic data of each connected Edge device.

      In the example we are configuring the Timedata.Dummy service. It takes no configuration parameters, so just press Save. In a production system you would want to use a real implementation like Timedata.InfluxDB.

      Configuration of Backend Timedata.Dummy
      Figure 21. Configuration of Backend Timedata.Dummy
    5. Configure Metadata

      The Metadata service provider is responsible for authentication of Edge devices and Users connecting via UI.
      Configuration of Backend Metadata.Dummy
      Figure 22. Configuration of Backend Metadata.Dummy
      In the example we are configuring the Metadata.Dummy service. It takes no configuration parameters, so just press Save. In a production system you would want to use a real implementation like Metadata.File, which uses a static JSON file as input, or Metadata.Odoo, which uses the Odoo business software for authentication and IoT device management. This will require the Odoo-OpenEMS-Addon to be installed on your Odoo instance. See the OpenEMS Live-Demo Gitpod workspace for a full, production ready example configuration. For more information see → Gitpod Workspace

6.2. Configure OpenEMS Edge

Next we will configure OpenEMS Edge to connect to the OpenEMS Backend Edge.Websocket service.

  1. Switch back to the Apache Felix Web Console Configuration for OpenEMS Edge .

  2. Configure the Controller Api Backend Component. The default values can be accepted without changes right now.

    Configuration of Controller Api Backend
    Figure 23. Configuration of Controller Api Backend

    Some configuration parameters are still noteworthy here:

    1. Apikey is used to authenticate this Edge at the Backend Metadata service. It has to be unique for each Edge.

    2. Uri is set to ws://localhost:8081. This defines an unencrypted websocket (ws://) connection to the local computer on port 8081 like we configured before for the Edge.Websocket. For a production setup you would want to use a TLS encrypted websocket with a wss:// uri.

      Once you press save you should see logs in OpenEMS Edge

      INFO  [onent.AbstractOpenemsComponent] [ctrlBackend0] Activate Controller.Api.Backend
      INFO  [socket.AbstractWebsocketClient] Opening connection [Controller.Api.Backend:ctrlBackend0] to websocket server [ws://localhost:8081]
      INFO  [.controller.api.backend.OnOpen] [ctrlBackend0] Connected to OpenEMS Backend

      and OpenEMS Backend

      INFO  [s.backend.edgewebsocket.OnOpen] [Edge.Websocket] Edge [edge0] connected

6.3. Connect OpenEMS UI with Backend

  1. In the Visual Studio Code terminal stop the running ng serve…​ by pressing ctrl + c

  2. Restart OpenEMS UI in 'local backend mode':

    ng serve -c openems-backend-dev

OpenEMS UI can work both for local connections to OpenEMS Edge as well as cloud connections to OpenEMS Backend. The switch requires some basic parameters that are defined in 'environment' files ui/src/themes/openems/environments. The possible parameters for ng serve -c…​ are defined in the ui/angular.json file.
  1. Open a browser at http://localhost:4200

  2. You should see OpenEMS UI Login. Log in with any email / username and password.

    Metadata.Dummy accepts any user/password combination. For production use, switch to a different Metadata implementation as described above.
    UI via Backend
    Figure 24. UI via Backend

    Click on OpenEMS Edge #0 to see the same live-view as before on the local connection.

7. Next steps

Now that you setup a complete development environment and have a working instance of OpenEMS Edge, OpenEMS Backend an OpenEMS UI, you can continue implementing your first device driver in OpenEMS. We provide a tutorial that explains the steps to implement an electric meter in OpenEMS Edge that is connected via Modbus/TCP.

The meter itself is simulated using a small Modbus slave application, so no external hardware is required for this guide. → Implementing a Device

8. Help

If you experienced any problems or doubts, please get in touch with us on the OpenEMS Community forum.