So lately I received my Arduino Uno starter kit with many modules and sensors. It was my first time getting into electronics and microcontrollers (Not programming, though. Been familiar with that for a while). From all the modules, I really liked the infrared receiver and transmitter as I was fascinated by the abillity to send and receive information wirelessly.
After learning the basics of IR, decoding many remote codes (Of my A/C, TV) and trying to resend them, I tried to use the infrared of my Galaxy S4 (If anyone tried, you know it's a pain in the ass working with these reflected, undocumented methods...). After managing to send codes I captured with the Arduino, I thought it was the time to create my own "digital protocol" and try some complicated communication between the phone and the Arduino.
The protocol is failry simple:
5ms starting pulse, 0.5ms break,
1ms pulse for a '1', 0.5ms pulse for a '0', both followed by a 0.5ms break,
5ms ending pulse.
A simple app I created lets the user input some text, and transmits the text (The characters' ASCII values) when you tap a button. The Arduino reads the pulse, decodes it and recreates the string, then displays it on a LCD.
I know it's nowhere as complicated as other projects submitted here, but it's pretty cool to see it working fluently, and it's my first "big" project after all
If anyone has any suggestions for improvements or for other uses for this communication (Cool stuff to do with my phone and Arduino), I'd be happy to know.
If you want to get higher bit rates there are dedicated IR receivers that will allow much faster comms over IR, but you seem to have it working well as is.
What modulation frequency did you use or is it fixed by the phone?
Is the IR only one way? or can the Samsung phone receive IR also?
The "carrier wave" (In quotes because it's not really the carrier wave but you get the meaning) frequency is 38kHz. This frequency is fixed by the receiver (I think it is a PNA4602 or a similar variant), but I can set the frequency on the phone.
The digital modulation frequency is smaller though, as a '1' takes 1.5ms to send and a '0' takes 1ms, so the bitrate is somewhere between 600bps to 1000bps. Theoretically, if I used a real OOK modulation, I could get a maximum bitrate of 38kbps. But there would be many errors this way, this receiver is indeed not very reliable. If I'll ever need a higher bitrate, I'll get a better receiver with preferably a higher carrier frequency.
The IR is only one way, I'm almost certain the Galaxy S4 doesn't have a receiver.
The 38kHz modulation is filtered out by the IR receiver, so you won't usually have access to this and you are right it would be nearly all errors if you tried to use it.
FYI: diferent IR protocols have different modulation frequencies & there are dedicated IR receivers for different modulation frequencies and environments. You can read all up about IR on the IRremote blog and also the sb-projects site (via google)
Thanks for sharing your project...always great to see something new.
AnalysIR:
The 38kHz modulation is filtered out by the IR receiver, so you won't usually have access to this and you are right it would be nearly all errors if you tried to use it.
FYI: diferent IR protocols have different modulation frequencies & there are dedicated IR receivers for different modulation frequencies and environments. You can read all up about IR on the IRremote blog and also the sb-projects site (via google)
Thanks for sharing your project...always great to see something new.
Yea, I know there are different receivers dedicated for different modulation frequencies. I'll try to find receivers with higher frequencies for higher bitrates. I'll also take a look at that blog and site.
The bummer with the IR is the high latency of the Galaxy S4 IR blaster and the pulses processing speed of the Arduino. I've got a small R/C toy car today, broke up the remote and connected wires in the right spots to the Arduino (So it controls the remote). Next, I control the Arduino through IR, but the latency is huge (1sec+) so the R/C car bumps into walls before I can stop it :(. I think IR isn't suitable for this purpose (At least not the IR blaster of the S4), although there are R/C toys using IR for transmission. So now I control that car using serial port communication with my laptop (Works fluently with no latency at all) and I'll try to use bluetooth, although I really like the IR Do you have any idea how can I reduce the lags?
There shouldnt be much latency with IR. (not 1 sec). A typical signal has 50-70 millisecond transmit time So you shouldn't have delay of more than 100 or max 200 ms. If the signal is being relayed then it could be double this.
Maybe an idea to review the IR code to see if there is any delay inserted between sending IR of 1 second or similar (eg delay(1000)).
I was going to say that a slow serial connection can introduce latency, but you have tested that & its fine. The only other option is the S4, but can't help there. It could also be the reaction time of the touch screen or just the phone app itself.
If all that fails, there are some free apps available to connect to an Arduino with bluetooth (or even WiFI) and then send the IR. Search for 'Touch OSC'. These apps typically come with GUI builders for the phone.