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

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Hardware
  3. Microwave Radar Module as PIR replacement.

Microwave Radar Module as PIR replacement.

Scheduled Pinned Locked Moved Hardware
42 Posts 21 Posters 42.3k Views 26 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • scalzS Offline
    scalzS Offline
    scalz
    Hardware Contributor
    wrote on last edited by scalz
    #8

    @Yveaux ahah excellent another module! do you have one of these ?
    On all specs they all claims few mA, not sure if it's the best idea on batt..I was thinking to use these things on AC. but that will need tests on power supply.
    HB100 I have are shielded..don't know which module is best. I was inspired from this
    http://www.limpkin.fr/index.php?post/2013/08/09/Making-the-electronics-for-a-%247-USD-doppler-motion-sensor

    Edit: the link you pointed, wow the module seems very small!

    YveauxY 1 Reply Last reply
    0
    • scalzS scalz

      @Yveaux ahah excellent another module! do you have one of these ?
      On all specs they all claims few mA, not sure if it's the best idea on batt..I was thinking to use these things on AC. but that will need tests on power supply.
      HB100 I have are shielded..don't know which module is best. I was inspired from this
      http://www.limpkin.fr/index.php?post/2013/08/09/Making-the-electronics-for-a-%247-USD-doppler-motion-sensor

      Edit: the link you pointed, wow the module seems very small!

      YveauxY Offline
      YveauxY Offline
      Yveaux
      Mod
      wrote on last edited by
      #9

      @scalz no, just browsing on Ali.
      These modules are active, in contrast to PIRs, so I expect their power usage to always be higher than PIRs.
      But it won't hurt ordering some I guess :laughing:

      http://yveaux.blogspot.nl

      1 Reply Last reply
      0
      • scalzS Offline
        scalzS Offline
        scalz
        Hardware Contributor
        wrote on last edited by
        #10

        @Yveaux completely agree:smiley: hop, in the basket :laughing:

        1 Reply Last reply
        0
        • SparkmanS Offline
          SparkmanS Offline
          Sparkman
          Hero Member
          wrote on last edited by
          #11

          Looks like an interesting module. Since these are advertised as working in the 5.8 GHz band, it would be interesting to see exactly where in the band they are and if they cause interference for WiFi channels.

          Cheers
          Al

          1 Reply Last reply
          0
          • D Offline
            D Offline
            danta
            wrote on last edited by danta
            #12

            I was inspired by this topic and bought some cheap modules from ebay:
            http://www.ebay.com/itm/5-8GHZ-Microwave-Radar-Sensor-6-9M-Smart-Switch-for-Home-Control-/401082379029?hash=item5d625f6b15:g:4BMAAOSwxp9W2Ser

            http://www.ebay.com/itm/Microwave-Radar-Sensor-LED-Light-Control-Smart-Switch-Precise-for-Spherical-Lamp-/351673918969?hash=item51e16625f9:g:rYAAAOSwZ8ZW4MpE

            Does anyone know how to hook them up? Was anyone able to make them work? The chinese seller is not really helpful in providing some more details.
            I really like the idea of having a motion sensor behind a wall (read: out of sight), even if it means powering it from a wall socket.

            1 Reply Last reply
            2
            • greglG Offline
              greglG Offline
              gregl
              Hero Member
              wrote on last edited by
              #13

              @danta lol - I too was inspired by this thread and bought a couple of modules which arrived last week. Mine are identical to those in your first ebay link.

              I've not tried to use them yet, but I think you use them identical to a PIR. ie VCC, GND and Signal.

              As @Yveaux mentioned... these use the same IC as the PIR's, but these do seem to lack the ability to tune the sensitivity and timeouts like the PIR's have.

              So in short... try to use them as you would a PIR.

              1 Reply Last reply
              1
              • hekH Offline
                hekH Offline
                hek
                Admin
                wrote on last edited by hek
                #14

                @danta

                Interesting! Must have missed this topic... Never seen those before.

                1 Reply Last reply
                0
                • mark_vennM Offline
                  mark_vennM Offline
                  mark_venn
                  wrote on last edited by
                  #15

                  There are units that are fitted into light fittings that are being used as fall detectors; a PIR knows someone is in the room but something measuring the height of the person moving around that suddenly notices an increase in the distance can trigger an alarm. An increase in distance can mean that the person is now on the floor and no longer vertical. Something like this could be used maybe?

                  1 Reply Last reply
                  0
                  • epierreE Offline
                    epierreE Offline
                    epierre
                    Hero Member
                    wrote on last edited by
                    #16

                    I have this one, but did not have time to test it yet 2-16M : Gravity: Digital Microwave Sensor (Motion Detection)

                    http://www.dfrobot.com/index.php?route=product/product&product_id=1403#.VzNKlfndWnk

                    z-wave - Vera -> Domoticz
                    rfx - Domoticz <- MyDomoAtHome <- Imperihome
                    mysensors -> mysensors-gw -> Domoticz

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      danta
                      wrote on last edited by
                      #17

                      I started playing with the first module listed in my previous post:

                      0_1463001162404_sensor.jpg

                      The module is really as easy to connect as a normal pir sensor. There are small text on the pcb. The top most connection (indicated with a 'o') is the sensor output (3,3v for a high and 0v for a low). The middle connection is ground and the bottom connection is Vcc (3,3 to 20v according to the ebay listing).

                      0_1463001269028_connection.jpg

                      My setup was really simple, just a chinduino powered via usb. The sensor connected to +5v, ground and the output to analog pin A0 (I could have used a digital pin).

                      0_1463001506022_setup.jpg

                      The first results are really promising. Some characteristics:

                      • The sensor is omnidirectional.
                      • Output is high (3,3V) for 30s when movement is detected
                      • New movement will restart the 30s timer
                      • 'low' power consumption. Triggered: 1.5mA; Idle: 1.4mA (measured @5v using a normal multimeter)
                      • The sensor doesn't react to temperature/light fluctuations (unlike most pir sensors)

                      Some range tests that triggered the output (note that this is probably not the maximum distance, just the stuff I tested):

                      • 0-4 meter distance (clear line of sight), moving my arm
                      • 5-8 meter distance (clear line of sight), walking around
                      • walking around at 5 meter distance with an indoor brick wall between me and the sensor

                      Stuff that I still need to test:

                      • Can the sensitivity be tweaked
                      • How to change the trigger timer to something else than 30s
                      • Duration test to see if the module is prone to false positives
                      1 Reply Last reply
                      2
                      • D Offline
                        D Offline
                        drock1985
                        wrote on last edited by
                        #18

                        hi @danta

                        Did you have any luck removing the 30 second delay/counter from the radar module?

                        My Projects
                        2 Door Chime Sensor
                        Washing Machine Monitor

                        1 Reply Last reply
                        0
                        • V Offline
                          V Offline
                          vil1driver
                          wrote on last edited by vil1driver
                          #19

                          @danta, this device can detect you when you are in another room ?

                          @drock1985,
                          detection delay can be adjusted from 1 second to hundreds of second (two minutes max) by adjusting R6 resistor on the board as explained on this Taobao page (Chinese). By default there’s no resistor and the delay is 30 seconds, and you can adjust the delay by using 1K to 250K resistor.

                          1 Reply Last reply
                          0
                          • D Offline
                            D Offline
                            danta
                            wrote on last edited by danta
                            #20

                            @drock1985, Didn't test it yet. I was playing with the other module I bought. Too bad that the other module only seems to work stable from 6V and up (I should have known it, as it was listed on ebay as 7-12v). I was just hoping that it would work at lower voltages. So I will probably stick with the first module for now.

                            @vil1driver, Yes, detection works through wall and door. I only tested it at a distance of about 5 meter with a brick indoor wall between me and the sensor. I also had to walk around before the sensor picked me up (just lifting my arm wasn't enough).

                            1 Reply Last reply
                            0
                            • korttomaK Offline
                              korttomaK Offline
                              korttoma
                              Hero Member
                              wrote on last edited by
                              #21

                              Seems like these modules are using the BISS0001 so it will probably not be possible to run them on a battery node because the BISS has a 3V minimum voltage demand. The current consumption is anyhow also a bit to high for battery application (3mA).

                              0_1465813900381_WP_20160613_13_16_48_Pro.jpg

                              • Tomas
                              Luke CorkillL 1 Reply Last reply
                              0
                              • korttomaK korttoma

                                Seems like these modules are using the BISS0001 so it will probably not be possible to run them on a battery node because the BISS has a 3V minimum voltage demand. The current consumption is anyhow also a bit to high for battery application (3mA).

                                0_1465813900381_WP_20160613_13_16_48_Pro.jpg

                                Luke CorkillL Offline
                                Luke CorkillL Offline
                                Luke Corkill
                                wrote on last edited by
                                #22

                                I've bought a couple of these and in many ways have been impressed.
                                My only issue is that I find them far too sensitive (e.g. Detecting movement through wallls)
                                Has anyone managed to reduce the sensitivity?

                                1 Reply Last reply
                                1
                                • bjacobseB Offline
                                  bjacobseB Offline
                                  bjacobse
                                  wrote on last edited by
                                  #23

                                  @Luke-Corkill said:

                                  I've bought a couple of these and in many ways have been impressed.
                                  My only issue is that I find them far too sensitive (e.g. Detecting movement through wallls)
                                  Has anyone managed to reduce the sensitivity?

                                  To reduce sensitivity workaround - Can you place them high and point them in an angle pointing downwards to ground? will this work?

                                  1 Reply Last reply
                                  0
                                  • greglG Offline
                                    greglG Offline
                                    gregl
                                    Hero Member
                                    wrote on last edited by
                                    #24

                                    There has been some chat about these modules over on Pete Scargill's site.
                                    Seems that using some aluminium foil you can create a shield so there are at least directional.

                                    Here is the thread ( starting at the relevant comment)

                                    http://tech.scargill.net/microwave-radar/#comment-16685

                                    I have not tested this myself yet...

                                    bjacobseB 1 Reply Last reply
                                    0
                                    • greglG gregl

                                      There has been some chat about these modules over on Pete Scargill's site.
                                      Seems that using some aluminium foil you can create a shield so there are at least directional.

                                      Here is the thread ( starting at the relevant comment)

                                      http://tech.scargill.net/microwave-radar/#comment-16685

                                      I have not tested this myself yet...

                                      bjacobseB Offline
                                      bjacobseB Offline
                                      bjacobse
                                      wrote on last edited by bjacobse
                                      #25

                                      @gregl
                                      Thanks for good link :-)
                                      Yes offcurse I'm so sloooooow we need a proper waveguide or a hornet antenna, so ensure correct directionality ;-)

                                      This might not be needed, but a hint what could be done: http://hforsten.com/horn-antenna-for-radar.html

                                      When my doppler radar arrives I will make a trial with a small tinbox I don't know about using alufoil is good for a long periode used outside
                                      http://hackaday.com/2014/02/24/guest-post-try-radar-for-your-next-project/#jp-carousel-115578

                                      1 Reply Last reply
                                      0
                                      • YveauxY Yveaux

                                        @scalz e.g. at http://s.aliexpress.com/AbEBreya

                                        0_1459859566297_Microwave-Radar-Module-Body-Sensing-Radar-Switch-DC-5V-10M-Home-Control-.jpg_640x640.jpg

                                        0_1459859704122_Microwave-Radar-Module-Body-Sensing-Radar-Switch-DC-5V-10M-Home-Control-.jpg_640x640 (1).jpg

                                        cimba007C Offline
                                        cimba007C Offline
                                        cimba007
                                        wrote on last edited by cimba007
                                        #26

                                        @Yveaux I did some extensive testing on the FC1816 module and I thought I might drop my experience:

                                        http://electronics.stackexchange.com/questions/226031/pinout-of-microwave-motion-sensor-fc1816

                                        In the end I used an 150ohm Series resistor + ~100µF cap behind this to power the FC1816. This eliminated much of the leftover noise. If this is not enough I presented a way to lower the module amplification. In the end I deactivated the biss-trigger output alltogether and grabbed the raw signal. Doing some manual processing:

                                        1. take 100 reads
                                        2. get the stddev (statistics library)
                                        3. high stddev = high fluctuation in values = movement

                                        Take a look at my current working copy of my code for the FC1816:

                                        Some notes:

                                        I power the VCC of the FC1816 from some arduino pins. Thus I can deactivate the microwave sensor at will. This is still not recommended. If you visit the previous link you can see that the BISS has some kind of "warmup"-Period.

                                        I use 3,3Volt to power the NRF24, the arduino and the FC1816 and suffered no strange consequences so far.

                                        Get get some insight about the link quality of the NRF24 I made the function RF24_getObserverTX() accessible from user-space:

                                        MySensors\drivers\RF24\RF24.cpp

                                        uint8_t RF24_getObserveTX(void)
                                        {
                                        	return RF24_readByteRegister(OBSERVE_TX);
                                        }
                                        

                                        MySensors\drivers\RF24\RF24.h

                                        uint8_t RF24_getObserveTX(void);
                                        

                                        The Idea behind the OBSERVE_TX register is that the lower byte presents the number of retrys the NRF24 used in the last send.
                                        The upper 4 bits present the number of total failed packets. I suggest using (0x0F & RF24_getObserveTX()) to get a usable number 0-15 presenting the retry-count. Anything > 0 suggests a packetloss on your link. 15 most likely will mean you ran into an complete fail as the max number of retrys was exhausted.

                                        This number might be capped by

                                        // ARD, auto retry count
                                        #define RF24_ARC 15
                                        

                                        from the RF24.h driver-file.

                                        TO not run into compiling errors you might need:

                                        http://arduiniana.org/libraries/streaming/
                                        https://github.com/RobTillaart/Arduino/tree/master/libraries/Statistic

                                        MicrowaveRadarSensor.ino

                                        #include <Streaming.h>
                                        #include "Statistic.h"
                                        
                                        
                                        /**
                                         * 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.
                                         *
                                         *******************************
                                         *
                                         * REVISION HISTORY
                                         * Version 1.0 - Henrik EKblad
                                         * 
                                         * DESCRIPTION
                                         * Example sketch showing how to measue light level using a LM393 photo-resistor 
                                         * http://www.mysensors.org/build/light
                                         */
                                        
                                        #define MY_NODE_ID 10
                                        #define MY_BAUD_RATE 57600
                                        
                                        // Enable debug prints to serial monitor
                                        //#define MY_DEBUG 
                                        
                                        // Enable and select radio type attached
                                        #define MY_RADIO_NRF24
                                        //#define MY_RADIO_RFM69
                                        
                                        #include <SPI.h>
                                        #include <MySensors.h>  
                                        
                                        #define LIGHT_SENSOR_ANALOG_PIN A3
                                        #define MICRO_SENSOR_ANALOG_PIN A1
                                        
                                        unsigned long SLEEP_TIME = 1000; // Sleep time between reads (in milliseconds)
                                        
                                        #define CHILD_ID_LIGHT 0
                                        #define CHILD_ID_MICRO 0
                                        #define TRIPPED_THRESHOLD 50
                                        
                                        MyMessage msg_light(CHILD_ID_LIGHT, V_LIGHT_LEVEL); // 23
                                        MyMessage msg_micro(CHILD_ID_MICRO, V_TRIPPED);     // 16
                                        MyMessage msg_micro_debug(0,V_VAR1);   // 24
                                        MyMessage msg_obstx_debug(0,V_VAR2);   // 25
                                        
                                        void before()
                                        {
                                          // LightSensor
                                          pinMode(A3,INPUT_PULLUP);
                                          pinMode(A2,OUTPUT);
                                          digitalWrite(A2,LOW);  
                                        
                                          // Microwave
                                          pinMode(5,OUTPUT);        // VCC BISS0001
                                          digitalWrite(5,HIGH);
                                          
                                          pinMode(6,OUTPUT);        // Enabled
                                          digitalWrite(6,LOW);      // Enable
                                          
                                          pinMode(7,OUTPUT);        // GND
                                          digitalWrite(7,LOW);
                                          
                                          pinMode(8,OUTPUT);        // VCC Radar
                                          digitalWrite(8,HIGH);
                                        
                                          pinMode(A1,INPUT);        // PIR 2nd Amplification Stage
                                        
                                          // Other
                                        }
                                        void setup()
                                        {
                                         
                                        }
                                        void presentation()  {
                                          // Send the sketch version information to the gateway and Controller
                                          sendSketchInfo("Microwave+Light", "1.0");
                                        
                                          // Register all sensors to gateway (they will be created as child devices)
                                          // https://www.mysensors.org/download/serial_api_20#sensor-type
                                          present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
                                          present(CHILD_ID_MICRO, S_MOTION);
                                          //present(0, S_ARDUINO_NODE);
                                          
                                        }
                                        
                                        void loop()      
                                        {     
                                          // Report VCC
                                          static long vcc = readVcc();
                                          static int vccpercent = map(vcc,1800,3280,0,100);
                                          sendBatteryLevel(max(min(vccpercent,100),0),false);
                                          Serial << "| vcc: ";
                                          p(F("%4d"),vcc);
                                          Serial << " ";
                                          // Required for ack
                                          //wait(100);
                                        
                                          // Report LightLevel
                                          analogRead(LIGHT_SENSOR_ANALOG_PIN);
                                          int lightLevel_raw = analogRead(LIGHT_SENSOR_ANALOG_PIN);
                                          int lightLevel = (1023-lightLevel_raw)/10.23; // as of 1023 !!
                                          Serial << "| light_raw: ";
                                          p(F("%4d"),lightLevel_raw);
                                          Serial << " ";
                                          Serial << "| light: ";
                                          p(F("%3d"),lightLevel);
                                          Serial << " ";
                                          send(msg_light.set(lightLevel),false);
                                        
                                          // Report WirelessLink Information
                                          Serial << "| observe_tx: ";
                                          uint8_t obstx = RF24_getObserveTX();
                                          p(F("%X"),obstx);
                                          Serial << " ";
                                          send(msg_obstx_debug.set(0x0F&obstx),false);
                                         
                                          // Report Microwave
                                          Statistic mw_s;
                                          mw_s.clear();
                                          
                                          delay(90);
                                          analogRead(MICRO_SENSOR_ANALOG_PIN);
                                          delay(10);
                                          for(int i = 0; i < 1000; i++)
                                          {
                                            mw_s.add(analogRead(MICRO_SENSOR_ANALOG_PIN));
                                            delay(1);
                                          }
                                          Serial << "| mw_raw: ";
                                          int stddev = mw_s.pop_stdev();
                                          p(F("%4d"),stddev);
                                          Serial << " ";
                                          
                                          Serial << "| mw_min: ";
                                          int minimum = mw_s.minimum();
                                          p(F("%4d"),minimum);
                                          Serial << " ";
                                        
                                          Serial << "| mw_max: ";
                                          int maximum = mw_s.maximum();
                                          p(F("%4d"),maximum);
                                          Serial << " ";
                                          
                                          Serial << "| mw: " << (stddev > TRIPPED_THRESHOLD ? "1" : "0") << " ";
                                          send(msg_micro_debug.set(stddev),false);
                                          while(!send(msg_micro.set(stddev > TRIPPED_THRESHOLD ? "1" : "0"),true))
                                          {
                                            wait(10);
                                          }
                                          
                                          if(isTransportOK()) 
                                            wait(100);
                                          else
                                            wait(1000);
                                          Serial << endl;
                                          //mysleep(500);
                                        
                                        }
                                        // https://forum.mysensors.org/topic/3463/m_ack_variable-or-m_set_variable/2
                                        void receive(const MyMessage &message) {
                                          if (message.isAck()) {
                                              Serial.print("| GW ack");
                                              }
                                        }
                                        

                                        Helper.ino

                                        long readVcc() {
                                          // Read 1.1V reference against AVcc
                                          // set the reference to Vcc and the measurement to the internal 1.1V reference
                                          #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
                                            ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
                                          #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
                                            ADMUX = _BV(MUX5) | _BV(MUX0);
                                          #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
                                            ADMUX = _BV(MUX3) | _BV(MUX2);
                                          #else
                                            ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
                                          #endif  
                                        
                                          delay(2); // Wait for Vref to settle
                                          ADCSRA |= _BV(ADSC); // Start conversion
                                          while (bit_is_set(ADCSRA,ADSC)); // measuring
                                        
                                          uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH  
                                          uint8_t high = ADCH; // unlocks both
                                        
                                          long result = (high<<8) | low;
                                        
                                          result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
                                          //result *= 1.0637;
                                          return result; // Vcc in millivolts
                                        }
                                        
                                        #include <stdarg.h>
                                        void p(const __FlashStringHelper *fmt, ... ){
                                          char buf[128]; // resulting string limited to 128 chars
                                          va_list args;
                                          va_start (args, fmt);
                                        #ifdef __AVR__
                                          vsnprintf_P(buf, sizeof(buf), (const char *)fmt, args); // progmem for AVR
                                        #else
                                          vsnprintf(buf, sizeof(buf), (const char *)fmt, args); // for the rest of the world
                                        #endif
                                          va_end(args);
                                          Serial.print(buf);
                                        }
                                        
                                        void mysleep(int SLEEP_TIME)
                                        {
                                            if(isTransportOK()){
                                              Serial << "| wait ";
                                              wait(25);
                                              Serial << "| zZz > ";
                                        
                                              sleep(SLEEP_TIME);
                                              Serial << "| < zZz " << endl;
                                            } 
                                            else {
                                              wait(1000);
                                            }
                                        }
                                        
                                        YveauxY 1 Reply Last reply
                                        3
                                        • cimba007C cimba007

                                          @Yveaux I did some extensive testing on the FC1816 module and I thought I might drop my experience:

                                          http://electronics.stackexchange.com/questions/226031/pinout-of-microwave-motion-sensor-fc1816

                                          In the end I used an 150ohm Series resistor + ~100µF cap behind this to power the FC1816. This eliminated much of the leftover noise. If this is not enough I presented a way to lower the module amplification. In the end I deactivated the biss-trigger output alltogether and grabbed the raw signal. Doing some manual processing:

                                          1. take 100 reads
                                          2. get the stddev (statistics library)
                                          3. high stddev = high fluctuation in values = movement

                                          Take a look at my current working copy of my code for the FC1816:

                                          Some notes:

                                          I power the VCC of the FC1816 from some arduino pins. Thus I can deactivate the microwave sensor at will. This is still not recommended. If you visit the previous link you can see that the BISS has some kind of "warmup"-Period.

                                          I use 3,3Volt to power the NRF24, the arduino and the FC1816 and suffered no strange consequences so far.

                                          Get get some insight about the link quality of the NRF24 I made the function RF24_getObserverTX() accessible from user-space:

                                          MySensors\drivers\RF24\RF24.cpp

                                          uint8_t RF24_getObserveTX(void)
                                          {
                                          	return RF24_readByteRegister(OBSERVE_TX);
                                          }
                                          

                                          MySensors\drivers\RF24\RF24.h

                                          uint8_t RF24_getObserveTX(void);
                                          

                                          The Idea behind the OBSERVE_TX register is that the lower byte presents the number of retrys the NRF24 used in the last send.
                                          The upper 4 bits present the number of total failed packets. I suggest using (0x0F & RF24_getObserveTX()) to get a usable number 0-15 presenting the retry-count. Anything > 0 suggests a packetloss on your link. 15 most likely will mean you ran into an complete fail as the max number of retrys was exhausted.

                                          This number might be capped by

                                          // ARD, auto retry count
                                          #define RF24_ARC 15
                                          

                                          from the RF24.h driver-file.

                                          TO not run into compiling errors you might need:

                                          http://arduiniana.org/libraries/streaming/
                                          https://github.com/RobTillaart/Arduino/tree/master/libraries/Statistic

                                          MicrowaveRadarSensor.ino

                                          #include <Streaming.h>
                                          #include "Statistic.h"
                                          
                                          
                                          /**
                                           * 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.
                                           *
                                           *******************************
                                           *
                                           * REVISION HISTORY
                                           * Version 1.0 - Henrik EKblad
                                           * 
                                           * DESCRIPTION
                                           * Example sketch showing how to measue light level using a LM393 photo-resistor 
                                           * http://www.mysensors.org/build/light
                                           */
                                          
                                          #define MY_NODE_ID 10
                                          #define MY_BAUD_RATE 57600
                                          
                                          // Enable debug prints to serial monitor
                                          //#define MY_DEBUG 
                                          
                                          // Enable and select radio type attached
                                          #define MY_RADIO_NRF24
                                          //#define MY_RADIO_RFM69
                                          
                                          #include <SPI.h>
                                          #include <MySensors.h>  
                                          
                                          #define LIGHT_SENSOR_ANALOG_PIN A3
                                          #define MICRO_SENSOR_ANALOG_PIN A1
                                          
                                          unsigned long SLEEP_TIME = 1000; // Sleep time between reads (in milliseconds)
                                          
                                          #define CHILD_ID_LIGHT 0
                                          #define CHILD_ID_MICRO 0
                                          #define TRIPPED_THRESHOLD 50
                                          
                                          MyMessage msg_light(CHILD_ID_LIGHT, V_LIGHT_LEVEL); // 23
                                          MyMessage msg_micro(CHILD_ID_MICRO, V_TRIPPED);     // 16
                                          MyMessage msg_micro_debug(0,V_VAR1);   // 24
                                          MyMessage msg_obstx_debug(0,V_VAR2);   // 25
                                          
                                          void before()
                                          {
                                            // LightSensor
                                            pinMode(A3,INPUT_PULLUP);
                                            pinMode(A2,OUTPUT);
                                            digitalWrite(A2,LOW);  
                                          
                                            // Microwave
                                            pinMode(5,OUTPUT);        // VCC BISS0001
                                            digitalWrite(5,HIGH);
                                            
                                            pinMode(6,OUTPUT);        // Enabled
                                            digitalWrite(6,LOW);      // Enable
                                            
                                            pinMode(7,OUTPUT);        // GND
                                            digitalWrite(7,LOW);
                                            
                                            pinMode(8,OUTPUT);        // VCC Radar
                                            digitalWrite(8,HIGH);
                                          
                                            pinMode(A1,INPUT);        // PIR 2nd Amplification Stage
                                          
                                            // Other
                                          }
                                          void setup()
                                          {
                                           
                                          }
                                          void presentation()  {
                                            // Send the sketch version information to the gateway and Controller
                                            sendSketchInfo("Microwave+Light", "1.0");
                                          
                                            // Register all sensors to gateway (they will be created as child devices)
                                            // https://www.mysensors.org/download/serial_api_20#sensor-type
                                            present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
                                            present(CHILD_ID_MICRO, S_MOTION);
                                            //present(0, S_ARDUINO_NODE);
                                            
                                          }
                                          
                                          void loop()      
                                          {     
                                            // Report VCC
                                            static long vcc = readVcc();
                                            static int vccpercent = map(vcc,1800,3280,0,100);
                                            sendBatteryLevel(max(min(vccpercent,100),0),false);
                                            Serial << "| vcc: ";
                                            p(F("%4d"),vcc);
                                            Serial << " ";
                                            // Required for ack
                                            //wait(100);
                                          
                                            // Report LightLevel
                                            analogRead(LIGHT_SENSOR_ANALOG_PIN);
                                            int lightLevel_raw = analogRead(LIGHT_SENSOR_ANALOG_PIN);
                                            int lightLevel = (1023-lightLevel_raw)/10.23; // as of 1023 !!
                                            Serial << "| light_raw: ";
                                            p(F("%4d"),lightLevel_raw);
                                            Serial << " ";
                                            Serial << "| light: ";
                                            p(F("%3d"),lightLevel);
                                            Serial << " ";
                                            send(msg_light.set(lightLevel),false);
                                          
                                            // Report WirelessLink Information
                                            Serial << "| observe_tx: ";
                                            uint8_t obstx = RF24_getObserveTX();
                                            p(F("%X"),obstx);
                                            Serial << " ";
                                            send(msg_obstx_debug.set(0x0F&obstx),false);
                                           
                                            // Report Microwave
                                            Statistic mw_s;
                                            mw_s.clear();
                                            
                                            delay(90);
                                            analogRead(MICRO_SENSOR_ANALOG_PIN);
                                            delay(10);
                                            for(int i = 0; i < 1000; i++)
                                            {
                                              mw_s.add(analogRead(MICRO_SENSOR_ANALOG_PIN));
                                              delay(1);
                                            }
                                            Serial << "| mw_raw: ";
                                            int stddev = mw_s.pop_stdev();
                                            p(F("%4d"),stddev);
                                            Serial << " ";
                                            
                                            Serial << "| mw_min: ";
                                            int minimum = mw_s.minimum();
                                            p(F("%4d"),minimum);
                                            Serial << " ";
                                          
                                            Serial << "| mw_max: ";
                                            int maximum = mw_s.maximum();
                                            p(F("%4d"),maximum);
                                            Serial << " ";
                                            
                                            Serial << "| mw: " << (stddev > TRIPPED_THRESHOLD ? "1" : "0") << " ";
                                            send(msg_micro_debug.set(stddev),false);
                                            while(!send(msg_micro.set(stddev > TRIPPED_THRESHOLD ? "1" : "0"),true))
                                            {
                                              wait(10);
                                            }
                                            
                                            if(isTransportOK()) 
                                              wait(100);
                                            else
                                              wait(1000);
                                            Serial << endl;
                                            //mysleep(500);
                                          
                                          }
                                          // https://forum.mysensors.org/topic/3463/m_ack_variable-or-m_set_variable/2
                                          void receive(const MyMessage &message) {
                                            if (message.isAck()) {
                                                Serial.print("| GW ack");
                                                }
                                          }
                                          

                                          Helper.ino

                                          long readVcc() {
                                            // Read 1.1V reference against AVcc
                                            // set the reference to Vcc and the measurement to the internal 1.1V reference
                                            #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
                                              ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
                                            #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
                                              ADMUX = _BV(MUX5) | _BV(MUX0);
                                            #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
                                              ADMUX = _BV(MUX3) | _BV(MUX2);
                                            #else
                                              ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
                                            #endif  
                                          
                                            delay(2); // Wait for Vref to settle
                                            ADCSRA |= _BV(ADSC); // Start conversion
                                            while (bit_is_set(ADCSRA,ADSC)); // measuring
                                          
                                            uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH  
                                            uint8_t high = ADCH; // unlocks both
                                          
                                            long result = (high<<8) | low;
                                          
                                            result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
                                            //result *= 1.0637;
                                            return result; // Vcc in millivolts
                                          }
                                          
                                          #include <stdarg.h>
                                          void p(const __FlashStringHelper *fmt, ... ){
                                            char buf[128]; // resulting string limited to 128 chars
                                            va_list args;
                                            va_start (args, fmt);
                                          #ifdef __AVR__
                                            vsnprintf_P(buf, sizeof(buf), (const char *)fmt, args); // progmem for AVR
                                          #else
                                            vsnprintf(buf, sizeof(buf), (const char *)fmt, args); // for the rest of the world
                                          #endif
                                            va_end(args);
                                            Serial.print(buf);
                                          }
                                          
                                          void mysleep(int SLEEP_TIME)
                                          {
                                              if(isTransportOK()){
                                                Serial << "| wait ";
                                                wait(25);
                                                Serial << "| zZz > ";
                                          
                                                sleep(SLEEP_TIME);
                                                Serial << "| < zZz " << endl;
                                              } 
                                              else {
                                                wait(1000);
                                              }
                                          }
                                          
                                          YveauxY Offline
                                          YveauxY Offline
                                          Yveaux
                                          Mod
                                          wrote on last edited by
                                          #27

                                          @cimba007 wow, you did some serious research there! (I see you make good use of the arduino plot function)
                                          I'll certainly come back to your research once I start with this sensor (so much to choose from...)
                                          Any ideas about current consumption? Is this a viable alternative to battery powered pir sensors?

                                          http://yveaux.blogspot.nl

                                          cimba007C 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          15

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

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