Multiple IRTemps sharing clock pin

Our range of tiny modules are designed to make it easy for you to quickly add functionality to your projects. [Module List]
wavefront
Posts: 7
Joined: Thu Nov 20, 2014 12:34 am

Re: Multiple IRTemps sharing clock pin

Post by wavefront » Fri Nov 21, 2014 1:33 am

Hi Angus,

Yeah the wiring is the same on the board as in the sketch. I've tried so many combinations of these and other pins and this is just where it ended up.

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Multiple IRTemps sharing clock pin

Post by angusgr » Fri Nov 21, 2014 3:40 am

OK thanks, I just wanted to check as it's easy to swap a pin and not notice!

If you wire the second sensor up to D10-D12 does it start working? Is it possible you have a dud sensor?


Angus

wavefront
Posts: 7
Joined: Thu Nov 20, 2014 12:34 am

Re: Multiple IRTemps sharing clock pin

Post by wavefront » Fri Nov 21, 2014 3:59 am

I'll double check this when I get home. This has been a project that I was working on a few months ago and it stalled because I hit this problem. Originally I wasn't using 10-12 for the working sensor, I was using 11-13, and a different pin order, but I'm sure that I tested both sensors back then and they were working independently on those pins.

Perhaps yes it does pay to check again... Thanks, I'll let you know what I find.

I have a couple more questions about the sketch, for when I get both sensors working... How do I initialise both of them? Can I use code such as:

Code: Select all

//set constants

static const byte PIN_DATA    = 10;
static const byte PIN_CLOCK   = 11; 
static const byte PIN_ACQUIRE  = 12;

static const byte PIN_DATA_R    = 1;
static const byte PIN_CLOCK_R  = 2; 
static const byte PIN_ACQUIRE_R  = 3;

float irTemperature
float amTemperature
float irTemperature_R
float amTemperature_R

IRTemp irTemp(PIN_ACQUIRE, PIN_CLOCK, PIN_DATA);
IRTempR irTemp(PIN_ACQUIRE_R, PIN_CLOCK_R, PIN_DATA_R);


//retrieve temperatures 

irTemperature = irTemp.getIRTemperature();
amTemperature = irTemp.getAmbientTemperature();

irTemperature_R = irTempR.getIRTemperature();
amTemperature_R = irTempR.getAmbientTemperature();
And if I'm using an analogue port in place of a digital, can I just use:

Code: Select all

static const byte PIN_DATA_R    = A1
Will A1 be ok with the byte data type?

I'm new to C and I'm picking it up as I go along, but I can't find an example of anything like this so far...

wavefront
Posts: 7
Joined: Thu Nov 20, 2014 12:34 am

Re: Multiple IRTemps sharing clock pin

Post by wavefront » Fri Nov 21, 2014 11:52 am

Alright all sorted.

The IRTemp sensor wasn't working, so I have another now that is (borrowed albeit). Can't believe I spent so long trying to get it working when it was clearly not going to lol

I figured out the code too, my example was wrong.

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Multiple IRTemps sharing clock pin

Post by angusgr » Sun Nov 23, 2014 8:50 pm

Hi wavefront,

Glad you got it sorted. Sorry a faulty part caused you all that trouble.

Angus

Post Reply