Avatar for David1234321

David1234321

Member since Apr 2020 • Last active Nov 2022
  • 17 conversations
  • 81 comments

First time user of this - seem very cool

Most recent activity

  • in Puck.js, Pixl.js and MDBT42
    Avatar for David1234321

    Ok
    Thanks

    it seem that now everything is working for me (almost),
    I will continue working - and if I will have more question I will ask.

    Thank you very much for the help!

  • in Puck.js, Pixl.js and MDBT42
    Avatar for David1234321

    so I can't read the pin status and know if it's "1" \ "0"?

  • in Puck.js, Pixl.js and MDBT42
    Avatar for David1234321

    Ok, it's working - thank you!

    but now I see another problem ,
    when I try to read the pin status using this command:

    NRF.setServices({
      "3e440001-f5bb-357d-719d-179272e4d4d9": {
        "3e440002-f5bb-357d-719d-179272e4d4d9": {
          description: "Setup Led",  // optional, default is null,
          writable : true,
          readable : true,
          notify: true,
          maxLen : 10,
          value : "Setup_Data",
          onWrite : function(evt) {
            data = evt.data[0];
            g.clear();
            g.setFontVector (20);
            g.drawString('Data receive',2,2);
            g.drawString(data,2,40);
            g.flip();
            if (data =="1") {
           // if (data < 18) {
               digitalWrite(LED, 1);
               digitalWrite(Relay_Pin, 1);
                }
           else {
           digitalWrite(LED, 0);
           digitalWrite(Relay_Pin, 0);}
           Relay_Status = digitalRead(Relay_Pin); 
    
          }
        },
    	"3e440008-f5bb-357d-719d-179272e4d4d9": {
         description: "Device Temp",  // optional, default is null,
          readable : true,
          notify: true,
          value : [E.getTemperature()]
        }
      }
    }, {});
    

    it turn off the led that connected to Relay_Pin

    when I remove the this line - the led stay on
    what could be the problem ?
    when I read the data from "nRF" I can see the value is "0x01"

    and one final "understanding" question:
    if I understand correct - there is no need for the connected device to know the Service UUID , just the CHAR uuid
    there is no used of the service - right ?

    ***I mange to make my Python code work - and there I only used the CHAR UUID , didn't use \ took any attention for the Service UUID

  • in Puck.js, Pixl.js and MDBT42
    Avatar for David1234321

    when I print to the OLED
    E.getTemperature() - I get 24.5 , so it's OK
    so if I will use this Characteristic for the temperature '2A6E' - will it show me ok on the nRF?
    I have looked here
    https://programmaticponderings.com/2020/­08/04/getting-started-with-bluetooth-low­-energy-ble-and-generic-attribute-profil­e-gatt-specification-for-iot/

    and you can see in the nRf he is showing decimal value and say it's temp
    https://programmaticponderings.files.wor­dpress.com/2020/08/screenshot_20200731-1­85558-5.png

    I guess I will need to change the UUID also , no ?

    Thanks ,

    About my code

    1. can I see the MAC of the remote device that connected?
      I want to print it on the OLED , for testing
    2. I have wrote this code , it's seem to be working,
      my problem is when I disconnect:
      LED2 is off (as it should be)
      but on the OLED I still see "Connected" and the temp is changing every 5 seconds
      I guess it's because the Interval function that is still running
      can you see what I did wrong?

      My_MAC = NRF.getAddress();
      Relay_Pin = 22;
      
      print("My MAC address is " , My_MAC);
      var n = 0;
      
      
      function start(){
      // write some text
      g.setFontVector (20);
      g.drawString("David Test!",2,2);
      g.drawString("BLE ON",2,40);
      // write to the screen
      g.flip();
      }
      
      function BLE_Connect(){ 
      setInterval(function() {
      NRF.updateServices({
      "3e440001-f5bb-357d-719d-179272e4d4d9" : {
      "3e440008-f5bb-357d-719d-179272e4d4d9" : {
        value :  [E.getTemperature()],//to be able to see that read is correct
        notify: true
      }
      
      }
      });
      g.clear();
      g.setFontVector (20);
      g.drawString("Connected!",2,2);
      g.setFontVector (10);
      g.drawString("Temp is: " + E.getTemperature(), 1, 40);
      g.flip();
      }, 5000);
      
      }
      
      function BLE_Disconnect(){
      g.clear();
      g.setFontVector (20);
      g.drawString("Waiting!",2,2);
      g.flip();
      }
      
      var i2c = new I2C();
      i2c.setup({ scl : D20, sda: D19 });
      var g = require("SSD1306").connect(i2c, start);
      
      
      NRF.setAdvertising({}, {name:"OfficeTest"});
      
      NRF.setServices({
      "3e440001-f5bb-357d-719d-179272e4d4d9": {
      "3e440002-f5bb-357d-719d-179272e4d4d9": {
        description: "Setup Led",  // optional, default is null,
        writable : true,
        readable : true,
        notify: true,
        maxLen : 10,
        value : "Setup_Data",
        onWrite : function(evt) {
          data = evt.data[0];
          if (data < 18) {
              digitalWrite(LED, 1);
              digitalWrite(Relay_Pin, 1);
              }
         else {
         digitalWrite(LED, 0);
         digitalWrite(Relay_Pin, 0);}
      
        }
      },
      	"3e440008-f5bb-357d-719d-179272e4d4d9": {
       description: "Device Temp",  // optional, default is null,
        readable : true,
        notify: true,
        value : ["Temp_Location"]
      }
      }
      }, {});
      
      setInterval(function() {
      NRF.updateServices({
      "3e440001-f5bb-357d-719d-179272e4d4d9" : {
      "3e440002-f5bb-357d-719d-179272e4d4d9" : {
        value :  [data, heartrate],//to be able to see that read is correct
        notify: true
      },
      }
      }); }, 5000);
      
      // On disconnect, turn off led
      NRF.on('disconnect', function() {
      digitalWrite(LED2, 0);
      BLE_Disconnect();
      });
      
      NRF.on('connect', function() {
      digitalWrite(LED2, 1);
      BLE_Connect();
        
      });
      

    Thank you again ,

  • in Puck.js, Pixl.js and MDBT42
    Avatar for David1234321

    Obviously :-)

    it's working

    thanks,

  • in Tutorials
    Avatar for David1234321

    OK
    I will stay with the nRF

    Thanks,

  • in Puck.js, Pixl.js and MDBT42
    Avatar for David1234321

    I'm using this device
    128×64 OLED display module (SSD1306) , I will try

    just to be ready
    if I take the code:

    function start(){
     // write some text
     g.drawString("Hello World!",2,2);
     // write to the screen
     g.flip();
    }
    
    // I2C
    I2C1.setup({scl:B6,sda:B7});
    var g = require("SSD1306").connect(I2C1, start);
    

    it's should work ?
    will change it to print if someone is connected or not

    Thanks ,

Actions