Announcement

Collapse
No announcement yet.

Bluetooth HM-10 in projects used?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bluetooth HM-10 in projects used?

    At the moment I am experimenting with the BLE HM-10 sensor: a very energy efficient option for controlling, even if you are already online via WiFi.
    I've reviewed your tutorials, but have not found an example. Is it possible to set with serial.read and turn on the internal LED with "on"?
    I enclose an Arduino example code:
    https://www.heise.de/developer/artik...t-3361763.html

  • #2
    Hello there,
    I don't know which PHPoC device you are referring to, but I assume that you are using PHPoC Shield with Arduino in your experiment. I think there would be no problem if you want to use those functions. You just need to include the required Arduino library.
    P/S: I am not quite sure I fully understand the article. I only know two German words, Danke and Guten tag . But I tried with Google translate tho.
    Cheers

    Comment


    • #3
      I have tested it once and it has become clear to me: the shields grind through the ports and so it works with the P4S-348.
      https://www.hackster.io/ingo-lohs/bl...-module-6eb803

      It gets interesting with the use of black/blue boards. I assume that a separate library will be needed here?

      Comment


      • #4
        Good to hear, my friend.

        I think if it is just for sending some AT commands via serial port, then PHPoC Blue/Black can do it well, too.

        There are two UART ports on Blue/Black for you to choose.
        You can look for RX/TX pin layout in the manual
        And I guess you will find all the UART functions you need here:
        https://www.phpoc.com/support/manual...hp?id=l_sd_340
        So again, I guess, just official library sd_340.php is enough for this
        Cheers

        Comment


        • #5
          I followed the advice, but the smartphone app shows nothing. probably because of my misapplied example code:

          <?php
          include "/lib/sd_340.php";

          $rbuf = "";
          while(1)
          {
          $rlen = uart_readn(1, $rbuf, 5); // Reading 5 bytes of data from the UART0
          if($rlen)
          {
          echo "$rbuf\r\n";
          // check if 1 then LED on Port 13 on
          if($rlen == "1") {
          digitalWrite(13, HIGH);
          }
          break;
          }
          }

          ?>

          Comment


          • #6
            Well, I think first you need to set up serial parameters.
            You can use uart_setup function for this.

            Here, echo can be used to print the message to PHPoC Debugger console, but if you want to send the data via UART port, you may need to use uart_write function.

            Make sure you declare your own digitalWrite function to control the LED, or you can take a look at tutorial about sending data via UART port and controlling LED at https://www.phpoc.com/phpoc_iot_boar...s_examples.php.

            Another thing is that I am not sure if uart_readn or uart_read should be used in your application. You may need to check this as well.

            For debugging PHPoC code, you can check the message on PHPoC Debugger console, it will surely help a lot.
            You just need to connect your board to PHPoC Debugger, and make sure the Run button on top center of Debugger is selected (the script is running).

            May the Force be with you, my friend

            Comment


            • #7
              Without a BLE module, the examples will work with the transmission of text in code, Homer.
              The question that arises for me is how to first submit my input via the smartphone and the BLE module, to check the input and to react to it.

              This code generates a Lib error:
              PHP error: maximum execution time exceeded in file lib / sd_340.php on line 264

              Whether it is on Wiring? Have tried Port 8 and 9 and U1TX/10 and U1RX/11.

              Thanks for the time and your support,
              Ingo



              <?php
              include "/lib/sd_340.php";
              uart_setup(0, 9600); // Configuring UART0 to 9600 bps

              // 8 UART #0 RTS / UIO0 #8 > TXD
              // 9 UART #0 CTS / UIO0 #9 > RXD

              uio_setup(0, 13, "out low"); // Configuring Port 13 for LED

              // Init vars
              $rbuf = "";
              $rlen = 0;

              while(1) // Read every second
              {
              $rlen = uart_readn(0, $rbuf, 3); // Reading 3 bytes of data from the UART0
              if($rlen) { // in any case of transfered text
              echo "$rbuf\r\n"; // Output in Browser or PHPoC Debugger
              if ($rbuf == "on") { // in case of "on" put LED on Port 13 brigt and blink the LED
              while(1)
              {
              uio_out(0, 13, LOW);
              usleep(250000);
              uio_out(0, 13, HIGH);
              usleep(250000);
              }
              break;
              }
              else {
              uio_out(0, 13, LOW);
              break;
              }
              }

              }
              ?>

              Comment


              • #8
                I think the current problem is in reading UART.
                I see that you are choosing UART0. U0TX and U0RX are pin 4 and pin 5, respectively.
                Probably you need to check UART wiring and configuration again.

                After that, in case you run it without any error, but the app still does not work as expected, you can print out all the exchanging message on Arduino Serial Monitor, and compare with those echoed on PHPoC Console. We will get a lot of information by doing so.

                Hope that helps, my friend

                Comment


                • #9
                  Not a big step for you, but for me ;-)
                  Nice that the guess with the wiring has been confirmed. That was probably not very clear to me that there are several serial interfaces with U0, 8/9 and U1.

                  This code now works as expected:

                  <?php

                  // Mapping BLE HM-10 to P4S-34x
                  // GND <> GND
                  // VCC <> 3.3V
                  // RXD <> U0TX/4
                  // TXD <> U0RX/5

                  include_once "/lib/sd_340.php";
                  $rbuf = ""; // Var for reading data

                  uart_setup(0, 9600); // Configuring UART0 to 9600bps

                  echo "PHPoC Example : P4S-34X / UIO / bright LED on Port 13 and 2 internal LED via BLE Modul HM-10\r\n";

                  uio_setup(0, 13, "out low");
                  uio_setup(0, 30, "out low"); // internal LED30 on - why?
                  uio_setup(0, 31, "out low"); // internal LED31 on - why?

                  while(1)
                  {
                  uart_read(0, $rbuf); // Reading data from UART0 into $rbuf

                  if ($rbuf == "1") {
                  uio_out(0, 13, HIGH);
                  uio_out(0, 30, LOW); // yes, low to put internal LED30 bright
                  uio_out(0, 31, LOW); // yes, low to put internal LED31 bright
                  echo "LEDs bright\r\n";
                  } else if ($rbuf == "2") {
                  uio_out(0, 13, LOW);
                  uio_out(0, 30, HIGH);
                  uio_out(0, 31, HIGH);
                  echo "LEDs off\r\n";
                  } else {
                  echo "Command <$rbuf> not known\r\n";
                  }
                  }

                  ?>

                  Also interesting are the two internal LEDs on port 30/31: these are defined as "out low", but react in opposite to port 13 (the LED) to LOW / HIGH.

                  Congratulations on the update to v1.5 of the debugger!

                  Thank you so much for the patience with me,
                  Ingo

                  https://www.instagram.com/p/BrnvHolF...on_share_sheet

                  Comment


                  • #10
                    Great to hear!

                    About the internal LEDs on PHPoC Blue/Black, their positive pins are connected to 3.3V.
                    And putting the output to LOW means you set the negative pin of these LEDs to LOW.
                    That's why the internal LEDs will be on if we output LOW.

                    Keep up the interesting work, my friend

                    Comment

                    Working...
                    X