Prototyping 433mhz receiver

CacoCaco The Netherlands

Hi,

I'm trying create a prototype with a 433mhz receiver which usually works with the Arduino IDE for the ESP8266 using the RCSwitch library. However, since MongooseOS is a great platform with a lot of default stuff already builtin, I'm trying to get the 433mhz receiver to work with mos aswell.

Following the attempt to at least receive something:

GPIO.set_mode(pin, GPIO.MODE_INPUT);

let pin = 4;

GPIO.set_int_handler(pin, GPIO.INT_EDGE_ANY, function(pin){

// print('Received interrupt on pin',pin); // This spams if connected to console

// Trying to mimic the RCSwitch interrupt handler func here

let time = Sys.uptime()*1000; //convert to millis

let duration = time - lastTime;

if(duration > 4300) { //nSeperationLimit

//This doesn't print

print('Long stretch');

}

lastTime = time;

},null);

GPIO.enable_int(pin);

It seems that there are no long stretches. Printing in the interrupt function receives a lot of spam.

Is it even possible to do this in javascript, or should I implement this in C? And is it possible to use the library as is (C++) or do I have to convert it to C?

Thanks in advance.

Ps. How do I markup multiline code?

Comments

  • rojerrojer Dublin, Ireland

    what kind of timing are we talking here? if you need microseconds-level timing, you will have to do it in C, JS is just not fast enough.

  • CacoCaco The Netherlands

    Seeing that millis() is used in the original RCSwitch library, I guess it's millisecond timing. But still, the interrupt handler seems to get called a lot.

  • rojerrojer Dublin, Ireland

    i worked with a 433 mhz receiver myself (Quasar QAM RX2) and it's very noisy.
    there's a lot of noise around, and it's constantly receiving stuff - mostly noise.
    welcome to the RF world, i guess :)
    i ended up implementing my own version of manchester encoding to get the data over the air.

  • CacoCaco The Netherlands

    Ok, but then I don't understand why the RCSwitch library works with the duration > 4300 check in place, since the noise doesn't change.

    I'll see if I can add some logging to the Arduino version in the interrupt handler and check whether that behaves the same.

    And start on porting it to C I guess.

Sign In or Register to comment.