Go Down

Topic: Create a matrix of DS18B20 Digital Temp Probes by Address (Read 208 times) previous topic - next topic

allezgrand

Jan 24, 2020, 11:01 pm Last Edit: Jan 24, 2020, 11:05 pm by allezgrand Reason: Added code tags
The standard was for setting these up is to give them a char array. But I plan to use more than 10 of them and use the code for a couple different applications so I want to create a matrix of them to make processing easier.

Currently I do this with thermistors by initializing something like:

Code: [Select]

const int NUMSAMPLES = 64;
uint32_t samplesTotal[numberOfThermistors];
uint32_t samples[numberOfThermistors][NUMSAMPLES];


It works well and I've been happy with it, but there's too much noise in my application and the readings are all over the place, so I'm switching to digital.

Standard initialization is something like:

Code: [Select]
uint8_t sensor1[8] = { 0x28, 0xE6, 0x02, 0x94, 0x97, 0x12, 0x03, 0x24 };

but I want to make that a matrix that I can work with more easily. Something like:

Code: [Select]

float tempSensor[1][8] = { 0x28, 0x58, 0x2A, 0x94, 0x97, 0x11, 0x03, 0xA3 };
float tempSensor[2][8] = { 0x28, 0xBA, 0x07, 0x94, 0x97, 0x09, 0x03, 0x6A };


but this gives me a "conflicting declaration" error.

How can I do something like this where each sensor has a unique index and uses its unique address?

Thanks in advance for your help!

Nick_Pyner

I want to create a matrix of them to make processing easier.
This sounds very much like technobabble, but using more than 10 DS18B20s together is fine, it is what they are designed for, and all you need do is use them just like everybody else does.
You might try here

allezgrand

I was looking at doing it the way you linked to initially, but it seems to make calibration rather cumbersome. I was hoping to create an array of each value needed for calibration and calculate the corrected value for all 10 in a for loop.

If I could initialize the DS18B20's in an array of arrays (or whatever term you prefer I use to make it not sound like technobabble), I can rather quickly and easily use that to create a running average for each, calibrate with the rawLow, rawRange, rawHigh, and rawValue of each without having to add a lot more steps. Maybe I'm missing something, but it feels like a highly manual cut and paste process when I create the code and then move it between programs. Are you saying there isn't a way to do it with an array of arrays? Can you suggest a better way?

Nick_Pyner

Maybe I'm missing something,
I think that is rather likely, and it is the need to do all this stuff. I recall you used to be working with thermistors, where this sort of stuff may have been merited, but you are now moving to DS18B20, where it probably isn't.
Quote
it feels like a highly manual cut and paste process when I create the code and then move it between programs.
I have no idea what you are talking about here but it might be just more of the same - perceived rather than real, need.

If the DS18B20 is indeed too much of a sow's ear for your perceived silk purse, I rather suspect your real problem is a bad choice of sensor, and you need to take a deep breath and jump into the world of precision thermocouples or something.

wvmarle

Code: [Select]

float tempSensor[1][8] = { 0x28, 0x58, 0x2A, 0x94, 0x97, 0x11, 0x03, 0xA3 };
float tempSensor[2][8] = { 0x28, 0xBA, 0x07, 0x94, 0x97, 0x09, 0x03, 0x6A };


but this gives me a "conflicting declaration" error.
And that's indeed what you're doing. Plus using one of the most inappropriate types, of course.

Code: [Select]

uint8_t tempSensor[2][8] = {{0x28, 0x58, 0x2A, 0x94, 0x97, 0x11, 0x03, 0xA3},
                            {0x28, 0xBA, 0x07, 0x94, 0x97, 0x09, 0x03, 0x6A}};
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

allezgrand

Thank you, wvmarle!! That's exactly what I was looking for!

Go Up