I want to use a "listen-before-talk" approach to transmit data from sensors connected to a transmitter and receiver pair to a MCU connected to a transmitter and receiver, which means that the sensor will only transmit data once it has been asked to do so by the MCU, but the problem I'm having is that my receivers will have no way of knowing if the information it's receiving is from one of my transmitters or from some other 433 transmitter in the area.The receiver I want to use has a product description here which seems to suggest there may be a method of pairing up my transmitters and receivers but how? If I transmit transmitter ID information e.g if the transmitter is transmitting 4 bits, I make the first two bits always "11" so the receiver knows that the information is from one of the transmitters it should listen to would I then be able to filter data I don't want on the AVR?
Those types of transmitters and receivers only work on a single channel. The receivers usually employ a form of active gain control (AGC), so will increase the gain until something (usually noise) is received. The gain is reduced to an appropriate level when a transmission starts.
Generally best practice is to:
- Agree on a bit rate between the two systems (e.g. 4800bps). Generally receiver/transmitter pairs will give you some guidance on these.
- Transmit a preamble of 10101010 (generally somewhere between 8 and 40 bits) before starting the main transmission. This has two purposes - it allows the AGC to settle at a good point, and can be detected by the microcontroller so it is aware that a transmission is starting.
- Transmit a sync word e.g. 0xD5F7, and only listen to packets which have the correct sync word. The length of the sync word varies.
- Use the rest of the data packet to detail the address, direction, and data.
I have found that the VirtualWire library for the Arduino is actually a nice, clear example of how to go about this. Maybe take a look, even if you are working with another microcontroller family.
One further thing worth considering is the encoding of bits. You can just send a 1 as a 1 and a 0 as a 0. There are more complex schemes though. Manchester encoding ensures that each bit of data transmitted has at least one signal transition. This has two significant effects:
- Regardless of the data sent, there will be an equal number of highs and lows sent. This means the AGC can work properly and there is no DC bias to the signal.
- As there is a transition for each bit, it is easy to recover the clock from the signal even if it is not known. This really means you transmitters no longer have a need to use an external crystal - the internal oscillator is accurate enough.