Navigation

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

    Posts made by finch666

    • RE: Wiegand sending codes to domoticz

      Hi mscory,

      It's been a while, but as far as I remember I was able to see the values as text in domoticz, but was not able to use those in events.

      posted in Troubleshooting
      finch666
      finch666
    • RE: Windmill

      You can charge a battery, of course.....
      A small dynamo will do the job.

      posted in General Discussion
      finch666
      finch666
    • RE: Parking Sensor problem

      @BulldogLowell said:

      @mikeg291

      It could be that transient sound waves are reflecting/scattering around and affecting the readings. The NewPing library states that 29milliseconds should be the shortest delay between reads.

      Sound travels a little more than one foot in 1millisecond so you have an inherent delay in an empty garage; 15 feet each way, for example is about 30milliseconds from ping to read.

      So, if you insert a delay(50) after you obtain the distance you may leave enough time for all of the sound to be absorbed or reflected away.

      I second this. Built the sensor with a neopixel ring and the leds go berserk when I am about 3 cm away from the sensor with my hand.

      posted in Troubleshooting
      finch666
      finch666
    • Wiegand sending codes to domoticz

      Trying to get a Wiegand 26 reader to send the tagcode to domoticz.
      Being not a wizard in coding, I think I got something wrong. I need to send the cardCode to domoticz to use in events, but the code appears in domoticz as "lux".
      Does anyone out there knows how to correct the program (much obliged)

      //
      //
      #include <MySensor.h>
      #include <SPI.h>
      #define ID 0
      
       
      MySensor gw;
      MyMessage msg(ID, S_CUSTOM);
      
      #define MAX_BITS 100                 // max number of bits 
      #define WEIGAND_WAIT_TIME  3000      // time to wait for another weigand pulse.  
      
      unsigned char databits[MAX_BITS];    // stores all of the data bits
      unsigned char bitCount;              // number of bits currently captured
      unsigned char flagDone;              // goes low when data is currently being captured
      unsigned int weigand_counter;        // countdown until we assume there are no more bits
      
      unsigned long facilityCode=0;        // decoded facility code
      unsigned long cardCode=0;            // decoded card code
      
      // interrupt that happens when INTO goes low (0 bit)
      void ISR_INT0()
      {
        //Serial.print("0");
        bitCount++;
        flagDone = 0;
        weigand_counter = WEIGAND_WAIT_TIME;  
        
      }
      
      // interrupt that happens when INT1 goes low (1 bit)
      void ISR_INT1()
      {
        //Serial.print("1");
        databits[bitCount] = 1;
        bitCount++;
        flagDone = 0;
        weigand_counter = WEIGAND_WAIT_TIME;  
      }
      
      void setup()
      {
        gw.begin();
        gw.sendSketchInfo("Wiegand", "1.0");
        gw.present(ID, S_CUSTOM); 
        pinMode(13, OUTPUT);  // LED
        pinMode(2, INPUT);     // DATA0 (INT0)
        pinMode(3, INPUT);     // DATA1 (INT1)
        
        Serial.begin(9600);
        Serial.println("RFID Readers");
        
        // binds the ISR functions to the falling edge of INTO and INT1
        attachInterrupt(0, ISR_INT0, FALLING);  
        attachInterrupt(1, ISR_INT1, FALLING);
        
      
        weigand_counter = WEIGAND_WAIT_TIME;
      }
      
      void loop()
      {
        // This waits to make sure that there have been no more data pulses before processing data
        if (!flagDone) {
          if (--weigand_counter == 0)
            flagDone = 1;	
        }
        
        // if we have bits and we the weigand counter went out
        if (bitCount > 0 && flagDone) {
          unsigned char i;
          
          Serial.print("Read ");
          Serial.print(bitCount);
          Serial.print(" bits. ");
          
         
          if (bitCount == 26)
          {
                  // facility code = bits 2 to 9
            for (i=1; i<9; i++)
            {
               facilityCode <<=1;
               facilityCode |= databits[i];
            }
            
            // card code = bits 10 to 23
            for (i=9; i<25; i++)
            {
               cardCode <<=1;
               cardCode |= databits[i];
            }
            
            printBits();  
            
          }
          else {
                Serial.println("Unable to decode."); 
          }
           // cleanup and get ready for the next card
           bitCount = 0;
           facilityCode = 0;
           cardCode = 0;
           for (i=0; i<MAX_BITS; i++) 
           {
             databits[i] = 0;
           } 
      
       }
      
      }
      
      void printBits()
      {
            // I really hope you can figure out what this function does
            Serial.print("FC = ");
            Serial.print(facilityCode);
            Serial.print(", CC = ");
            Serial.println(cardCode); 
            gw.send(msg.set(cardCode)); 
      }
      
      posted in Troubleshooting
      finch666
      finch666
    • RE: Wiegand support?

      Thanks.
      Knew this, but esp easy has native support for a wiegand reader, where mysensors has not. Had the software (included access control) up and running, but unreliable; as said before.
      So I'm searching for a substitute for the esp.

      posted in Feature Requests
      finch666
      finch666
    • Wiegand support?

      Finally done away with esp sensors, wich to me appeared unreliable, and switched to the NRF solution. Stable as a rock so far, but I really miss the possibility to intergrate my wiegand door access in the network.
      Anyone developing something like this at the moment?

      posted in Feature Requests
      finch666
      finch666
    • IDX table cleanup possible?

      Been running Domoticz now for a month and experimenting with programming sensors, I notice IDX numbers keep rising. Not used IDX's are not re-assigned by domoticz.
      Is it possible to re-assign IDX numbers, so I won't run out off IDX's, or is it a none existing problem I see ahead?

      posted in Domoticz
      finch666
      finch666
    • RE: [SOLVED]Arduino nano clone, serial gateway not working

      It appeared my radio module wasn't functioning......😠
      The nano gateway works perfect now.......😌
      Thank you, TheoL, for your reactions!

      posted in Troubleshooting
      finch666
      finch666
    • RE: [SOLVED]Arduino nano clone, serial gateway not working

      Yep, even larger than 4.7 uF.
      Could it be the 5V pin on the nano, not giving enough current?(a 3.3V regulator is connected to this pin). I thought this pin was directly connected to the 5V coming from the usb connection (powered hub attached). But if it isn't........ will be investigating that later this day...
      This topic could be a lead; will try to get 3.3v directly from the nano.........

      posted in Troubleshooting
      finch666
      finch666
    • [SOLVED]Arduino nano clone, serial gateway not working

      Trying to use a nano clone instead of mij current uno to establish a serial gateway to a raspberry. The nano however, keeps giving me a radio fail.
      Checked the wiring 4 or 5 times, so that should be okay.
      Searched the interweb for problems with these clones, but nothing useful came up, besides known problems with a USB driver, wich don't seem to be relevant, given the fact that uploading a sketch gives no problems.
      Anyone else experienced such problems? Is there a solution? Or would it be much smarter to use a mini with a ftdi232?

      posted in Troubleshooting
      finch666
      finch666
    • RE: [SOLVED]Two nodes with relays interfering

      @sundberg84 said:

      The output on node 2 looks strange - ID 0 is (and should only be) the gateway!

      I guess you mean node 1. And indeed, I really messed up the code somehow. Reloaded the original sketch and adapted it again, now everything works like a charm.
      Thanks everyone for thinking along!

      posted in Troubleshooting
      finch666
      finch666
    • RE: [SOLVED]Two nodes with relays interfering

      I just cleared the eeprom on node 2, but nothing changed.
      Output node 2:

      send: 1-1-0-0 s=255,c=0,t=18,pt=0,l=5,sg=0,st=ok:1.5.1
      send: 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
      repeater started, id=1, parent=0, distance=1
      send: 1-1-0-0 s=255,c=3,t=11,pt=0,l=24,sg=0,st=ok:power meter and actuator
      send: 1-1-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
      send: 1-1-0-0 s=3,c=0,t=13,pt=0,l=0,sg=0,st=ok:
      send: 1-1-0-0 s=3,c=2,t=24,pt=0,l=0,sg=0,st=ok:
      send: 1-1-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:
      read: 0-0-1 s=3,c=2,t=24,pt=0,l=0,sg=0:
      Received last pulse count from gw:0
      read: 0-0-1 s=1,c=1,t=2,pt=0,l=1,sg=0:1
      send: 1-1-0-0 s=1,c=1,t=2,pt=0,l=1,sg=0,st=ok:1
      Incoming change for sensor:1, New status: 1
      read: 0-0-1 s=1,c=1,t=2,pt=0,l=1,sg=0:0
      send: 1-1-0-0 s=1,c=1,t=2,pt=0,l=1,sg=0,st=ok:0
      Incoming change for sensor:1, New status: 0
      

      Output node 1:

      send: 0-0-0-0 s=255,c=0,t=18,pt=0,l=5,sg=0,st=ok:1.5.1
      send: 0-0-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
      repeater started, id=0, parent=0, distance=0
      send: 0-0-0-0 s=255,c=3,t=11,pt=0,l=5,sg=0,st=ok:Relay
      send: 0-0-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
      send: 0-0-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:
      send: 0-0-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:
      send: 0-0-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:
      send: 0-0-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:
      send: 0-0-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:
      send: 0-0-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:
      read: 0-0-0 s=1,c=1,t=2,pt=0,l=1,sg=0:1
      send: 0-0-0-0 s=1,c=1,t=2,pt=0,l=1,sg=0,st=ok:1
      Incoming change for sensor:1, New status: 1
      read: 0-0-0 s=1,c=1,t=2,pt=0,l=1,sg=0:0
      send: 0-0-0-0 s=1,c=1,t=2,pt=0,l=1,sg=0,st=ok:0
      Incoming change for sensor:1, New status: 0
      read: 0-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0:66.6
      

      Node 2 was not powered when I monitored this node 1 output.

      posted in Troubleshooting
      finch666
      finch666
    • [SOLVED]Two nodes with relays interfering

      As a noob I ran into a problem with two nodes.
      One (node 1) is running code to actuate 6 relays. the other one (node 2) has a relay and a pulse meter.
      Whenever I actuate the relay on node 2 (connected to pin 4), then relay 1 on node 1 (also connected to pin 4) is actuated too. When I actuate relay 1 on node 1 however, node 2 is not affected.
      Some how seems I'm overlooking something basic, but I can't figure it out 😞
      Node 1 is running the following code:

      
      #include <MySigningNone.h>
      #include <MyTransportNRF24.h>
      #include <MyTransportRFM69.h>
      #include <MyHwATMega328.h>
      #include <MySensor.h>
      #include <SPI.h>
      
      #define RELAY_1  3  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define NUMBER_OF_RELAYS 6 // Total number of attached relays
      #define RELAY_ON 0  // GPIO value to write to turn on attached relay
      #define RELAY_OFF 1 // GPIO value to write to turn off attached relay
      #define CHILD_ID 1
      
      // NRFRF24L01 radio driver (set low transmit power by default) 
      MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);  
      //MyTransportRFM69 radio;
      // Message signing driver (none default)
      //MySigningNone signer;
      // Select AtMega328 hardware profile
      MyHwATMega328 hw;
      // Construct MySensors library
      MySensor gw(radio, hw);
      
      void setup()  
      {   
        // Initialize library and add callback for incoming messages
        gw.begin(incomingMessage, AUTO, true);
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Relay", "1.0");
      
        // Fetch relay status
        for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
          // Register all sensors to gw (they will be created as child devices)
          gw.present(CHILD_ID, S_LIGHT);
          // Then set relay pins in output mode
          pinMode(pin, OUTPUT);   
          // Set relay to last known state (using eeprom storage) 
          digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
        }
      }
      
      
      void loop() 
      {
        // Alway process incoming messages whenever possible
        gw.process();
      }
      
      void incomingMessage(const MyMessage &message) {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type==V_LIGHT) {
           // Change relay state
           digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
           // Store state in eeprom
           gw.saveState(message.sensor, message.getBool());
           // Write some debug info
           Serial.print("Incoming change for sensor:");
           Serial.print(message.sensor);
           Serial.print(", New status: ");
           Serial.println(message.getBool());
         } 
      }
      
      

      Node 2 code:

      
      #include <MySensor.h>
      #include <SPI.h>
      
      
      #define DIGITAL_INPUT_SENSOR 3                  // The digital input you attached your sensor.  (Only 2 and 3 generates interrupt!)
      //#define PULSE_FACTOR 12500                       // Nummber of blinks per m3 of your meter (One rotation/liter)
      #define PULSE_FACTOR 1000
      #define SLEEP_MODE false                        // flowvalue can only be reported when sleep mode is false.
      #define MAX_WATT 10000                            // Max flow (l/min) value to report. This filetrs outliers.
      #define INTERRUPT DIGITAL_INPUT_SENSOR-2        // Usually the interrupt = pin -2 (on uno/nano anyway)
      #define CHILD_ID 3                              // Id of the sensor child
      #define RELAY_10  4  // Arduino Digital I/O pin number for first relay
      #define NUMBER_OF_RELAYS 1 
      #define RELAY_ON 0
      #define RELAY_OFF 1
      unsigned long SEND_FREQUENCY = 10000;              // Minimum time between send (in miliseconds). We don't want to spam the gateway.
      
      MySensor gw;
      
      double ppl = ((double)PULSE_FACTOR)/1000;        // Pulses per liter
      
      volatile unsigned long pulseCount = 0;   
      volatile unsigned long lastBlink = 0;
      volatile double watt = 0;
      boolean pcReceived = false;
      unsigned long oldPulseCount = 0;
      unsigned long newBlink = 0;   
      double oldwatt = 0;
      double oldKwh;
      double Kwh;                     
      unsigned long lastSend;
      unsigned long currentTime;
      unsigned long lastPulse;
      
      MyMessage wattMsg(CHILD_ID,V_WATT);
      MyMessage KwhMsg(CHILD_ID,V_KWH);
      MyMessage pcMsg(CHILD_ID,V_VAR1);
      
      void setup()  
      {  
        gw.begin(incomingMessage, AUTO, true);
        //gw.begin(incomingMessage, AUTO, false, AUTO, RF24_PA_LOW);
        //gw.begin(incomingMessage, AUTO, false, AUTO);
        //  gw.send(pcMsg.set(0));
        //  gw.send(volumeMsg.set(0.000, 3));
        //Water meter setup
        //Serial.print("PPL:");
        //Serial.print(ppl);
      
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("power meter and actuator", "1.0");
      
        // Register this device as current sensor
        gw.present(CHILD_ID, S_POWER);      
      
        // Fetch last known pulse count value from gw
        gw.request(CHILD_ID, V_VAR1);
        //pulseCount = oldPulseCount = 0;
      
        //Serial.print("Last pulse count from gw:");
        //Serial.println(pulseCount);
      
        attachInterrupt(INTERRUPT, onPulse, RISING);
        lastSend = millis();
      
        //RELAY SETUP
        for (int sensor=1, pin=RELAY_10; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
          // Register all sensors to gw (they will be created as child devices)
          gw.present(sensor, S_LIGHT);
          // Then set relay pins in output mode
          pinMode(pin, OUTPUT);   
          // Set relay to last known state (using eeprom storage) 
          digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
        }
      
      }
      
      
      void loop()     
      { 
        gw.process();//////t
        currentTime = millis();
        bool sendTime = currentTime - lastSend > SEND_FREQUENCY;
        if (pcReceived && (SLEEP_MODE || sendTime)) {
          // New flow value has been calculated  
          if (!SLEEP_MODE && watt != oldwatt) {
            // Check that we dont get unresonable large flow value. 
            // could hapen when long wraps or false interrupt triggered
            if (watt<((unsigned long)MAX_WATT)) {
              gw.send(wattMsg.set(watt, 2));        // Send flow value to gw
            }
      
            //Serial.print("g/min:");
            // Serial.println(flow);
            oldwatt = watt;
          }
      
          // No Pulse count in 2min 
          if(currentTime - lastPulse > 20000){
            watt = 0;
          } 
      
      
          // Pulse count has changed
          if (pulseCount != oldPulseCount) {
            gw.send(pcMsg.set(pulseCount));                  // Send  volumevalue to gw VAR1
            double volume = ((double)pulseCount/((double)PULSE_FACTOR)*264.172);
            //double volume = ((double)pulseCount/((double)PULSE_FACTOR));     
            oldPulseCount = pulseCount;
            if (Kwh != oldKwh) {
              gw.send(KwhMsg.set(Kwh, 3));               // Send volume value to gw
              oldKwh = Kwh;
            } 
          }
          lastSend = currentTime;
        } 
        else if (sendTime) {
          // No count received. Try requesting it again
          gw.request(CHILD_ID, V_VAR1);
          lastSend=currentTime;
        }
      
        if (SLEEP_MODE) {
          gw.sleep(SEND_FREQUENCY);
        }     
      
      
      }
      
      
      void onPulse()     
      { 
        if (!SLEEP_MODE) {
          unsigned long newBlink = micros();   
          unsigned long interval = newBlink-lastBlink;
          lastPulse = millis();
          if (interval < 2080) {       // Sometimes we get interrupt on RISING,  500000 = 0.5sek debounce ( max 120 l/min)  WAS 2080
            return;   
          }
      
          watt = ((60000000.0 /interval) / ppl)*.264172;
          //flow = ((60000000.0 /interval) / ppl);
          // Serial.print("interval:");
          // Serial.println(interval);
          lastBlink = newBlink;
          // Serial.println(flow, 4);
        }
        pulseCount++;
      
      }
      
      void incomingMessage(const MyMessage &message) {
        if (message.type==V_VAR1) {  
          pulseCount = oldPulseCount = message.getLong();
          Serial.print("Received last pulse count from gw:");
          Serial.println(pulseCount);
          pcReceived = true;
        }
        if (message.type==V_LIGHT) {
          // Change relay state
          digitalWrite(message.sensor-1+RELAY_10, message.getBool()?RELAY_ON:RELAY_OFF);
          // Store state in eeprom
          gw.saveState(message.sensor, message.getBool());
          // Write some debug info
          Serial.print("Incoming change for sensor:");
          Serial.print(message.sensor);
          Serial.print(", New status: ");
          Serial.println(message.getBool());
        } 
      
      }
      

      Can somebody help me to figure this out?

      posted in Troubleshooting
      finch666
      finch666