using multiple IR sensors on same board

i am using multiple IR sensors (TSOP1738) on the same Arduino Uno Board.

whenever i test the connections i end up getting inputs from both the sensors, pin11 and pin12, when any one of them is connected.

when pin12 is connected, i observe input on serialMonitor for both the pins.
when pin11 is connected, i see some output for a while, but nothing after that.

i tried using two objects of decode_results, it didn't work.

i have attached the code below.
please let me know where i am going wrong.

#include <boarddefs.h>
#include <IRremote.h>
#include <IRremoteInt.h>

//428946

int RECV_PIN_1 = 11;
int RECV_PIN_2 = 12;
IRrecv irrecv1(RECV_PIN_1);
IRrecv irrecv2(RECV_PIN_2);
decode_results results;

void setup()
{
Serial.begin(9600);
irrecv1.enableIRIn();
irrecv2.enableIRIn();
}

void loop()
{

if (irrecv1.decode(&results))
{

if (results.value == 428946) {
Serial.println("BUTTON PRESSED FOR SENSOR 1");
}
else {
Serial.print(" SENSOR 1 : ");
Serial.println(results.value );
}
results.value = 0;
irrecv1.resume(); // Receive the next value

}

if (irrecv2.decode(&results))
{
if (results.value == 428946) {
Serial.println("BUTTON PRESSED FOR SENSOR 2");
}
else {
Serial.print(" SENSOR 2 : ");
Serial.println(results.value );
results.value = 0;
}
irrecv2.resume(); // Receive the next value

}
}

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Write code for ONE ONLY IR unit, get it working.
Then think about adding the second.

Can you tell us your electronics, programming, arduino, hardware experience?

Thanks.. Tom.. :slight_smile:

All input from the last activated input pin goes into a common buffer. You can not have multiple pins active at the same time. Multiple objects also won't help, because they use the same input buffer.

Why do you need multiple IR sensors? Eventually you can tie their outputs together, to one input pin, if that is what you want.

DrDiettrich:
All input from the last activated input pin goes into a common buffer. You can not have multiple pins active at the same time. Multiple objects also won't help, because they use the same input buffer.

Why do you need multiple IR sensors? Eventually you can tie their outputs together, to one input pin, if that is what you want.

Im trying to operate my room's electrical appliances, putting them all on one arduino Uno card.
i want them to operate separately.
i thought of using more than one arduino cards but that will spike the cost.

TomGeorge:
Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Write code for ONE ONLY IR unit, get it working.
Then think about adding the second.

Can you tell us your electronics, programming, arduino, hardware experience?

Thanks.. Tom.. :slight_smile:

i attempted running the same with only one sensor at first, i worked perfectly.
but when i started attempting to do the same with more, things didn't workout.

Different codes can be transmitted for different commands. On a remote control you can have multiple buttons, each of which sends a specific code.

DrDiettrich:
Different codes can be transmitted for different commands. On a remote control you can have multiple buttons, each of which sends a specific code.

yes. that would work for one room.
if i want to extend this to other rooms as well, then using the same remote for sensor in different rooms, integrated on the same arduino Uno R3 card.
is it possible?

i really don't want to increase the cost of the project by buying more uno cards.
is there any possible way to use multiple IR sensors on the same board?

Do you want to use the same codes for each room, or different codes for different rooms?

IMO the cost of the required actuators and cables will exceed the cost of simple Arduino boards.

DrDiettrich:
Do you want to use the same codes for each room, or different codes for different rooms?

IMO the cost of the required actuators and cables will exceed the cost of simple Arduino boards.

i'd intend to use the same code for all the rooms.
all the sensors in the rooms would be connected to the same arduino.

If you use the same codes for every room, you need one controller for each room, which can activate the actuator corresponding to a code in this room.

Hi,

i really don't want to increase the cost of the project by buying more uno cards.

google and research arduino nano

check ebay prices.

Tom... :slight_smile:

3-pin IR sensors have open collector outputs, so (a few) sensors can be connected in parallel, and connected to one Arduino input. Even different frequencies and/or different locations.
Leo..

DrDiettrich:
If you use the same codes for every room, you need one controller for each room, which can activate the actuator corresponding to a code in this room.

i understand that, but i am concerned about receiving signals from those actuators (3-4) onto the same board.

Actuators don't send signals, they are output devices. Where do your inputs come from?

DrDiettrich:
Actuators don't send signals, they are output devices. Where do your inputs come from?

a signal will be sent from an IR remote to the IR sensor placed at a electric appliance (fan).
once received, it should be processed.

now, this processing would be done on one arduino Uno R3 which should then perform action on the related appliance ( at the moment, i'm just turning on and off a LED to act as a light ).

the arduino uno performing this processing for one IR reciever in one room, is to be processing inputs for another room as well.

how should i program the whole setup so that a single arduino, to handle inputs from 2-3 room's IR receiver?

is it even possible? how?

I.e. you want to spend one IR sensor for each appliance?

You have been told several times already, that you can tie all sensor outputs together, and connect them to a single Arduino input pin.