• Hi,
    I've been following the REMOTE CONTROL SOCKETS tutorial, it was all going well.
    Based on the photo in the tutorial I'm using the same remote and plug socket.
    I was able to connect to pick up the remote controls "messages" (although I did use the transmitter with 4pins)

    Having received codes (e.g. 0b1110010111111111000011100) I changed the setup to be a transmitter. (again using the transmitter with 4 pins only 3 pins connected)

    This is where I get stuck.
    I used the send code in the tutorial but none of my plugs turn on or off.
    I double checked, and using the remote control it works fine.

    I have recreated all of the wiring but still no luck.

    Any tips on how I can go about debugging this or figuring out what is wrong?

  • I have the same receiver and transmitter as on this image:
    After some tests I found that left one on the image is the transmitter (3 pins) and right one is the receiver (4 pins)

    I using the code from example, here are my exact code with connections:

    /**
      On press button BTN1 send bits (CODE variable) from transmitter (A1) to receiver (A0) multiple times. Blue LED blinking on send data, green LED blinking on receive data.
      
      Transmitter:
        GND <-> GND
        VCC <-> Bat
        ATAD <-> A1
        
      Receiver:
        GND <-> GND
        VCC <-> 3.3 (If using Bat there are many errors that we get on input)
        DATA1 OR DATA2 <-> A0
    */
    
    var t,n, counter = 0;
    
    // When the signal rises, check if it was after ~5ms of delay - if so (and if we have a code) display it.
    function sigOn(e) {
     // console.log('sigOn:', getTime());
      var d = e.time-t;
      if (d>0.005 && n>0) {
        console.log(counter++, ":0b"+n.toString(2));
        n=0;
      }
      t = e.time;
      LED2.write(1);
    }
    
    // When the signal falls, measure the length of our pulse. 
    // If it was within range, record a 1 or a 0 depending on the length. 
    // If it wasn't in range, zero it
    function sigOff(e) {
     // console.log('sigOff:', getTime());
      var d = e.time-t;
      t = e.time;
      if (d>0.0001 && d<0.001)
        n = (n<<1) | ((d>=0.0004)?1:0);
      else
        n=0;
      LED2.write(0);
    }
    
    setWatch(sigOn,A0,{repeat:true,edge:"ris­ing"});
    setWatch(sigOff,A0,{repeat:true,edge:"fa­lling"});
    
    var TX = A1;
    var CODE = 0b10100000111111101110;
    
    function sendCommand(command) {
      LED3. write(1);
      var bits = (CODE & ~0b11111) | command;
      for (var i=24;i>=0;i--) {
        if ((bits>>i)&1) {
          digitalPulse(TX,1,0.9);
          digitalPulse(TX,0,0.3);
        } else {
          digitalPulse(TX,1,0.3);
          digitalPulse(TX,0,0.9);
        }
      }
      digitalPulse(TX,1,0.001);
      LED3. write(0);
    }
    
    function sendMultiple(command) {
      var n = 9;
      var interval = setInterval(function() {
        sendCommand(command);
        if (n-- < 0) clearInterval(interval);
      }, 50);
    }
    
    var socketOn = false;
    setWatch(function() {
      socketOn = !socketOn;
      sendMultiple(socketOn ? 0b11110 : 0b01110);
    }, BTN1, { repeat:true, edge:"rising", debounce:10 });
    
    
    // A1 -> transmitter (3 wires) green
    // A0 -> receiver (4 wires) yellow
    

    Hope this helps, LMK if you need some help, I passed it before few days. :)

    BTW, how did you checked the remote control that it works fine?

    PS: Here is additional good explanation for the code if you need it.

  • Thanks so much.
    I had the transmitter and receiver the wrong way around.

    Using your code I've now got a switch turning on and off! :)
    Now I just need to figure out why only "channel 1" switches work and not 4.

    Am I correct in thinking all I need to change is the CODE variable?

    For channel 4 I get this output: 0b1110010111111111000011100
    So I replace the current string in code with that but it still turns on channel 1.

    Thanks again for your help.

  • @yayAdrian what do you mean "got a switch" and "channel"? Can you please add more details for what would be done? Thanks

  • Sorry,
    Switch = wall plug
    channel = the buttons on the remote say 1, 2, 3, 4

  • Still didn't tested the remote, it on it's way from Hong Kong , I sending and receiving the bits on the same board :)
    But lets try to understand it.
    Does each channel sends different code? just try to debug it with console.log()

  • So I went back to basics with the code and found that

    sendMultiple(socketOn ? 0b11110 : 0b01110);
    

    Was causing me the problem. I replaced that by passing the full code (e.g. 4 = 0b1110010111111111000011100) and I am able to turn all of the channels/1,2,3,4 on and off.
    Thanks for your help. Hope you get your remotes and switches soon.

  • Glad you got it working eventually!

    @yayAdrian: Did you change the line 'CODE=' in the code that you put into Espruino? If you didn't it may explain why you had to put the full code into sendMultiple

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Hit problem with REMOTE CONTROL SOCKETS 433hz tutorial

Posted by Avatar for yayAdrian @yayAdrian

Actions