IRSensor



  • Hi All,

    I may have misunderstood the use case here.
    Following the build http://www.mysensors.org/build/ir

    I have connected only an IR Receive Sensor to Power 5V Grnd & Pin 8.
    IR Transmitter is not connected

    What I am trying to achieve is to press a button on a remote and then have domoticz act upon it through a script.

    The Sensor serial monitor appears to be telling me that it is communicating with the Gateway, at least I don't see "Fail" anywhere. I can also see reference to IRSensor in the Domoticz log. So far so good.

    A couple of questions
    However I don't appear to see any device in the Domoticz list that I can add. Have I missed a step?

    I can see that some of the code has been commented out. Do I need to uncomment some of this (or all of it) in order for it to decode the IR button. I notice that some of it has // and some of it has /.../ Not really sure if I am supposed to uncomment all of it or just some.

    Any help is greatly appreciated.

    Best Wishes.

    James.


  • Contest Winner

    Are you sure the IR sensor isn't broken? AdAfruit has a good tutorial on this link text



  • Thank you. I don't think it is broken. If I press a key on the remote I can see some output in the serial monitor. I just don't see any device in domoticz.



  • This post is deleted!

  • Hero Member

    Is the ir node not showing up in the mysensor gateway under the hardware settings tab?



  • Yes - The gateway is shown under Hardware. I am using it with other nodes Temp sensors.

    I can also see the IR sensor in the Domoticz log

    2016-02-05 07:51:23.671 MySensors: Node: 14, Sketch Name: IR Sensor
    2016-02-05 07:51:23.702 MySensors: Node: 14, Sketch Version: 1.0
    

    I just can't find a device I can add.

    Best wishes.

    James.


  • Hardware Contributor

    Devices in Domoticz is not added until a correct first value is sent, its not enough with a presentation - is this the case?



  • @sundberg84
    Thank you. I thought that might be the case. Hence my second original question

    I can see that some of the code has been commented out. Do I need to uncomment some of this (or all of it) in order for it to decode the IR button. I notice that some of it has // and some of it has /.../ Not really sure if I am supposed to uncomment all of it or just some.

    // Dumps out the decode_results structure.
    // Call this after IRrecv::decode()
    // void * to work around compiler issue
    //void dump(void *v) {
    //  decode_results *results = (decode_results *)v
    /*void dump(decode_results *results) {
      int count = results->rawlen;
      if (results->decode_type == UNKNOWN) {
        Serial.print("Unknown encoding: ");
      } 
      else if (results->decode_type == NEC) {
        Serial.print("Decoded NEC: ");
      } 
      else if (results->decode_type == SONY) {
        Serial.print("Decoded SONY: ");
      } 
      else if (results->decode_type == RC5) {
        Serial.print("Decoded RC5: ");
      } 
      else if (results->decode_type == RC6) {
        Serial.print("Decoded RC6: ");
      }
      else if (results->decode_type == PANASONIC) {	
        Serial.print("Decoded PANASONIC - Address: ");
        Serial.print(results->panasonicAddress,HEX);
        Serial.print(" Value: ");
      }
      else if (results->decode_type == JVC) {
         Serial.print("Decoded JVC: ");
      }
      Serial.print(results->value, HEX);
      Serial.print(" (");
      Serial.print(results->bits, DEC);
      Serial.println(" bits)");
      Serial.print("Raw (");
      Serial.print(count, DEC);
      Serial.print("): ");
    
      for (int i = 0; i < count; i++) {
        if ((i % 2) == 1) {
          Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
        } 
        else {
          Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
        }
        Serial.print(" ");
      }
      Serial.println("");
    }
    */
    

    Can you advise what I should uncomment?
    I presume once I have got the correct code from the serial monitor and running above. I can then enter it here

    void incomingMessage(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type==V_LIGHT) {
         int incomingRelayStatus = message.getInt();
         if (incomingRelayStatus == 1) {
          irsend.send(NEC, 0x1EE17887, 32); // Vol up yamaha ysp-900
         } else {
          irsend.send(NEC, 0x1EE1F807, 32); // Vol down yamaha ysp-900
         }
         // Start receiving ir again...
        irrecv.enableIRIn(); 
      }
    }
    

    This will then allow Domoticz to create the device switch.

    Thank you for any help you can give.

    Best wishes.

    James



  • I thought I would close this. Just as well that my Google skills are better than my programming skills.

    This sketch helped me out and resolved my issues.

    https://www.domoticz.com/forum/viewtopic.php?f=42&t=7648&start=20#p53663
    by gizmocuz. Thank you.

    Best wishes.

    James.


Log in to reply
 

Suggested Topics

  • 8
  • 90
  • 2
  • 3
  • 2
  • 29

15
Online

11.2k
Users

11.1k
Topics

112.5k
Posts