Receiving process information on your Android device is not difficult

2010-06-22

Freddy Martens

A few weeks ago, I bought myself an HTC Desire which is an Android based phone. The phone can be used to read email, browse the web and make a phone call. It can also run a homebrewn applications that have been developed using the Android SDK. My first application should be one related to my line of work. It should be able to send and receive process information using COTS products like the OPC DataHub. The OPC DataHub is an application that collects various types of data from OPC Servers, or other sources and makes that data available to any given client. The image below shows a typical setup in which the OPC DataHub is used.

Writing the Android application was not difficult. Cogent already provides a Java library to interact with the DataHub and the Hello Android tutorial helped me to get started on the front-end. I was able to run my first application in the Android Virtual Device after a few hours of coding and editing XML resource files.

After verifying the application, it was ready to run on the phone. I uploaded the apk file to a webserver and downloaded it from there. The result… well see for yourself.

The application can connect to the OPC DataHub hosted by Cogent or you can connect to  your local OPC DataHub.

Here are a few steps to get started on android development:

  1. Get the Eclipse installation instructions from the Eclipse WIKI
  2. Get the Android SDK installation instructions from the Android SDK website
  3. Get the Datahub documentation from the OPC DataHub website
  4. Download and install the Eclipse IDE for Java developers
  5. Download and install the Android SDK
  6. Download and install the OPC DataHub
  7. Create a new Android Virtual device.
  8. Import our example that you can download. The source code is easy to read and documented.
  9. Add the datahub java archive to the project, it is not included in the download. The java library is included in the OPCDataHub download and can be found in: c:\program files\OPC DataHub\Plugin\WebServer\html\Java\
  10. Read through our example. It is documented and it should help you writing your first Android client for the OPC Datahub.

A few application came to mind when developing this application:

  1. Monitor OEE data, directly from the shop floor.
  2. Adjust setpoints on the fly.
  3. Get the latest equipment alarms.
  4. Commissioning machinery.

If you have questions about this post, please leave a comment. We will try to answer them as soon as time allows us.

Visit the Cogent support forum if you have question regarding the OPC Datahub. Questions about Android cannot be posted in the various Android newsgroups available. For sales inquiries, contact Cogent or ATS. ATS can also assist you with the implementation of the OPC DataHub in your production environment.

Advertisements
This entry was posted in Post Embedded, Post MES, Post PLC, Post Scada and tagged , , , , , , , . Bookmark the permalink.

15 Responses to Receiving process information on your Android device is not difficult

  1. Altino says:

    Hello Freddy Martens, I really enjoyed this stuff.
    And I really would love to try this, but for the moment I don´t have an android phone.
    So I would like to start by testing your example. Could You please tell me how can I test your example. I already have installed the android sdk but I´m really new to this so I don´t know what I have to do in order to test your example.

    Appreciate any help.

    Altino Gonçalves

  2. andy says:

    What is the advantage of using the OPC Datahub instead of running an OPC client on the Android device and connecting to the required OPC servers?

    • atstechlab says:

      Since I haven’t found a proper working and easy to use OPC client for Android/Java. If you know a good and lightweight OPC Client implementation that runs on Android/Java, please let me know. The OPC datahub might look like overkill but it provides me a clean java inplementation to communicate with multiple OPC servers. Please take a look at http://www.opcdatahub.com/Docs/adc-javaprogramming.html. I used the DatahubConnector class to talk to the OPC Datahub and it is pure TCP/IP communication and the jar is not that big. So the advantage is IMHO the clean and easy coding using the DatahubConnector class. Please let me know if you have more questions.

  3. Lieven says:

    Hey Freddy,

    Thanks alot for this! I never had made an App before.
    In just a few hours i made the app and got the app working on my HTC Desire.

    We’re going to try it with are own OPC server now!

    Thanks agian!

  4. Ari says:

    Hey hello,

    Thank you very much for this amasing implementation, thats the only one OPC XML Client for Android on the internet. But it is not working with my local OPC DataHub which is installed on my PC. With OPC DataHub hosted by Cogent working fine. I can see on the latest point change cycle is increasing but with local OPC DataHub nothing happening. I think I am missing something on the properties of the DataHub. I activated Webserver and changed my port to 4685. At OPC DA Configuration is a domain generated and OPC Client of DataHub is running without any problems. I can read and write variables. Anything else that I forgot to activate?

    PS: After I click the connect, latest OPCDatahub event is onConnectionSuccess for almost 5s but no change at the latest point change, then it changes to onConnectionFailure with reason=Inactivitytimeout.

  5. antonio says:

    How can i obtain an app that show on display all the informations contained in OPC Server? I analyze this problem, but i can’t solve the access to all the points. Can you help me? Thank you.

  6. John Aston says:

    Note that this is only a demo for OPC Datahub, I hope you have very deep pockets if you intend to actually create a serious application.

    • Freddy Martens says:

      Yes John, This is only a demo. I showed that it was not difficult to access OPC data on an Android phone using the CogentDatahub. A serious application would indeed require more work. Thanks for the heads up to the rest of the readers.

  7. Khoder says:

    hiii
    i didn’t understand how the opc datahub can communicate and sends real time values to the android phone. which type of connection will be between the datahub and the mobile phone. can anyone help me with this task.
    thanks

  8. kalle says:

    Hi Freddy, is it possible to read/write more than one point at the same time?????????
    if yes, how to modify the code to do it???
    Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s