• Sure. A tiny disclaimer though, I don't know anything about this, I'm learning about microcontrollers as I go ;) Therefore, I might use the wrong terminology :)

    My board is the HYSTM32 3.2". It's currently running the 1v41 of Espruino (if that matters).
    I have two separate modules for RF signals, one receiver and one transmitter. Sorry for these links leading to a swedish shop, they can probably be found in other online stores as well (probably cheaper too).

    Any way.

    I soldered some headers onto my board so that I easily can connect and disconnect stuff while learning about these things. I tried connecting the modules using a breadboard, but the antenna pin seems to act up when doing so. So I just use male-female connector wires from the transmitter into the board. Connected ground and power (3v3) and the data pin to A2.

    I had found examples online to receive and transmit rf signals, but they were either for arduino or for raspberry pi. I ended up using the rc-switch library as a base.

    The example TypeA_WithDIPSwitches_Lightweight seemed to be the easiest way to start. My cheap RF-plugs is using this setup, 5dip on the remote and 2x5 dip on the plug. This example is more or less directly translatable into Espruino. Though I tweaked it a little bit:

    var thePin = A2;
    function send(numberHigh, numberLow) {
      digitalPulse(thePin, 1, 0.35 * numberHigh);
      digitalPulse(thePin, 0, 0.35 * numberLow);
    function sendCode(code) {
      for (repeat=0; repeat < 6; repeat++) {
        for (i=4; i < 16; i++) {
          send(1, 3);
          if (((code << (i-4)) & 2048) > 0) {
            send(1, 3);
          } else {
            send(3, 1);
    function on() {
    function off() {

    As my plugs and remote is set with the following system code:

    1   2    3   4    5
    on  off  on  off  on

    and the plug in the above code has the following dips set:

    a    b    c    d    e
    off  on   off  off  off

    I therefore use the code 1010101000 and append 10 for turning on and 01 for turning off.

    Theres a pretty good explanation on the rc-switch wikipages for how these plugs operate.

    My next goal is to port the receiving code so that my rf-receiver can react to the remote that comes along with the plugs.


Avatar for Mudderman @Mudderman started