logo elektroda
logo elektroda
X
logo elektroda

How do I receive data from a remote control on a Wemos D1 Mini with a 433MHz RF module?

kaimaz 1761 23
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 18144289
    kaimaz
    Level 6  
    Hello

    I have made the board and have everything after connected. First comes the 4 channel 433MHz radio module and then the wemos d1 mini. The libraries are installed and everything is working because I am able to connect to the wifi or light up the LED. However, I don't know how and I've been looking and trying for 2h+ and I still don't know how. When I press the button on the remote control then the radio module receives data and transmits it to the wemos d1 mini. Just how to receive this data? I have tried :
    /*
      Example for receiving
      
      https://github.com/sui77/rc-switch/
      
      If you want to visualize a telegram copy the raw data and 
      paste it into http://test.sui.li/oszi/
    */
    
    #include <RCSwitch.h>
    
    RCSwitch mySwitch = RCSwitch();
    
    void setup() {
      Serial.begin(115200);
      mySwitch.enableTransmit(4);  // Receiver on interrupt 0 => that is pin #2
    }
    
    void loop() {
      if (mySwitch.available()) {
        output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol());
        mySwitch.resetAvailable();
      }
    }
    .

    However, nothing happens.
    This is what my board looks like:
    How do I receive data from a remote control on a Wemos D1 Mini with a 433MHz RF module? How do I receive data from a remote control on a Wemos D1 Mini with a 433MHz RF module? .

    And I have no idea why it doesn't work. The power supply is 5v, it now flies via usb as you can see by the stepper down the board is powered.
  • ADVERTISEMENT
  • #2 18144424
    khoam
    Level 42  
    kaimaz wrote:
    When I press the button on the remote control then the radio module receives the data and transmits it to the wemos d1 mini. Just how do I receive this data?
    .
    kaimaz wrote:
    mySwitch. enableTransmit (4);
    .
    Do you want to transmit or receive codes from the remote control?

    The example for receiving from the rc-switch library is a little different:
    Code: C / C++
    Log in, to see the code
    .
  • #3 18144987
    kaimaz
    Level 6  
    @khoam want to receive :) with remote transmit in receiver connected to wemos I am receiving
  • ADVERTISEMENT
  • #4 18145003
    khoam
    Level 42  
    kaimaz wrote:
    want to receive with remote transmit in receiver connected to wemos I receive
    .
    Does the example I gave in my previous post work for you?
  • #5 18145011
    kaimaz
    Level 6  
    Unfortunately not :( admittedly there you have ``mySwitch.enableReceive(0)`` and I have it connected to D2 which as you can see from the diagram is pin 4. How do I receive data from a remote control on a Wemos D1 Mini with a 433MHz RF module? .
  • #6 18145053
    khoam
    Level 42  
    Actually for the ESP8266 this code should look slightly different (different pin number):
    Code: C / C++
    Log in, to see the code
    .
  • #7 18145083
    kaimaz
    Level 6  
    Unfortunately I've tried before and both don't work, in the serial monitor I have the question mark reversed.

    Added after 4 [minutes]: .

    /*
      Simple example for receiving
      
      https://github.com/sui77/rc-switch/
    */
    
    #include <RCSwitch.h>
    
    RCSwitch mySwitch = RCSwitch();
    
    void setup() {
      Serial.begin(9600);
      mySwitch.enableReceive(4);  // Receiver on interrupt 0 => that is pin #2
    }
    
    void loop() {
      if (mySwitch.available()) {
        
        int value = mySwitch.getReceivedValue();
        
        if (value == 0) {
          Serial.print("Unknown encoding");
        } else {
          Serial.print("Received ");
          Serial.print( mySwitch.getReceivedValue() );
          Serial.print(" / ");
          Serial.print( mySwitch.getReceivedBitlength() );
          Serial.print("bit ");
          Serial.print("Protocol: ");
          Serial.println( mySwitch.getReceivedProtocol() );
        }
    
        mySwitch.resetAvailable();
      }
    }
    .

    This is another example I found from this library but in general most of these queries return some weird bushes in the serial monitor and so I have Serial.begin the same as baud in the serial monitor How do I receive data from a remote control on a Wemos D1 Mini with a 433MHz RF module? .
  • #8 18145102
    khoam
    Level 42  
    kaimaz wrote:
    in Serial Monitor I have the question mark reversed.

    Do you have the speed set correctly in Serial Monitor i.e. according to Serial.begin()? In the code from post #6 it is 115,200.
  • #9 18145114
    kaimaz
    Level 6  
    @khoam as you can see from the printscreen when I have 9600 set it here and here and when 115200 set it here and here :) .
  • ADVERTISEMENT
  • #10 18145131
    khoam
    Level 42  
    If you are supplying the RF receiver module with 5V, you should use a 5V/3V3 level converter when connecting to pin D2 on the wemos.
  • #11 18145145
    kaimaz
    Level 6  
    In general, on my board the current goes through the RF module at 5V, and then it goes to the Wemos at 5V. And when I want to connect to the wifi it works, and the test flashing light too. Unfortunately I can't receive data. My RF receiver has two data and I connected one to D2 and the other to D3.
  • #12 18145162
    khoam
    Level 42  
    kaimaz wrote:
    generally on my board current goes through the RF module at 5V, and then it goes to the Wemos at 5V. And when I want to connect to the wifi it works, and the test flashing light too.
    .
    This has nothing to do with it - if you are sending data to a pin in Wemos, it must be in 3V3 logic, not 5V. Otherwise you could damage that pin.

    For this case you can use the simplest solution:

    How do I receive data from a remote control on a Wemos D1 Mini with a 433MHz RF module? .
  • #13 18145174
    kaimaz
    Level 6  
    but generally when I put the meter to the data pins on the transmitter there is no voltage at all when I press the button on the remote control, so I thought there was no current there?

    Added after 13 [minutes]:

    How do I receive data from a remote control on a Wemos D1 Mini with a 433MHz RF module? .
    I have this one and now there is 5V going to VCC at my place.
    GND goes to GND
    DATA 2 goes to D2 and DATA 3 goes to D3
    Then from VCC goes from Wemos d1 mini 5v and GND to GND

    Do you think to unsolder and give a resistor between DATA 2 and D2?

    And interesting that when I check the voltage on DATA2 and GND with a meter it doesn't show anything when I press the button on the remote, is this normal?
  • ADVERTISEMENT
  • #14 18145330
    khoam
    Level 42  
    kaimaz wrote:
    DATA 2 goes to D2 and DATA 3 goes to D3
    .
    The DATA2 and DATA3 pins are in this receiver module connected to each other , so there is no point in connecting both of these pins to Wemos.
    https://lastminuteengineers.com/433mhz-rf-wireless-arduino-tutorial/
    You use D2 from the Wemos and connect it to DATA2 or DATA3 in the RF receiver module through the level converter whose schematic I have already given.

    kaimaz wrote:
    I find it interesting that when I check the voltage on DATA2 and GND with a meter it shows nothing when I press the button on the remote control, is this normal?
    .
    Such measurements are made with an oscilloscope.

    Edit: As you have connected DATA2 and DATA3 from the receiver module to different pins on the Wemos, you have shorted these pins together quite effectively....
  • #15 18145535
    kaimaz
    Level 6  
    I don't exactly have such a resistor. I have 1k, 4.7k and smaller

    Because this diagram I don't know how to apply to me. I have unsoldered DATA2 and DATA3 and 5V goes to VCC and to 5V in d1 mini and GDN goes to GDN and then to GDN in d1 mini. If I put a resistor there for example from DATA2 to D2 on the d1 mini is that enough? and which one to use?


    Are there any small oscillators? because I found on allegro only big ones :(

    Added after 3 [hours] 11 [minutes]:

    @khoam generally I gave 1k and 4k7 to the gdn. and used this code
    
    #include <RCSwitch.h>
    
    RCSwitch mySwitch = RCSwitch();
    
    void setup() {
      Serial.begin(115200);
      mySwitch.enableReceive(4); // albo mySwitch.enableReceive(4)
    }
    
    void loop() {
      if (mySwitch.available()) {
        
        Serial.print("Received ");
        Serial.print( mySwitch.getReceivedValue() );
        Serial.print(" / ");
        Serial.print( mySwitch.getReceivedBitlength() );
        Serial.print("bit ");
        Serial.print("Protocol: ");
        Serial.println( mySwitch.getReceivedProtocol() );
    
        mySwitch.resetAvailable();
      }
    }
    
    .

    in the serial monitor it appeared:
    ⸮⸮ ⸮load 0x4010f000, len0x2d
    csum 0x2d
    v6000001c
    ~ld
    
    Exception (29):
    epc1=0x4000e1b2 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
    
    ctx: sys 
    sp: 3ffff920 end: 3fffffb0 offset: 01a0
    
    >>>stack>>>
    3ffffac0:  3ffe8de2 000002f4 60000e00 401004f4  
    3ffffad0:  3fffff10 000000a2 60000e00 401071ac  
    3ffffae0:  40206cd0 40101890 00000000 40206d0c  
    3ffffaf0:  40101b70 000003fd 000000a2 60000200  
    3ffffb00:  3fffff10 00000000 00000000 00000000  
    3ffffb10:  ffffe6fc ffffffff ffff0003 0000000f  
    3ffffb20:  4b414241 554e5f53 4741505f 00494441  
    3ffffb30:  feefeffe feefeffe feefeffe feefeffe  
    3ffffb40:  00030503 73000001 6b656e79 696d616d  
    3ffffb50:  316b656e 9240003f 39401048 00000035  
    3ffffb60:  30000001 d03ffee3 013fffda c8000000  
    3ffffb70:  b03ffee2 d0402015 0a3fffda 14000000  
    3ffffb80:  393ffef5 00402018 50afc2b2 8264d7ee  
    3ffffb90:  856680df 8d642dbb a1c91200 e1b89120  
    3ffffba0:  e275bf85 ce70548b ffffffff ffffffff  
    3ffffbb0:  ffffffff ffffffff 0dd800ff 2221a417  
    3ffffbc0:  0000000f 79726146 6b6e694c 3743345f  
    3ffffbd0:  00393644 00000000 00000000 00000000  
    3ffffbe0:  00000000 00000000 00000000 00000000  
    3ffffbf0:  00000000 00000000 00000000 00000000  
    3ffffc00:  00000000 00000000 00000000 00000000  
    3ffffc10:  00000000 00000000 00000000 00000000  
    3ffffc20:  00000000 ffffff00 ffffffff ffffffff  
    3ffffc30:  ffffffff ffffffff ffffffff ffffffff  
    3ffffc40:  ffffffff 000001ff ffffff04 ffff0001  
    3ffffc50:  0000000f 4b414241 554e5f53 4741505f  
    3ffffc60:  00494441 feefeffe feefeffe feefeffe  
    3ffffc70:  feefeffe 656e7973 6d616d6b 6b656e69  
    3ffffc80:  40003f31 40104892 00003539 00000100  
    3ffffc90:  3ffee330 3fffdad0 00000001 3ffee2c8  
    3ffffca0:  402015b0 3fffdad0 0000000a 3ffef514  
    3ffffcb0:  40201839 ffffffff ffffffff ffffffff  
    3ffffcc0:  ffffffff ffffffff ffffffff ffffffff  
    3ffffcd0:  ffffffff ffffffff ffffffff ffffffff  
    3ffffce0:  ffffffff ffffffff ffffffff ffffffff  
    3ffffcf0:  ffffffff ffffffff ffffffff ffffffff  
    3ffffd00:  ffffffff ffffffff ffffffff ffffffff  
    3ffffd10:  ffffffff ffffffff ffffffff ffffffff  
    3ffffd20:  ffffffff ffffffff ffffffff ffffffff  
    3ffffd30:  ffffffff ffffffff ffffffff ffffffff  
    3ffffd40:  ffffffff ffffffff ffffffff ffffffff  
    3ffffd50:  ffffffff ffffffff ffffffff ffffffff  
    3ffffd60:  ffffffff ffffffff ffffffff ffffffff  
    3ffffd70:  ffffffff ffffffff ffffffff ffffffff  
    3ffffd80:  ffffffff ffffffff ffffffff ffffffff  
    3ffffd90:  ffffffff ffffffff ffffffff ffffffff  
    3ffffda0:  ffffffff ffffffff ffffffff ffffffff  
    3ffffdb0:  ffffffff ffffffff ffffffff ffffffff  
    3ffffdc0:  ffffffff ffffffff ffffffff ffffffff  
    3ffffdd0:  ffffffff ffffffff ffffffff ffffffff  
    3ffffde0:  ffffffff ffffffff ffffffff ffffffff  
    3ffffdf0:  ffffffff ffffffff ffffffff ffffffff  
    3ffffe00:  ffffffff ffffffff ffffffff ffffffff  
    3ffffe10:  ffffffff ffffffff ffffffff ffffffff  
    3ffffe20:  ffffffff ffffffff ffffffff ffffffff  
    3ffffe30:  ffffffff ffffffff ffffffff ffffffff  
    3ffffe40:  ffffffff ffffffff ffffffff ffffffff  
    3ffffe50:  ffffffff 00000003 ffffff00 ffffffff  
    3ffffe60:  ffffffff ffffffff ffffffff ffffffff  
    3ffffe70:  ffffffff ffffffff ffffffff ffff0064  
    3ffffe80:  00000000 00000000 ffffffff ffffffff  
    3ffffe90:  ffffffff ffffffff ffffffff ffffffff  
    3ffffea0:  ffffffff ffffffff ffffffff ffffffff  
    3ffffeb0:  ffffffff ffffffff ffffffff ffffffff  
    3ffffec0:  ffffffff ffffffff ffffffff ffffffff  
    3ffffed0:  ffffffff ffffffff ffffffff ffffffff  
    3ffffee0:  ffffffff ffffffff ffffffff ffffffff  
    3ffffef0:  ffffffff 50afc2b2 8264d7ee 856680df  
    3fffff00:  8d642dbb a1c91200 e1b89120 e275bf85  
    3fffff10:  ce70548b ffffffff ffffffff ffffffff  
    3fffff20:  ffffffff ffffffff ffffffff ffffffff  
    3fffff30:  ffffffff ffffffff ffffffff ffffffff  
    3fffff40:  ffffffff ffffffff ffffffff ffffffff  
    3fffff50:  ffffffff ffffffff ffffffff ffffffff  
    3fffff60:  ffffffff ffffffff ffffffff ffffffff  
    3fffff70:  ffffffff ffffffff ffffffff ffffffff  
    3fffff80:  ffffffff ffffffff ffffffff ffffffff  
    3fffff90:  ffffffff 2575aa0e a6c3b7eb 950406cd  
    3fffffa0:  400201e9 b0e746c5 ffffff01 55aa55aa  
    <<<stack<<<
    sld⸮⸮|⸮l⸮|⸮d⸮b|⸮⸮⸮⸮s⸮c⸮c⸮⸮gg⸮lgg⸮⸮⸮cpx⸮⸮l{lsl
    .

    in the terminal appeared:
    Arduino: 1.8.9 (Linux), Board: "WeMos D1 R2 & mini, 80 MHz, 115200, 4M (3M SPIFFS)"
    
    Sketch uses 225341 bytes (21%) of program storage space. Maximum is 1044464 bytes.
    Global variables use 32180 bytes (39%) of dynamic memory, leaving 49740 bytes for local variables. Maximum is 81920 bytes.
    Uploading 229488 bytes from /tmp/arduino_build_720927/ReceiveDemo_Advanced.ino.bin to flash at 0x00000000
    ................................................................................ [ 35% ]
    ................................................................................ [ 71% ]
    ...............warning: espcomm_send_command: no final C0
    warning: espcomm_send_command(FLASH_DOWNLOAD_DATA) failed
    warning: espcomm_send_command: didn't receive command response
    error: espcomm_upload_mem failed
    error: espcomm_upload_mem failed
    
    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.
    
    .

    I have everywhere set to 115200 in upload speed also. So in general something starts to appear :D but something crashes :( .

    Any ideas?

    Added after 9 [minutes]:

    this receive demo sample :

    /*
      Simple example for receiving
      
      https://github.com/sui77/rc-switch/
    */
    
    #include <RCSwitch.h>
    
    RCSwitch mySwitch = RCSwitch();
    
    void setup() {
      Serial.begin(115200);
      mySwitch.enableReceive(D2);  // Receiver on interrupt 0 => that is pin #2
    }
    
    void loop() {
      if (mySwitch.available()) {
        
        int value = mySwitch.getReceivedValue();
        
        if (value == 0) {
          Serial.print("Unknown encoding");
        } else {
          Serial.print("Received ");
          Serial.print( mySwitch.getReceivedValue() );
          Serial.print(" / ");
          Serial.print( mySwitch.getReceivedBitlength() );
          Serial.print("bit ");
          Serial.print("Protocol: ");
          Serial.println( mySwitch.getReceivedProtocol() );
        }
    
        mySwitch.resetAvailable();
      }
    }
    .

    returns in the serial monitor:
     1384, room 16 
    tail 8
    chksum 0x2d
    csum 0x2d
    v6000001c
    ~ld
    .

    and when I give
    mySwitch.enableReceive(4)
    it returns the same
     1384, room 16 
    tail 8
    chksum 0x2d
    csum 0x2d
    v6000001c
    ~ld ⸮


    only at the end it adds ⸮
  • #16 18146001
    khoam
    Level 42  
    kaimaz wrote:
    So in general something is starting to appear but something is crashing
    .
    No code loading into Wemos - process stops with an error while loading. A completely different class of problem.
    kaimaz wrote:
    Uploading 229488 bytes from /tmp/arduino_build_720927/ReceiveDemo_Advanced.ino.bin to flash at 0x000000
    ................................................................................ [ 35% ]
    ................................................................................ [ 71% ]
    ...............warning: espcomm_send_command: no final C0
    warning: espcomm_send_command(FLASH_DOWNLOAD_DATA) failed
    .
    Remove the Wemos module from the chip and then try to program it.
  • #17 18146419
    kaimaz
    Level 6  
    I have now successfully uploaded it but it still shows nothing new in the serial monitor but
     1384, room 16 
    tail 8
    chksum 0x2d
    csum 0x2d
    v6000001c
    ~ld
    ⸮


    Any idea what else could be done?
  • #18 18146435
    khoam
    Level 42  
    It looks as if the program does not start at all. Check this by uploading some simple example program e.g. blink.
  • #19 18146480
    kaimaz
    Level 6  
    sample blink works without a problem :
    /*
      Blink
    
      Turns an LED on for one second, then off for one second, repeatedly.
    
      Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
      it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
      the correct LED pin independent of which board is used.
      If you want to know what pin the on-board LED is connected to on your Arduino
      model, check the Technical Specs of your board at:
      https://www.arduino.cc/en/Main/Products
    
      modified 8 May 2014
      by Scott Fitzgerald
      modified 2 Sep 2016
      by Arturo Guadalupi
      modified 8 Sep 2016
      by Colby Newman
    
      This example code is in the public domain.
    
      http://www.arduino.cc/en/Tutorial/Blink
    */
    
    // the setup function runs once when you press reset or power the board
    void setup() {
      // initialize digital pin LED_BUILTIN as an output.
      pinMode(LED_BUILTIN, OUTPUT);
    }
    
    // the loop function runs over and over again forever
    void loop() {
      digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(1000);                       // wait for a second
      digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
      delay(1000);                       // wait for a second
    }
    .
    I don't know why that one doesn't work. And I already have everything soldered together a bit pointlessly.

    But maybe still a board to save :) I'll leave the radio and the d1 mini alone is enough for me. I will power it 5v to 5v and gdn to gdn. for this i want to write an app and if someone clicks in the app "open" it will command a voltage of for example 3.3v from pin?or from 3v3? any idea how to do this?
  • #20 18146586
    khoam
    Level 42  
    Please show again what the logs look like when uploading the receiver code, which then generates messages in Serial Monitor, as in post #17.
  • #21 18146704
    StaryVirus_e_Wiarus
    Level 21  
    Hi
    This receiver from post #13 does not pass 115200 b/s. Its maximum capability is probably 4800 b/s. And one more thing: your remote works on 433 MHz or 315 MHz. The receiver can operate on either. They were made on 433 MHz or on 315 MHz. They differed by some component.
  • #22 18146714
    khoam
    Level 42  
    StaryVirus_e_Wiarus wrote:
    This receiver from post #13 does not pass 115200 b/s.
    .
    Nowhere in the code is the "speed" of the RF receiver set.

    Added after 5 [minutes]:

    A description of the receiver and transmitter is attached.
  • #23 18146747
    StaryVirus_e_Wiarus
    Level 21  
    Here you go:
    Code: C / C++
    Log in, to see the code
  • #24 18146751
    khoam
    Level 42  
    StaryVirus_e_Wiarus wrote:
    Well then please:
    .
    Well then please explain to us all now what this speed setting is on the RF receiver, which is not connected to Serial in Wemos. I will also mention that without the "Serial.begin()" line, the RF receiver will also work.

    To make things easier: the source codes of the rc-switch library are here:
    https://github.com/sui77/rc-switch

Topic summary

The discussion revolves around receiving data from a remote control using a Wemos D1 Mini and a 433MHz RF module. The user successfully connected the hardware and installed the necessary libraries but struggled to receive data from the remote. Various code snippets were shared, highlighting the need to use the correct pin configuration for the RF receiver. The importance of using a level converter for voltage compatibility between the 5V RF module and the 3.3V Wemos was emphasized. Users suggested checking the serial monitor settings and ensuring the RF receiver's baud rate compatibility. The conversation also touched on the wiring of the RF module and the potential issues with connecting both data pins to the Wemos, which could lead to short-circuiting. Ultimately, the user was advised to troubleshoot the connections and verify the RF module's specifications.
Summary generated by the language model.
ADVERTISEMENT