RcReceiver interrupt

Hello,

I’m trying to get my RcReceiver working.
It’s working when a send a signal with the RcTransmitter.

But when my program is waiting the RcReceiver doesn’t capture anything?
Do I need to enable the interrrupt?

test.ino (5.67 KB)

Why not just post the code so people can read it, instead of forcing people to download it?

#include <SPI.h>
#include <Ethernet.h>
#include <RemoteTransmitter.h>
#include <RemoteReceiver.h>
#include <IRremote.h>
#define MAXMESSAGE 26

// Enter a MAC address of your Ethernet shield or Arduino.
byte mac[] = {
  0x90, 0xA2, 0xDA, 0x00, 0x6C, 0xFE
};

// Arduino's IP address, dependent on your network configuration
IPAddress ip(192, 168, 0, 20);

// Node.js Server IP Address
IPAddress server(192, 168, 0, 142);

int RECV_PIN = 5;
IRrecv irrecv(RECV_PIN);
decode_results results;
KaKuTransmitter kaKuTransmitter(7);
String readString = "10";

// Create the Ethernet client
EthernetClient client;

void setup() {
  // start the Ethernet connection:
  Ethernet.begin(mac, ip);
  // start the serial library:
  Serial.begin(115200);
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  // The 1337 PORT is for the TCP server, not the Web Server (8090 in node.js setup)
  if (client.connect(server, 1337)) {
    Serial.println("connected");
  }
  else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
  RemoteReceiver::init(0, 3, showCode);
  irrecv.enableIRIn();
  Serial.println("IR receiver ready");
}

void loop()
{
  char buffer[MAXMESSAGE];
  char tokenList[] = "-";
  char *tokenPtr;
  char *dim;
  int charsRead;
  int dimwaarde;

  //if you are connected and data is available
  if (client.available()) {

    charsRead = client.readBytesUntil('\n', buffer, MAXMESSAGE - 1);
    buffer[charsRead] = '\0';

    Serial.println(buffer);
    tokenPtr = strtok(buffer, tokenList);
  }

while (tokenPtr != '\0') {
      Serial.println(tokenPtr);
      tokenPtr = strtok('\0', tokenList);
      if(strcmp(tokenPtr,"A3") == 0){
        Serial.println("A3 gevonden");
        dim = strtok('\0', tokenList);
        Serial.println(dim);      
      }

  if (strcmp(buffer,"A1ON") == 0) {
    kaKuTransmitter.sendSignal('A', 1, true);
    client.println("Living1 aan");
  }
  else if (strcmp(buffer,"A1OF") == 0) {
    kaKuTransmitter.sendSignal('A', 1, false);
    client.println("Living1 uit");
  }
  if (strcmp(buffer,"A2ON") == 0) {
    kaKuTransmitter.sendSignal('A', 2, true);
    client.println("Living2 aan");
  }
  else if (strcmp(buffer,"A2OF") == 0) {
    kaKuTransmitter.sendSignal('A', 2, false);
    client.println("Living2 uit");
  }
  if (strcmp(buffer,"B1ON") == 0) {
    kaKuTransmitter.sendSignal('B', 1, true);
    client.println("Badkamer1 aan");
  }
  else if (strcmp(buffer,"B1OF") == 0) {
    kaKuTransmitter.sendSignal('B', 1, false);
    client.println("Badkamer1 uit");
  }
  if (strcmp(buffer,"B2ON") == 0) {
    kaKuTransmitter.sendSignal('B', 2, true);
    client.println("Badkamer2 aan");
  }
  else if(strcmp(buffer,"B2OF") == 0) {
    kaKuTransmitter.sendSignal('B', 2, false);
    client.println("Badkamer2 uit");
  }
  if (strcmp(buffer,"C1ON") == 0) {
    kaKuTransmitter.sendSignal('C', 1, true);
    client.println("WC aan");
  }
  else if (strcmp(buffer,"C1OF") == 0) {
    kaKuTransmitter.sendSignal('C', 1, false);
    client.println("WC uit");
  }
  if (strcmp(buffer,"I1ON") == 0) {
    kaKuTransmitter.sendSignal('I', 1, true);
    client.println("Inkom aan");
  }
  else if (strcmp(buffer,"I1OF") == 0) {
    kaKuTransmitter.sendSignal('I', 1, false);
    client.println("Inkom uit");
  }
  if (strcmp(buffer,"S1ON") == 0) {
    kaKuTransmitter.sendSignal('S', 1, true);
    client.println("Slaapkamer1 aan");
  }
  else if (strcmp(buffer,"S1OF") == 0) {
    kaKuTransmitter.sendSignal('S', 1, false);
    client.println("Slaapkamer1 uit");
  }
  if (strcmp(buffer,"S2ON") == 0) {
    kaKuTransmitter.sendSignal('S', 2, true);
    client.println("Slaapkamer2 aan");
  }
  else if (strcmp(buffer,"S2OF") == 0) {
    kaKuTransmitter.sendSignal('S', 2, false);
    client.println("Slaapkamer2 uit");
  }
  if (strcmp(buffer,"S3ON") == 0) {
    kaKuTransmitter.sendSignal('S', 3, true);
    client.println("Tussenkamer aan");
  }
  else if (strcmp(buffer,"S3OF") == 0) {
    kaKuTransmitter.sendSignal('S', 3, false);
    client.println("Tussenkamer uit");
  }
  if (strcmp(buffer,"S4ON") == 0) {
    kaKuTransmitter.sendSignal('S', 4, true);
    client.println("Bureau aan");
  }
  else if (strcmp(buffer,"S4OF") == 0) {
    kaKuTransmitter.sendSignal('S', 4, false);
    client.println("Bureau uit");
  }
  if (strcmp(buffer,"K1ON") == 0) {
    kaKuTransmitter.sendSignal('K', 1, true);
    client.println("Keuken aan");
    readString = "";
  }
  else if (strcmp(buffer,"K1OF") == 0) {
    kaKuTransmitter.sendSignal('K', 1, false);
    client.println("Keuken uit");
  }
  if (strcmp(buffer,"K2ON") == 0) {
    kaKuTransmitter.sendSignal('K', 2, true);
    client.println("Berging aan");
  }
  else if (strcmp(buffer,"K2OF") == 0) {
    kaKuTransmitter.sendSignal('K', 2, false);
    client.println("Berging uit");
  }
  if (strcmp(buffer,"U1ON") == 0) {
    kaKuTransmitter.sendSignal('U', 1, true);
    client.println("Buitenspot aan");
  }
  else if (strcmp(buffer,"U1OF") == 0) {
    kaKuTransmitter.sendSignal('U', 1, false);
    client.println("Buitenspot uit");
  }
}
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    switch (results.value) {
      case 1470210214:
        kaKuTransmitter.sendSignal('A', 2, true);
        break;
      case 851019735:
        kaKuTransmitter.sendSignal('A', 2, false);
        break;
    }
    irrecv.resume();
  }
}

void showCode(unsigned long receivedCode, unsigned int period) {
  // Note: interrupts are disabled. You can re-enable them if needed.
  // Print the received code.
  Serial.print("Code: ");
  Serial.print(receivedCode);
  Serial.print(", period duration: ");
  Serial.print(period);
  Serial.println("us.");
}

Have you satisfied yourself that all those libraries work happily together. Conflict between libraries is very common in the Arduino world.

It would also be useful if you provide an explanation of what the code is supposed to do and how it is intended to work.

You have a very strange mixture of IF and ELSE IF.
Also, you have an awful lot of them. Why not delete all but 2 or three while testing the project/

...R

I don't know how can I verify if the libraries are working good together?
I deleted all the code and checked the RcReceiver is working great except when I used the code for TCP socket and IrReceiver.

jonaspolfliet:
working great except when I used the code for TCP socket and IrReceiver.

Sounds ominous. I don't have your hardware so I can't do any tests.

...R