NEXA MYCR-3. Getting binary from radio signal / finding the signal ++ RESOLVED.

Hi.

I got a radio controlled NEXA MYCR-3 mains power switch. I tried some NEXA libraries and guides, even one made for the version that came before the MYCR-3, but it was unable to pick up the signal from my transmitter.

I tried using this program I found to pick up the signal, but I get nothing in the serial monitor:

/*
 * AM-HRR3 receiver test
 *
 * Homeeasy protocol receiver for the new protocol.
 *
 * This protocol isn't documented so well, so here goes (this is largely from memory).
 *
 * The data is encoded on the wire (aerial) as a Manchester code.
 *
 * A latch of 275us high, 2675us low is sent before the data.
 * There is a gap of 10ms between each message.
 *
 * 0 = holding the line high for 275us then low for 275us.
 * 1 = holding the line high for 275us then low for 1225us.
 * 
 * The timings seem to vary quite noticably between devices.  HE300 devices have a
 * low for about 1300us for a 1 whereas HE303 devices seem to have a low of about
 * 1100us.  If this script does not detect your signals try relaxing the timing
 * conditions.
 * 
 * Each actual bit of data is encoded as two bits on the wire as:
 * Data 0 = Wire 01
 * Data 1 = Wire 10
 *
 * The actual message is 32 bits of data (64 wire bits):
 * bits 0-25: the group code - a 26bit number assigned to controllers.
 * bit 26: group flag
 * bit 27: on/off flag
 * bits 28-31: the device code - a 4bit number.
 *
 * The group flag just seems to be a separate set of addresses you can program devices
 * to and doesn't trigger the dim cycle when sending two ONs.
 *
 * There's extra support for setting devices to a specific dim-level that you get
 * with the HE100 ultimate remote control. I think this involves sending a Wire 11 at
 * the on/off flag position and then the message is longer with another 4 bits for dim
 * level.
 * Need to look into this.
 *
 * Barnaby Gray 12/2008
 * Peter Mead   09/2009
 */

int rxPin = 8;


void setup()
{  pinMode(rxPin, INPUT);
  Serial.begin(9600);
}


void loop()
{
  int i = 0;
  unsigned long t = 0;

  byte prevBit = 0;
  byte bit = 0;

  unsigned long sender = 0;
  bool group = false;
  bool on = false;
  unsigned int recipient = 0;

  // latch 1
  while((t < 9480 || t > 10350))
  { t = pulseIn(rxPin, LOW, 1000000);
  }

  // latch 2
  while(t < 2550 || t > 2700)
  { t = pulseIn(rxPin, LOW, 1000000);
  }

  // data
  while(i < 64)
  {
    t = pulseIn(rxPin, LOW, 1000000);

    if(t > 200 && t < 365)
    { bit = 0;
    }
    else if(t > 1000 && t < 1360)
    { bit = 1;
    }
    else
    { i = 0;
      break;
    }

    if(i % 2 == 1)
    {
      if((prevBit ^ bit) == 0)
      { // must be either 01 or 10, cannot be 00 or 11
        i = 0;
        break;
      }

      if(i < 53)
      { // first 26 data bits
        sender <<= 1;
        sender |= prevBit;
      } 
      else if(i == 53)
      { // 26th data bit
        group = prevBit;
      }
      else if(i == 55)
      { // 27th data bit
        on = prevBit;
      }
      else
      { // last 4 data bits
        recipient <<= 1;
        recipient |= prevBit;
      }
    }

    prevBit = bit;
    ++i;
  }

  // interpret message
  if(i > 0)
  { printResult(sender, group, on, recipient);
  }
}


void printResult(unsigned long sender, bool group, bool on, unsigned int recipient)
{
  Serial.print("sender ");
  Serial.println(sender);

  if(group)
  { Serial.println("group command");
  }
  else
  { Serial.println("no group");
  }

  if(on)
  { Serial.println("on");
  }
  else
  { Serial.println("off");
  }

  Serial.print("recipient ");
  Serial.println(recipient);

  Serial.println();
}

So to get the binary codes my transmitter sends out I hooked up my receiver to my laptop with some resistors as a “line in” device and recorded it with audacity to get the binary information.

This is for example “Button 1: on”

Imgur

But I am trying to find a way to convert this to 0 and 1s, so I am wondering if anyone knows of a program that can do this? I read about SOX, but I found it really hard to use and no guidance on the interwebs on how to turn a wav file into binary for it. Or if anyone knows of a rf receiver program that can pick up my NEXA MYCR-3 I could have another go with that.

I just wanted to let you know I have the same hardware and was struggling with this.

I was able to decode my NEXA remote control ID using the NewRemoteSwitch library.

https://bitbucket.org/fuzzillogic/433mhzforarduino/wiki/Home

I used the ShowReceivedCode example. In the code, I changed the pin number to match mine as well as the serial speed to 9600 in the setup() block.

Results:
Addr 28305978 unit 0 on, period: 268us.
Addr 28305978 unit 1 on, period: 268us.
Addr 28305978 unit 2 on, period: 268us.
Addr 28305978 group off, period: 269us.

smilespray:
I just wanted to let you know I have the same hardware and was struggling with this.

I was able to decode my NEXA remote control ID using the NewRemoteSwitch library.

fuzzillogic / 433mhzforarduino / wiki / Home — Bitbucket

I used the ShowReceivedCode example. In the code, I changed the pin number to match mine as well as the serial speed to 9600 in the setup() block.

Results:
Addr 28305978 unit 0 on, period: 268us.
Addr 28305978 unit 1 on, period: 268us.
Addr 28305978 unit 2 on, period: 268us.
Addr 28305978 group off, period: 269us.

Thanks alot Smileyspray! I basically gave up, but I will now try again thanks to your help :slight_smile:

Here’s my final post. Thanks to Smilespray via PM I got my code working.

I used NewRemoteSwitch Library and ShowReceivedCode to get my Address (Example: 28305978).

Then I used NewRemoteTransmitter.h to make my application thanks to Smilespray.

Project: Control MYCR3 via Web Interface/Android App:

Final Code (Ethernet Shield needed + Transmitter/Receiver / ESP8266 optional).

#include <SPI.h>
#include <Ethernet.h>
#include <NewRemoteTransmitter.h>


const unsigned long TRANSMITTER_ADDRESS = 27612394; //My personal transmitter address
const int PIN_TRANSMITTER = 8;

// Create a transmitter on address TRANSMITTER_ADDRESS, using digital pin PIN_TRANSMITTER to transmit, 
// with a period duration of 260ms (default), repeating the transmitted
// code 2^3=8 times.
NewRemoteTransmitter transmitter(TRANSMITTER_ADDRESS, PIN_TRANSMITTER, 260, 3);

// Ethernet configuration
uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // MAC Address
uint8_t ip[] = { 192,168,1,230 };                        // IP Address
EthernetServer server(80);                           // Server Port 80

// RemoteTransmitter configuration
// Connect Transmitter to Pin 11 and receiver to pin 2 (all digital)
// FAN 1 ON/OFF:
// Addr 27612394 unit 0 on, period: 267us.
// Addr 27612394 unit 0 off, period: 267us.
// FAN 2 ON/OFF:
// Addr 27612394 unit 1 on, period: 266us.
// Addr 27612394 unit 2 off, period: 267us.
// FAN 3 ON/OFF:
// Addr 27612394 unit 2 on, period: 267us.
// Addr 27612394 unit 1 off, period: 266us.
// ALL POWER OFF:
// Addr 27612394 group off, period: 267us.


void setup() {
  Ethernet.begin(mac, ip);
  server.begin();
  pinMode(PIN_TRANSMITTER, OUTPUT);
  Serial.begin(9600);
  }

  
void loop() {
  char* command = httpServer();
}


void processCommand(char* command) {
  if        (strcmp(command, "1-on") == 0) {
    transmitter.sendGroup(true); //All fans on
  } else if (strcmp(command, "1-off") == 0) {
    transmitter.sendGroup(false); //All fans off
  } else if (strcmp(command, "2-on") == 0) {
    transmitter.sendUnit(0, true);
  } else if (strcmp(command, "2-off") == 0) {
    transmitter.sendUnit(0, false);
  } else if (strcmp(command, "3-on") == 0) {
    transmitter.sendUnit(1, true);
  } else if (strcmp(command, "3-off") == 0) {
    transmitter.sendUnit(1, false);
  }
}

/**
 * HTTP Response with homepage
 */
void httpResponseHome(EthernetClient c) {
  c.println("HTTP/1.1 200 OK");
  c.println("Content-Type: text/html");
  c.println();
  c.println("<html>");
  c.println("<head>");
  c.println(    "<title>MPC NEXA Webserver</title>");
  c.println(    "<style>");
  c.println(        "body { font-family: Arial, sans-serif; font-size:12px; }");
  c.println(    "</style>");
  c.println("</head>");
  c.println("<body>");
  c.println(    "<h1>MPC NEXA Webserver</h1>");
  c.println(    "<ul>");
  c.println(        "<li><a href=\"./?1-on\">Turn on all fans</a></li>");
  c.println(        "<li><a href=\"./?1-off\">Turn off all fans</a></li>");
  c.println(    "</ul>");
  c.println(    "<ul>");
  c.println(        "<li><a href=\"./?2-on\">Turn on fan 1</a></li>");
  c.println(        "<li><a href=\"./?2-off\">turn off fan 1</a></li>");
  c.println(    "</ul>");
  c.println(    "<ul>");
  c.println(        "<li><a href=\"./?3-on\">Turn on fan 2</a></li>");
  c.println(        "<li><a href=\"./?3-off\">turn off fan 2</a></li>");
  c.println(    "</ul>");
  c.println(    "<hr>");
  c.println("</body>");
  c.println("</html>");
}

/**
 * HTTP Redirect to homepage
 */
void httpResponseRedirect(EthernetClient c) {
  c.println("HTTP/1.1 301 Found");
  c.println("Location: /");
  c.println();
}

/**
 * HTTP Response 414 error
 * Command must not be longer than 30 characters
 **/
void httpResponse414(EthernetClient c) {
  c.println("HTTP/1.1 414 Request URI too long");
  c.println("Content-Type: text/plain");
  c.println();
  c.println("414 Request URI too long");
}

/**
 * Process HTTP requests, parse first request header line and 
 * call processCommand with GET query string (everything after
 * the ? question mark in the URL).
 */
char*  httpServer() {
  EthernetClient client = server.available();
  if (client) {
    char sReturnCommand[32];
    int nCommandPos=-1;
    sReturnCommand[0] = '\0';
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        if ((c == '\n') || (c == ' ' && nCommandPos>-1)) {
          sReturnCommand[nCommandPos] = '\0';
          if (strcmp(sReturnCommand, "\0") == 0) {
            httpResponseHome(client);
          } else {
            processCommand(sReturnCommand);
            httpResponseRedirect(client);
          }
          break;
        }
        if (nCommandPos>-1) {
          sReturnCommand[nCommandPos++] = c;
        }
        if (c == '?' && nCommandPos == -1) {
          nCommandPos = 0;
        }
      }
      if (nCommandPos > 30) {
        httpResponse414(client);
        sReturnCommand[0] = '\0';
        break;
      }
    }
    if (nCommandPos!=-1) {
      sReturnCommand[nCommandPos] = '\0';
    }
    // give the web browser time to receive the data
    delay(1);
    client.stop();
    Serial.print("Restarting Web Server");
    
    return sReturnCommand;
  }
  return '\0';
}

I then used MIT App Inventor to make an application for my Android Phone: