Introducing Modbus-Droid!

After much furious learning and coding between VLI semesters, I have finally churned out my first ever Android app.


Modbus-Droid is a Modbus TCP client / scanner, that is designed to scan a contiguous block of modbus registers at a regular interval.

Using the software:

All you do to get this going, is go to the settings page and set the IP address of the Modbus Server (or slave in old terminology), the TCP port you want to communicate on, and the polling time. Then set the register offset you want to start reading values at, the length (or quantity) of registers you want to read, and the register type (Holding Registers/Coils, Input Registers/Coils). Press Menu->Connect, and once it connects and receives modbus register data, it will display in a list. You can then change the settings for the offset, register range, or register length at any time, and the list will update on the next scan.

Finally, you can also change the data display – which is how the data you are reading is displayed on the screen. Coil data can, of course, only be displayed as binary – so I represent those as “True” or “False”. But the register data can be displayed as binary – a collection of 16 1’s or 0’s for each register, unsigned and signed integers (single register, double register, or quad register types), as well as floats and double floats (which are 32-bit and 64-bit respectively).

If you are displaying Holding Registers, you can write the values, and the write dialog displayed will be tailored to your data display. So if you have the binary display, you will get a list of 16 checkboxes, where you can set, or unset individual bits within the register. If you are displaying an unsigned int, it will not let you put in a decimal place or a negative sign. Similarly, it will let you put in a negative sign when you are displaying signed ints, and it will give you the decimal place when you are displaying floats. I just want to make sure that people, like me, don’t make a mistake when entering the data to be written.

Other aspects of the project that are interesting to me

One thing about this whole process that has really excited me is that this was a fun learning experience for me, and I feel pretty confident that whatever Alec (my friend who only lives a few blocks away, and who is also a hobby android developer – his app is called MeterMaid) and I cook up for our next project will go a little faster and we both are confident enough in our knowledge of the Android APIs to go quite a bit quicker.

I’m also excited to release my first ever open source project, which is based upon an open source library – Modbus4J. (To be fair, there is one component of the library, that the original creator has chosen to not open source).

I’ve used this project to learn a little about Launchpad project hosting site, and the Bazaar version control system. I’m definitely not an expert by any means on either system, so please give me any feedback on how to better manage this project, or better set up the launchpad site (or better utilize bazaar for code management).
Launchpad site for the project:
Report and view Bugs Here:

Finally you should note – this is still in beta. I’m sure there are bugs I haven’t found, and a couple of less than optimal things that I do know about. So please let me know by emailing me or filing a bug.

  1. get an error: “Java.Net.UnknownHostException: Host is unresolved”

    ping the host with Android Ping is ok
    Connect to the host by Laptop and WLAN with ModbusScan32 is ok too.

    Any ideas ?
    Phone HTC Hero, Android 2.1 update 1

    1. Sorry I haven’t gotten back to you yet. I have been swamped at my day job. Anyway, I tried to reproduce your problem and have not yet been able to – any more information you could give me like what OS you are running and what you are trying to talk to?

  2. Any chance I could get a configurable Slave ID/Bridge Index/Device Address/whatever they call it this week? We manufacture Modbus/TCP to Modbus bridges, and there might be more than just address 1 that I want to talk to.

    1. That isn’t a bad feature request – and I might look into that sometime.

      But definitely not this week, I’m on a deadline for a moonlighting project, and I’m swamped with some school stuff, and my day job.

      Feel free to look at the source code on Launchpad and hack it in yourself – I don’t think it would be too terrible to add that as a preference, and then pull it out to look at for the modbuswrites and reads.

      1. Wow. Thanks for the quick reply. I’m no programmer myself, but I’ll show it to our software guy. He’s been wanting to scratch that same Android programming itch. This should be the perfect starter! Only downside might be that our president may force him to “finish” this project for you! 😉

        1. No worries if he ‘finishes’ it for me.

          I have a handful of things I’ve highlighted as a target for 1.0 release. There are also some similar feature requests on the mango discussion boards where I announced the release. You guys might be able to get a little bit of support there if I’m unavailable. Otherwise feel free to post bugs or comments to the launchpad site, and if I can spare some time I might jump in and help answer or write some code for this.

          Whatever you do, just keep in mind that this is GPLv3 (per the modbus4j library), so any changes you make need to be open sourced as well (feel free to submit patches or I could probably give your software guy commit access to the launchpad site – this would fulfill the obligations under the GPL).

          Good luck, sorry I don’t have time to hack on this project right now! I hope to get back to it late spring/summer time frame.

          1. Well it turns out the programmer has no experience with Java. So there’s not much chance of him workworking on this, after all.

          2. Bummer! Well, you can always try over at the Mango forums if someone might want to pick that task up as a moonlighting gig who has some extra time.

            Otherwise, Like I said, submit some feature requests and bug reports to launchpad, and I’ll dig into them later in the year.

            Do you know if the formal ModbusTCP spec supports the idea of supplying a slave ID of something other than 1? I’m unfamiliar with doing this, though it makes a lot of sense in a TCP to RTU gateway for modbus devices.

          3. OK, so crazy thing. After I wrote my last comment, I had a quick idea on how to possibly accomplish this pretty quickly. I tried to test it quick with my modbus simulator which says it is setting the slave address/ID to something other than 1, but modbusdroid is able to connect to it no matter what. Anyway, I pushed the update to launchpad. You should be able to download and install the APK file at the address below since I’m too lazy to figure out how to add the binary files compiled form eclipse to the bzr ignore path:


            Let me know if that does anything for your situation.

Comments are closed.