I have to design a project that uses an LED to transmit data and a LDR to receive the data or signal from the LED. But the problem is I have to use two Arduino UNO boards, one for LED transmit and another for LDR to receive. I know we can just use one Arduino board, but in my condition, my project is to have another advanced application that requires using two Arduino boards and have to separate the LED and LDR .So, how can the led transmit data? For example speed of car, so that LDR can receive data and display at the LCD? How to connect between the two Arduino?
Virtual light communication
arduinocommunicationldrledlight
Related Solutions
As the question does not state which digital IR Transmitter and Receiver modules are in use, this answer explains how infrared data communication can be achieved using simply a generic IR LED, and a modulated IR receiver such as Vishay's TSOP17xx or other similar parts.
Assumptions:
- IR LED chosen can be driven with 20 mA current, e.g. IR333
- TSOP1756 sensor is to be used (56 KHz modulation).
- Change modulation frequency according to actual part used in sensor module. For TSOP11 38, for instance, modulation frequency is 38 KHz.
Receiving:
This is the easy part. Simply connect the OUT pin of the sensor to the serial RX pin of your Arduino (digital Pin 0). If your Arduino is one of the basic (older) models, use Serial.read()
in loop()
:
int inputByte = 0;
if (Serial.available() > 0) {
// read the incoming byte:
inputByte = Serial.read();
// Do stuff with this byte, then loop again
For the Arduino Mega or Due, you can also use Serial1, Serial2 or Serial3, depending on which RX pin you use.
For additional reference, see the Arduino Serial reference.
N.B. Power the sensor with the same voltage as your Arduino actually runs its microcontroller at, either 3.3 or 5 Volts depending on Arduino model. Each Arduino board has a suitable voltage output pin you can use for this. Do not use the external supply (7 to 12 Volts typically) provided to the Arduino board.
Transmitting:
You have two options: (1) Arduino, LED and passive components, or (2) using an additional logic gate component. The first option is good for low-current IR LEDs (20-30 mA tops):
- Set one of the Arduino timers (Timer1 for instance, it is a 16-bit timer) for the modulation frequency, with output to one of the timer pins D9 or D10 associated with this timer.
- For a 16 MHz Arduino, to get approximately 56 KHz, use a counter overflow value of 286 ( =
55,944 Hz
). An overflow value of 421 will deliver38,005 Hz
instead, if needed. Connect a suitable current limiting resistor (120 to 150 Ohms on a 5 Volt Arduino = approximately 18 mA to 23 mA limit), a small signal diode, and the LED in series as shown below:
simulate this circuit – Schematic created using CircuitLab
- When the TX pin is high, the LED will be pulsed at the modulation frequency. When TX pin is low, the LED will not light up, and the small-signal diode in series will protect the LED from reverse breakdown.
- If your Arduino is the 3.3 Volt type, then the small-signal diode is not really essential.
For driving a higher current LED, an additional logic component, a quad AND gate such as SN74AS1008 can be used. This part sources or sinks up to 48 mA per gate, and multiple gates can be paralleled for higher current drive.
- Connect the Timer1 output as set up above, to one input of each of the AND gates.
- Connect the TX output as mentioned above, to the second input of each of the AND gates.
- Connect a current limiting resistor of suitable value to each output pin of these 4 AND gates - such that the sum of the 4 output currents equals the desired drive current on the LED
- Connect the other ends of the 4 current limiting resistors to the Anode of the LED, with the Cathode connected to Arduino ground.
- You may have to supply the AND gate's Vcc from an external (5 Volts) power supply, since the Arduino's on-board regulator will overheat if too much current is drawn through it. Make sure the ground of this external supply is connected to Arduino GND.
Now simply use Serial.write()
in your Arduino loop()
code, to transmit any serial data, which will be received by the Serial.read()
at the other end, as described previously.
I take it that the question is whether or not the radio frequency (RF) signals between the two devices will be blocked by the components in a car, when one of the devices is outside and one is inside.
Metal and other conducting materials are efficient at blocking RF. Also placing an antenna close to metal is also likely to "de-tune" the antenna, meaning it will not be as efficient on the intended frequency. Also 2.4GHz signals are not great at penetrating and have shorter range than lower frequencies. Say 900MHz would work almost 3 times as far with the same TX and RX properties. Cars can also come with metallic paints which block RF and the wind screen's coating commonly also blocks RF.
That being said, a typical bluetooth low energy device with a TX power of 0dBm and an RX sensitivity of say -90dBm gives you a theoretical 90dBm "link budget". To carry a 2.4GHz RF signal in free space for 3m, you need a link budget of 50dBm plus at least 10dBm of so called "fade margin". (Simple calculator: http://www.qsl.net/pa2ohh/jsffield.htm) Now this leaves us with a margin of 30dBm for attenuation caused by the car chassis.
RF will radiate in all directions and bounce off of materials. The question becomes, is there a way for the RF to travel between the two devices which would cause less than 30dBm of fading/attenuation. This very well may not be a straight line, but may instead be for example by bouncing off the road or getting wave-guided through the ventilation :).
Causing 30dBm attenuation is actually not very easy as the RF tends to "leak" through any and all routes. You'd be hard pressed to find locations in a car where there isn't some route that the RF finds that causes less than 30dBm of attenuation. There are some numbers for common building materials http://www.moonblink.com/store/attenuation_at_24ghz_.cfm that give you an idea of typical losses for materials.
In summary: Yes it is possible for two devices to communicate when one is placed outside of the car and one is placed inside of the car. Just don't place the antenna straight onto metal which would detune it and block a lot of RF paths.
Related Topic
- RS232 Splitter Capable of Transmitting/Receiving data to one device and only Transmitting to another
- Electronic – Visible light communication receiver
- Electrical – Visible Light Communication Signal Transmission
- Electronic – arduino – LDR not detecting light from LED when finger placed between the two
- Electronic – Arduino I2C communication between 2 master networks
Best Answer
You can use the following library where IRtest2.ino does both tx and rx, depending upon it finding the receiver. There are other examples of doing just transmit and just receive.
Another receiver code that is more realtime. InputCapture.ino