1

I have two Attiny85 communicating over 433mhz radio (Rx & Tx on either ends) using virtual wire library, how will the programming be to pair them by the press of a button on either module ? i have so far been able to pair them both through the program (exclude any external devices by giving a node ID to listen to in my Rx) or think of adding DIP switches (but i run out of pins & combinations sooner). I am expecting something similar to a commercial product where i can connect/pair multiple Tx modules to a single Rx base station in a press of a button on the Tx side. so i am seeking some technical expertise on the idea to understand such programming technique/methods.

Regardless of using 433mhz or a NRF24L01 module or anything else, i want to know how this feature of pairing module together is made.

------ Edit 22 July 2021: This is added here in response from Crisl's comment

you have correctly understood my question, yes i want to learn how such a pairing protocol is implemented, i am not too concerned about the device for the communication gateway.

this question is regarding the protocol, and not about a specific circuit

------ I am a mechanical engineer by profession, with a hobby towards programming & electronics, so kindly spare some patience/detail in explaining this concept/technique.

New contributor
phoenix99 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
3
  • 1
    please add a diagram of the system that you are trying to build – jsotola Jul 22 at 2:21
  • If you are talking about these simple 433MHz modules, which are also used for example in garage openers, then there is normally no pairing. The sender just sends some data (a static code, rolling code or other security measurement) and the receiver receives that data and acts accordingly. They normally don't have a sense of which device send the data. That would be an overlying protocol. Can you please describe, what you want to achieve? Current it is rather broad, so that we cannot really give advice on what would be the best option. – chrisl Jul 22 at 6:46
  • @chrisl.....yes i want to learn the protocol implementation, i am clueless on how to learn such a protocol, maybe give me some reference to learn that will also help – phoenix99 Jul 22 at 11:15
1

If it is sufficient to distinguish between the two (or several) transmitters and you don't need to exclude intrusions, accidental or otherwise, a "protocol" can be as simple as:

XMTRID BYTECOUNT BYTE[0] BYTE[1] ... BYTE[COUNT-1]

, where each of the above represents a single byte. Does the library include message integrity checking, such as a checksum? If not, and the physical conditions warrant, you might add that to your protocol as well, and include an expectation by the transmitter that it receives an acknowledgement or rejection of correct reception (ACK or NAK) within a short time and will re-transmits the same message if it hasn't received an ACK. Then you'll want a message ID byte that increments for each new message (but not for retramsmission), so the receiver can reject a retransmission (if, say, its attempt to acknowledge had been lost).

Then your protocol could look something like this:

XMTRID MSGID CHKSUM BYTECOUNT BYTE[0] BYTE[1] ... BYTE[COUNT-1]

. and it just keeps getting better from there as you add features for robustness, security, and whatever else you might need it to accomplish. But I'm guessing this is already sufficient.

Update: To clarify:

XMTRID    - ID of sending 433MHz radio (any value you like, as long as each device has its own).
MSGID     - An incrementing number (rollover allowed), a new one for each *new* message
            (enables the receiver to distinguish new messages from resent ones).
CHKSUM    - A sum of bytes in the message to let the receiver check the message integrity.
BYTECOUNT - The number of message bytes to follow.
BYTE[0] ... BYTE[BYTECOUNT-1] - The actual message data.
1
  • Thanks, i understand your logic. this has sparked some new thinking for new topics to learn and experiment on. and i suppose you mean the Tx ID as "XMTRID" ?, and what is the difference between CHKSUM BYTECOUNT BYTE[0] BYTE[1] ... BYTE[COUNT-1] – phoenix99 Jul 22 at 17:41

Your Answer

phoenix99 is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.