• Hello,
    I want to create a simple BLE that will "post" my website
    I have connected the device using a serial-usb and I can see it on the "ESPRUINO WEB IDE"
    "Found MDBT42Q,2v04"
    now what ?
    I have look at the tutrial , and mange to make LED1 blink
    but now what?
    how do I write a code to it the will publish my website "http://www.myWeb.com" ?

    Thanks ,

  • What about using the EspruinoHub for this?

    A BLE -> MQTT bridge for Raspberry Pi and other Embedded devices

    https://github.com/espruino/EspruinoHub

  • Mon 2020.04.13

    Hi @David1234321,

    Here is a really quick way to demo how Espruino BLE devices interact with web pages. Just did this as a quick reminder of how to find the link and do the web page button click watch the LED remotely function:

    http://www.espruino.com/Quick+Start+BLE

    purposely not pasting link so as to inform where to find in future

    Hunt for 'Go to the Puck.js site' beneath 'Once Web Bluetooth is set up' heading.

    make sure the MDBT42Q is not connected with an existing WebIDE

    Use that page to to find the 'Try Me' buttons to the lower right of code blocks

    Has a simple deployed web page :

    https://www.espruino.com/Web%20Bluetooth

    Also check out the myriad of tutorials:

    Tutorials
    http://www.espruino.com/Tutorials

    1. Do I have to use PI with this device?
      it can't work as standalone ?
      setup it once , connect it to power and "forget" about it?

    2. I have try 4 time to understand how to work with this site
      https://www.espruino.com/Web%20Bluetooth
      and also this
      http://www.espruino.com/Quick+Start+BLE
      this is the most ununderstable explain\exmaple I have ever read .
      and I read a lot of tech .
      can't find a simple guide of how to upload using a serial connection,
      I don't have bluetooth on my computer - so I can't upload create a project on it?

    maybe there is a very simple even "dumb" guide ?

    Thanks,


    maybe I didn't understand the using of the BLE
    do I have to have an internet connection for it to work?
    if not - why do I need to use pi?
    or the pi is just for manage the data and get all kind of stat about people how see my BLE?

    Thanks ,

  • Do I have to use PI with this device?

    No.

    it can't work as standalone ?

    Yes, it can work on its own just fine.

    do I have to have an internet connection for it to work?

    No. However you told us "I want to create a simple BLE that will "post" my website".

    Bluetooth LE devices don't magically connect to the internet. It's like complaining that your Laptop can't view websites when you have no WiFi router.

    if not - why do I need to use pi?

    If you want the MDBT42Q to connect to the internet then you need something to act as a 'bridge' between bluetooth and the internet - like you need a WiFi router to connect your Laptop to the internet. That's what we're suggesting the Pi is for, but it's by no means the only thing you could use.

    For instance using Web Bluetooth on a phone/tablet/laptop is super quick and easy:

    https://www.espruino.com/Web%20Bluetooth­ will show you how to create a website which will communicate with the MDBT42Q - but only when that webpage is open.

    Still, that may be what you want?

    This is just a super simple webpage which will output whatever text your MDBT42Q decides to print. You can then do with that what you want.

    <html>
    <body>
      <script src="https://www.puck-js.com/puck.js"></script>
      <button id="go">Go!</button>
      <script type="text/javascript">
        var connection;
        document.getElementById("go").addEventListener("click", function() {
          if (connection) {
            connection.close();
            connection = undefined;
          }
          Puck.connect(function(c) {
            if (!c) {
              alert("Couldn't connect!");
              return;
            }
            connection = c;
            // Handle the data we get back
            connection.on("data", function(d) {
              console.log("Got "+JSON.stringify(d));
            });
          });
        });
    </script>
    </body>
    </html>
    
  • Tue 2020.04.14

    Good Morning David @David1234321,

    'I can see it on the "ESPRUINO WEB IDE"'
    'this is the most ununderstable explain\exmaple I have ever read . and I read a lot of tech'

    Thank you for your feedback. Is it possible there is a bit of mis-communication here as we sense a bit of frustration on that end? The post title indicated 'First time user' and the desired project goal is quite a bit narly!

    We made the assumption that many skills had previously been acquired, thus only a bit on getting started with Espruino was all that was needed. I provided the links in post #3 in order to perform the ideas that were presented using just a browser to load and interact with, rather than connecting and coding the PI hardware solution, which could be time consuming.



    We need a bit a bit more about your PC, tools and knowledge, so please respond with those items as listed here:

    The first post pinned at the top of the Forums category:

    http://forum.espruino.com/microcosms/130/
    which links to:
    http://forum.espruino.com/conversations/335009/#comment14774556

    containing loads of recommended reference links along with detail that would assist us in getting a user up and running quickly.

    Q: Are we working with the MDBT42Q breakout board, or a project connected to the module itself?



    But maybe that was a bit overkill, and some videos will trigger some more appropriate questions:

    this is five years old and uses a USB connection but is a good introduction
    This video gives a basic overview of the steps:

    http://www.espruino.com/Web+IDE

    This video demos writing code that is sent over BLE:

    http://www.espruino.com/BLE+Communications

  • OK
    let see if I understand it correct I will try to expalin even more:
    1 .I'm using Desktop computer with windows7, no bluetooth.
    I'm connecting to the device using serial connection - working without any problem. I can see :"Found MDBT42Q,2v04"
    I can also send in the terminal
    "1+2"
    and I get 3
    so this mean everything is OK,right?
    2 .I mange to upload a simple blink led code I press the "up arrow" , and also wrote on the terminal "save()". - now after power reboot the device is running my new code.
    up until here - I guess I did good , and understand how to use the web IDE.

    what I want to do is :
    write\flash a code so the devcie will publish my own data as BLE
    for example : "Hello to all
    connect to david.com to get free gift":

    • david.com will be a link
    • I assume the remote device will be with internet connection.

    now I have some questions:

    1. can I do this using this device?
    2. is there an example code for this? or something to begin with ?
    3. is there any way to know who is connect to my website using the BLE "advertisement"?
      so I can "save" the mac address ?
    4. can I change the text over the internet? i guess I will have to uplaod the all code again ?
      I understand that for 3-4 I need internet connection and a device that can connect to it using serial (?) , like PI
      and I need to know the pi IP and everything . this is not a problem.
      but for the first stage to show my project work I need to make a POC of 1&2.
      after it I will add in the main code all kind of functions like"
      "Send MAC to MyServer using UDP"
      "Save Log to PI"

    hope now my project is more understanble and you can help me continue working on it ,

    Thanks ,

  • Thr 2020.04.16

    re: steps 1 and 2

    'I guess I did good , and understand how to use the web IDE'

    Success @David1234321 !!


    post #7 'what I want to do is :    . . .   so the devcie will publish my own data as BLE'

    I was with you up until that statement. I'm not sure if this is a technology misundetanding, or a language misunderstanding.

    post #4 'get all kind of stat about people how see my BLE?'
    post #4 'maybe I didn't understand the using of the BLE'

    Regarding post #7 "data as BLE" and post #4 "see my BLE" and "using of the BLE"

    I would have expected something like post #7 "my own data using BLE" instead. BLE B_luetooth L_ow E_nergy is a technology not a web server, as the choice of words leads me to believe there lies the misunderstanding.



    The simple post #3 load the web page and click a button is the easiest demo to show how a web page communicates with the MDBT42Q. What is the result of clicking on that 'Try Me' button? Load the page using a BLE equipped phone, should the PC not support BT.

    With that response, we'll be able to answer the questions in #7 post.

    B.T.W. are we using the breakout board as I inquired back in post #6?

  • Hi,

    can I do this using this device?

    Yes, but in Android Google turned automatic scanning for them off by default because it was being abused for advertisements

    Effectively what you're asking for is a QR code over Bluetooth?

    is there an example code for this? or something to begin with ?

    Yep:

    You basically broadcast a URL/ID and the title comes from the website you link to.

    is there any way to know who is connect to my website using the BLE "advertisement"?

    You can add a unique ID to the URL - much like how you'd track any other visit on the web.

    so I can "save" the mac address ?

    NRF.getAddress() will give you the nRF52's address - so you can just add that (or part of it) to the URL.

    can I change the text over the internet? i guess I will have to uplaod the all code again ?

    Usually the text comes from the website's title, so you can change that easily.

    I understand that for 3-4 I need internet connection and a device that can connect to it

    Actually I think for what you want, there's a good chance you don't need an internet connection at all.

  • I think this is a language misunderstanding.
    yes I'm using breakout board.
    I don't want QR code.

    I will try to make my project simpler and in 2 steps :

    step 1:
    I have a buliding with 4 floors
    I want to put MDBT42Q in each floot , that will use the BLE and "publish" the floor number
    (floor1 - "http://www.floor1.com , floor2-http://www.floor2.com , etc...".
    in each floor I can only see 1 MDBT42Q (lets say I will put each device far way for the other one , so it is possible that in 1st floor I will only see the firsr MDBT42Q).
    I only use Android phone , and I have enable the scanning(to avoid problems).

    I think this is a very simple and easy example for what I want to do , and after I will do this I will understand better what to do and do other steps.
    I looked at

    http://www.espruino.com/Eddystone
    

    and this is what I have upload

    require("ble_eddystone").advertise("http://www.david.com");
    
    var  on = false;
    setInterval(function() {
      on = !on;
      LED1.write(on);
    }, 200);
    

    the blinking part - just to see it's working ....

    and now it's working

    what about

    Gordon

    said?

    how can I "save" the user MAC that saw the message ?
    only by the website I direct to ?

    and what does this line do?

    NRF.getAddress() will give you the nRF52's address - so you can just add that (or part of it) to the URL.

    If I understand correctlly (which I guess I didn't :-) )

    this is what I have uploud :

    NRF.setAdvertising([
       require("ble_eddystone").get("http://www.David1.com"),
      {} // this will add a 'normal' advertising packet showing name/etc
    ], {interval:100});
    NRF.setScanResponse(require("ble_eddystone").get("http://www.david.com"));
    var  on = false;
    setInterval(function() {
      on = !on;
      LED1.write(on);
    }, 500);
    

    also how can I add more information in the message ? another small message?20 chars?
    not jsut the URL? - or this is not a possible ?

    Thank you for the time and the patience that you give me :-)!

  • Sun 2020.04.19

    Hi @David1234321 glad to see the progress.

    Did you get the quick demo link #3 post transfering data back and forth to the MDBT42Q working?

    'how can I "save" the user MAC that saw the message '

    Please check out the functions here that make up the NRF class, then once the desired data has been collected, we'll work on the save part.

    http://www.espruino.com/Reference#t_l_NRF_getAddress



    Just yesterday, a link resurfaced to what @AkosLukacs previously published, but using the magnometer on a Puck, which the MDBT42Q doesn't have. Please read over what is a close working example to what I believe you are after.

    Dynamic reading of BLE characteristic?

    code in post #5 link there


    'how can I add more information in the message ? another small message?'

    See heading 'An Example' for instructions on URL shortening:

    https://www.espruino.com/Eddystone

    or are you after appending values as information to that URL?

    https://en.wikipedia.org/wiki/Query_string


    'I don't want QR code'

    Is it possible what is really desired is how NFC works as the indication is to use a phone to pull floor detail from each device?

    'NFC tag programmable from JavaScript (when an antenna is connected)'
    https://www.espruino.com/MDBT42Q

    https://www.espruino.com/NFCTag

    https://www.espruino.com/Reference#l_NRF_NFCon

  • Hello Robin

    1. yes, I mange to connect to my phone and use termnial to send\get text.
    2. about "NRF class" - I guess it can get only the person how connect to the BLE Device - right ?
      because (as I understand ) when I publish the floor number ,everyone can see it -even 100 people with andorid . it will be like a billboard on the highway(which you don't know really how much people read your sign).
    3. I have try to do as it said here https://www.espruino.com/Eddystone , but couldn't see any different between NRF.setAdvertising() and require("ble_eddystone").advertise("goo.gl/B3J0Oc");
      is it posiable to addvertise a string and not a url?
      for example "This is the 1st floor".?
    4. can I use another language\fonts for the addvertide? not english? Chinese\Arabic\etc..

    5. if I connect the BLE to a PI -can I control on it and send differnet text every x hours using python code or whatever?

    Thank you for the help

  • Thr 2020.04.23

    Hi David, I'm near my limit on NRF understanding at the moment as I'm still trying to get tinyMQTT and a MQTT broker running on Windows10 to assist further with the advertising questions. With success with that ~1 week? I hope to do exactly what you are doing. In the mean time, lets get a few questions confirmed and maybe some others may assist.

    'when I publish the floor number ,everyone can see it -even 100 people'

    So, do you want those 100 people to be able to see, or do you want to block all but the five or so you give a secret key to?

    https://www.espruino.com/Reference#l_NRF_setSecurity

     

    'is it posiable to addvertise a string and not a url'

    I'm not sure, but I don't see why not. In the EddyStone example, that device is a Beacon, and it's purpose is to advertise a URL, when another Android device is in close proximity.

    https://www.espruino.com/Reference#l_NRF_setAdvertising

    As EddyStone is mentioned a lot, and there is a reference in the link above, is the intent to make your MDBT42Q behave exactly like an EddyStone beacon then?

    As you mention Beacons several times, we can safely say we are not dealing with NFC and rule that out then?

  • yes I'm only intresting in using Bluethoot beacon not NFS .

    I don't need anyone to connect to the Bluethoot (there will be nothing to connect to...), just want to advertide using it .

    I saw I can advertise URL , but I want to add myown text - not just URL .this is my big question ?

    Thanks ,

  • 'in using Bluethoot beacon not NFS'

    Confirming, the above is just a typo and 'NFC' was intended?

    'but I want to add myown text'

    I'm not 100% sure, but as you will need to write the receiving code part in order to detect that text, it will be easy enough to try. What does the EddyBeacon spec say? Please provide link and reference when that is found, as the setAdvertise() data attribute does make the URL distinction, for it's corresponding value, meaning that there might be a text attribute if a URL string is not intended.

  • How do you want the text to be displayed? Next to the URL?

    The text comes from the web page at that URL's title I believe.

    I did actually have an example where I did require("ble_eddystone").advertise("goo.gl/D8sjLK#"+doorOpenings);

    It might be that you can actually have a script on there that changes the page's title based on the text in the link.

    Otherwise if you only have a limited set of text you want to display you could just change the url:

    require("ble_eddystone").advertise("http://www.david.com/a");
    require("ble_eddystone").advertise("http://www.david.com/b");
    // etc
    
  • I understand
    I feel now I have more then enough to start,
    Thanks for all the help !

    another related question:
    I have another think I want to do -run a scan once every second and get the signal and mac of the around and save it to the device. (and then decide if I want to connect to it or not , by MAC or signal)

    how do I do this?

  • run a scan once every second and get the signal and mac of the around and save it to the device.

    Just call http://www.espruino.com/Reference#l_NRF_findDevices and it'll call back with the devices that are found.

    It's worth supplying a filter though as if you run it somewhere busy you can potentially get so many BLE devices it uses up your available memory :)

  • great
    I will start a new post with some question that I have about it now

    Thanks!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

First time user - how to seup BLE message on my MDBT42Q,2v04?

Posted by Avatar for David1234321 @David1234321

Actions