Android Arduino Communication through Modbus and Rs485

In this post I’d like to describe you a project I’m working on that consists of connecting an Android multi touch panel to one (or more) Arduino slave(s) using modbus protocol and RS485.
Even though the idea of this project could be applied in many fields, I chose to contextualize it in a typical smart home context: a touch display that dims lights, shows temperatures and bulbs statuses.


The nice feature of the Android multi touch panel I used is that it has many interfaces such as Ethernet, RS485, RS32 and I²C as well.
I expressly selected RS485 because Arduino-based microcontrollers are not ready for Ethernet yet (even though some examples still exist but without great success). Indeed, RS485 is a well known standard that has been widely used in the indus­trial con­text and in building automa­tion appli­ca­tions. It is a half-duplex, 2-wires, low noise bus that allows high speeds and remote devices connection (up to 1200 meters).
Furthermore, modbus is a serial communication protocol, developed for industrial applications, open and easy to deploy and maintain. I used modbus RTU, but other variations of the protocol still exist though. Continue reading

Using Bundle Android to Exchange Data between Threads

The question that I want to answer with this post is the following: How bundle Android works for exchanging data from a running thread to the main UI?

This is a fairly common situation in Android projects and very simple to figure it out. The context might be the following:

  1. An Android activity that creates a thread running some work
  2. The created thread has to exchange some data with the main UI thread

This situation can be handled by using a combination of Android bundles and messages. Continue reading

How to configure an Android Vnc Server

android vnc server from android clientIn this post I would like to show you the steps required to set up an Android Vnc Server to remotely control Android devices. This walkthrough has been tested with the Ltouch Android panels, but with simple modifications this tutorial can be used with any other Android devices.

Prerequisites:
The only requirement for this would be to have a rooted device (the Ltouch is already rooted). A basic knowledge of linux terminal commands could speed up the setup process. Continue reading

La libreria Pltouch I/O come il PLC: Un esempio pratico

In uno dei primi articoli della serie sul Pltouch, abbiamo discusso di come la libreria I/O per il Pltouch venga in contro ai tanti sviluppatori che sono abituati alla programmazione per PLC.

Coloro che sviluppano software per PLC sfruttano il paradigma di programmazione per cui tutto il codice viene eseguito in maniera sequenziale all’interno di un while(true) infinito. Purtroppo questa apparente semplificazione rende piuttosto ripida la curva di apprendimento di linguaggi con paradigma di esecuzione diversi (quali per esempio Java).

La libreria I/O Pltouch cerca invece di rendere questa curva più liscia possibile proponendo un approccio che permette di utilizzare anche in ambito Android lo stile di programmazione PLC.

Continue reading

The Pltouch I/O Library as the PLC: An Example

In one of the first blog posts of the Pltouch series, we anticipated that the I/O library can be used in a way the PLC developers are familiar with (but it is not the only way of course).

PLC developers are accustomed to have a big infinite loop in which the code is executed sequentially. Conversely, in PC programs and in apps as well, this is not the case, there is no infinite loop and in mobile apps there are even many entry points. 

Based on those assumptions, the learning curve of PLC developers that want to embrace the Android/Java world might be steep. In order to smooth the steepness of this learning curve, the Pltouch I/O library allows users to continue to use the PLC-style  way of doing things even in the context of Android apps. 

Continue reading

How to set the Android network interface using shell commands

android network configurationIn this post, I’d like to tell you how to set the Android network preferences on Android devices, that is, IP Address, Netmask, Gateway and DNS. This process can be easily done using the Android GUI, specifically in the Settings/Ethernet menu configuration. However, sometimes it is useful to know the shell commands in order to add them in boot scripts. The commands that you’ll find below, has been tested with the Android Ltouch F multi-touch, but I’m confident that there settings should work also with other devices too.

Continue reading

Android IO library for the BieMme Pltouch

In a previous article we introduced the Pltouch, a brand new Android-based HMI with an additional set of I/O pins addressable directly from the Java source code. 

In this post, we would like to explain the rationale behind the Android IO library that is provided free of charge in every Pltouch. This Android Java library acts as a bridge between the Android world and the low level I/O pins.

Once the library has been imported in an Eclipse workspace there are two ways in order to structure your app’s code. In both cases you have to

  • Create an instance of the Android IO library
  • Store this reference in the activity class (like for instance using private/public class field)
  • Call the initialization method

Let’s go through every point and expand each one with examples.

Continue reading

How to configure Android adb without using the mini-usb

android serial lines debugAs presented in an earlier blog post, the Android adb daemon (in the host device) can be set to listen for requests coming from wifi or ethernet instead of the default usb. This process is common for the majority of Android smartphone/tablets and in order to achieve it, the host device must receive at least a set of initialisation commands sent throughout the mini-usb connector.

The mini-usb is a very good connector but when you have to disconnect and reconnect it many times, it may fail or broke. As a consequence, having a mini-usb connector that does not work, means that you can not upload your apks, debug and in general manage your Android device. Continue reading

How to create an Android System App with the Ltouch Panels

Android software stackThe topic we would like to tell you today is how to create an Android System App with the any of the touch panels/tablets Ltouch F, FW (Wifi) or development boards Ltouch S and SW (Wifi). An Android system app is a special kind of application that has higher privileges and does not live in normal user application sandbox.

Example of tasks that can be performed with system apps are:

  • Install and remove other apps
  • Execute commands in super user mode with the Java command: Runtime.getRuntime.exec
  • Low level permission for interacting with the platform
  • Full access to device’s resources

Continue reading