system
March 2, 2014, 10:46pm
1
Hi there!
A weekend struggling to run two libraries in a arduino mini pro.
(IRremote) and (OneWire / DallasTemperature)
I need a display that shows two temperatures (internal and external) and control multiple parameters using a remote control.
If I run the library (irRemote) alone, works perfectly.
If I add the library temperature and try to obtain the temperatures, the IR codes will be received by others, as if it was some interference or even noise. But with no problem for reading two temps.
Minimal code:
#include <OneWire.h>
#include <DallasTemperature.h>
#include <IRremote.h>
OneWire oneWire(9);
DallasTemperature sensors(&oneWire);
IRrecv irrecv(12);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
sensors.begin(); // Start up the library
sensors.setResolution(12);
}
void loop() {
sensors.requestTemperaturesByIndex(0);
sensors.requestTemperaturesByIndex(1);
if (irrecv.decode(&results)) {
Serial.print(results.value, HEX);
Serial.print(" ");
Serial.print(sensors.getTempCByIndex(0));
Serial.print(" ");
Serial.println(sensors.getTempCByIndex(1));
irrecv.resume(); // Receive the next value
}
}
Output:
B460BBF6 25.50 47.88
B460BBF6 25.50 47.88
E7D38153 25.50 47.88
558EE57A 25.50 47.88
FFFFFFFF 25.50 47.88
B54A30CF 25.50 47.88
B460BBF6 25.50 47.88
B54A30CF 25.50 47.88
B54A30CF 25.50 47.88
B54A30CF 25.50 47.88
B54A30CF 25.50 47.88
B54A30CF 25.50 47.88
B460BBF6 25.50 47.88
6D762804 25.50 47.88
A056290F 25.50 47.88
B460BBF6 25.50 47.88
B54A30CF 25.56 47.88
C60FEC0E 25.56 47.88
B54A30CF 25.56 47.88
2D836E80 25.56 47.88
765CA58A 25.56 47.88
65446873 25.56 47.88
B460BBF6 25.56 47.88
39026987 25.56 47.88
The "B54A30CF" is the right code.
Temperature values are perfect. In celsius.
References:
http://milesburton.com/Dallas_Temperature_Control_Library
http://www.pjrc.com/teensy/td_libs_OneWire.html
Please help.
Thanks a lot.
increase serial speed to 115200.
the "irrecv.resume()" must be executed earlier. (before the 'slow' printing)
+1 on previous post..
The FFFFFFFF is just a repeat signal which is sent when you keep the key pressed (assuming NEC protocol).
You should also put in a check for accepting only valid signals and code for the allowable time gap between receiging valid signals.
That is your code should ignore any duplicate IR signals that arrive too quickly.
system
March 3, 2014, 10:40pm
4
Hi,
Changed the code as suggested:
void setup()
{
Serial.begin(115200);
irrecv.enableIRIn(); // Start the receiver
sensors.begin(); // Start up the library
sensors.setResolution(12);
}
void loop() {
sensors.requestTemperaturesByIndex(0);
sensors.requestTemperaturesByIndex(1);
if (irrecv.decode(&results)) {
Serial.print(results.value, HEX);
irrecv.resume(); // Receive the next value
Serial.print(" ");
Serial.print(sensors.getTempCByIndex(0));
Serial.print(" ");
Serial.println(sensors.getTempCByIndex(1));
}
}
This is the output:
B54A30CF 25.75 35.88
B54A30CF 25.75 35.88
B54A30CF 25.81 35.88
B460BBF6 25.81 35.88
FFFFFFFF 25.81 35.88
FFFFFFFF 25.81 35.88
FFFFFFFF 25.81 35.88
B54A30CF 25.81 35.88
FFFFFFFF 25.81 35.94
B460BBF6 25.81 35.94
C71AB2D4 25.81 35.94
B460BBF6 25.81 35.94
B54A30CF 25.81 35.94
9A0F155B 25.81 35.94
64B22996 25.81 36.00
B54A30CF 25.81 36.00
B54A 25.81 35.94
B54A30CF 25.81 35.94
B54A30CF 25.81 36.00
B460BBF6 25.81 36.00
E1281B8C 25.81 36.00
B54A30CF 25.75 36.00
7B6D53D3 25.75 36.00
B460BBF6 25.75 36.00
B460BBF6 25.75 36.00
7D9FAF95 25.75 36.00
2E02652A 25.75 36.00
B460BBF6 25.75 36.00
A3FC89A7 25.75 36.00
FDF0AEA5 25.75 36.00
64266B34 25.75 36.00
19D15EBF 25.75 36.00
59AE1D8 25.75 35.94
For this test, I can keep pressed a button (Yes, the F's are correct) or press with a random speed.
If I check the right code (B54A30CF), I will have a lot of lag's:
PRESS
PRESS
PRESS
PRESS Ok received.
PRESS
PRESS
PRESS
PRESS Ok received
PRESSSSSSSSSSS Ok received.
PRESS
But this:
OneWire oneWire(9);
DallasTemperature sensors(&oneWire);
IRrecv irrecv(12);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
sensors.begin(); // Start up the library
sensors.setResolution(12);
}
void loop() {
// sensors.requestTemperaturesByIndex(0);
// sensors.requestTemperaturesByIndex(1);
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
// Serial.print(" ");
// Serial.print(sensors.getTempCByIndex(0));
// Serial.print(" ");
// Serial.println(sensors.getTempCByIndex(1));
}
}
Works perfectly. With a long or short press in the control:
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
B54A30CF
Thanks.
Hmm.. ir-lib uses timer1. (see http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html )
timer1 is related to pins 9 and 10
.. I'd try a different pin for one-wire.
system
March 5, 2014, 10:06pm
6
Hi...
with these changes:
OneWire oneWire(3);
DallasTemperature sensors(&oneWire);
IRrecv irrecv(9);
decode_results results;
Still the same reading:
B54A30CF 24.06 26.31
B54A30CF 24.06 26.25
F1711E6C 24.06 26.25
FFFFFFFF 24.06 26.25
FFFFFFFF 24.06 26.25
FFFFFFFF 24.06 26.25
B54A30CF 24.06 26.25
FFFFFFFF 24.06 26.25
B460BBF6 24.06 26.19
B54A30CF 24.06 26.12
B54A30CF 24.06 26.06
D878D07D 24.06 26.06
B54A30CF 24.06 26.00
2F842E4F 24.06 26.00
76FAD87C 24.06 26.00
7CCF99E1 24.06 26.00
A807A948 24.06 26.12
B460BBF6 24.06 26.12
A82F36A3 24.06 26.12
B54A30CF 24.06 26.19
FFFFFFFF 24.06 26.19
FFFFFFFF 24.12 26.19
B54A30CF 24.12 26.19
B54A30CF 24.12 26.19
B54A30CF 24.12 26.19
FFFFFFFF 24.12 26.19
B54A30CF 24.12 26.19
All examples on net indicates IR pin to 11:
B54A30CF 24.44 24.37
B54A30CF 24.44 24.37
D9D5AA37 24.44 24.37
B54A30CF 24.44 24.37
FFFFFFFF 24.44 24.31
FFFFFFFF 24.44 24.31
B54A30CF 24.44 24.31
59AE1D8 24.44 24.37
B54A30CF 24.44 24.37
FFFFFFFF 24.44 24.37
B54A30CF 24.44 24.37
Thanks...
system
July 26, 2014, 7:43pm
7
Hi, I have the same problem here. Have you managed to solve it? Thanks.
gert3d
October 15, 2016, 5:40pm
8
The conflict still exists.
I narrowed it down to the OneWire library.
After using the function search(addr) the IRremote call: if (irrecv.decode(&results))
sometimes points to a random code and sometimes it does not.
Anybody with a solution?