Modbus-Droid (or as it is called on the Blackberry app world market – Mobile Modbus) was designed to be a simple Modbus TCP client / scanner. I wanted to have something similar to Modscan32, a program I use a lot at my work, but on my phone. My goal was to provide the simplicity of Modscan32, so I put the information I change the most – the register type, the register offset, and the quantity of registers to read – all right up front. The other stuff, like IP address, poll time and what-not are on a settings screen.
Download the app here: market://search?q=pname:com.bencatlin.modbusdroid
or scan this QR code:
Modbus-Droid is also open source, and built on an open source library – Modbus4J (that I had to modify a little for my needs).
The source code is available on GitHub here:
https://github.com/bigcat/ModbusDroid
and and archive that stops at version 1.0 is still available on launchpad here:
https://launchpad.net/modbusdroid
Both of these project hosting sites include my modified version of the Modbus4J.
Features
- Intuitive Interface (if you are familiar with modbus)
- Time-based polling
- Write single holding registers and holding coils just by touching the value
- Ability to view data in multipe formats, including binary for registers for people who like to use the register space for combined boolean data (like I do at work).
- Write dialogs allow you to write data in the format you are displaying (i.e. a register displayed as binary allows you to set individual bits true and false inside the register)
Known Issues/bugs on 1.0
- No way to handle byte-swapped data sources. I have found a place in the Modbus4J library I think I could handle this, but it was more surgery than I was comfortable with. I might tackle this somewhere down the road.
- Some of the error messaging (like the connection lost error) results in a pretty cryptic or ‘programmer’ type of message. Hopefully I’ll get to putting in some human-readable text in a future version if I have time.
- And I’m sure there a few others I haven’t found yet, if you find some please report the bugs on GitHub
- This isn’t exactly a bug or issue, but there have been a lot of people contacting me about some compiler errors, or how to get this started in eclipse. Here is a the thing – please make sure you have the SDK installed correctly and can compile a sample project. I really want to help with questions and issues, but I can’t remotely debug your compiler or computer setup issues. This is my hobby project right now (hopefully android development will someday become my day job), and I don’t currently have the time or resources to write a bunch of documentation about it. But fortunately google already did, so reference the android SDK documentation before emailing me. Also, if you are still experiencing problems after getting a sample project to compile in eclipse and install in the emulator or your device, please refer to the GitHub site for the project to report bugs, or post questions, not the comments here.
Screenshots
- Connected with Menu showing
- Modbus-Droid settings screen
- Writing an integer value to a Holding Register






This sounds like a useful app, but I’m having a couple problems on DroidX:
1. How do you specify the slave ID for the MODBUS device?
2. I get a force close every time I attempt to “connect”. I know the phone can connect, because I’ve used the “Superview Mobile” app successfully with the same MODBUS device.
I would be happy to do some beta testing for you. We have various types of MODBUS devices we can try this with.
Thanks.
1) I updated the APK file at the launchpad site (https://launchpad.net/modbusdroid), and I updated the android market, so you should see an update if you downloaded it from there. And that will have the ability to set the slave ID.
2) That is a bummer! Does it give you an option to report the problem to me when the app closes? If it does could you do that, so I can see the error log it sends in the android developers console for the app, and I will see if I can track down the issue when I have some spare time.
Thanks for the feedback!
Can I ask what kind of changes were done in original Modbus4J library ?
Was it something Android-specific or just general bugfixing or extension ?
I haven’t looked at that in a long time, so I’m pretty fuzzy on what I did. I think I made a class to make it easier for me to handle modbusTCP connections in Android, and I seem to remember making a few other changes for something (but I can’t remember what I did now).
I can extract out the library w/ the changes and put them somewhere convenient for you if you like.
About the Modbus4J modifications, any chance you could put them up somewhere? It’d be great. Thank you.
Right now they are all included w/ the source code for the project at http://www.launchpad.net/modbusdroid. I think I added a a locator class that was for getting a range of registers in order to avoid using the built-in functionality that packs requests together and initiates a ‘batch’. I needed more of a simple polling.
Unfortunately I haven’t separated them out, and didn’t really do a good job of keeping the changes in some form that is easy to track (which is a bummer and not smart on my part because now I would love to re-sync w/ the main svn of modbus4J and it is a PITA for me to remember what I did). I have a few ideas to work on this project to improve it a bit, and one thing I might do is separate out just my modifications to the library as its own deal – as well as android 3.0+ tablet and phone support.
Hello BigCat,
I want to use your modbus code.But your code some errors when i want to connect my device. What is this error source?
11-25 11:49:49.600: E/AndroidRuntime(348): FATAL EXCEPTION: Modbus4JTcpMaster
11-25 11:49:49.600: E/AndroidRuntime(348): java.lang.NullPointerException
11-25 11:49:49.600: E/AndroidRuntime(348): at com.bencatlin.modbusdroid.MbDroidMsgExceptionHandler.receivedException(MbDroidMsgExceptionHandler.java:23)
11-25 11:49:49.600: E/AndroidRuntime(348): at com.serotonin.messaging.MessageControl.data(MessageControl.java:156)
11-25 11:49:49.600: E/AndroidRuntime(348): at com.serotonin.messaging.InputStreamListener.run(InputStreamListener.java:76)
11-25 11:49:49.600: E/AndroidRuntime(348): at java.lang.Thread.run(Thread.java:1019)
1) I’d really like any issues or questions posted at launchpad.net/modbusdroid
2) I’m going to need a lot more information about what is going on here. Are you compiling this yourself and running it from eclipse? If so, is this the first time you’ve tried getting an app to run on your device from eclipse. What are you doing when this error occurs? What IP address are you trying to connect to, and what are all the values in your settings page? And what addresses are you trying to write to?
Hello Bigcat,
My device address is 85.107.41.190 and port 502. My device response is a little delaying about 100 -200 ms.
I disabled m message lines at com.bencatlin.modbusdroid.MbDroidMsgExceptionHandler.receivedException.Your code is no error above.
Thanks for the feedback.
Please,Read 10000 address and two byte packet modbus RTU type for my device. Other address are password protected.My device return error code.
I would really appreciate it if you would go to the launchpad site for this project and post your questions there.
Furthermore – this application doesn’t currently support Modbus RTU.
Sorry Bigcat,Our company IP address is dinamically. Our ip address now 85.100.151.0
I am trying to read the addresss 30256 but the apk shows the address 30256 doesnt allowme to have the complete address. Any idea how to get the complete address??
Frank, I imagine that you are trying to read an input register based on the 30000 offset. I suggest trying to read address 256 with the type set to input register. Let me know if that works, and if not, what error message you are getting that prevents you from inputting the entire register offset you want to. And if you would, post any of your other questions or bugs at the launchpad site mentioned in the main post. Thanks and best of luck with your getting your device to work with the app!
Hello, I think you developed a really usefull ap, my question is:
When I poll my PLC using a Modbus TCP OPC server I query address 410300, in Modbus-Droid which address should I input?
Thanks for your help.
You should reference this document for more details on how ModBus works and common conventions for registers and stuff like that. It is a really great document on the protocol IMO. If that doesn’t work, the official modbus spec is readily available online and free (just google it – I think it is the first hit).
http://www.lammertbies.nl/comm/info/modbus.html
I am a student and I am trying to build an application for Monitoring PLC on android as an exercise for android programming. However, I do not know anything about PLC programming and how to use the modbus4j library ,Is it an open source library or some important files are closed.
Where can i find the entire modbus4j library. Please reply soon. Need help.
You can find more information about the modbus 4j library here: http://sourceforge.net/projects/modbus4j/
I’m not sure what you are asking about PLC programming – that is a field that is pretty diverse. But if it speaks modbus over an ethernet connection you should be able to talk to it w/ the modbus4j library in java. I didn’t make any massive changes to the library for my app – mostly just removed the serial port portions since the standard libraries to support that aren’t in android, so I would start there doing something similar for your class project.
Hi BigCat,
I’m try to use your source code but i get problem at
mbTCPMaster = mbFactory.createModbusTCPMaster(ipParameters, true);
application come to Force Close at this command.
Please help me to solve that. Thank you so much.
i am new at android..i am getting error missing lib seroutils.jar.. build path error
Hi BigCat,
I have installed your app in my phone and it works very well – great app. Now i’m trying use your source code… but not good news yet
Best regards,
Marco
Hi BIgcat,
Thanks a lot for sharing such a nice application. it would be very helpful to me. I just downloaded the project source from github and Modbus4J library from sourceforge.net. but is it modfied version of Modbus4J? it will be great if you put Modbus4J libray at some place. so,we can get it very easily
Thanks & Regards
Juned Khan
The source from the version of modbus4j is included in my source code – under the com.serotonin.modbus4j package folder. The serioutils.jar is not currently included for several reasons, but it is available on the modbus4j sourceforge page. I can’t remember when I last got a copy of their library to verify against, so no promises it will compile with the latest version, but if you need to sourceforge should let you go back to early 2011 and grab the copy from then and it should work.
how to read holding register? is it similar to writing?