Android Serial Connection - android

I looked around and I have a hard time finding an answer to my question. We have an app written with Xamarin. I see SerialPort class being exposed. Not sure what it means in terms of Android. We will be using this application with custom made tablets in our device. We can have usb 3.0s but our hardware team would like to implement UART or RS 232 ports instead. We have a microcontroller which will communiucate with our tablet. Is this even possible or are we stuck witb adding a usb/serial converter in the middle. Thanks for the insight

Related

Can you manipulate Raspberry Pi sensor data on an Android smartphone?

I am new to using the RPi and just got the A+ model which I have been using to generate different types of data from external sensors. I was wondering if it is possible to send this data it is gathering to an android device in real-time, and if so the best method? I want to be able to notify the user (through a an app made with the Ionic framework) when the data enters a particular range etc.
And also is it possible to do this whilst the user is walking around with both the devices in hand?
The short answer to the question is: Yes, you can ;-)
The longer answer is much longer, since there are many ways to do this.
The one I personally would choose as the simplest is classic Bluetooth (not LE) using the SPP profile, which basically makes the BT link a serial connection between the RPi and the phone.
On this serial link you invent you own streaming protocol suitable for the data you want to transfer.
On the RPi side you install a module such as this: https://www.sparkfun.com/products/12577
(There are many alternatives, but the RN42 module is very foolproof...)
Don't know the level of your hardware skills, you might need something more plug and play if you feel uncomfortable hooking up the 4 wires needed for 3.3V power and serial communications between the Pi and the BT Module...
On the phone side you install https://github.com/don/BluetoothSerial, which gives you an API reachable from Ionic where you can receive the BT data stream.
With that and a bit of coding on both sides you are good to go.
I've used a Raspberry Pi in combination with an Android smartphone & Lego NXT.
Communication was achieved using Bluetooth on Raspbian. I used a cheap $1 USB Bluetooth dongle. The Bluetooth stack had to be compiled for Raspi, which may not be necessary anymore. Steps can be found here: Bluetooth error: Native Library bluecove_arm not available
Bluetooth seems most logical to me.
I'm at work at the moment, hence the lightweight answer, if you'd like to discuss this further then please leave a comment and I'll be happy to provide more verbose response.
You can upload the data to any cloud services. You can use Xively/Box. Xively is specially made for real time data collection.
To connect RPi to Xively, refer this: https://xively.com/dev/tutorials/pi/
For Box, refer this: http://www.sbprojects.com/projects/raspberrypi/webdav.php
You can then use Xively API in your android app. You can see GitHub for this
Google app store already has some apps for you, if you want to use
It might look a little complex. But its really simple once you follow the above methods.

Gameboy-like keys and D-Pad for Android

I wanted to make an RPG for Android 2.3 Mobile Phone and thought that the good old Gameboy had the perfect format for such games. So I want to build a "Case" with a D-Pad and a few keys and connect them with the Android Device over USB. I don't want Bluetooth, because it needs to much energy. I thought about giving the Case its own Battery Cell and maybe loading the Android Device with it. So my Question is:
How can I access the Keys of this Case from the Android Device?
You might consider the Android Open Accessory Development Kit.
Even if you don't want to buy the ADK, the above link has information that will be useful to you in developing an interface to your accessory. In particular, the section on implementing the accessory protocol and the following section on how the ADK implements the protocol should prove informative. In addition, you'll probably want to look at the USB Accessory link which contains a section concerning communication with an accessory.
You can use USB on devices that have a host USB port unfortunately, not many devices have this. Your other options are bluetooth or wifi both can be accomplished in a multitude of ways. If you Google Arduino + Android I believe you will find examples of people connecting hardware to Android devices via Arduino. This is not the only way to do it, just an example of one way you could do it.
Android USB documentation
http://developer.android.com/guide/topics/usb/index.html
EDIT
You, could I suppose, use Arduino as the USB host also and use accessory mode on the Android end. In any case this none of these options are incredibly straightforward and you will need to do a lot of research to accomplish what you are envisioning.

Android + Arduino project: should I have them talk via Bluetooth or USB?

I'm starting a project where I'm going to try to write a program for Android that will control and/or send/receive input to/from an Arduino gadget. Like, make an LED light blink, as the simplest example. I can either get a Bluetooth shield for the Arduino board and go the Bluetooth route, as per the example Androino! Control an Arduino from your Android device using a cheap Bluetooth module.
Or I can buy a USB host shield for the Arduino board and have the phone talk to the Arduino device via a USB connection, as per the example Adventures in Android ADK Development: Hardware.
Which implementation option is easier and more foolproof both from hardware setup (soldering? compatibility issues?) and programming perspectives (additional Python scripting required? 'listening' on Android for a Bluetooth device vs. a USB device and sending data back and forth?) I've been doing Android development for a couple of months, but I have NO experience with Arduino.
I don't mean this to be a lazy question - I'm able to do the research, but I'm inexperienced and am trying to choose my implementation right away so I can order the right hardware stuff in time for a deadline. I have to make sure I choose an implementation I can actually DO.
EDIT: Might it be easier still to use an ethernet shield on the Arduino board and have the Arduino gadget talk to the Android phone via TCP/IP? I don't know why this didn't occur to me from the beginning. But there seems to be far less in term of tutorials on this kind of implementation, for reasons I'm unsure of.
I am currently working on a project that interfaces an Arduino and an Android phone via bluetooth. And from my experience so far all I can say is STAY AWAY!
All the articles online about cheap bluetooth modules working perfectly are highly misleading to say the least. It might be easy and perfect if you buy an $80 shield, but not if you're on a budget. I bought a $30 shield and it only seems to work on one of the seven Android devices I have tried to use. Furthermore, it seems completely unresponsive to the standard bluetooth connection methodology and requires a host of workaround/hackish method calls that are all highly unsafe and unstable.
On the other hand a USB connection is far more reliable, better supported and of course has the inherent advantage of speed and since it is well supported does not suffer from all the pitfalls bluetooth connectivity does. It is just as easy to setup from a hardware perspective (no work required if you get a decent shield), reasonably priced compared to bluetooth shields and in my experience generally easier to code.
If you are on a budget and can do with a hardwired connection I highly recommend USB over bluetooth.
I don't know the details of either. But I would say if the phone is going to stay with the board then use USB. For lower latency and in general, I find a hardwired connection to be better for all applications.
I have no experience in Arduino and some decent experience in Android and I decided to get the usb connection to work from the phone to arduino to light up the led.
I used a Nexus One and an Arduino Mega ADK and I got the usb connection working in around 5 hours of tinkering and I was absolutely excited to get the led to light up when I clicked a button. But then I decided to go to the next level because bluetooth sounded way too cool to pass up.
Anyways around 30 hours later I FINALLY got it working and I can say it was COMPLETELY worth it. There was a TON I needed to learn, but once I got it working I can say it was not all in vain.
I bought the Bluetooth Itead V2.2 shield ($25 for me) then connected it to my arduino and used my Nexus One with Amarino to send a signal to my chip and turn off and on the led.
http://iteadstudio.com/store/index.php?main_page=product_info&products_id=468
From my experience it was definitely difficult, but the learning curve is what makes these projects so fun. So I would say GO FOR IT!
Good luck in your future works!

Make a mobile device a remote control for a tablet?

I'm trying to make an app on an Android device that will control an application on an iPad or Android tablet. (I'm testing with an Samsung Galaxy S2 and an iPad 2).
The application is pretty simple for now. When one selects a colour on the Android mobile, that colour displays on the tablet device.
The question is, how to connect the two devices. Just now I've verified that I can pair the two devices using Bluetooth. Also, the Samsung has a "Kies" Wifi Direct feature (which I don't understand fully), that allows the iPad to connect to the Galaxy as a wifi hotspot.
The connections are there, but I don't know if either protocol can be used to actually get the apps to talk to each other to get the control I'm looking for.
Should I be using Bluetooth, Wifi, or something else?
And in whichever case, how?
My opinion is that you should not stick so much around the physical medium used for connectivity either is WiFi or Bluetooth. You should abstract this aspect, in both cases you will be using sockets (I'm speaking about Android), if it's Bluetooth you will be using Bluetooth Sockets, if it's WiFi: TCP sockets. You could have a intermediate layer that abstracts the type of connection and through a factory to use either Bluetooth or TCP.
Bluetooth - http://developer.android.com/guide/topics/wireless/bluetooth.html
For WiFi you should study if P2P would help.
You will need two applications:
- one on the tablet - the server which listens for commands from the client (change color, do this or this)
- second on the smartphone - the client which sends commands.
I've built a few apps that do exactly that between iPhone and iPad. But the principle is the same. I used Bonjour networking. It's just a fancy name for ZeroConfig networking between devices. It's written originally by Apple but it's open source so there should be Android support out there for it too. Really simple and easy to work with.
If you already have a working connection then you already have the first half of your answer, that said you should really consider implementing a solution that uses a variety of connection types, WIFI, Bluetooth, etc.. The question I think you are really asking is how to pass data and messages between the apps once you have the connection.
There are a lot of ways to accomplish this. You could implement your own lightweight message passing system. If you haven't done this before it is more complicated than it originally seems, especially as you would be required to implement the system for each OS you end up using.
Should I be using Bluetooth, Wifi, or something else?
It depends on what situations you want your program to work in.
Bluetooth can provide a direct connection between your devices. A potential issue with bluetooth is that it has a limited range. If you're devices need to be far away from each other, you may want to go with wifi. Otherwise, bluetooth could work great.
If both devices are connected to the internet, you can make them talk to each other through there. The advantage of this approach is that it doesn't matter how far apart your devices are as long as they're both online. A disadvantage is that you'll have to figure out how to find the tablet's ip address before you can talk to it. This is actually a HUGE disadvantage because it can be quite problematic if both of your devices are not on the same wifi. You could have the user type in the destination ip address, but you'll have problems getting it to work if the user is behind a router (which will almost always be the case). The point is, it gets hairy.
If both of your devices are on the same wifi, you can use ZeroConf AKA bonjour (like Dancreek said) to figure out what ip address you need to send info to. I've previously used a library called jmdns (easy to find with google) to implement zero configuration networking. It's good because the user doesn't have to worry about ip addresses... it's intuitive for the user.
And in whichever case, how?
Networking is a pretty big topic, so I can't expand on this question to much. Short answer is, it depends on what method you choose. Search for some tutorials and start by getting one of your devices to send something as simple as an int to the other.

Serial port on an APAD - where to discuss this?

I've got an application that is written in Java and which talks to a device using virtual serial port (ie a USB CDC ACM device). Currently it runs an a PC (Windows/Linux/Mac OS X),
but it would be a perfect match to be able to port this to a cheap tablet PC to create a stand alone system.
I've been googling for hours now and it seems quite a lot of people are interested in this sort of thin (no surprise there) and some have managed, but I've not found a good match for what I'm looking for or a good place to discuss this.
I'm looking at something like this:
http://www.prlog.org/10776061-101-inch-android-ipad-android-google-mid-tablet-pc.html
I would like to discuss the following:
This says that it supports USB host so it should be doable, eh?
Android is a kind of Linux so I should be able to use a serial dongle there, right?
Has Android got drivers so that I could just plug in a serial port dongle and open it as /dev/tty?
Would the above quoted APAD be usable as a development platform ?
So where would be a best place to discuss this?
br Kusti
To keep this at least partly programming-related: If your application has a GUI, moving to Android is not going to be a load-it-and-go effort. Android has a very different application structure that you're used to and doesn't have Swing (if that's what you're using) or any GUI toolkits other than its own.
On your USB problem: There is support for a few USB-to-RS232C adapters in the stock kernel, but there are a bunch of practical reasons not to use it. Most involve limiting yourself to devices that support host mode, cabling and powering the Android device and the serial adapter. You might be better off using a Bluetooth-to-RS232 adapter on your serial device, which would allow your app to run on a wider variety of devices and gets you the bonus feature of being wireless to put in your marketing material.
I just ported the RXTX library to the Android. Unfortunately I had to fork it to accomodate for different layout of the android projects. More details are here http://v-lad.org/projects/gnu.io.android/
You need to have a device that supports host USB mode. Also the kernel on the device has to support the USB to Serial converter or you have to recompile the kernel yourslef.

Categories

Resources