I found that my smartphone (android 4.2.2) is not able to generate square waveforms (i need it to use the audio output as serial line for data transfer). At beginning i supposed it was my application, but then i made many significant tests. These are latest tests. I hope you can find an explanation for the phenomenon.
I generated a wav file with a square waveform at 500Hz inside it. I play the wav file on a android phone and on a apple iphone. I recorded and analyzed the signal with my notebook (the audio cable connected to the notebook audio input).
Then i repeated the tests with the audio cable connected between a bluetooth transceiver device and the notebook audio input. And the smartphones connected via bluetooth (one at time) to the bluetooth transceiver device.
NOTE: the bluetooth transceiver device is a device that receives audio data via bluetooth and gives a audio output with a standard audio jack.
This is the signal generated by the iphone directly connected on the audio jack:
This is the signal generated by the bluetooth device receiving data from the iphone:
This is the signal generated by the android device directly connected with the audio jack:
This is the signal generated by the bluetooth device receiving data from the android smartphone:
Analisys:
-The bluetooth device introduces a cut to the bandwidth of the signal (it seems to me acceptable).
-The iphone has really good analog part (it outputs a very good square waveform)
-The android device has really bad analog part (even if it is perfect for music play)
-the data sent by the android phone to the bluetooth device is not correct, in fact the aquired signal is different than the one aquired with data coming from iphone.
I restored the smartphone to factory default but the problem was not solved. I also tried to install kitkat custom rom but the problem is still there. I also tried with a Nexus 5 (android 5) and samsung S4 mini (android 4.2.2 like mine) and they acts like the iphone.
I suspect that the problem has to do with DTS studio sound (i tried disabiling it and setting it in different ways without success). the DTS seems to be the only software difference between my phone and the samsung s4 mini.
QUESTION: I can understand that the analog side of my android device is not good as the iphone, i could also suppose that the analog part of my android device is broken... but i don't understand why i don't obtain the same result when i insert the bluetooth transceiver device.
why are you using a square wave? Is this a requirement? Square waves make sense in digital systems, but as an analog signal it has all sorts of nasty characteristics (like infinite spectrum if I recall). Why not use two tones in the human audible range which the phone's audio systems is design for?
There are lots of signalling and modulation techniques used for sending data over analog or audio channels. Have you looked at any of the following?
How could you transfer data over an audio line?
Audio Modem: data over sound
Transfering data using audio signal in android
The third link describes using Frequency-shift keying in Android. This looks like a very good solution. The wikiepedia page for FSK includes the following comments on Audio FSK
Audio frequency-shift keying (AFSK) is a modulation technique by which digital data is represented by changes in the frequency (pitch) of an audio tone, yielding an encoded signal suitable for transmission via radio or telephone. Normally, the transmitted audio alternates between two tones: one, the "mark", represents a binary one; the other, the "space", represents a binary zero. ... AFSK has the advantage that encoded signals will pass through AC-coupled links, including most equipment originally designed to carry music or speech.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With