Skip to Content

SAPUI5 Cordova Electricity Meter Reading

In many homes there are still electricity meters with a mechanical counter that do not provide a direct interface for reading the consumption of electrical energy. In this blog, I am trying to capture the consumption of electrical energy with a mobile device (Android) as a scanner to read the information from the mechanical counter and record it in the database like SAP HCP. In this case, we are going to build a SAPUI5 Cordova electricity meter reading with the SDK from



  • Go to website to download the SDK Cordova plugin and obtain the license. 
  • Setup and build the Cordova project under C:\programs
    • cordova create C:\programs\meterReading com.enterprisemobility.meterReading meterReading
    • cd c:\programs\meterReading\
    • cordova platform add android
    • cordova plugin add <path_to_AnylineSDK_Cordova_Plugin>

  • Create a function to scan the mechanical counter by calling the scanElectricMeter function in ElectricScan.controller.js:
    scanElectricMeter: function() {
    cordova.exec(this.onResult, this.onError, "AnylineSDK", "scanElectricMeter", this.energyConfig);
  • If scan is success, it will call the onResult function which will capture the meter reading value and pass the information to the ScanResult.view.js.
    onResult: function(result) {
    var meterType = []; var reading=[];
    var data = [];
    for(var i = 0; i < meterType.length; i++) {
    data.push({"meterType": meterType[i], "reading": reading[i]});
    var oModel1 = new sap.ui.model.json.JSONModel({ "zgwmat": data });
    sap.ui.getCore().setModel(oModel1, "zgwmatmodel");
    var bus = sap.ui.getCore().getEventBus();
    bus.publish("nav", "to", {
      id : "scanresult",
  • I have attached the complete source code in this blog: Replace the c:\Programs\meterReading\www folder with the attached www folder.
  • Download SAPUI5 runtime here and save it under C:\Programs\meterReading\www\resources
  • Build the cordova project under c:\programs\meterReading, execute command cordova build
  • Install the generated .apk from c:\Programs\meterReading\platforms\android\build\outputs\apk to your Android device.

That’s it!

You must be Logged on to comment or reply to a post.
  • Dear Ferry,

    long time no see!

    have you tried mobile JS frameworks like Ionic, React etc?

    which I think are more suitable comparing SAPUI5 for such scenario.

    UI5 is designed more for simple enterprise UI whereas others are more for internet life.



    • Hi Legend

      Yes, very long time we haven't meet! 🙂

      I haven't tried other JS framework that you have mentioned. Thanks for the suggestion, I shall explore it sometime.



    • Hi Sven,

      Please try to debug the code in Eclipse and see what was missing. Did you replace the www folder with the attached one? also you need to get a valid license from If someone can build the scanning process as an opensource, that will be great!

      Ferry Djaja

        • I think there is a missing step to add the plugin to Cordova. Please download the AnylineSDK_CordovaPlugin and add to your cordova project. You can refer to their document here.

          I have updated the above blog to add the AnylineSDK Cordova plugin with this command:

          cordova plugin add <path_to_AnylineSDK_Cordova_Plugin>

  • You caught us at an exciting time, we’ve just launched our Community Edition yesterday, which is why it will take until early next week for the Cordova Plugin to be released again. Sorry for the inconvenience!

    I think you’ve talked to my colleague Carina already today, if you need anything - always reach out to us!

    Great blog post by the way 🙂 Thanks!

  • We have also developed and deployed a meter reading application in UI5, and are busy admiring the appearance of the anyline SDK.

    This is what our entry field looks like:

    meter reading entry.jpg

    I do have some questions regarding the anyline meter reading entry:

    1. How accurate is it – in the example, it appears as if the library knew to ignore decimal fragments, so it must somehow have OCR logic that can compensate  for the digits on the far right being a different colour. Will this work for every possible meter type, both water and electricity?

    2. What happens if the face of the meter is covered in mud (as is normally the case for my water meter in winter!) – is there also an option for manual entry?

    meter reading entry.jpg
    • For item 2, yes we can create a manual entry before you submit the meter reading.

      For item 1, I will leave it to Matthias Gasser to answer this.

      May I know which library you are currently using to develop the meter reading? are you also using Anyline?