Pairing Sensors to Arduino

Most of us know how to pair 2 Bluetooth devices.

Many of us also know how to pair a sensor to a repeater or controller running a matching decoding chip.

I am using an AVR chip (Arduino) for my controller. I can either manually store the sensor's code in EEPROM or on an SD card.

I am looking for recommendations for "pairing" a sensor with the Arduino, bearing in mind my sketch would already be loaded.

Firstly I imagine I would need a hardware switch to select "pairing mode" and possibly even "un-pairing mode".

In pairing mode, first thing would be to check if the sensor's code already exists and if not, add it otherwise just signal "pairing complete".

Un-pairing would effectively work the other way round.

First idea is to always start-up giving pairing/un-pairing option. If I use a time limit, either mode can be from a single pushbutton/input. No selection will default to normal mode.

I am still trying to wrap my head around this, but any suggestion on how best to code this option? I was thinking of using a series of prompts once a mode is selected. A reset button will allow re-boot and exiting pairing/un-pairing mode.

Not looking for code just pitfalls to avoid - memory over-use being one.

Actually just writing this post has given me a much clearer idea of what I want to do.

Still, TIA for any further guidance.

Ok so I just about have my head around this.

I will using the SD card.

One issue is the sketch expects the numeric codes to be in ascending order, one per line. Un-pairing is obviously not an issue.

Any suggestions on how to code writing a "new" numeric value on the line between an "existing" lower and higher value?

Hopefully I will get some responses now :)

Not sure if you are actually talking about "pairing" like Bluetooth or just identifying sensors attached. The latter is what I will do with my controller - it will have 2 18S20 temp sensors on the onewire connection. My plan is at power up, if the code does not see the sensors at the expected address (or as in the case of initial startup, the addresses will be "0" in eeprom, it will go into setup mode - requesting the user to warm one of the sensors up so it can identify it, then do the other one writing the addresses to eeprom for future use. If one of the sensors gets changed (it fails etc.), then it would again be looking to identify the sensor at power up. The other option would be a jumper on the circuit board that caused it to go into "find sensors" mode. After successful configuration, you would remove the jumper (or you could use a switch - I like the jumper better though - cheaper and less prone to environmental issues)

gpsmikey: Not sure if you are actually talking about "pairing" like Bluetooth or just identifying sensors attached.

As per my initial post and the thread title, I actually mean pairing i.e. recording the sensor's code.