433.92Mhz Transmitter and Receiver
The 433.92Mhz modules are generally pretty basic. Each module is either an AM transmitter or an AM receiver, and has a single digital input or output.
There is no real filtering/encoding/decoding performed by the module. If there is a signal the receiver outputs a logic 1, and if there isn't it outputs a logic 0. This means that everything has to be handled by Espruino.
The modules appear to have quite a wide input voltage range (3.3v - 12v) however check your part's description first! We've found that at lower voltages (for instance 3.3v) the receiver works but at limited sensitivity (which is sometimes good if you want to isolate the signal from a nearby transmitter).
Receiver
The Receiver often has 4 wires, although the middle two (signal) are connected together - leaving just GND, VCC and Signal (Data Out) to connect up.
Note: As the 433.92Mhz band is used by all kinds of devices, you may find that there is a huge amount of data on the Data Out line, and that it is hard to isolate weaker signals.
Transmitter
The Transmitter usually has just 3 wires, GND, VCC and Signal (Data In).
Software
As these modules are literally just radios, the protocol you use on them is entirely up to you (as is the decoder).
We have however created a module that handles transmission and reception of small packets using a very simple protocol (no header or addressing, one byte CRC).
The module itself is called 433 (About Modules).
Transmitting
Just call the tx
method to transmit. Messages should be quite short, as they are only transmitted at around 2 kBits/sec.
The arguments are:
- The pin the transmitter is on
- The data to send (string or array)
- The number of retransmissions. This should probably be at least 3.
- A callback to be called when transmission is complete
require("433").tx(B13, "Hello", 3, function() {
console.log("Sent!");
});
Receiving
Just call rx
to start receiving - the second argument is a callback that'll be called for each received packet (with a Uint8Array
as the first argument). Note that there may be duplicate
packets received.
require("433").rx(B13, function (data) {
console.log(data);
});
Note: Receiving is still far from perfect, and in very noisy environments the amount of invalid data being received may make it difficult for Espruino to handle communications with the console.
You may find that reception (especially with low quality non-squelching receivers) isn't very good and results in a FIFO_FULL
error showing the signal couldn't be handled fast enough.
In order to work around this, you may find the following code (which can use JIT in newer firmwares) behaves a little better.
var pin = B13;
var n="";
function decode() {
var l = n.length;
var d = new Uint8Array((l+7)>>3);
for (var i=0;i<l;i+=8)
d[i>>3] = parseInt(n.substr(i,8),2);
var data = new Uint8Array(d.buffer,0,d.length-1);
var chksum = data.reduce(function(a,b){return a^b;},0);
if (chksum == d[d.length-1])
console.log(data);
}
setWatch(sig, function(e){
"jit";
var d = 10000*(e.time-e.lastTime);
if (d<2 || d>10) {
if (n.length>20) decode();
n="";
} else if (!e.state) n+=0|d>5;
}, {repeat:true, edge:"both"});
Using
Buying
433Mhz modules can be purchased from many places, but some are better at transmitting/receiving than others. See this forum post for a bit more information.
This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.