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. Development
  3. Bluetooth Proximity Sensor

Bluetooth Proximity Sensor

Scheduled Pinned Locked Moved Development
bluetoothpresence
33 Posts 9 Posters 32.0k Views 7 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.
  • K Offline
    K Offline
    Konrad Walsh
    wrote on last edited by Konrad Walsh
    #17

    @hek
    I have to wait for you to figure this one out... I have tried many methods but not making progress at all...

    Your code does work by the way.. It sends and receives the data without issue.. but getting it all repackaged for a MySensors plugin isn't happening for me..

    I have taken the binary switch recipe and I am using that so that it will turn on on/off based on the BT id it sees ..

    I might start a fresh tonight.. Ill post any updates if I make progress on it..

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

      I was thinking of just emulating a door-sensor. When BT detects someone in proximity it sends 1 and 0 when no-one is in range. Just like the binary switch you proposed..

      If you want to send in which device in range you could use VAR1-5 with the BT device identifier as payload (at some interval).

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Konrad Walsh
        wrote on last edited by
        #19

        I have given up.. I cant get anywhere with this but I think its cause I bought hc-06.. Are you closer?

        P 1 Reply Last reply
        0
        • hekH Offline
          hekH Offline
          hek
          Admin
          wrote on last edited by
          #20

          Last time I tested with the new HC-05 I couldn't get it to enter AT mode. Will probably make another test when I have some time.

          1 Reply Last reply
          0
          • K Offline
            K Offline
            Konrad Walsh
            wrote on last edited by
            #21

            ok.. mine enters AT mode.. and I can get it to send and receive data.. I may as well keep plugging at it so

            1 Reply Last reply
            0
            • K Konrad Walsh

              I have given up.. I cant get anywhere with this but I think its cause I bought hc-06.. Are you closer?

              P Offline
              P Offline
              PedroC88
              wrote on last edited by
              #22

              @Konrad-Walsh For what I know, the HC-06 is automatically configured to take in AT commands, so that shouldn't be a problem, although mine (that I got today) seems to be defective as I send it the AT command, but I'm getting no answer.

              1 Reply Last reply
              0
              • hekH hek

                I accidentally feed the first module with reversed polarity. It did not like that very much. :(

                The second module arrived this week, but I haven't hooked it up yet. Planned on using software serial and had a test sketch going something like this:

                /* $Id$
                
                Serial terminal for the HC-05 bluetooth module.
                Sets up BT module and allow user interaction with the device via the Arduino Serial Monitor.
                
                Wiring of BT HC-05 device to the Arduino
                RX -> 11
                TX -> 10
                KEY -> 9
                */
                
                #include <SoftwareSerial.h>
                
                // Bluetooth to Arduino pins.
                #define BTkey 9
                #define BTrxPin 10
                #define BTtxPin 11
                
                enum { SYNC, ASYNC };
                
                SoftwareSerial BTSerial(BTrxPin, BTtxPin);
                
                // Send a command to the bluetooth device.
                // mode ASYNC - don't want for the response
                // mode SYNC - wait for the response
                void sendBluetoothCommand(String cmd, uint8_t mode) {
                  Serial.print(mode == SYNC ? "SYNC> " : "ASYNC> ");
                  Serial.println(cmd);
                
                  BTSerial.println(cmd);
                  if (mode == ASYNC) return;
                  
                  char ch = 0;
                  while (ch != '\n') {
                    if (BTSerial.available()) {
                      ch = BTSerial.read();
                       Serial.write(ch);
                    }
                  }
                }
                
                void setup()
                {
                   Serial.begin(57600);
                   
                  /////////////////////////////////////////////////////////
                  // SETUP BLUETOOTH  
                  // define pin modes for tx, rx:
                  pinMode(BTrxPin, INPUT);
                  pinMode(BTtxPin, OUTPUT);
                  // Switch module to AT mode
                  pinMode(BTkey, OUTPUT);
                  digitalWrite(BTkey, HIGH);  
                  BTSerial.begin(38400);
                  sendBluetoothCommand("AT", SYNC);
                  sendBluetoothCommand("AT+NAME=blueNode", SYNC);
                  // AT+ROLE=p1
                  // p1 - 0 Slave Role, 1 Master Role, 2 Slave-Loop role.
                  sendBluetoothCommand("AT+ROLE=1", SYNC);
                  // AT+INQM=p1,p2,p3
                  // p1 - 0 inquire_mode_standad, 1 inquire_mode_rssi
                  // p2 - maximum number of bluetooth devices response
                  // p3 - the maximum of limited inquiring time. 1~48 (1.28s ~ 61.44s)
                  //      15*1.28 = 19sec 
                  sendBluetoothCommand("AT+INQM=0,5,15", SYNC);
                }
                
                void loop()
                {
                  // Keep reading from HC-05 and send to Arduino Serial Monitor
                  if (BTSerial.available())
                    Serial.write(BTSerial.read());
                
                  // Keep reading from Arduino Serial Monitor and send to HC-05
                  if (Serial.available())
                    BTSerial.write(Serial.read());
                }
                

                And.. the first module was of the wrong type (I think). Must support master-mode if I understand it correctly. The second one I bought was this type.

                P Offline
                P Offline
                PedroC88
                wrote on last edited by
                #23

                @hek When you say you inverted the polarity... are you talking about VCC and GRD? or Rx and TX?

                hekH 1 Reply Last reply
                0
                • P PedroC88

                  @hek When you say you inverted the polarity... are you talking about VCC and GRD? or Rx and TX?

                  hekH Offline
                  hekH Offline
                  hek
                  Admin
                  wrote on last edited by
                  #24

                  @PedroC88

                  vcc/gnd

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    Konrad Walsh
                    wrote on last edited by
                    #25

                    i am "semi" abandoned it.. I couldn't get it work at all...

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      Konrad Walsh
                      wrote on last edited by
                      #26

                      i am "semi" abandoned it.. I couldn't get it work at all... but I cant say I fully grasp the syntax yet. Hopefully @HEK gets the notion...

                      P 1 Reply Last reply
                      0
                      • K Konrad Walsh

                        i am "semi" abandoned it.. I couldn't get it work at all... but I cant say I fully grasp the syntax yet. Hopefully @HEK gets the notion...

                        P Offline
                        P Offline
                        PedroC88
                        wrote on last edited by
                        #27

                        @Konrad-Walsh At the end I got the HC06 to work, I'm finally understanding all of this, if you tell me what you're trying to accomplish and the code u have I might be able to help. Also the module you're using.

                        1 Reply Last reply
                        0
                        • Ø Offline
                          Ø Offline
                          Øyvind A. Espnes
                          wrote on last edited by
                          #28

                          I really like this idea, but for it to be effective we need to measure the decibel level of the connection and not just connected/disconnected state. Is this possible?

                          P 1 Reply Last reply
                          0
                          • Ø Øyvind A. Espnes

                            I really like this idea, but for it to be effective we need to measure the decibel level of the connection and not just connected/disconnected state. Is this possible?

                            P Offline
                            P Offline
                            PedroC88
                            wrote on last edited by
                            #29

                            @Øyvind-A.-Espnes I haven't tried it, but with the AT+INQM command you can specify wether you want the RSSI of the device when issuing the AT+INQ command. This document can better explain it.

                            After that it should just be a matter of parsing the resulting string and extract the signal strength.

                            1 Reply Last reply
                            0
                            • D Offline
                              D Offline
                              Dean
                              wrote on last edited by
                              #30

                              I was thinking about going this route, but until last weekend I was using Tasker and having it tell Vera that I am here when my phone connects to my Wifi. I bought a new phone and I can't get it to stay connected when it hasn't been used in a while, so I have to rethink...

                              While a Mysensors option could be good, what I am going to do is use my many Android tablets that I have throughout my home and have them always searching my my mobile. With them all throughout my home, I won't have to worry about bluetooth range.

                              Sorry it isn't a Mysensors option, but I thought I would share what I am going to do :-)

                              1 Reply Last reply
                              0
                              • N Offline
                                N Offline
                                Newzwaver
                                wrote on last edited by
                                #31

                                Any luck with BT?

                                1 Reply Last reply
                                0
                                • riochickenR Offline
                                  riochickenR Offline
                                  riochicken
                                  wrote on last edited by
                                  #32

                                  @hek

                                  Hi,

                                  Did you get anywhere with this? I would like to build a bluetooth sensor myself but since this is an old thread, I am not really sure if the market has been modernized a little with bluetooth devices..

                                  Thanks!

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

                                    Sorry, no. Realised modern phones BT goes into sleep mode which means they don't announce themselves for longer periods. Kind of made it meaningless for the application.

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


                                    11

                                    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