IMrek – Android group chat app using MQTT
IMrek was a project for my Android App Development class. It was developed start to finish in about a month and a half in my free time.
IMrek is a simple group chat app, similar to IRC’s channels. The MQTT protocol was perfect for this because it is very lightweight, and therefore easy on battery life and still comparatively fast on slower mobile networks.
Here are some screenshots of the app in action:
Features include:
- Registration/Login via PHP (before MQTT login)
- Channel list
- Join/Create a Channel
- Send/Receive messages on channels
- Message history
- New message notifications
- Persistent background service
IMrek’s background service handles the MQTT connection, and tries to reconnect automatically if the connection is lost. It also attempts to restart itself if it crashes or is killed by the Android OS for any reason.
Another pretty awesome feature (in my opinion) is that you can left and right swipe between channels, without having to go back to the conversation list. This uses the same swipe effect that swiping between images in the image gallery does. It accomplishes this by using activity fragments for each channel.
The code for IMrek is open source, and you can get a copy from Github.
I recently presented IMrek, along with an Arduino MQTT client I made, at the Johnson & Wales 2012 Tech Exhibit. The Arduino client was the result of my recent experimentation of reading IR remotes with my Arduino board. I thought an Arduino MQTT client that used an LCD and infrared keyboard would be awesome, and I just couldn’t put off the thought.
The Arduino client is rather simplistic:
- I use this Arduino HTTPClient library to authenticate with IMrek’s PHP server-side
- On Github, I forked Nicholas O’Leary’s Arduino MQTT client library pubsubclient and implemented user/pass authentication, the result of which I use for the authenticated MQTT connection.
- I read in IR signals using the IRRemote library, and map them to the keyboard keys.
The LCD display shows an input line (with the message you’re typing), a sent/received count, and the last message the client received from the server. Currently, it it hard-coded to connect to one MQTT topic, but that can easily be changed (Future updates!).
If you’d like to try it out yourself, you can get the code on Github.
As far as the physical circuit goes, the mass of it is just the LCD hookup (it’s a 4×20 LiquidCrystal display), and then an IR receiver connected to pin 32, and a blue status LED connected to pin 30 to show when a signal is received.
I’m running this on my ATMega2560 with the R3 version of the ethernet shield:
I also have some more pictures from my presentation at the Tech Exhibit (and hopefully video soon!):
And my brief presentation, if anyone is interested:
Update: IMrek now uses Eclipse Paho for its MQTT client library.
read more






