David1234321
Member since Apr 2020 • Last active Nov 2022Most recent activity
-
- 20 comments
- 1,634 views
-
-
-
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
-
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-profile-gatt-specification-for-iot/and you can see in the nRf he is showing decimal value and say it's temp
https://programmaticponderings.files.wordpress.com/2020/08/screenshot_20200731-185558-5.pngI guess I will need to change the UUID also , no ?
Thanks ,
About my code
- can I see the MAC of the remote device that connected?
I want to print it on the OLED , for testing 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 ,
- can I see the MAC of the remote device that connected?
-
- 5 comments
- 574 views
-
-
-
- 3 comments
- 559 views
-
I'm using this device
128×64 OLED display module (SSD1306) , I will tryjust 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 notThanks ,
First time user of this - seem very cool