I want to transfer data from an Arduino to an android mobile phone. Data will be integers which are continuously generated values from a sensor attached to Arduino . What is the most fastest approach for this ? I mean what is the best code to transfer this data without any delay? I would like to use most optimized code because in my project delays will cause errors in my android app.Please help me. Data rate will be about 1 integer per milisecond .Thanks in advance....
I have managed to create a connection to, and receive data from, a bluetooth stick reader (cattle ear tags) using the tutorial from the following Google Developers guide. Seems to me that it will keep listening full time for the messages.
https://developer.android.com/guide/topics/connectivity/bluetooth.html
It worked on >= Android 4.3, because only after this version Android is capable of receiving Low Energy Bluetooth.
well that gives me an idea, #nopasara 's comment. If I can find a way to include 2 integers per 16bits i will be able to achieve the challenge ? I think that will be a possible task with C language bit operators.....
Related
I'm trying to use an android app to do the processing of a path finding algorithm for a robot using Bluetooth. But currently, it takes 1 or 2 seconds for the transfer to complete, so that there is an output in the Arduino. Is there a way to minimise this to make the transfer-output instant?
This kind of delay is causing problems such as stopping instantly when an obstacle is detected. Is there any better way of doing this?
Thanks in advance!
You didn't mention which device you are using. I assume that you connected the Bluetooth chip set to UART port(As in arduino Uno), In that case the slowest part in whole communication is the serial interface between Arduino and Bluetooth chip set. Check what baud rate you are using and can it increase further. I think default will be 9600 which is only around 960 bytes per second. Set the maximum baud rate supported by your device and the Bluetooth chip.
Simple answer: You can't, bluetooth is laggy like that. If you instead had your path finding algorithm on the arduino board itself, you could avoid the issue. You can also try adding a delay to your arduino code, because it is possible that the arduino is sending messages repeatedly without taking into account the lag that bluetooth has.
Two simple solutions worked for me:-
Increase the delay to 50 - 100 milliseconds.
Add this after the Serial.begin(9600) in setup();
Serial.setTimeout(50);
Step two is the most important. It worked for me only after I added the above code. This is not mentioned very often in many other forums that I have looked when I had the exact same problem.
I'm working on a simple project in which i need to control a Arduino Robot (2-servo motors) through an Android Phone's Gyroscope Sensor, via Internet.
As you can visualize, 3-axis Gyroscopic Coordinates change quite sensitively even with little change in Phone's orientation in 3D space, so i want to minimize the Lag to milliseconds.
Now aside from hardware, my first milestone is to send Gyroscope coordinates from Android to a computer through internet as Fast and Continuously as possible (like a RealTime stream of Numeric data). I know traditional HTTP based Client-Server mechanism will be quite slow therefore i've looked into following:
Google's Chanel API
WebRTC
WebSockets
According to my research, Channel API shows latency that from 10ms to even in Seconds. Also GAE limits requests to 30 seconds. Here is a Channels API stress test:
http://channelapistresstest.appspot.com/
Try clicking "send 5"-button a lot, and you will see latency numbers going up to several seconds.
Now WebRTC sounds most promising and faster than WebSockets. I'll be really grateful if someone can guide me about practical implementation of WebRTC in Native JAVA and Native Android (Any good libraries? i want to send coords. from Android and Receive via a JAVA-SE client on Desktop). I'm not interested in Hybrid App solutions (like Crosswalk). I would also like to know about How should i setup a Signalling Server. Summing it up i have following questions:
Which method should i use? (Channel API, WebSockets, WebRTC or something else) with native Java and android support?
Incase of WebRTC, how should i setup a Signalling server? (just brief description) or a WebSocket Server for WebSockets?
Can i make use of Google's Cloud platform or something similar to reduce complexity at my end?
Any overall suggestion?
Thanks in advance.
You do not want to use WebRTC. WebRTC requires you to setup a separate signaling channel like WebSockets anyway, so it is needlessly complex and very heavyweight for what you are trying to do.
If your requirement is simply to communicate a series of gyroscope values from an device to another, I recommend:
Start with a simple socket server
Connect your clients to this server via a socket
Relay messages from one client to the other
A simple server to print socket input to standard output is just a few lines of Python, for example. This does require you to learn to use sockets because your clients need to be interpreting the byte stream in the same way. You can also use WebSockets, but this may increase the complexity of your server significantly; Java EE is significantly more complex than Java SE, for example.
If you want data integrity (I imagine you do), you should use TCP.
If you are really worried about latency, you should also skip going to the Internet. Run everything on a LAN. I imagine you have to see the device under control anyway, so there's no point on going out to the Internet.
I would ignore WebRTC for this project. It is more complicated to setup and requires a special server.
WebSocket should be just fine for this project. It is as fast as TCP.
If you would like to avoid even this delay at all cost, but packet loss is not a problem, then I would go for simple UDP. For all these, you don't need any library, just a few lines of code.
Hey i am pretty new to arduino but really learning a lot! This might be a little ambitious but i am looking to access navigation data on a android phone with arduino and then use this data for a output.
E.g when the google navigation says i am 100m from a left turn, i want to set an LED to high.
I assume i need a bluetooth shield to connect to the phone but i am unclear as to what else i would need to make this possible.
Any help would be a great help, i am at the deep end here so a little direction would be awesome.
Bluetooth would be great, yes. Making an Arduino and an Android communicate with BT is pretty easy. You can get really chez BT chips on eBay that works like a charm (I do that for my project).
Then you need to know exactly what kind of data you could get from the Android and how it is formated (JSON, XML, raw coordinates, something else?).
Do you know if you can get the data from directly from the Google Maps App on the phone?
What I would do (if it's possible, I'm not sure): rebuild some kind of GPS application which sends "markers" to the Arduino via bluetooth, i.e. when you're less than 100 meters away, it tells the Arduino to blink faster, if you took the wrong exit, it starts recalculating and tells the Arduino to blink red, something like that.
Is that what you intend to do? Or am I totally wrong? :)
I'm researching on transferring text data over male-to-male audio jack cable.
I'm testing this on HTC one V and on PC, which supports male-to-male audio jack for data transfer as mentioned in this Wikipedia article. It says:
The first, which places the return signal on the second ring and the microphone on the sleeve, is used by Apple's iPhone line, HTC devices, latest Samsung, Nokia and Sony phones, among others.
You can see my code here.
Problems I face during transfer: if I generate tone by entering any value from 0-31 at sender side, receiver will get actual value in 2-3 try due to the wrong type of FSK modulation/demodulation. Would you suggest the best error correction code that will help me out for correcting the input received from another Android device?
If anyone has done this type of data transfer before, please suggest a code reference or some basic guidance regarding technical aspects, so I can complete this and make it open source for everyone.
I'm looking for the same, I got one awesome explination about Transfering data using audio signal in android by Sudar , go through once that may be helpful to you.
The slides here are even more detailed: Showing how to communicate with an Arduino and reading a light signal and convert it A/D.
http://de.slideshare.net/wolfpaulus/android-arduino-and-the-headphone-jack
I have a microcontroller collecting sensor data at a rate of about 4 Hz. I would like to send this data over Bluetooth to a remote entity. I'm thinking the serial port profile (SPP) would be best, since it emulates a physical cable. Under normal usage, it would not be unreasonable to expect the connection to be held open for 10 to 12 hours at a time.
Has anyone done any work in this field? Does anyone know the best profile to use, or any resources to use as reference? Thanks in advance.
Yup I'd use SPP/RFCOMM. That will be supported in all Bluetooth versions and all implementations (except for the very very very basic which might not support RFCOMM/SPP). There shouldn't be any problem with keeping the connection open for a long time.
Bluetooth 2.1 supports a streaming mode over a basic RFCOMM channel, if your API will let you configure it.