Navigation

    • Register
    • Login
    • Search
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. twosh
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    twosh

    @twosh

    1
    Reputation
    48
    Posts
    784
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    twosh Follow

    Best posts made by twosh

    • How to sleep the Arduino but still have it respond to the Vera?

      Hi,

      I'm trying to save some cpu cycles here! I'm using the pretty much unmodified rfid lock sketch, except I've added code for a LED diode to show if it's armed or disarmed. Since this puppy will only be used when you leave or enter the house, 99% of the time it could sleep. Here is the loop:

      void loop() {
        gw.process(); // Process incomming messages
      
        boolean success;
        uint8_t key[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID
        uint8_t currentKeyLength;                        // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
      
        
        // Wait for an ISO14443A type cards (Mifare, etc.).  When one is found
        // 'uid' will be populated with the UID, and uidLength will indicate
        // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
        success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &key[0], &currentKeyLength);
        
        if (success) {
          Serial.print("Found tag id: ");
          for (uint8_t i=0; i < currentKeyLength; i++) 
          {
            if (i>0) Serial.print(",");
            Serial.print("0x");Serial.print(key[i], HEX); 
          }
          for (uint8_t i=currentKeyLength; i < maxKeyLength; i++) 
          {
            Serial.print(",0x00"); 
          }
      
      
          Serial.println("");
      
          boolean valid = false;
          // Compare this key to the valid once registered here in sketch 
          for (int i=0;i<keyCount && !valid;i++) {
            for (int j=0;i<currentKeyLength && !valid;j++) {
              if (key[j] != validKeys[i][j]) {
                break;
              }
              if (j==currentKeyLength-1) {
                valid = true;
              }
            }
          }
          if (valid) {
            // Switch lock status
            setLockState(!lockStatus, true);       
          }
          
          // Wait for card/tag to leave reader    
          while(nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &key[0], &currentKeyLength));
        }
        gw.sleep(2000);
      } 
      

      Using this loop the arduino works great when using the rfid-tag to trigger a change in armed / disarmed, but the arduino does NOT respond to commands from my Vera (UI7).

      I think I know what the problem is - basically the Arduino is sleeping when the command from the controller arrives, and thus it can't process it. Changing the last bit of code like this (moving the gw.sleep(2000) only to trigger if an rfid-tag has been read works:

          // Wait for card/tag to leave reader    
          while(nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &key[0], &currentKeyLength)); 
          gw.sleep(2000);
        }
      } 
      

      But then again, using this code it doesn't sleep at all except for the 2 seconds 2 times a day when I trigger it. 🙂

      So, how could I have the best of both worlds? I want to let it sleep until 1) there is an incoming command from my Vera or 2) an rfid-tag is recognized. Is it possible?

      As always, thanks in advance for any input!

      posted in Troubleshooting
      twosh
      twosh

    Latest posts made by twosh

    • RE: Decoding / converting IR-codes

      I will check and post my on and off codes later tonight if I can find the time. I have only access to the remote until next weekend so I won't be able to actually verify anything until then. :s

      @Moshe-Livne I agree that the remote must be sending not only the "on"-command, but the whole state as currently displayed on the remote, because if you point the remote away from the pump, make some changes, then point it at the pump and make another change all the changes will come into effect. Then again, the pump itself (mine at least) does remember its last state because it can wake up after a power outage with the same settings as before the outage.

      posted in Troubleshooting
      twosh
      twosh
    • Decoding / converting IR-codes

      Hi,

      I've built the IR sender/receiver sensor and I am alble to receive and send codes without problems when using codes for my Sony receiver. However the main reason for building this particular sensor is that I would like to control my Mitshubishi Kirigamine air to air heat pump. The remote model for the pump is KM08A.

      I can't find any codes on the net for this remote som I tried receiving the code when pushing the on/off button. I thought that I could capture the code and then use it to send the command I wanted. This is what I got via the serial monitor:

      Decoded Unknown: Value:0 (0 bits)
      Raw samples(100): Gap:17100
        Head: m3400  s1800
      0:m350 s1350	1:m350 s1350		 2:m400 s450	3:m400 s450		 
      4:m400 s500	5:m350 s1350		 6:m350 s500	7:m400 s450		 
      8:m350 s1400	9:m350 s1350		 10:m350 s500	11:m350 s1350		 
      12:m400 s450	13:m350 s500		 14:m400 s1350	15:m350 s1350		 
      
      16:m350 s500	17:m350 s1350		 18:m350 s1350	19:m400 s500		 
      20:m350 s500	21:m350 s1350		 22:m350 s500	23:m350 s500		 
      24:m400 s1300	25:m350 s550		 26:m350 s500	27:m350 s500		 
      28:m350 s500	29:m350 s500		 30:m400 s450	31:m400 s500		 
      
      32:m350 s500	33:m350 s500		 34:m350 s500	35:m350 s500		 
      36:m350 s500	37:m350 s550		 38:m350 s500	39:m350 s500		 
      40:m350 s500	41:m400 s450		 42:m400 s500	43:m350 s500		 
      44:m350 s500	45:m350 s1350		 46:m350 s500	47:m350 s500		 
      
      48:m400
      Extent=57850
      Mark  min:350	 max:400
      Space min:450	 max:1400
      
      

      But how do I use this? Can I convert it somwhow to the 0x00000 format used in the sketch? I appreciate any thoughts and suggestions!

      Cheers,
      Tim

      posted in Troubleshooting
      twosh
      twosh
    • RE: Controlling existing relays

      @phil-pritchard No, not really. As I've mentioned tinkering with hardware is new to me so I don't actually have any knowledge of what exists and whats possible from that side of the table. Would you like to expand on your thoughts? 🙂

      I've ordered a bunch of these hall effect sensors: http://www.ebay.com/itm/221649135732?rmvSB=true

      20A ACS712 Module 5V Measuring Range Current Sensor Hall Board For Arduino new

      $1.52
      2242 available
      posted in Hardware
      twosh
      twosh
    • RE: Controlling existing relays

      Thanks @sparkman for once again nudging me in the right direction!
      I went trough the code in my sketch a couple of times commenting out various sections and suddenly the sensor started functioning correctly. So I checked that function closely and noticed that I was out of bounds in a for-loop. that stupid NUMBER_OF_CURRENT_PINS +1 . That +1 had accidentally stayed there from an early version of the sketch. Correcting that, my sketch seems to load without problems - go figure! 😛

      posted in Hardware
      twosh
      twosh
    • RE: Sensebender Micro

      @tbowmo It was just a thought I came up with and thought to share my idea and arguments. 🙂
      I think the Sensebender Micro is great especially if you would like to monitor temperatures (which of course many of us wants to), but I just think that a less expensive, light option (that would be available to order... 🙂 ) could appeal to many. Great that you have requested a quote!

      posted in Announcements
      twosh
      twosh
    • RE: Controlling existing relays

      @Sparkman
      I tried powering the Megas radio from a Nanos 3.3V pin and GND. The Nano is working fine as a sensor by itself, so I guess the radio gets enough power from it. However, this way I only got "check wires" from the Mega... 😞

      Just a thought; if it helps, I'm defining these pins for the Mega in my sketch, but I don't see how that could affect this particular problem...

      const int relayPin[] = {22, 23, 24, 25, 26, 27, 28, 29};
      const int currentPin[] = {A0, A1, A2, A3, A4, A5, A6, A7, A8, A9};
      
      posted in Hardware
      twosh
      twosh
    • RE: Sensebender Micro

      @hek said:

      That's the old A10. It would probably work but A20 has some firmware fixes and more tests performed on it.
      I have nothing to say about the price. It is the same as for A20.. As you can see it is the most expensive part on the micro board (30% of it's price).

      Would you consider a Sensebender Micro Light-version without this component? i mean, if it's 30 % of the price, not available and not imo a critical component (you could always add your own humidity/temp sensors), there are quite a few reasons why a light version would be tempting. At least to me. 🙂

      Cheers,
      Tim

      posted in Announcements
      twosh
      twosh
    • RE: Controlling existing relays

      Thanks for the suggestion, @Sparkman !
      I have just the radio connected for now, but still getting that "version mismatch"-error. I will try getting a separate 3.3v power to the radio tomorrow and see if that would help.

      posted in Hardware
      twosh
      twosh
    • RE: Controlling existing relays

      Tried powering the Mega from computers USB 5V, and two different 12V DC adapters - still getting version mismatch. Anybody knows what's going on?

      posted in Hardware
      twosh
      twosh
    • RE: Controlling existing relays

      Finally found a combination that worked with the mega as a sensor. Here is the pin mapping if it will save time for anyone:

      9 CE
      10 CSN/CS
      52 SCK
      51 MOSI
      50 MISO
      2 IRQ

      Doesn't require any config changes, but I am currently getting some "0;0;3;0;9;version mismatch" in serial monitor. Have 10 uF cap on the radio.

      posted in Hardware
      twosh
      twosh