I looked into automatic channel selection with XBees.
Going from the manual , I found out that these options work, mainly the settings for
ATA1 are interesting:
Configure the coordinator with:
ATA2 6 // 0b110 : allow associations (bit 3), automatic channel select (bit 2), fixed pan id (bit 1) ATCE 1 // coordinator enable ATAP 2 // API mode 2 (with escaped characters) ATID 7970 // pan id ATMY 1111 // address of the coordinator ATDL 1 // destination address low bytes ATDH 0 // destination address high bytes
Configure the nodes with:
ATA1 6 // 0b110 : use automatic association (bit 3), automatic channel select (bit 2), fixed pan id (bit 1) ATCE 0 // coordinator enable ATAP 2 // API mode 2 (with escaped characters) ATID 7970 // pan id ATMY 1 // address of the coordinator (or ATMY 2) ATDL 1111 // destination address low bytes (address of coordinator) ATDH 0 // destination address high bytes
What will happen according to the manual is that the coordinator upon startup will scan the channels (different frequencies in the 2.4 GHz range) for the one that has the least energy on it. Then it will pick that one.
The nodes will look for a coordinator on any channel that matches the pan ID they have, and switch to that channel.
As a side effect the MY address of the XBee on the nodes is reset, so this is solved by setting it in the node firmware to the desired address again.