Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
T

twosh

@twosh
About
Posts
48
Topics
4
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Decoding / converting IR-codes
    T twosh

    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.

    Troubleshooting

  • Decoding / converting IR-codes
    T twosh

    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

    Troubleshooting

  • Controlling existing relays
    T twosh

    @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

    Hardware

  • Controlling existing relays
    T twosh

    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! :P

    Hardware

  • Sensebender Micro
    T twosh

    @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!

    Announcements

  • Controlling existing relays
    T twosh

    @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};
    
    Hardware

  • Sensebender Micro
    T twosh

    @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

    Announcements

  • Controlling existing relays
    T twosh

    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.

    Hardware

  • Controlling existing relays
    T twosh

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

    Hardware

  • Controlling existing relays
    T twosh

    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.

    Hardware

  • Controlling existing relays
    T twosh

    My Mega arrived today so I could load it with my customized sketch that I've worked on for controlling relays as well as measuring current. I'm still waiting for the current sensors, but I've already got a problem... I keep getting "check wires" via the serial monitor, and the Mega is not detected by the gateway.

    Basically I think that the wiring of the radio to the Mega is wrong, but after scavenging the forum and trying a handfull of different wiring combinations I still can't get this to work.

    I have tried using the normal (nano, pro mini) pins, using pins 14-16, 50-52, etc. but nothing seems to work. I have NOT modified any config files yet, but based on the various threads I've read it's unclear to me if you should or shouldn't.

    @Sparkman , do you use a mega yourself, and have successfully wired the radio?

    @hek, would it be possible to add instructions for the Mega (and perhaps the Uno as well) to the general build guide for connecting the radio?

    Hardware

  • Newbie with vera
    T twosh

    Hi @csnij !

    Have you tried adding a capacitor to the radio as suggested in the guide http://www.mysensors.org/build/connect_radio#connecting-a-decoupling-capacitor ?

    You might also have some bad quality clones of the NRF24L01+ chip. Try searching the forum for fake clones or bad clones and you will probably see some threads discussing it.

    Then again, you might have normal interference from e.g. walls. Is there clear sight between the node and the gateway or do you have thick walls etc?

    Best wishes,
    Tim

    Vera

  • Energy pulse meter + outside temperature
    T twosh

    @mbj Would you mind sharing your sketch? :) Right now I'm using two separate arduinos for measuring energy and temperature (hot/cold side) on my heat pump. Would be nice to combine this into one arduino, one sketch.

    Cheers,
    Tim

    My Project temp energy pulse me

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

    I'm back to choosing between no sleep, and the sleep(); function posted above. I can't get gw.sleep(); to work with either one or two interrupts, with or without declaring interrupts(); and/or attachInterrupt();.

    I'm ready to try more stuff if anyone got any ideas, but with my own limited understanding of both hardware in general and arduino in particular it feels like I'm running on fumes here. :o

    Thanks everyone for your contribution, and @hek - you've done a great job with MySensors! :clap:

    Troubleshooting

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

    Hi again!

    I've tried different approaches now with the gw.sleep(); func without success, using CHANGE, RISING or FALLING. No reaction either from tag or the Vera.

        // Wait for card/tag to leave reader    
        while(nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &key[0], &currentKeyLength)); 
        // gw.sleep(2000);
      }
      gw.sleep(0, CHANGE, 1, CHANGE, 0); // int8_t sleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, unsigned long ms=0);
    }
    

    I've also tried adding this to setup();

      interrupts();
    

    as well as this:

      attachInterrupt(0, loop, CHANGE);
      attachInterrupt(1, loop, CHANGE);
    

    Nothing happens. It just continues to sleep...

    Troubleshooting

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

    Ah, there it is! I was looking at his:
    https://github.com/mysensors/CodeBender/blob/master/MySensor.h

    Big thanks @hek ! I'll try this when I get home!

    Troubleshooting

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

    Hi @hek and thanks for the info!

    However, I'm not sure that I find anything regarding listening for both D2 and D3-pins in MySensors.h, I only find:

    */**
    	 * Sleep (PowerDownMode) the Arduino and radio. Wake up on timer or pin change.
    	 * See: http://arduino.cc/en/Reference/attachInterrupt for details on modes and which pin
    	 * is assigned to what interrupt. On Nano/Pro Mini: 0=Pin2, 1=Pin3
    	 * @param interrupt Interrupt that should trigger the wakeup
    	 * @param mode RISING, FALLING, CHANGE
    	 * @param ms Number of milliseconds to sleep or 0 to sleep forever
    	 * @return true if wake up was triggered by pin change and false means timer woke it up.
    	 */
    	bool sleep(int interrupt, int mode, unsigned long ms=0);
    

    Which is the same as the documentation, right?

    Troubleshooting

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

    Earlier I tried using gw.sleep(2, CHANGE, 1000); but that didn't work then. Should I use it another way? And how do I make sure I listen for interrupts on both the D2 and D3 pins?

    Troubleshooting

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

    Hi all!

    Soldered a cable between D3 and the IRQ on the RFID-chip and it seems to have solved my problem. The response time is a bit slow - I need to keep my tag pressed to the RFID-chip for 2-5 seconds before it switches mode. Any idea why that would be? Note that I'm using the sleep function from http://forum.mysensors.org/topic/1112/how-low-can-arduino-can-go/20 and not gw.sleep();

    My sketch looks like this:

    /* 
      RFID Lock sensor/actuator
      
      Henrik Ekblad <henrik.ekblad@mysensors.org>
    
      Use RFID tag to lock/unlock a door or trigger a scene on your controller.
      This example sketch allows you to add an optional relay or solenoid 
      which can be activated/opened by RFID or controller.  
    
      Use the I2C wiring option for your RFID module and connect to the following Arduino pins.
      
      RFID       Arduino
      -----      -------
      GND   ->   GND
      VCC   ->   +5V
      SCL   ->   A5
      SDA   ->   A4
      
      Use normal wiring for NRF24L01 radio
      
      Attach a optional relay or solonoid lock to pin 4
      
    */
     
    #include <MySensor.h>  
    #include <SPI.h>
    #include <Wire.h>
    #include <PN532_I2C.h>
    #include <PN532.h>
    #include <avr/sleep.h>
    
    
    // Add your valid rfid keys here. To find you your key just run sketch; hold your new RFID tag in fron ot the reader; 
    // and copy the key from serial output of this sketch.
    const uint8_t maxKeyLength = 7;
    uint8_t validKeys[][maxKeyLength] = {
                          //Removed my keys here when posting the sketch
                      };
    int keyCount = sizeof validKeys / maxKeyLength; 
    
    
    #define CHILD_ID 99   // Id of the sensor child
    #define YELLOWLED 5  // Pin for the Yellow led.
     
    /*Pin definitions*/
    const int lockPin = 4;         // (Digital 4) The pin that activates the relay/solenoid lock.
    
    bool lockStatus;
    MySensor gw;
    MyMessage lockMsg(CHILD_ID, V_LOCK_STATUS);
    PN532_I2C pn532i2c(Wire);
    PN532 nfc(pn532i2c);
     
    void setup() {
      
      pinMode(lockPin, OUTPUT);
      pinMode(YELLOWLED, OUTPUT);
    
      nfc.begin();
      uint32_t versiondata = nfc.getFirmwareVersion();
      if (! versiondata) {
        Serial.print("Couldn't find PN53x board");
        while (1); // halt
      }
      Serial.print("Found NFC chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); 
      Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); 
      Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
      // Set the max number of retry attempts to read from a card
      // This prevents us from waiting forever for a card, which is
      // the default behaviour of the PN532.
      nfc.setPassiveActivationRetries(0x3);
      
      // configure board to read RFID tags
      nfc.SAMConfig();
    
      // Init mysensors library
      gw.begin(incomingMessage);
      
      gw.sendSketchInfo("RFID Lock", "1.0");
      gw.present(CHILD_ID, S_LOCK);
      
      lockStatus = gw.loadState(0);    // Read last lock status from eeprom
      setLockState(lockStatus, true); // Now set the last known state and send it to controller
      
    }
     
    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);
      }
      sleep();
    } 
     
     
     
    // Unlocks the door.
    void setLockState(bool state, bool send){
      if (state) {
         Serial.println("close lock");
         digitalWrite(YELLOWLED, HIGH);}
      else {
         Serial.println("open lock");
         digitalWrite(YELLOWLED, LOW);}
      if (send)
        gw.send(lockMsg.set(state));
      digitalWrite(lockPin, state);
      gw.saveState(0,state);
      lockStatus = state;
    }
     
    void incomingMessage(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type==V_LOCK_STATUS) {
         // Change relay state
         setLockState(message.getBool(), false); 
      
         // Write some debug info
         Serial.print("Incoming lock status:");
         Serial.println(message.getBool());
       } 
    }
    
    void sleep(){
       // disable ADC
      ADCSRA = 0;  
    
      // clear various "reset" flags
      MCUSR = 0;     
      // allow changes, disable reset
      WDTCSR = bit (WDCE) | bit (WDE);
      // set interrupt mode and an interval 
      WDTCSR = bit (WDIE) | bit (WDP3) | bit (WDP0);    // set WDIE, and 1 second delay
      wdt_reset();  // pat the dog
      
      set_sleep_mode (SLEEP_MODE_PWR_DOWN);  
      noInterrupts ();           // timed sequence follows
      sleep_enable();
     
      // turn off brown-out enable in software
      MCUCR = bit (BODS) | bit (BODSE);
      MCUCR = bit (BODS); 
      interrupts ();             // guarantees next instruction executed
      sleep_cpu ();  
      
      // cancel sleep as a precaution
      sleep_disable();
    }
    
    
    Troubleshooting

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

    Thanks @BulldogLowell ! I can see that the chip has an IRQ pin and GND among others. SInce I'm not a hardware guy could you tell me if it would be enough to connect the IRQ to my arduino D3-pin? Would I need to connect some other pins as well, e.g. the RFID GND to Arduino GND? (The RFID is already connected to Arduino GND via the 4 pins mentioned in the MySensor guide for connecting the RFID.)

    Troubleshooting
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular