SWE2/RJ45 Expander "Port Order" for DS18B20

This feels like a stupid question…

But using https://shop.openenergymonitor.com/rj45-expander-for-ds18b20-pulse-sensors/ or SWE2 Sensor Connection Module, Sheepwalk Electronics with numerous DS18B20… There’s obviously no order you should plug them in (or is there something like that)… But how do you work out which is which when it gets to emoncms?

I know you could go through each temperature probe (when placed remotely) and heat it up and see… But there feels like there should be a better way?

All the sensors talk on the same one wire (that’s why they’re called OneWire sensors) so the physical order is totally irrelevant. It’s all done by the serial number assigned during manufacture.

But there’s worse…
If one of your sensors goes AWOL, on restarting (whatever you’re running - you don’t say) the sequence in which those that remain appear will almost certainly change. When it starts, the sketch searches for sensors and the order they are found in is explained in ‘Learn’.

Because of that, I made provision in emonLibCM to fix the positions of the sensors, so that each always appears in the same ‘slot’. When you are setting that up, you connect a sensor, look at the address, then copy that address (by hand, sadly) into the array; then repeat for each sensor. Compile the sketch and the sensors are fixed in position for ever.

The array looks like this:

DeviceAddress allAddresses[] = {       
    {0x28, 0x81, 0x43, 0x31, 0x7, 0x0, 0xFF, 0xD9}, 
    {0x28, 0x8D, 0xA5, 0xC7, 0x5, 0x0, 0x0, 0xD5},      // Use the actual addresses, as many as required
    {0x28, 0xC9, 0x58, 0x32, 0x7, 0x0, 0x0, 0x89}       // up to a maximum of 6    
};

(That’s for 3 sensors.)

As the standard emonTx and emonPi code stands, you can’t do that without making modifications.

Thanks!

I presumed it had to be done by something (it couldn’t be completely indeterministic), but it wasn’t obvious (I hadn’t dug into it further)

I’m using an emonPi.

I wonder if we can get the interface to expose the serial number… I’ll have a look when I have a bit more time and see what I can cobble together, and/or using a different library like you suggest

Unfortunately, I haven’t tried to make emonLibCM work with the emonPi yet - and I fear problems because of the need to handle incoming radio traffic as well as the much heavier sampling load.

If you haven’t got an emonTx to plug the sensors in to get the serial numbers, you’re going to struggle. Basically, you’ll need to get a sketch into the emonPi’s “emon” front end that reads the serial numbers, then replace the standard emonPi sketch (or more likely modify it) to use the addresses you give it.

That should not be too hard - everything has been done before, just not in the emonPi.

You will be able to write a sketch for the emonPi using emonLibCM to report the serial numbers, but I doubt it will run with JeeLIb and be able to use the radio. If you don’t need the radio, it’s well worth trying.

(Hint - when I mess with the emonPi front end, I disassemble it and connect using the programmer and FTDI connector - but you still need the Pi for power. That’s much easier than trying to do it at arm’s length via PUTTY, LAN and the Pi or stuff like that.)

Need to remember I need to do a proper shutdown/reboot when changing senors…