Arduino-Temperature-Control-Library icon indicating copy to clipboard operation
Arduino-Temperature-Control-Library copied to clipboard

Location for MAX31825

Open pmr1 opened this issue 1 year ago • 11 comments

This version of 1-wire temperature sensors has an address function allowing up to 64 addresses. Each address specifies the temperature sensor can be location. It does this by sampling the value of a resistor connected to ADD0 and ground .. see the data sheet for specific values.

I have updated library files to include a getLocation function. It samples the resistor value and writes the address to the 6 lsb bits in the status register. To access this you have to read the scratchpad .. the address located at scratchpad[2] DallasTemperature.zip

pmr1 avatar Feb 09 '24 12:02 pmr1

Sounds interesting, I do not recall seeing this in the datasheet (which page?)

RobTillaart avatar Feb 09 '24 12:02 RobTillaart

See page 13 on attached data sheet max31825_281123.pdf

pmr1 avatar Feb 09 '24 12:02 pmr1

Is there an example how to use? I see this new function:

bool DallasTemperature::getLocation(const uint8_t* deviceAddress)
		{
			int b = _wire->reset();
				if (b == 0)
					return false;

			_wire->select(deviceAddress);
	        _wire->write(DETECTADD);

	     b = _wire->reset();
	       return (b == 1);

		}

Where / how does it read the location ? I assume that I could get a number 0..63 or so

OK, lets first read the datasheet

RobTillaart avatar Feb 09 '24 12:02 RobTillaart

Yes here is an arduino script running on an arduino mini pro .. but that should not matter. This outputs the temperatures from 5 sensors:
row listing from left to right, Device type, run, temperature 0 , location 0, temperature 1, location1, temperature 2 location 2, etc. The device type, 0x3B is a MAX31825.

I only had one sensor attached here temp37.zip

A 10k resistor attached to ADD0 listed as having an address 0x3a

:3b ,0 , ,13.94,3a, ,-127.00,3a, ,-127.00,3a, ,-127.00,3a, ,-127.00,3a

pmr1 avatar Feb 09 '24 12:02 pmr1

Datasheet P13

Address

Although the 64-bit ROM code allows each 1-Wire device on a bus to be identified for communication purposes, it does not provide any information about the location of the device. The MAX31825 includes two address pins (ADD0 and ADD1). ADD0 can be connected to an external resistor whose value is measured by the MAX31825 in response to the Convert Location command, resulting in five location address bits (A4:A0) being stored in the Status register. Because the location resistor values on the board are known, this location address allows the location of the MAX31825 to be uniquely identified. Mapping of the address selection resistor value to A4:A0 is shown in Table 1. In addition to ADD0, the ADD1 input can be connected to GND or VDD (or DQ in parasite-power mode). This selects the value of bit A5, yielding a total of 64 available addresses. A5 = 1 when ADD1 is connected to VDD and 0 when ADD1 is grounded.

  • 5 bits A0..A4 are defined with the 1% resistor at AD0 ==> so less precise resistors could cause address clashes
  • 6th bit A5 is defined by the AD1
  • location is set in the status register of the ScratchPad.

RobTillaart avatar Feb 09 '24 12:02 RobTillaart

@pmr1 OK, I understand from the prototype code how one gets a location from the MAX31825. The implementation has to be engineered, with a more clear API as a DS18B20 does not support this call

I would propose something like this

int DallasTemperature::getLocation(const uint8_t* deviceAddress)
{
  if (_wire->reset() == 0) return -1;
  _wire->select(deviceAddress);
  _wire->write(DETECTADD);    //  0x88
  if (_wire->reset() == 0) return -1;

  readScratchPad(deviceAddress, ScratchPad);
  return ScratchPad[2];
}

RobTillaart avatar Feb 09 '24 12:02 RobTillaart

Should add a test for model in the function

#define DS1825MODEL  0x3B   // also MAX31825

RobTillaart avatar Feb 09 '24 12:02 RobTillaart

Ok but the existing api does recognise the 31825 and it does have a get address function so no need ro define an extra constant.

Sent from Outlook for Androidhttps://aka.ms/AAb9ysg


From: Rob Tillaart @.> Sent: Friday, February 9, 2024 12:45:16 PM To: milesburton/Arduino-Temperature-Control-Library @.> Cc: pmr1 @.>; Mention @.> Subject: Re: [milesburton/Arduino-Temperature-Control-Library] Location for MAX31825 (Issue #250)

@pmr1https://github.com/pmr1 OK, I understand from the prototype code how one gets a location from the MAX31825. The implementation has to be engineered, with a more clear API as a DS18B20 does not support this call

I would propose something like this

int DallasTemperature::getLocation(const uint8_t* deviceAddress) { if (_wire->reset() == 0) return -1; // not supported _wire->select(deviceAddress); _wire->write(DETECTADD); if (_wire->reset() == 0) return -1;

readScratchPad(deviceAddress, ScratchPad); return ScratchPad[2]; }

— Reply to this email directly, view it on GitHubhttps://github.com/milesburton/Arduino-Temperature-Control-Library/issues/250#issuecomment-1935866820, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABCPD2ZGMYPS36NGWMU7OHDYSYK5ZAVCNFSM6AAAAABDBLQUL6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZVHA3DMOBSGA. You are receiving this because you were mentioned.Message ID: @.***>

pmr1 avatar Feb 09 '24 12:02 pmr1

That model I mentioned is already defined in the .h file (did not invent it)

What I do not know if the original DS1825, which has the same model byte as the MAX31825, does support location.

Another question is what happens if the 2 lines are not connected / floating? What does getLocation() return? Can you test?

RobTillaart avatar Feb 09 '24 13:02 RobTillaart

  1. No the Max 31825 has a different scratchpad to the DS1825.
  2. if Add0, 1 are left connected temperature still reads.

Sent from Outlook for Androidhttps://aka.ms/AAb9ysg


From: Rob Tillaart @.> Sent: Friday, February 9, 2024 1:01:27 PM To: milesburton/Arduino-Temperature-Control-Library @.> Cc: pmr1 @.>; Mention @.> Subject: Re: [milesburton/Arduino-Temperature-Control-Library] Location for MAX31825 (Issue #250)

That model I mentioned is already defined in the .h file (did not invent it)

What I do not know if the original DS1825, which has the same model byte as the MAX31825, does support location.

Another question is what happens if the 2 lines are not connected / floating? What does getLocation() return? Can you test?

— Reply to this email directly, view it on GitHubhttps://github.com/milesburton/Arduino-Temperature-Control-Library/issues/250#issuecomment-1935890115, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABCPD2Y4POXOW6MSKNQI5QLYSYM2PAVCNFSM6AAAAABDBLQUL6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZVHA4TAMJRGU. You are receiving this because you were mentioned.Message ID: @.***>

pmr1 avatar Feb 09 '24 14:02 pmr1

Oh right, I see your point the DS1825 does have an address function but operates via external pins and the address is seen in the configuration register. The Max31825 comes in a solder bump package measuring 0. 8mm x 1mm and is a bugger to solder. So using a resistor is a convenient way of fixing an address.

Sent from Outlook for Androidhttps://aka.ms/AAb9ysg


From: Rob Tillaart @.> Sent: Friday, February 9, 2024 1:01:27 PM To: milesburton/Arduino-Temperature-Control-Library @.> Cc: pmr1 @.>; Mention @.> Subject: Re: [milesburton/Arduino-Temperature-Control-Library] Location for MAX31825 (Issue #250)

That model I mentioned is already defined in the .h file (did not invent it)

What I do not know if the original DS1825, which has the same model byte as the MAX31825, does support location.

Another question is what happens if the 2 lines are not connected / floating? What does getLocation() return? Can you test?

— Reply to this email directly, view it on GitHubhttps://github.com/milesburton/Arduino-Temperature-Control-Library/issues/250#issuecomment-1935890115, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABCPD2Y4POXOW6MSKNQI5QLYSYM2PAVCNFSM6AAAAABDBLQUL6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZVHA4TAMJRGU. You are receiving this because you were mentioned.Message ID: @.***>

pmr1 avatar Feb 09 '24 14:02 pmr1