Android serial port via audio jack

后端 未结 1 1675
滥情空心
滥情空心 2020-12-29 09:41

I want to get data using serial port via audio jack. I don\'t have any idea about this. But I find a app audioserial can send data to. So, I think it should be get data like

相关标签:
1条回答
  • 2020-12-29 10:24

    You can record audio on the microphone jack without any problems. Doing this, you can essentially use your Android phone as a digital oscilloscope. You can then programatically convert this back to digital I/O.

    Serial output -> Android audio input -> Sampled square block wave -> digital I/O
    

    Please note that most serial levels are either 5V or 3.3V. This will destroy your microphone input! Peak level for consumer audio electronics is usually 1.7V. You will need to create a voltage divider using two resistors to be able to use your android microphone input as a serial input. If you want to create a device that behaves according to the spec (http://en.wikipedia.org/wiki/RS-232#Voltage_levels), you will need to be able to handle -3V to +25V!

    You will then need to sample the audio input. See http://en.wikipedia.org/wiki/File:Rs232_oscilloscope_trace.svg for a nice oscilloscope trace of what you will receive as input. You will need to create Java code to detect the timing of RS-232 as well as the start and stop bits (if configured).

    I think the determining factor in your project will be CPU speed of the phone. I'm not sure you will be able to talk 19200baud with the remote party and be able to generate a UI at the same time.

    Doing the inverse is also possible by the way (generating a square waveform to drive a serial output), but will require some voltage multiplier (darlington chain or other transistor-based method) to increase the voltage to the desired level (+5V).

    0 讨论(0)
提交回复
热议问题