Navigation

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

    Posts made by martins

    • RE: Serial Gateway

      @gohan IDE version 1.8.1.

      posted in Troubleshooting
      martins
      martins
    • RE: Serial Gateway

      @gohan I'm pulling my hair out of my head. Tried it with 2 different power sources(one an 2amp ipad charger). 2 Different mcu's. 2 Different rfm69 radios. Symptom is the same.

      Configured one with the stock standard mockmysensor and it runs without a problem. Take that same one and load the serial gateway and it does this weird loop/reset thing.

      Thanks

      posted in Troubleshooting
      martins
      martins
    • RE: Serial Gateway

      @mfalkvidd said in Serial Gateway:

      mcu

      It's currently connected via an usb ftdi connector to my laptop so the power should be fine. It's an arduino pro mini 3.3v 8mhz.

      posted in Troubleshooting
      martins
      martins
    • RE: RFID Log

      @dpcr

      MyMessage TEXTMsg(CHILD_ID_TXT,V_TEXT);  // Send UID of RFID tag
      
        sendSketchInfo("RFID UID", "0.0.9",false);
        present(CHILD_ID_TXT, S_INFO, "RFID UID",false);
      
        #ifdef MY_DEBUG
          Serial.print("UID sent to Controller: ");
          Serial.println(uid_rfid_str);
        #endif
        send(TEXTMsg.set(uid_rfid), false);		
      

      Hope this helps. I use it this way and it works like a charm. Just remember you need to convert the uid to string in order to send it as text to Domoticz.

      Regards,
      Martin

      posted in Development
      martins
      martins
    • Serial Gateway

      I just can't seem to fix this. This is the serial monitor output captured. Is it normal that the gateway act in this way? It'seems to me it reloads itself but I can't figure out why!!

      ;255;3;0;9;MCO:BGN:INIT GW,CP=RRNGA--,VER=2.1.1
      0;255;3;0;9;TSM:INIT
      0;255;3;0;9;TSF:WUR:MS=0
      0;255;3;0;9;TSM:INIT:TSP OK
      0;255;3;0;9;TSM:INIT:GW MODE
      0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
      0;255;3;0;9;MCO:REG:NOT NEEDED
      0;255;3;0;14;Gateway startup complete.
      0;255;0;0;18;2.1.1
      0;255;3;0;9;MCO:BGN:STP
      0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=255,c=3,t=0,pt=1,l=1,sg=0:84
      253;255;3;0;0;84
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=255,c=3,t=0,pt=1,l=1,sg=0:84
      253;255;3;0;0;84
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=255,c=3,t=0,pt=1,l=1,sg=0:84
      253;255;3;0;0;84
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=10,c=1,t=37,pt=2,l=2,sg=0:-76
      253;10;1;0;37;-76
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=10,c=1,t=37,pt=2,l=2,sg=0:-76
      253;10;1;0;37;-76
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=10,c=1,t=37,pt=2,l=2,sg=0:-76
      253;10;1;0;37;-76
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=255,c=3,t=1,pt=0,l=0,sg=0:
      253;255;3;0;1;
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=255,c=3,t=1,pt=0,l=0,sg=0:
      253;255;3;0;1;
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=255,c=3,t=1,pt=0,l=0,sg=0:
      253;255;3;0;1;
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=255,c=3,t=1,pt=0,l=0,sg=0:
      0;255;3;0;9;TSF:MSG:ACK REQ
      0;255;3;0;9;!TSF:MSG:SEND,0-0-253-253,s=255,c=3,t=1,pt=0,l=0,sg=0,ft=0,st=NACK:
      0;255;3;0;9;MCO:BGN:INIT GW,CP=RRNGA--,VER=2.1.1
      0;255;3;0;9;TSM:INIT
      0;255;3;0;9;TSF:WUR:MS=0
      0;255;3;0;9;TSM:INIT:TSP OK
      0;255;3;0;9;TSM:INIT:GW MODE
      0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
      0;255;3;0;9;MCO:REG:NOT NEEDED
      0;255;3;0;14;Gateway startup complete.
      0;255;0;0;18;2.1.1
      0;255;3;0;9;MCO:BGN:STP
      0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=1,c=1,t=16,pt=2,l=2,sg=0:0
      253;1;1;0;16;0
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=1,c=1,t=16,pt=2,l=2,sg=0:0
      253;1;1;0;16;0
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=1,c=1,t=15,pt=1,l=1,sg=0:1
      253;1;1;0;15;1
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=1,c=1,t=15,pt=1,l=1,sg=0:1
      253;1;1;0;15;1
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=1,c=1,t=15,pt=1,l=1,sg=0:1
      253;1;1;0;15;1
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=3,c=1,t=16,pt=2,l=2,sg=0:0
      253;3;1;0;16;0
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=3,c=1,t=16,pt=2,l=2,sg=0:0
      253;3;1;0;16;0
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=3,c=1,t=15,pt=1,l=1,sg=0:1
      253;3;1;0;15;1
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=3,c=1,t=15,pt=1,l=1,sg=0:1
      253;3;1;0;15;1
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=255,c=3,t=0,pt=1,l=1,sg=0:84
      253;255;3;0;0;84
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=255,c=3,t=0,pt=1,l=1,sg=0:84
      253;255;3;0;0;84
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=255,c=3,t=0,pt=1,l=1,sg=0:84
      253;255;3;0;0;84
      0;255;3;0;9;TSF:MSG:READ,253-253-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
      0;255;3;0;9;TSF:MSG:BC
      0;255;3;0;9;TSF:MSG:FPAR REQ,ID=253
      0;255;3;0;9;TSF:PNG:SEND,TO=0
      0;255;3;0;9;TSF:CKU:OK
      0;255;3;0;9;TSF:MSG:GWL OK
      0;255;3;0;9;!TSF:MSG:SEND,0-0-253-253,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0
      0;255;3;0;9;MCO:BGN:INIT GW,CP=RRNGA--,VER=2.1.1
      0;255;3;0;9;TSM:INIT
      0;255;3;0;9;TSF:WUR:MS=0
      0;255;3;0;9;TSM:INIT:TSP OK
      0;255;3;0;9;TSM:INIT:GW MODE
      0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
      0;255;3;0;9;MCO:REG:NOT NEEDED
      0;255;3;0;14;Gateway startup complete.
      0;255;0;0;18;2.1.1
      0;255;3;0;9;MCO:BGN:STP
      0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
      0;255;3;0;9;TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
      0;255;3;0;9;!TSF:MSG:LEN,0!=7
      0;255;3;0;9;TSF:MSG:READ,253-253-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1
      0;255;3;0;9;TSF:MSG:PINGED,ID=253,HP=1
      0;255;3;0;9;!TSF:MSG:SEND,0-0-253-253,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=NACK:1
      0;255;3;0;9;MCO:BGN:INIT GW,CP=RRNGA--,VER=2.1.1
      0;255;3;0;9;TSM:INIT
      0;255;3;0;9;TSF:WUR:MS=0
      0;255;3;0;9;TSM:INIT:TSP OK
      0;255;3;0;9;TSM:INIT:GW MODE
      0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
      0;255;3;0;9;MCO:REG:NOT NEEDED
      0;255;3;0;14;Gateway startup complete.
      0;255;0;0;18;2.1.1
      0;255;3;0;9;MCO:BGN:STP
      0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
      0;255;3;0;9;TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
      0;255;3;0;9;!TSF:MSG:LEN,0!=7

      posted in Troubleshooting
      martins
      martins
    • RE: RFID and NRF24L01 Wireless Network Coding Issues

      @Aron-SjΓΆberg said in RFID and NRF24L01 Wireless Network Coding Issues:

      int getID()

      Change that line in the getID() function to return 0;

      posted in Troubleshooting
      martins
      martins
    • RE: Serial Gateway crash and reloads

      @Yveaux

      alt text

      posted in Troubleshooting
      martins
      martins
    • RE: Serial Gateway crash and reloads

      IDE 1.8.1

      0_1489826183494_upload-88d0d7f0-c39a-47e1-aa30-6f49a3310a96

      posted in Troubleshooting
      martins
      martins
    • RE: Serial Gateway crash and reloads

      Narrowed it down a bit more. As soon as I change the true (req ack) to false the gateway don't crash anymore. So my question now is why would a ack req cause the gateway to crash ?

        send(TEXTMsg.set(uid_rfid), false);```
      posted in Troubleshooting
      martins
      martins
    • RE: Serial Gateway crash and reloads

      Changed the arduino pro mini. Same effect. As soon as this is executed the serial gateway restarts send(TEXTMsg.set(uid_rfid), true);

      Output on serial gateway:
      0;255;3;0;9;!TSF:MSG:SEND,0-0-10-10,s=9,c=1,t=47,pt=0,l=8,sg=0,ft=0,st=NACK:c350fd4b
      Gateway restart😒
      0;255;3;0;9;MCO:BGN:INIT GW,CP=RRNGA--,VER=2.1.1
      0;255;3;0;9;TSM:INIT
      0;255;3;0;9;TSF:WUR:MS=0
      0;255;3;0;9;TSM:INIT:TSP OK
      0;255;3;0;9;TSM:INIT:GW MODE
      0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
      0;255;3;0;9;MCO:REG:NOT NEEDED
      0;255;3;0;14;Gateway startup complete.
      0;255;0;0;18;2.1.1
      0;255;3;0;11;MySensors Serial Gateway
      0;255;3;0;12;2.0.0
      0;255;3;0;9;MCO:BGN:STP
      0;255;3;0;9;MCO:BGN:INIT OK,TSP=1

      posted in Troubleshooting
      martins
      martins
    • RE: Serial Gateway crash and reloads

      This works perfect without the gateway reloading:

      void granted (int setDelay) {
        value = 1;
        send(msg.set(value==HIGH ? 1 : 0));
        delay(setDelay);
        value = 0;
        send(msg.set(value==HIGH ? 1 : 0));
        #ifdef MY_DEBUG
          Serial.print("UID sent to Controller: ");
          Serial.println(uid_rfid_str);
        #endif
      									
      // Send to gateway the UID to keep log of who entered
      //  send(TEXTMsg.set(uid_rfid), false);
      }
      

      However as soon as I uncomment this it reloads:

       send(TEXTMsg.set(uid_rfid), true);
      

      Some more code:

      MyMessage msg(CHILD_ID,V_TRIPPED);
      MyMessage TEXTMsg(CHILD_ID_TXT,V_TEXT);  // Send UID of RFID tag
      
      
      void presentation() {
        sendSketchInfo("RFID Gate", "1.0");
        present(CHILD_ID, S_DOOR);
        
        sendSketchInfo("RFID UID", "0.0.1");
        present(CHILD_ID_TXT, S_INFO, "RFID UID", true);
      }
      
      posted in Troubleshooting
      martins
      martins
    • RE: Serial Gateway crash and reloads

      Even connected directly via usb to the ide I get the same symptom.

      posted in Troubleshooting
      martins
      martins
    • RE: Serial Gateway crash and reloads

      I comment out one msg.set from the sensor and that fix the problem. I really don't think this is power related. And this is the gateway guys. It is only powering an arduino mini pro and a rfm69.

      posted in Troubleshooting
      martins
      martins
    • RE: Serial Gateway crash and reloads

      Powered by a raspberry pi 3 of its 3.3 v. Couple of mockmysensors running of this serial gateway as well asva door sensor without any problem. However as soon as this rfid sensor sends a s_info back containing text and request an ack the gateway reboots. If I remove the sendmsg it runs fine. This text however contains the rfid_ui key and is required to log which card triggered the event.

      posted in Troubleshooting
      martins
      martins
    • Serial Gateway crash and reloads

      Why would this message cause the gateway to crash and reloads ? All it does is send a text field to the gateway and requesting an ack:

      0;255;3;0;9;TSF:MSG:READ,10-10-0,s=9,c=1,t=47,pt=0,l=8,sg=0:c350fd4b
      0;255;3;0;9;TSF:MSG:ACK REQ
      0;255;3;0;9;!TSF:MSG:SEND,0-0-10-10,s=9,c=1,t=47,pt=0,l=8,sg=0,ft=0,st=NACK:c350fd4b
      0;255;3;0;9;MCO:BGN:INIT GW,CP=RRNGA--,VER=2.1.1
      0;255;3;0;9;TSM:INIT
      0;255;3;0;9;TSF:WUR:MS=0
      0;255;3;0;9;TSM:INIT:TSP OK
      0;255;3;0;9;TSM:INIT:GW MODE
      0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
      0;255;3;0;9;MCO:REG:NOT NEEDED
      0;255;3;0;14;Gateway startup complete.
      0;255;0;0;18;2.1.1
      0;255;3;0;11;MySensors Serial Gateway
      0;255;3;0;12;2.0.0
      0;255;3;0;9;MCO:BGN:STP
      0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
      0;255;3;0;9;TSF:MSG:READ,10-10-0,s=8,c=1,t=16,pt=2,l=2,sg=0:1
      10;8;1;0;16;1
      0;255;3;0;9;TSF:MSG:READ,10-10-0,s=8,c=1,t=16,pt=2,l=2,sg=0:0
      10;8;1;0;16;0
      0;255;3;0;9;TSF:MSG:READ,10-10-0,s=9,c=1,t=47,pt=0,l=8,sg=0:c350fd4b
      0;255;3;0;9;TSF:MSG:ACK REQ
      0;255;3;0;9;!TSF:MSG:SEND,0-0-10-10,s=9,c=1,t=47,pt=0,l=8,sg=0,ft=0,st=NACK:c350fd4b
      0;255;3;0;9;MCO:BGN:INIT GW,CP=RRNGA--,VER=2.1.1
      0;255;3;0;9;TSM:INIT
      0;255;3;0;9;TSF:WUR:MS=0
      0;255;3;0;9;TSM:INIT:TSP OK
      0;255;3;0;9;TSM:INIT:GW MODE
      0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
      0;255;3;0;9;MCO:REG:NOT NEEDED
      0;255;3;0;14;Gateway startup complete.
      0;255;0;0;18;2.1.1
      0;255;3;0;11;MySensors Serial Gateway
      0;255;3;0;12;2.0.0
      0;255;3;0;9;MCO:BGN:STP
      0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
      0;255;3;0;9;TSF:MSG:READ,10-10-0,s=255,c=3,t=22,pt=5,l=4,sg=0:60250
      10;255;3;0;22;60250

      Any suggestions on how to fix this is appreciated.

      Regards,
      Martin

      posted in Troubleshooting
      martins
      martins
    • Pass RFID UID tag to Domoticz

      Is there a way that I can pass the UID of an RFID tag as a parameter to Domoticz to have a log of which uid trigered the switch?

      Thanks,
      Martin

      posted in General Discussion
      martins
      martins
    • RE: RFID and NRF24L01 Wireless Network Coding Issues

      @gohan This is the code that works for me on my pro mini. Try it out.

      Here is my pins used:

      MOSI: Pin 11
      MISO: Pin 12
      SCK : Pin 13
      SS : Pin 8 (Configurable)
      RST : Pin 6 (Configurable)

      /*
        Arduino RFID Access Control
      
        Security !
      
        To keep it simple we are going to use Tag's Unique IDs
        as only method of Authenticity. It's simple and not hacker proof.
        If you need security, don't use it unless you modify the code
      
        Copyright (C) 2015 Omer Siar Baysal
      
        This program is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation; either version 2 of the License, or
        (at your option) any later version.
      
        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.
      
        You should have received a copy of the GNU General Public License along
        with this program; if not, write to the Free Software Foundation, Inc.,
        51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      
      */
      #define MY_DEBUG 
      
      #define MY_RADIO_NRF24
      //#define MY_RF24_PA_LEVEL RF24_PA_LOW
      
      //#define MY_RADIO_RFM69
      //#define MY_RFM69_FREQUENCY RF69_433MHZ
      //#define MY_IS_RFM69HW
      
      #if F_CPU == 8000000L
      #define MY_BAUD_RATE 38400
      #endif
      
      
      #define CHILD_ID 8
      #define MAX_CARDS       18
      
      #include <EEPROM.h>     // We are going to read and write PICC's UIDs from/to EEPROM
      #include <SPI.h>        // RC522 Module uses SPI protocol
      #include <MFRC522.h>	// Library for Mifare RC522 Devices
      #include <MySensors.h>
      
      /*
      	For visualizing whats going on hardware
      	we need some leds and
      	to control door lock a relay and a wipe button
      	(or some other hardware)
      	Used common anode led,digitalWriting HIGH turns OFF led
      	Mind that if you are going to use common cathode led or
      	just seperate leds, simply comment out #define COMMON_ANODE,
      */
      
      int value=0;
      
      boolean match = false;          // initialize card match to false
      boolean programMode = false;	// initialize programming mode to false
      boolean replaceMaster = false;
      
      int successRead;		// Variable integer to keep if we have Successful Read from Reader
      
      byte storedCard[4];		// Stores an ID read from EEPROM
      byte readCard[4];		// Stores scanned ID read from RFID Module
      byte masterCard[4];		// Stores master card's ID read from EEPROM
      byte countValidCards = 0;
      /*
      	We need to define MFRC522's pins and create instance
      	Pin layout should be as follows (on Arduino Uno):
      	MOSI: Pin 11 / ICSP-4
      	MISO: Pin 12 / ICSP-1
      	SCK : Pin 13 / ICSP-3
      	SS : Pin 10 (8)(Configurable)
      	RST : Pin 9 (6)(Configurable)
      	look MFRC522 Library for
      	other Arduinos' pin configuration
      */
      
      // bool lockStatus;
      
      #define SS_PIN 8
      #define RST_PIN 6
      
      MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance.
      // MFRC522::Uid validCards[MAX_CARDS];
      
      //MyMessage lockMsg(CHILD_ID, V_LOCK_STATUS);
      
      MyMessage msg(CHILD_ID,V_TRIPPED);
      
      
      // MFRC522 mfrc522(SS_PIN, RST_PIN);	// Create MFRC522 instance.
      
      
      ///////////////////////////////////////// Setup ///////////////////////////////////
      void setup() {
        //Protocol Configuration
        //Serial.begin(9600);	 // Initialize serial communications with PC
        
        pinMode(RST_PIN, OUTPUT);
        digitalWrite(RST_PIN, LOW);
        pinMode(SS_PIN, OUTPUT);
        digitalWrite(SS_PIN, LOW);
        
        SPI.begin();           // MFRC522 Hardware uses SPI protocol
        mfrc522.PCD_Init();    // Initialize MFRC522 Hardware
      
        //If you set Antenna Gain to Max it will increase reading distance
        //mfrc522.PCD_SetAntennaGain(mfrc522.RxGain_max);
      
        Serial.println(F("Access Control v3.4"));   // For debugging purposes
        ShowReaderDetails();	// Show details of PCD - MFRC522 Card Reader details
      
        if (EEPROM.read(500) != 143) {
          Serial.println(F("No Master Card Defined"));
          Serial.println(F("Scan A PICC to Define as Master Card"));
          do {
            successRead = getID();            // sets successRead to 1 when we get read from reader otherwise 0
          }
          while (!successRead);                  // Program will not go further while you not get a successful read
      
      //    printHex(mfrc522.uid.uidByte, mfrc522.uid.size);
          
          for ( int j = 0; j < 4; j++ ) {        // Loop 4 times
            EEPROM.write( 2 + j, readCard[j] );  // Write scanned PICC's UID to EEPROM, start from address 3
          }
            
          EEPROM.write(500, 143);                  // Write to EEPROM we defined Master Card.
          delay(500);
          
          Serial.println(F("Master Card Defined"));
      //    storeEeprom();
        }
        Serial.println(F("-------------------"));
        Serial.println(F("Master Card's UID"));
        for ( int i = 0; i < 4; i++ ) {          // Read Master Card's UID from EEPROM
          masterCard[i] = EEPROM.read(2 + i);    // Write it to masterCard
          Serial.print(masterCard[i], HEX);
        }
      
        Serial.println("");
        Serial.println(F("-------------------"));
        Serial.println(F("Everything Ready"));
        Serial.println(F("Waiting PICCs to be scanned"));
        Serial.println(EEPROM.read(500));
      }
      
      void presentation() {
        // Register binary input sensor to gw (they will be created as child devices)
        // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
        // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
        sendSketchInfo("RFID Gate", "1.0");
        present(CHILD_ID, S_DOOR);  
      }
      
      ///////////////////////////////////////// Main Loop ///////////////////////////////////
      void loop () {
        send(msg.set(value==HIGH ? 1 : 0));
        do {
          successRead = getID(); 	// sets successRead to 1 when we get read from reader otherwise 0
        }
        while (!successRead); 	//the program will not go further while you not get a successful read
      
        if (programMode) {
          if ( isMaster(readCard) ) { //If master card scanned again exit program mode
            Serial.println(F("Master Card Scanned"));
            Serial.println(F("Exiting Program Mode"));
            Serial.println(F("-----------------------------"));
            programMode = false;
            return;
          }
          else {
            if ( findID(readCard) ) { // If scanned card is known delete it
              Serial.println(F("I know this PICC, removing..."));
              deleteID(readCard);
              Serial.println("-----------------------------");
              Serial.println(F("Scan a PICC to ADD or REMOVE to EEPROM"));
            }
            else {                    // If scanned card is not known add it
              Serial.println(F("I do not know this PICC, adding..."));
              writeID(readCard);
              Serial.println(F("-----------------------------"));
              Serial.println(F("Scan a PICC to ADD or REMOVE to EEPROM"));
            }
          }
        }
        else {
          if ( isMaster(readCard)) {  	// If scanned card's ID matches Master Card's ID enter program mode
            programMode = true;
            Serial.println(F("Hello Master - Entered Program Mode"));
            int count = EEPROM.read(0); 	// Read the first Byte of EEPROM that
            Serial.print(F("I have "));    	// stores the number of ID's in EEPROM
            Serial.print(count);
            Serial.print(F(" record(s) on EEPROM"));
            Serial.println("");
            Serial.println(F("Scan a PICC to ADD or REMOVE to EEPROM"));
            Serial.println(F("Scan Master Card again to Exit Program Mode"));
            Serial.println(F("-----------------------------"));
          }
          else {
            if ( findID(readCard) ) {	// If not, see if the card is in the EEPROM
              Serial.println(F("Welcome, You shall pass"));
              granted(300);        	// Open the door lock for 300 ms
            }
            else {			// If not, show that the ID was not valid
              Serial.println(F("You shall not pass"));
              denied();
            }
          }
        }
      }
      
      /////////////////////////////////////////  Access Granted    ///////////////////////////////////
      void granted (int setDelay) {
        // setLockState(!lockStatus, true);
        value = 1;
        send(msg.set(value==HIGH ? 1 : 0));
        smartSleep(5000);
        value = 0;
        send(msg.set(value==HIGH ? 1 : 0));
      }
      
      ///////////////////////////////////////// Access Denied  ///////////////////////////////////
      void denied() {
      }
      
      
      ///////////////////////////////////////// Get PICC's UID ///////////////////////////////////
      int getID() {
        // Getting ready for Reading PICCs
          if ( ! mfrc522.PICC_IsNewCardPresent())
          return 0;
      
        // Verify if the NUID has been readed
        if ( ! mfrc522.PICC_ReadCardSerial())
          return 0;
      
        Serial.print(F("PICC type: "));
        MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
        Serial.println(mfrc522.PICC_GetTypeName(piccType));
      
        // Check is the PICC of Classic MIFARE type
        if (piccType != MFRC522::PICC_TYPE_MIFARE_MINI &&  piccType != MFRC522::PICC_TYPE_MIFARE_1K && piccType != MFRC522::PICC_TYPE_MIFARE_4K) {
          Serial.println(F("Your tag is not of type MIFARE Classic."));
          return;
        }
        Serial.println(F("Scanned PICC's UID:"));
        for (int i = 0; i < 4; i++) {  //
          readCard[i] = mfrc522.uid.uidByte[i];
          Serial.print(readCard[i], HEX);
        }
        Serial.println("");
        mfrc522.PICC_HaltA();
        return 1;
      
      /*  while (! mfrc522.PICC_IsNewCardPresent()) 
        {;}
        if ( ! mfrc522.PICC_IsNewCardPresent()) 
        { //If a new PICC placed to RFID reader continue
          Serial.println("No NCP");
          return 0;
        }
        if ( ! mfrc522.PICC_ReadCardSerial()) 
        {   //Since a PICC placed get Serial and continue
          Serial.println("RCS");
          return 0;
        }
        // There are Mifare PICCs which have 4 byte or 7 byte UID care if you use 7 byte PICC
        // I think we should assume every PICC as they have 4 byte UID
        // Until we support 7 byte PICCs
        Serial.println(F("Scanned PICC's UID:"));
        for (int i = 0; i < 4; i++) {  //
          readCard[i] = mfrc522.uid.uidByte[i];
          Serial.print(readCard[i], HEX);
        }
        Serial.println("");
        mfrc522.PICC_HaltA(); // Stop reading
        return 1;
        */
        
      }
      
      void ShowReaderDetails() {
        // Get the MFRC522 software version
        byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
        Serial.print(F("MFRC522 Software Version: 0x"));
        Serial.print(v, HEX);
        if (v == 0x91)
          Serial.print(F(" = v1.0"));
        else if (v == 0x92)
          Serial.print(F(" = v2.0"));
        else
          Serial.print(F(" (unknown),probably a chinese clone?"));
        Serial.println("");
        // When 0x00 or 0xFF is returned, communication probably failed
        if ((v == 0x00) || (v == 0xFF)) {
          Serial.println(F("WARNING: Communication failure, is the MFRC522 properly connected?"));
          Serial.println(F("SYSTEM HALTED: Check connections."));
          while (true); // do not go further
        }
      }
      
      ///////////////////////////////////////// Cycle Leds (Program Mode) ///////////////////////////////////
      void cycleLeds() {
      }
      
      //////////////////////////////////////// Normal Mode Led  ///////////////////////////////////
      void normalModeOn () {
      }
      
      //////////////////////////////////////// Read an ID from EEPROM //////////////////////////////
      void readID( int number ) {
        int start = (number * 4 ) + 2; 		// Figure out starting position
        for ( int i = 0; i < 4; i++ ) { 		// Loop 4 times to get the 4 Bytes
          storedCard[i] = EEPROM.read(start + i); 	// Assign values read from EEPROM to array
        }
      }
      
      ///////////////////////////////////////// Add ID to EEPROM   ///////////////////////////////////
      void writeID( byte a[] ) {
        if ( !findID( a ) ) { 		// Before we write to the EEPROM, check to see if we have seen this card before!
          int num = EEPROM.read(0); 		// Get the numer of used spaces, position 0 stores the number of ID cards
          int start = ( num * 4 ) + 6; 	// Figure out where the next slot starts
          num++; 								// Increment the counter by one
          EEPROM.write( 0, num ); 		// Write the new count to the counter
          for ( int j = 0; j < 4; j++ ) { 	// Loop 4 times
            EEPROM.write( start + j, a[j] ); 	// Write the array values to EEPROM in the right position
          }
          successWrite();
          Serial.println(F("Succesfully added ID record to EEPROM"));
        }
        else {
          failedWrite();
          Serial.println(F("Failed! There is something wrong with ID or bad EEPROM"));
        }
      }
      
      ///////////////////////////////////////// Remove ID from EEPROM   ///////////////////////////////////
      void deleteID( byte a[] ) {
        if ( !findID( a ) ) { 		// Before we delete from the EEPROM, check to see if we have this card!
          failedWrite(); 			// If not
          Serial.println(F("Failed! There is something wrong with ID or bad EEPROM"));
        }
        else {
          int num = EEPROM.read(0); 	// Get the numer of used spaces, position 0 stores the number of ID cards
          int slot; 			// Figure out the slot number of the card
          int start;			// = ( num * 4 ) + 6; // Figure out where the next slot starts
          int looping; 		// The number of times the loop repeats
          int j;
          int count = EEPROM.read(0); // Read the first Byte of EEPROM that stores number of cards
          slot = findIDSLOT( a ); 	// Figure out the slot number of the card to delete
          start = (slot * 4) + 2;
          looping = ((num - slot) * 4);
          num--; 			// Decrement the counter by one
          EEPROM.write( 0, num ); 	// Write the new count to the counter
          for ( j = 0; j < looping; j++ ) { 				// Loop the card shift times
            EEPROM.write( start + j, EEPROM.read(start + 4 + j)); 	// Shift the array values to 4 places earlier in the EEPROM
          }
          for ( int k = 0; k < 4; k++ ) { 				// Shifting loop
            EEPROM.write( start + j + k, 0);
          }
          successDelete();
          Serial.println(F("Succesfully removed ID record from EEPROM"));
        }
      }
      
      ///////////////////////////////////////// Check Bytes   ///////////////////////////////////
      boolean checkTwo ( byte a[], byte b[] ) {
        if ( a[0] != NULL ) 			// Make sure there is something in the array first
          match = true; 			// Assume they match at first
        for ( int k = 0; k < 4; k++ ) { 	// Loop 4 times
          if ( a[k] != b[k] ) 		// IF a != b then set match = false, one fails, all fail
            match = false;
        }
        if ( match ) { 			// Check to see if if match is still true
          return true; 			// Return true
        }
        else  {
          return false; 			// Return false
        }
      }
      
      ///////////////////////////////////////// Find Slot   ///////////////////////////////////
      int findIDSLOT( byte find[] ) {
        int count = EEPROM.read(0); 			// Read the first Byte of EEPROM that
        for ( int i = 1; i <= count; i++ ) { 		// Loop once for each EEPROM entry
          readID(i); 								// Read an ID from EEPROM, it is stored in storedCard[4]
          if ( checkTwo( find, storedCard ) ) { 	// Check to see if the storedCard read from EEPROM
            // is the same as the find[] ID card passed
            return i; 				// The slot number of the card
            break; 					// Stop looking we found it
          }
        }
      }
      
      ///////////////////////////////////////// Find ID From EEPROM   ///////////////////////////////////
      boolean findID( byte find[] ) {
        int count = EEPROM.read(0);			// Read the first Byte of EEPROM that
        for ( int i = 1; i <= count; i++ ) {  	// Loop once for each EEPROM entry
          readID(i); 					// Read an ID from EEPROM, it is stored in storedCard[4]
          if ( checkTwo( find, storedCard ) ) {  	// Check to see if the storedCard read from EEPROM
            return true;
            break; 	// Stop looking we found it
          }
          else {  	// If not, return false
          }
        }
        return false;
      }
      
      ///////////////////////////////////////// Write Success to EEPROM   ///////////////////////////////////
      // Flashes the green LED 3 times to indicate a successful write to EEPROM
      void successWrite() {
      }
      
      ///////////////////////////////////////// Write Failed to EEPROM   ///////////////////////////////////
      // Flashes the red LED 3 times to indicate a failed write to EEPROM
      void failedWrite() {
      }
      
      ///////////////////////////////////////// Success Remove UID From EEPROM  ///////////////////////////////////
      // Flashes the blue LED 3 times to indicate a success delete to EEPROM
      void successDelete() {
      }
      
      ////////////////////// Check readCard IF is masterCard   ///////////////////////////////////
      // Check to see if the ID passed is the master programing card
      boolean isMaster( byte test[] ) {
        if ( checkTwo( test, masterCard ) )
          return true;
        else
          return false;
      }
      
      /**
       * Helper routine to dump a byte array as hex values to Serial. 
       */
      void printHex(byte *buffer, byte bufferSize) {
        for (byte i = 0; i < bufferSize; i++) {
          Serial.print(buffer[i] < 0x10 ? " 0" : " ");
          Serial.print(buffer[i], HEX);
        }
      }
      
      
      //void presentation()  {
      //  sendSketchInfo("RFID Lock", "1.0");
      //  present(CHILD_ID, S_LOCK);
      //}
      
      void before() {
        // Make sure MFRC is disabled from the SPI bus
        pinMode(RST_PIN, OUTPUT);
        digitalWrite(RST_PIN, LOW);
        pinMode(SS_PIN, OUTPUT);
        digitalWrite(SS_PIN, LOW);
      }
      
      
      posted in Troubleshooting
      martins
      martins
    • RE: RFID and NRF24L01 Wireless Network Coding Issues

      @gohan What is the serial output or error that you get ?

      posted in Troubleshooting
      martins
      martins
    • RE: RFID and NRF24L01 Wireless Network Coding Issues

      @gohan Yes

      posted in Troubleshooting
      martins
      martins
    • RE: RFID and NRF24L01 Wireless Network Coding Issues

      Found the solution in this thread:

      https://forum.mysensors.org/topic/2439/rfid-garage-door-opener/35

      void before() {
      // Make sure MFRC is disabled from the SPI bus
      pinMode(RST_PIN, OUTPUT);
      digitalWrite(RST_PIN, LOW);
      pinMode(SS_PIN, OUTPUT);
      digitalWrite(SS_PIN, LOW);
      }

      posted in Troubleshooting
      martins
      martins
    • RE: RFID and NRF24L01 Wireless Network Coding Issues

      Sit with the same scenario. Separately both function. As soon as you share miso, mosi and sck it fails to initialize the radio. Anybody knows whether you can share this ?

      Thanks

      posted in Troubleshooting
      martins
      martins
    • RE: RFM69H and RFM69HCW

      That's what is on the radio.

      http://www.hoperf.cn/upload/docs/RF/SX/RFM69H_DataSheet_v1.3.pdf

      posted in Hardware
      martins
      martins
    • RFM69H and RFM69HCW

      Re: πŸ’¬ Connecting the Radio
      Is these radios compatible and mixable in the same 433mhz network ? My gateway runs the 69H but it seems the sensors running 69HCW can't register?

      Regards,
      Martin

      posted in Hardware
      martins
      martins
    • RE: Sleep function breaks code

      OK it's working. Main fix I think is I used the new 2.1.1 library and all comms to the RFM69 radio seems to be fixed.

      Current code:

      • DESCRIPTION
      • Simple binary switch example
      • Connect button or door/window reed switch between
      • digitial I/O pin 3 (BUTTON_PIN below) and GND.
      • http://www.mysensors.org/build/binary
        */

      // Enable debug prints to serial monitor
      #define MY_DEBUG

      // Enable and select radio type attached
      // #define MY_RADIO_NRF24
      #define MY_RADIO_RFM69
      #define MY_RFM69_FREQUENCY RF69_433MHZ
      #define MY_IS_RFM69HW

      #if F_CPU == 8000000L
      #define MY_BAUD_RATE 38400
      #endif

      #include <SPI.h>
      #include <MySensors.h>

      #define CHILD_ID 3
      #define BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch

      int oldValue=-1;

      // Change to V_LIGHT if you use S_LIGHT in presentation below
      MyMessage msg(CHILD_ID,V_TRIPPED);

      void setup()
      {
      // Setup the button
      pinMode(BUTTON_PIN,INPUT);
      // Activate internal pull-up
      digitalWrite(BUTTON_PIN,HIGH);
      }

      void presentation() {
      // Register binary input sensor to gw (they will be created as child devices)
      sendSketchInfo("Binary Sensor", "1.0");
      // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage.
      // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
      present(CHILD_ID, S_DOOR);
      // Send the sketch version information to the gateway and Controller
      }

      // Check if digital input has changed and send in new value
      void loop()
      {
      int value = digitalRead(BUTTON_PIN);
      #ifdef MY_DEBUG
      Serial.println("Sensor Value");
      Serial.println(value);
      #endif
      send(msg.set(value==HIGH ? 1 : 0));
      sleep(BUTTON_PIN-2, CHANGE, 0);
      }

      Thanks,
      Martin

      posted in Troubleshooting
      martins
      martins
    • RE: πŸ’¬ Easy/Newbie PCB for MySensors

      @ferro
      Pity because that would double the cost of the sensor board:

      Order PCBs for Easy/Newbie PCB for MySensors : $15
      Order PCBs for NRF2RFM69 : $15

      Thanks,
      Martin

      posted in OpenHardware.io
      martins
      martins
    • RE: Sleep function breaks code

      @mfalkvidd

      It's almost as if the RFM69 radio is not transmitting anymore:
      !TSP:SEND:TNR
      !TSP:SEND:TNR
      !TSP:SEND:TNR
      !TSP:SEND:TNR
      !TSP:SEND:TNR
      !TSP:SEND:TNR

      What does TNR mean ? Transmitter Not Ready ? I looked through the serial API but can't find any reference. Neither in the sensor API nor library API. Any suggestions ?

      Thanks,
      Martin

      posted in Troubleshooting
      martins
      martins
    • RE: πŸ’¬ Easy/Newbie PCB for MySensors

      @SUNDBERG84 - Do you have a board/design for the RFM69 radio ?

      Rergards,
      Martin

      posted in OpenHardware.io
      martins
      martins
    • RE: Sleep function breaks code

      Thanks. I'm trying these 2 but both givers the same results:

      /**

      • 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 henrik.ekblad@mysensors.org
      • 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.

      • DESCRIPTION
      • Simple binary switch example
      • Connect button or door/window reed switch between
      • digitial I/O pin 3 (BUTTON_PIN below) and GND.
      • http://www.mysensors.org/build/binary
        */

      // Enable debug prints to serial monitor
      #define MY_DEBUG

      // Enable and select radio type attached
      // #define MY_RADIO_NRF24
      #define MY_RADIO_RFM69
      #define MY_RFM69_FREQUENCY RF69_433MHZ
      #define MY_IS_RFM69HW

      #if F_CPU == 8000000L
      #define MY_BAUD_RATE 38400
      #endif

      #include <SPI.h>
      #include <MySensors.h>
      #include <Bounce2.h>

      #define CHILD_ID 3
      #define BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch

      Bounce debouncer = Bounce();
      int oldValue=-1;
      int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point

      unsigned long SLEEP_TIME = 60000; // sleep time between reads (seconds * 1000 milliseconds)
      int oldBatteryPcnt = 0;

      // Change to V_LIGHT if you use S_LIGHT in presentation below
      MyMessage msg(CHILD_ID,V_TRIPPED);

      void setup()
      {
      // use the 1.1 V internal reference
      #if defined(AVR_ATmega2560)
      analogReference(INTERNAL1V1);
      #else
      analogReference(INTERNAL);
      #endif

      // Setup the button
      pinMode(BUTTON_PIN,INPUT);
      // Activate internal pull-up
      digitalWrite(BUTTON_PIN,HIGH);

      // After setting up the button, setup debouncer
      debouncer.attach(BUTTON_PIN);
      debouncer.interval(5);

      }

      void presentation() {
      // Register binary input sensor to gw (they will be created as child devices)
      // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage.
      // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
      present(CHILD_ID, S_DOOR);
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Door Sensor", "1.0");
      }

      // Check if digital input has changed and send in new value
      void loop()
      {
      debouncer.update();
      // Get the update value
      int value = debouncer.read();

      if (value != oldValue) {
      // Send in the new value
      send(msg.set(value==HIGH ? 1 : 0));
      oldValue = value;

           // get the battery Voltage
      int sensorValue = analogRead(BATTERY_SENSE_PIN);
      

      #ifdef MY_DEBUG
      Serial.println(sensorValue);
      #endif

      // 1M, 470K divider across battery and using internal ADC ref of 1.1V
      // Sense point is bypassed with 0.1 uF cap to reduce noise at that point
      // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts
      // 3.44/1023 = Volts per bit = 0.003363075
      
      int batteryPcnt = sensorValue / 10;
      

      #ifdef MY_DEBUG
      float batteryV = sensorValue * 0.003363075;
      Serial.print("Battery Voltage: ");
      Serial.print(batteryV);
      Serial.println(" V");

      Serial.print("Battery percent: ");
      Serial.print(batteryPcnt);
      Serial.println(" %");
      

      #endif

      if (oldBatteryPcnt != batteryPcnt) {
      // Power up radio after sleep
      sendBatteryLevel(batteryPcnt);
      oldBatteryPcnt = batteryPcnt;
      }
      // sleep(SLEEP_TIME);
      sleep(BUTTON_PIN-2, CHANGE, SLEEP_TIME);
      }
      }

      /**

      • 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 henrik.ekblad@mysensors.org
      • 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.

      • DESCRIPTION
      • Interrupt driven binary switch example with dual interrupts
      • Author: Patrick 'Anticimex' Fallberg
      • Connect one button or door/window reed switch between
      • digitial I/O pin 3 (BUTTON_PIN below) and GND and the other
      • one in similar fashion on digital I/O pin 2.
      • This example is designed to fit Arduino Nano/Pro Mini

      */

      // Enable debug prints to serial monitor
      #define MY_DEBUG

      // Enable and select radio type attached
      //#define MY_RADIO_NRF24
      #define MY_RADIO_RFM69
      #define MY_RFM69_FREQUENCY RF69_433MHZ
      #define MY_IS_RFM69HW

      #if F_CPU == 8000000L
      #define MY_BAUD_RATE 38400
      #endif

      #include <SPI.h>
      #include <MySensors.h>

      #define BATTERY_SENSE_PIN A0

      #define SKETCH_NAME "Binary Sensor"
      #define SKETCH_MAJOR_VER "1"
      #define SKETCH_MINOR_VER "0"

      #define PRIMARY_CHILD_ID 3
      //#define SECONDARY_CHILD_ID 4

      unsigned long SLEEP_TIME = 60000; // sleep time between reads (seconds * 1000 milliseconds)

      #define PRIMARY_BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch
      //#define SECONDARY_BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch

      #if (PRIMARY_BUTTON_PIN < 2 || PRIMARY_BUTTON_PIN > 3)
      #error PRIMARY_BUTTON_PIN must be either 2 or 3 for interrupts to work
      #endif
      //#if (SECONDARY_BUTTON_PIN < 2 || SECONDARY_BUTTON_PIN > 3)
      //#error SECONDARY_BUTTON_PIN must be either 2 or 3 for interrupts to work
      //#endif
      //#if (PRIMARY_BUTTON_PIN == SECONDARY_BUTTON_PIN)
      //#error PRIMARY_BUTTON_PIN and BUTTON_PIN2 cannot be the same
      //#endif
      //#if (PRIMARY_CHILD_ID == SECONDARY_CHILD_ID)
      //#error PRIMARY_CHILD_ID and SECONDARY_CHILD_ID cannot be the same
      //#endif

      // Change to V_LIGHT if you use S_LIGHT in presentation below
      MyMessage msg(PRIMARY_CHILD_ID, V_TRIPPED);
      //MyMessage msg2(SECONDARY_CHILD_ID, V_TRIPPED);

      void setup()
      {
      // Setup the buttons
      pinMode(PRIMARY_BUTTON_PIN, INPUT);
      // pinMode(SECONDARY_BUTTON_PIN, INPUT);

      // Activate internal pull-ups
      digitalWrite(PRIMARY_BUTTON_PIN, HIGH);
      // digitalWrite(SECONDARY_BUTTON_PIN, HIGH);

      }

      void presentation() {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER);

      // Register binary input sensor to sensor_node (they will be created as child devices)
      // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage.
      // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
      present(PRIMARY_CHILD_ID, S_DOOR);
      // present(SECONDARY_CHILD_ID, S_DOOR);
      }

      // Loop will iterate on changes on the BUTTON_PINs
      void loop()
      {
      uint8_t value;
      static uint8_t sentValue=2;
      //static uint8_t sentValue2=2;
      //attachInterrupt(0, wakeUp, LOW);
      // Short delay to allow buttons to properly settle
      //sleep(5);

      value = digitalRead(PRIMARY_BUTTON_PIN);

      if (value != sentValue) {
      // Value has changed from last transmission, send the updated value
      send(msg.set(value==HIGH ? 1 : 0));
      sentValue = value;
      }

      // value = digitalRead(SECONDARY_BUTTON_PIN);

      // if (value != sentValue2) {
      // // Value has changed from last transmission, send the updated value
      // send(msg2.set(value==HIGH ? 1 : 0));
      // sentValue2 = value;
      // }

      // Sleep until something happens with the sensor
      sleep(PRIMARY_BUTTON_PIN-2, CHANGE, SLEEP_TIME);
      delay(2000);
      value = digitalRead(PRIMARY_BUTTON_PIN);
      }

      Regards,
      Martin

      posted in Troubleshooting
      martins
      martins
    • Sleep function breaks code

      Re: [πŸ’¬ Door](Window and Push-button Sensor)

      As soon as I use the sleep function with this door-sensor-code it breaks it. Works awhile and then gone.

      sleep(PRIMARY_BUTTON_PIN-2, CHANGE, 0);

      Serial output:
      !TSM:UPL FAIL, SNP
      TSM:FPAR
      TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
      !TSP:SEND:TNR
      !TSP:SEND:TNR
      !TSP:SEND:TNR
      !TSP:SEND:TNR
      !TSP:SEND:TNR
      !TSP:SEND:TNR

      And there it dies ! Any suggestions?

      Thanks,
      Martin

      posted in Troubleshooting
      martins
      martins
    • RE: πŸ’¬ Building a Raspberry Pi Gateway

      @marceloaqno
      Issue solved. Domoticz read directly the serial inputs from the arduino that's connected on the PI. I was under the impression that you need a gateway (software) running on the PI to interface with Domoticz.

      Thanks,
      Martin

      posted in Announcements
      martins
      martins
    • RE: πŸ’¬ Connecting the Radio

      @pepson

      From library API:

      MY_RFM69_FREQUENCY RF69_868MHZ For other frequency, add this define to your sketch and set it to your preferred value in RF69_433MHZ, RF69_868MHZ or RF69_915MHZ

      So it seems that 868MHZ is the default value.

      Regards

      posted in Announcements
      martins
      martins
    • RE: πŸ’¬ Connecting the Radio

      @martins

      Solved. This is the extra variables for the RFM69H / HW versions and to set the frequency.

      #define MY_RFM69_FREQUENCY RF69_433MHZ
      #define MY_IS_RFM69HW

      Range is now acceptible.

      Regards,
      Martin

      posted in Announcements
      martins
      martins
    • RE: πŸ’¬ Connecting the Radio

      I'm having trouble with the distance between my 2 RFM69 radios. If I use this tutorial and change the frequency to 433 mhz I get distances of up to 10 meters - https://learn.adafruit.com/adafruit-rfm69hcw-and-rfm96-rfm95-rfm98-lora-packet-padio-breakouts/rfm69-test

      However if I use the Mysensor libraries for the SerialGateway and the door sensor I don't even get 1 meter.
      I tried to declare these variables as well but no success.

      #define RFM69_FREQUENCY RF69_433MHZ
      #define IS_RFM69HW

      Any suggestions I might try out?

      Thanks,
      Martin

      posted in Announcements
      martins
      martins
    • RE: πŸ’¬ Building a Raspberry Pi Gateway

      @marceloaqno
      OK let me explain better. I've build an arduino serial gateway and connecting it on the uart of the pi. If I do tail -f /dev/ttyAMA0 I can see the messages comming in on the serial interface. However if I run ./bin/mysgw -d I get this error:

      mysgw: Starting gateway...
      mysgw: Protocol version - 2.1.0-beta
      mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.1.0-beta
      mysgw: TSF:LRT:OK
      mysgw: TSM:INIT
      mysgw: TSF:WUR:MS=0
      mysgw: !TSM:INIT:TSP FAIL
      mysgw: TSM:FAIL:CNT=1
      mysgw: TSM:FAIL:PDT
      mysgw: TSM:FAIL:RE-INIT

      This is the configure I used to build it:
      ./configure --my-gateway=serial --my-serial-port=/dev/ttyAMA0 --my-serial-baudrate=38400

      So the RFM69 Radio in not directly on the PI but on the arduino and is used as the serial gateway.

      Hope this clarify it more.

      Regards,
      Martin

      posted in Announcements
      martins
      martins
    • RE: πŸ’¬ Building a Raspberry Pi Gateway

      Get this error from the gateway installed on Raspberry Pi2 with RFM69 Radio.

      From the IDE it works fine:
      0;255;3;0;9;Starting gateway (RRNGA-, 2.0.0)
      0;255;3;0;9;TSM:INIT
      0;255;3;0;9;TSM:RADIO:OK
      0;255;3;0;9;TSM:GW MODE
      0;255;3;0;9;TSM:READY
      0;255;3;0;14;Gateway startup complete.
      0;255;0;0;18;2.0.0
      0;255;3;0;9;No registration required
      0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
      0;255;3;0;9;TSP:MSG:READ 255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
      0;255;3;0;9;TSP:MSG:BC
      0;255;3;0;9;TSP:MSG:FPAR REQ (sender=255)
      0;255;3;0;9;TSP:CHKUPL:OK
      0;255;3;0;9;TSP:MSG:GWL OK
      0;255;3;0;9;TSP:MSG:SEND 0-0-255-255 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=bc:0
      0;255;3;0;9;TSP:MSG:READ 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
      255;255;3;0;3;
      0;255;3;0;9;TSP:MSG:READ 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
      255;255;3;0;3;
      0;255;3;0;9;TSP:MSG:READ 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
      255;255;3;0;3;
      0;255;3;0;9;TSP:MSG:READ 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
      255;255;3;0;3;

      mysgw: Starting gateway...
      mysgw: Protocol version - 2.1.0-beta
      mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.1.0-beta
      mysgw: TSF:LRT:OK
      mysgw: TSM:INIT
      mysgw: TSF:WUR:MS=0
      mysgw: !TSM:INIT:TSP FAIL
      mysgw: TSM:FAIL:CNT=1

      From the gateway on the Pi this is the error:
      ./bin/mysgw -d
      mysgw: Starting gateway...
      mysgw: Protocol version - 2.1.0-beta
      mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.1.0-beta
      mysgw: TSF:LRT:OK
      mysgw: TSM:INIT
      mysgw: TSF:WUR:MS=0
      mysgw: !TSM:INIT:TSP FAIL
      mysgw: TSM:FAIL:CNT=1
      mysgw: TSM:FAIL:PDT
      mysgw: TSM:FAIL:RE-INIT
      mysgw: TSM:INIT
      mysgw: !TSM:INIT:TSP FAIL
      mysgw: TSM:FAIL:CNT=2
      mysgw: TSM:FAIL:PDT
      mysgw: TSM:FAIL:RE-INIT
      mysgw: TSM:INIT
      mysgw: !TSM:INIT:TSP FAIL
      mysgw: TSM:FAIL:CNT=3
      mysgw: TSM:FAIL:PDT
      mysgw: TSM:FAIL:RE-INIT
      mysgw: TSM:INIT
      mysgw: !TSM:INIT:TSP FAIL
      mysgw: TSM:FAIL:CNT=4
      mysgw: TSM:FAIL:PDT

      Any ideas where I might start looking at?

      Thanks,
      Martin

      posted in Announcements
      martins
      martins