<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Rfid sketch]]></title><description><![CDATA[<p dir="auto">Hello,<br />
can anyone help me to change the</p>
<p dir="auto">The relay should only put on for 3 seconds.</p>
<pre><code>/**
 * The MySensors Arduino library handles the wireless radio link and protocol
 * between your home built sensors/actuators and HA controller of choice.
 * The sensors forms a self healing radio network with optional repeaters. Each
 * repeater and gateway builds a routing tables in EEPROM which keeps track of the
 * network topology allowing messages to be routed to nodes.
 *
 * Created by Henrik Ekblad &lt;henrik.ekblad@mysensors.org&gt;
 * Copyright (C) 2013-2015 Sensnology AB
 * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
 *
 * Documentation: http://www.mysensors.org
 * Support Forum: http://forum.mysensors.org
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 *******************************
 *
 * REVISION HISTORY
 * Version 1.0 - Henrik Ekblad
 * 
 * DESCRIPTION
 * RFID Lock sensor/actuator
 * 
 * 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   -&gt;   GND
 * VCC   -&gt;   +5V
 * SCL   -&gt;   A5
 * SDA   -&gt;   A4
 * 
 * Use normal wiring for NRF24L01 radio
 * 
 * Attach a optional relay or solonoid lock to pin 4
 * http://www.mysensors.org/build/rfid 
 */

// Enable debug prints to serial monitor
#define MY_DEBUG 

// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69

#include &lt;SPI.h&gt;
#include &lt;MySensors.h&gt;  
#include &lt;Wire.h&gt;
#include &lt;PN532_I2C.h&gt;
#include &lt;PN532.h&gt;


// 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] = {
                    { 0xB3, 0xC6, 0xD9, 0x80, 0x00, 0x00, 0x00 },
                    { 0, 0, 0, 0, 0, 0, 0 },    // ADD YOUR KEYS HERE!
                    { 0, 0, 0, 0, 0, 0, 0 }};
int keyCount = sizeof validKeys / maxKeyLength; 


#define CHILD_ID 99   // Id of the sensor child

// Pin definition
const int lockPin = 4;         // (Digital 4) The pin that activates the relay/solenoid lock.
bool lockStatus;
MyMessage lockMsg(CHILD_ID, V_LOCK_STATUS);
PN532_I2C pn532i2c(Wire);
PN532 nfc(pn532i2c);

void setup() {

  pinMode(lockPin, 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&gt;&gt;24) &amp; 0xFF, HEX); 
  Serial.print("Firmware ver. "); Serial.print((versiondata&gt;&gt;16) &amp; 0xFF, DEC); 
  Serial.print('.'); Serial.println((versiondata&gt;&gt;8) &amp; 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();

  lockStatus = loadState(0);    // Read last lock status from eeprom
  setLockState(lockStatus, true); // Now set the last known state and send it to controller 
}

void presentation()  {
  sendSketchInfo("RFID Lock", "1.0");
  present(CHILD_ID, S_LOCK);
}

void loop() {
  bool 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, &amp;key[0], &amp;currentKeyLength);

  if (success) {
    Serial.print("Found tag id: ");
    for (uint8_t i=0; i &lt; currentKeyLength; i++) 
    {
      if (i&gt;0) Serial.print(",");
      Serial.print("0x");Serial.print(key[i], HEX); 
    }
    for (uint8_t i=currentKeyLength; i &lt; maxKeyLength; i++) 
    {
      Serial.print(",0x00"); 
    }


    Serial.println("");

    bool valid = false;
    // Compare this key to the valid once registered here in sketch 
    for (int i=0;i&lt;keyCount &amp;&amp; !valid;i++) {
      for (int j=0;j&lt;currentKeyLength &amp;&amp; !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, &amp;key[0], &amp;currentKeyLength));
  } 
} 



// Unlocks the door.
void setLockState(bool state, bool doSend){
  if (state) 
     Serial.println("open lock");
  else
     Serial.println("close lock");
  if (doSend)
    send(lockMsg.set(state));
  digitalWrite(lockPin, state);
  saveState(0,state);
  lockStatus = state;
}

void receive(const MyMessage &amp;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());
   } 
}l```</code></pre>
]]></description><link>https://forum.mysensors.org/topic/10203/rfid-sketch</link><generator>RSS for Node</generator><lastBuildDate>Tue, 18 Aug 2026 06:14:52 GMT</lastBuildDate><atom:link href="https://forum.mysensors.org/topic/10203.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 27 Feb 2019 13:22:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Rfid sketch on Sun, 10 Mar 2019 19:03:07 GMT]]></title><description><![CDATA[<p dir="auto">Hello,<br />
now i´m write the sketch to another arduino with rfid and relay.<br />
It doesn´t work .<br />
From fhem i can trigger the relay and in serial monitor the card´s where shown with serial.<br />
In fhem the lockstatus is set to off, when the card is in near of the reader, the lockstatus on doesn´t send to fhem.<br />
But the relay doesn´t trigger by card.<br />
Where is the mistake?<br />
The problem is the lockstate doesnt set to on.</p>
<pre><code>/**
 * The MySensors Arduino library handles the wireless radio link and protocol
 * between your home built sensors/actuators and HA controller of choice.
 * The sensors forms a self healing radio network with optional repeaters. Each
 * repeater and gateway builds a routing tables in EEPROM which keeps track of the
 * network topology allowing messages to be routed to nodes.
 *
 * Created by Henrik Ekblad &lt;henrik.ekblad@mysensors.org&gt;
 * Copyright (C) 2013-2015 Sensnology AB
 * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
 *
 * Documentation: http://www.mysensors.org
 * Support Forum: http://forum.mysensors.org
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 *******************************
 *
 * REVISION HISTORY
 * Version 1.0 - Henrik Ekblad
 * 
 * DESCRIPTION
 * RFID Lock sensor/actuator
 * 
 * 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   -&gt;   GND
 * VCC   -&gt;   +5V
 * SCL   -&gt;   A5
 * SDA   -&gt;   A4
 * 
 * Use normal wiring for NRF24L01 radio
 * 
 * Attach a optional relay or solonoid lock to pin 4
 * http://www.mysensors.org/build/rfid 
 */

// Enable debug prints to serial monitor
#define MY_DEBUG 

// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69

#include &lt;SPI.h&gt;
#include &lt;MySensors.h&gt;  
#include &lt;Wire.h&gt;
#include &lt;PN532_I2C.h&gt;
#include &lt;PN532.h&gt;


// 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] = {
                    { 0xB3, 0xC6, 0xD9, 0x80, 0x00, 0x00, 0x00 },
                    { 0x5B, 0xFC, 0x7A, 0xD, 0x00, 0x00, 0x00 },    // ADD YOUR KEYS HERE!
                    { 0xF1, 0x13, 0x54, 0x63, 0x00, 0x00, 0x00 },
                    { 0xCB, 0x6F, 0x2D, 0xD, 0x00, 0x00, 0x00 },
                    { 0x9B, 0x33, 0x2C, 0xD, 0x00, 0x00, 0x00 },
                    { 0x73, 0xFA, 0xF6, 0x1A, 0x00, 0x00, 0x00 },
                    { 0x83, 0x59, 0x36, 0x1A, 0x00, 0x00, 0x00 },
                    { 0x83, 0x1A, 0x3C, 0x1A, 0x00, 0x00, 0x00 },
                    { 0xB6, 0xB2, 0x52, 0xF8, 0x00, 0x00, 0x00 },
                    { 0x17, 0xE5, 0xD2, 0x2B, 0x00, 0x00, 0x00 },
                    { 0x79 ,0xF7, 0x88, 0x5A, 0x00, 0x00, 0x00 },
                    { 0x2B, 0xDC, 0x49, 0xB, 0x00, 0x00, 0x00 }};
int keyCount = sizeof validKeys / maxKeyLength; 

#define CHILD_ID 99   // Id of the sensor child


// Pin definition
const int lockPin = 4;         // (Digital 4) The pin that activates the relay/solenoid lock.
bool lockStatus;
MyMessage lockMsg(CHILD_ID, V_LOCK_STATUS);
PN532_I2C pn532i2c(Wire);
PN532 nfc(pn532i2c);

void setup() {

  pinMode(lockPin, 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&gt;&gt;24) &amp; 0xFF, HEX); 
  Serial.print("Firmware ver. "); Serial.print((versiondata&gt;&gt;16) &amp; 0xFF, DEC); 
  Serial.print('.'); Serial.println((versiondata&gt;&gt;8) &amp; 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();

  lockStatus = loadState(0);    // Read last lock status from eeprom
  setLockState(lockStatus, true); // Now set the last known state and send it to controller 
}

void presentation()  {
  sendSketchInfo("RFID Lock", "1.0");
  present(CHILD_ID, S_LOCK);
}

void loop() {
  bool 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, &amp;key[0], &amp;currentKeyLength);

  if (success) {
    Serial.print("Found tag id: ");
    for (uint8_t i=0; i &lt; currentKeyLength; i++) 
    {
      if (i&gt;0) Serial.print(",");
      Serial.print("0x");Serial.print(key[i], HEX); 
    }
    for (uint8_t i=currentKeyLength; i &lt; maxKeyLength; i++) 
    {
      Serial.print(",0x00"); 
    }


    Serial.println("");

    bool valid = false;
    // Compare this key to the valid once registered here in sketch 
    for (int i=0;i&lt;keyCount &amp;&amp; !valid;i++) {
      for (int j=0;j&lt;currentKeyLength &amp;&amp; !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, &amp;key[0], &amp;currentKeyLength));
  } 
} 



// Unlocks the door.
void setLockState(bool state, bool doSend) {
  if (state)
  {
    Serial.println("open lock");
  if (doSend)
    send(lockMsg.set(true));
    digitalWrite(lockPin, true);
    wait(5000);
    Serial.println("close lock");
  if (doSend)
    send(lockMsg.set(false));
    digitalWrite(lockPin, false);
  } else {
  if (doSend)
    send(lockMsg.set(state));
}
}

void receive(const MyMessage &amp;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());
   } 
}```

Hm, with other arduino now it works.</code></pre>
]]></description><link>https://forum.mysensors.org/post/97894</link><guid isPermaLink="true">https://forum.mysensors.org/post/97894</guid><dc:creator><![CDATA[The-Holgi]]></dc:creator><pubDate>Sun, 10 Mar 2019 19:03:07 GMT</pubDate></item><item><title><![CDATA[Reply to Rfid sketch on Sat, 09 Mar 2019 10:03:27 GMT]]></title><description><![CDATA[<p dir="auto">Thank you it works perfect.<br />
Here the complete sketch:</p>
<pre><code>/**
 * The MySensors Arduino library handles the wireless radio link and protocol
 * between your home built sensors/actuators and HA controller of choice.
 * The sensors forms a self healing radio network with optional repeaters. Each
 * repeater and gateway builds a routing tables in EEPROM which keeps track of the
 * network topology allowing messages to be routed to nodes.
 *
 * Created by Henrik Ekblad &lt;henrik.ekblad@mysensors.org&gt;
 * Copyright (C) 2013-2015 Sensnology AB
 * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
 *
 * Documentation: http://www.mysensors.org
 * Support Forum: http://forum.mysensors.org
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 *******************************
 *
 * REVISION HISTORY
 * Version 1.0 - Henrik Ekblad
 * 
 * DESCRIPTION
 * RFID Lock sensor/actuator
 * 
 * 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   -&gt;   GND
 * VCC   -&gt;   +5V
 * SCL   -&gt;   A5
 * SDA   -&gt;   A4
 * 
 * Use normal wiring for NRF24L01 radio
 * 
 * Attach a optional relay or solonoid lock to pin 4
 * http://www.mysensors.org/build/rfid 
 */

// Enable debug prints to serial monitor
#define MY_DEBUG 

// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69

#include &lt;SPI.h&gt;
#include &lt;MySensors.h&gt;  
#include &lt;Wire.h&gt;
#include &lt;PN532_I2C.h&gt;
#include &lt;PN532.h&gt;


// 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] = {
                    { 0xB3, 0xC6, 0xD9, 0x80, 0x00, 0x00, 0x00 },
                    { 0x5B, 0xFC, 0x7A, 0xD, 0x00, 0x00, 0x00 },    // ADD YOUR KEYS HERE!
                    { 0xF1, 0x13, 0x54, 0x63, 0x00, 0x00, 0x00 },
                    { 0xCB, 0x6F, 0x2D, 0xD, 0x00, 0x00, 0x00 },
                    { 0x9B, 0x33, 0x2C, 0xD, 0x00, 0x00, 0x00 },
                    { 0x73, 0xFA, 0xF6, 0x1A, 0x00, 0x00, 0x00 },
                    { 0x83, 0x59, 0x36, 0x1A, 0x00, 0x00, 0x00 },
                    { 0x83, 0x1A, 0x3C, 0x1A, 0x00, 0x00, 0x00 },
                    { 0xB6, 0xB2, 0x52, 0xF8, 0x00, 0x00, 0x00 },
                    { 0x17, 0xE5, 0xD2, 0x2B, 0x00, 0x00, 0x00 },
                    { 0x79 ,0xF7, 0x88, 0x5A, 0x00, 0x00, 0x00 },
                    
                    { 0x2B, 0xDC, 0x49, 0xB, 0x00, 0x00, 0x00 }};
int keyCount = sizeof validKeys / maxKeyLength; 

#define CHILD_ID 99   // Id of the sensor child


// Pin definition
const int lockPin = 4;         // (Digital 4) The pin that activates the relay/solenoid lock.
bool lockStatus;
MyMessage lockMsg(CHILD_ID, V_LOCK_STATUS);
PN532_I2C pn532i2c(Wire);
PN532 nfc(pn532i2c);

void setup() {

  pinMode(lockPin, 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&gt;&gt;24) &amp; 0xFF, HEX); 
  Serial.print("Firmware ver. "); Serial.print((versiondata&gt;&gt;16) &amp; 0xFF, DEC); 
  Serial.print('.'); Serial.println((versiondata&gt;&gt;8) &amp; 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();

  lockStatus = loadState(0);    // Read last lock status from eeprom
  setLockState(lockStatus, true); // Now set the last known state and send it to controller 
}

void presentation()  {
  sendSketchInfo("RFID Lock", "1.0");
  present(CHILD_ID, S_LOCK);
}

void loop() {
  bool 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, &amp;key[0], &amp;currentKeyLength);

  if (success) {
    Serial.print("Found tag id: ");
    for (uint8_t i=0; i &lt; currentKeyLength; i++) 
    {
      if (i&gt;0) Serial.print(",");
      Serial.print("0x");Serial.print(key[i], HEX); 
    }
    for (uint8_t i=currentKeyLength; i &lt; maxKeyLength; i++) 
    {
      Serial.print(",0x00"); 
    }


    Serial.println("");

    bool valid = false;
    // Compare this key to the valid once registered here in sketch 
    for (int i=0;i&lt;keyCount &amp;&amp; !valid;i++) {
      for (int j=0;j&lt;currentKeyLength &amp;&amp; !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, &amp;key[0], &amp;currentKeyLength));
  } 
} 



// Unlocks the door.
void setLockState(bool state, bool doSend) {
  if (state)
  {
    Serial.println("open lock");
  if (doSend)
    send(lockMsg.set(true));
    digitalWrite(lockPin, true);
    wait(5000);
    Serial.println("close lock");
  if (doSend)
    send(lockMsg.set(false));
    digitalWrite(lockPin, false);
  } else {
  if (doSend)
    send(lockMsg.set(state));
}
}

void receive(const MyMessage &amp;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());
   } 
}</code></pre>
]]></description><link>https://forum.mysensors.org/post/97654</link><guid isPermaLink="true">https://forum.mysensors.org/post/97654</guid><dc:creator><![CDATA[The-Holgi]]></dc:creator><pubDate>Sat, 09 Mar 2019 10:03:27 GMT</pubDate></item><item><title><![CDATA[Reply to Rfid sketch on Wed, 27 Feb 2019 18:25:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/the-holgi" aria-label="Profile: the-holgi">@<bdi>the-holgi</bdi></a> this should work</p>
<pre><code>void setLockState(bool state, bool doSend) {
  if (state)
  {
    Serial.println("open lock");
  if (doSend)
    send(lockMsg.set(true));
    digitalWrite(lockPin, true);
    wait(5000);
    Serial.println("close lock");
  if (doSend)
    send(lockMsg.set(false));
    digitalWrite(lockPin, false);
  } else {
  if (doSend)
    send(lockMsg.set(state));
}
}
</code></pre>
]]></description><link>https://forum.mysensors.org/post/97635</link><guid isPermaLink="true">https://forum.mysensors.org/post/97635</guid><dc:creator><![CDATA[mfalkvidd]]></dc:creator><pubDate>Wed, 27 Feb 2019 18:25:22 GMT</pubDate></item><item><title><![CDATA[Reply to Rfid sketch on Wed, 27 Feb 2019 17:10:59 GMT]]></title><description><![CDATA[<p dir="auto">I´ve change the code, now the state on transmitted to fhem, but state off not.</p>
<pre><code>void setLockState(bool state, bool doSend) {
  if (state)
  {
    Serial.println("open lock");
    digitalWrite(lockPin, true);
    wait(5000);
    Serial.println("close lock");
  if (doSend)
    send(lockMsg.set(state));
    digitalWrite(lockPin, false);
  }
}```</code></pre>
]]></description><link>https://forum.mysensors.org/post/97633</link><guid isPermaLink="true">https://forum.mysensors.org/post/97633</guid><dc:creator><![CDATA[The-Holgi]]></dc:creator><pubDate>Wed, 27 Feb 2019 17:10:59 GMT</pubDate></item><item><title><![CDATA[Reply to Rfid sketch on Wed, 27 Feb 2019 16:49:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/the-holgi" aria-label="Profile: the-holgi">@<bdi>the-holgi</bdi></a><br />
That's obvious... as now the state of the lock switches rather fast, the behaviour should be differen. I'd suggest to send both info (on/off) (on before wait(), off after) to get the events in FHEM also.</p>
]]></description><link>https://forum.mysensors.org/post/97632</link><guid isPermaLink="true">https://forum.mysensors.org/post/97632</guid><dc:creator><![CDATA[rejoe2]]></dc:creator><pubDate>Wed, 27 Feb 2019 16:49:21 GMT</pubDate></item><item><title><![CDATA[Reply to Rfid sketch on Wed, 27 Feb 2019 16:37:28 GMT]]></title><description><![CDATA[<p dir="auto">Hm,<br />
now in fhem the state is not transmitted.</p>
]]></description><link>https://forum.mysensors.org/post/97631</link><guid isPermaLink="true">https://forum.mysensors.org/post/97631</guid><dc:creator><![CDATA[The-Holgi]]></dc:creator><pubDate>Wed, 27 Feb 2019 16:37:28 GMT</pubDate></item><item><title><![CDATA[Reply to Rfid sketch on Wed, 27 Feb 2019 16:26:10 GMT]]></title><description><![CDATA[<p dir="auto">Thank you, it work´s perfect.<br />
greetings Holger</p>
]]></description><link>https://forum.mysensors.org/post/97630</link><guid isPermaLink="true">https://forum.mysensors.org/post/97630</guid><dc:creator><![CDATA[The-Holgi]]></dc:creator><pubDate>Wed, 27 Feb 2019 16:26:10 GMT</pubDate></item><item><title><![CDATA[Reply to Rfid sketch on Wed, 27 Feb 2019 14:10:37 GMT]]></title><description><![CDATA[<p dir="auto">change</p>
<pre><code>void setLockState(bool state, bool doSend){
  if (state) 
     Serial.println("open lock");
  else
     Serial.println("close lock");
  if (doSend)
    send(lockMsg.set(state));
  digitalWrite(lockPin, state);
  saveState(0,state);
  lockStatus = state;
}
</code></pre>
<p dir="auto">to</p>
<pre><code>void setLockState(bool state, bool doSend) {
  if (state)
  {
    Serial.println("open lock");
    digitalWrite(lockPin, true);
    wait(3000);
    Serial.println("close lock");
    digitalWrite(lockPin, false);
  }
}
</code></pre>
]]></description><link>https://forum.mysensors.org/post/97628</link><guid isPermaLink="true">https://forum.mysensors.org/post/97628</guid><dc:creator><![CDATA[mfalkvidd]]></dc:creator><pubDate>Wed, 27 Feb 2019 14:10:37 GMT</pubDate></item></channel></rss>