0
\$\begingroup\$

I want to send some Data to my Arduino by using the audio jack of my smartphone/computer. (USB is no option, since my smartphone does not support USB Host mode and I also don't want to go wireless or use a modem)

I have allready connected my computer to my Arduino and created a squarewave as the audio signal. But what the Arduino saw, was something like the derivative of the squarewave. Or a declining voltage of capacitor. I haven't lookt at it at a high enough sampling rate to specify this. (I didn't use an amplificator)

What do I have to do, to get the Arduino to read 0 and 1, like the signal I created?

\$\endgroup\$
  • \$\begingroup\$ Your sound card output is likely high pass filtered by a DC blocking capacitor. Try using a higher frequency to minimize the effect, and lightly bias your input to half of the supply voltage with large equal value resistors to each rail. Are you reading this with an ADC, or with a digital input? \$\endgroup\$ – Chris Stratton Jan 18 '15 at 22:54
  • \$\begingroup\$ I did use the analog input here, to first of all see what is arriving at the Arduino. But as suggested below, if I get a good signal, it would be easier to use the digital input. I'm going to experiment with higher frequencys now and see what happens. \$\endgroup\$ – Butterkekskrumel Jan 18 '15 at 23:15
  • \$\begingroup\$ You can probably do digital if you bias it near the threshold voltage and use a timer to measure the time between transitions. \$\endgroup\$ – Chris Stratton Jan 19 '15 at 0:27
1
\$\begingroup\$

Audio outputs are typically AC-coupled, i.e. there is a series capacitor. Try Manchester encoding, and experiment with different baud rates - perhaps start around 4000 symbols per second. I've done this successfully in the past but it takes some fiddling to get it to work.

\$\endgroup\$
0
\$\begingroup\$

The specifics of this depend on which Arduino you are using.

You are going to want to use a voltage divider so that the ground wire from the audio cable has voltage that is half that of your Arduino's '1'. If you are using a 5 Volt Arduino like the Arduino Uno, then ground should be set to 2.5V. If you are using a 3.3 Volt Arduino, 1.65V is what you want.

Since you are just sending '1's and '0's, connect the other wire to a digital port. Then you can just use the digitalRead() function.

You may want to amplify the signal a little if you are having trouble reading the correct values. You are also going to want check the sampling speed to make sure that you don't send the data too fast.

\$\endgroup\$
  • \$\begingroup\$ As said above in a comment, there might be a DC blocking capacitor. So I think it would not be possible to get a good digital signal? (What happens if I send 1,1,1,1,1,1,1....? The voltage would decrease all the time...) Maybe experiment with a sawtooth signal, to counter the DC blocking? I'm doing the amplification later, when I get a good signal. (It's an Arduino Uno) \$\endgroup\$ – Butterkekskrumel Jan 18 '15 at 23:25
  • \$\begingroup\$ You really don't want to use an offset ground - sooner or later the actual grounds will get connected somehow (both get connected to PC USB ports for example). Besides, consumer audio should be assumed to be possibly AC coupled making reliance on DC level unwise. If you want a signal that appears to be at an offset ground, AC couple it yourself (to be sure) and then bias it there. \$\endgroup\$ – Chris Stratton Jan 19 '15 at 0:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.