-
Yes, I was under the impression it would send it just when I ask it to.
So my if else statement just changes What is being advertised, not When it will be advertised.
My setInterval call determines the Frequency of the broadcast.
If I know it takes my son 3 minutes to get all of the dog food out and put it in bowls, then can't I set the interval to 60 seconds? (you mentioned not staying connected if it was too infrequent).
I have read over that page, all good info, but being new the concepts take a bit to sink in. Q & A really helps.
Thank you for your clarifications.
-
although I'd still recommend that you use the counter method if you want to be sure you don't miss things happening.
My IOT hub will be a rpi3. I plan on capturing the battery reading when the lid has been opened, and thus will only be one hit a day. In my else statement I send a 0, though you are recommending a count.
I don't plan on doing anything with the count, but I am interested in your suggestion, please tell me more about how this will help. (a bit slow here :) )
Here is the current state of my code:
function sendAdvert() { if(Puck.light() > 0.50){ NRF.setAdvertising({0x180F : [Puck.getBatteryPercentage()]}); } else{ NRF.setAdvertising({0xFFFF:[0]}); } } setInterval(sendAdvert, 1500); digitalRead(LED1); NRF.setTxPower(4);
-
Here is my proposed code, do you have any suggestions?
So in this code, LED1 is not an output, so I shouldn't have to do a read correct?
The only reason you suggested bumping power with setTxPower(4) is just to give me some more distance correct?
Thank you.
function sendAdvert() { if(Puck.light() > 0.50){ NRF.setAdvertising({0x180F : Puck.getBatteryPercentage()}); } else{ NRF.setAdvertising({0xFFFF:"0"}); } } NRF.setTxPower(4); setInterval(sendAdvert, 1500);
-
@allObjects, @Gordon Thank you for your great responses.
I have settled on using the light sensor, as the puck will be inside the tub, and will get flooded with light when he opens the lid.
Problem is distance. Gordon, how far should I expect a puck to Rpi to be able to communicate?
What I usually say is to transmit a number all the time, and to then just increment that number when something happens.
Isn't that going to burn up the battery? I would like to get a couple of months battery out of a once a day event advert.
-
@allObjects Thanks for you helpful comments.
Any thought on this comment?
Where I am having trouble is the BLE part of the equation. I just want to send a signal, do I have to do advertising and or GATT services, or can I just send a signal without all of the BLE ceremony?
-
Robin, thank you for those links. I will start reading and watching them.
I can figure out how to take a reading on the mag or accelerometer.
Where I am having trouble is the BLE part of the equation. I just want to send a signal, do I have to do advertising and or GATT services, or can I just send a signal without all of the BLE ceremony?
-
I plan on creating a notice to inform me when my son feeds the dogs.
I am going to Velcro the Puck in the round screw in lid to the dog food bucket.
When he turns the lid to open it up, the accelerometer will sense movement and send out a message (battery level).My Ras Pi will be listening for that message and when it receives it, it will send a message to my Azure IOT Hub. ( can handle the raspberry pi code)
I wonder if you could help me on the how I might go about programming the Puck to send a message when the accelerometer senses movement?
Is it possible with the graphical designer?
Thank you for any coding you can help me with so this doesn't take me a month to figure out.
-
Ok, I finally got connected on native to the puck.
It was confusing that I did not need to go into pairing mode to connect to the device when I was in settings/add Bluetooth device.
Who knew that a Bluetooth device could be paired without going into pairing mode?
Thank you for your help Gordon....now I can start asking some programming questions :)
==>Is there any harm in storing the battery upside down while not in use so it does not drain?
-
I am attempting to program my Puck through the native app on Win 10.
I have paired and connected my Puck (DfuTarg) in Settings.
When I try and connect the Puck in the native app, it only shows Com1 and Com3, non of which are the DfuTarg.
I have upgraded the firmware, done hard resets, but still can't access the Puck.
Ideas?
-
-
Ok, I have upgraded to Chrome 68, but when I try and connect it tells me "no compatible devices found"
Here is the console:
No chrome.serial - Chrome Serial disabled
No chrome.sockets - Chrome Socket disabled
serial_audio: Audio Sample rate : 44100
serial_audio: Audio Serial Baud 9600 Bit time 4.59375
WebSocket relay support enabled - running in web browser
WebSocket localhost support (EspruinoHost) enabled - running in web browser
serial_frame: Running in a frame - enabling frame messaging
No chrome.storage API - disabling Offline mode
Initialising SettingsConsole
Initialising Utils
Initialising Config
Initialising Notifications
Initialising Status
Initialising App
Initialising File
Initialising Code
Initialising Serial- Initialising Serial Web Audio
- Initialising Serial Web Bluetooth
- Initialising Serial Websocket Relay
- Initialising Serial Websocket to EspruinoHost
- Initialising Serial window.postMessage
Initialising SerialWebSocketRelay
Initialising SerialWebSocketLocal
Initialising Terminal
Initialising CodeWriter
Initialising Modules
Initialising Env
Initialising Flasher
Initialising EditorBlockly
Initialising EditorJavaScript
Initialising Send
Initialising MenuPortSelector
Initialising MenuSettings
Initialising MenuFlasher
Initialising SettingsAbout
Initialising SettingsFlasher
Initialising BoardJSON
Initialising VersionChecker
Initialising Compiler
Initialising Assembler
Initialising GetGitHub
Initialising Unicode
Initialising Minify
Initialising SaveOnSend
Initialising SetTime
Initialising Tutorial
Initialising Webcam
Initialising FontSize
Initialising UiMode
Initialising URLHandler
Initialising CodeLink
Initialising Project
Initialising Testing
Initialising Notification_Sound
Initialising Tern
Initialising Debugger
Initialising Tour
Initialising HelpLinks
Initialising Arrows
No code in storage.
Handling URL "https://www.espruino.com/ide/"
serviceworker> active
Couldn't connect to wss://localhost:31234 - disabling websockets for this session
ERROR: serial_frame: getPorts timeout, disabling
ERROR: getURL("/serial/ports") error :
/serial/ports doesn't exist - disabling WebSocket support
>>> Connecting...
Set Slow Write = true
BT> ERROR: NotFoundError: User cancelled the requestDevice() chooser.
ERROR: [notify_error] Connection Failed.
>>> Connection Failed.
- Initialising Serial Web Audio
-
Here is the console:
No chrome.serial - Chrome Serial disabled
No chrome.sockets - Chrome Socket disabled
serial_audio: Audio Sample rate : 44100
serial_audio: Audio Serial Baud 9600 Bit time 4.59375
WebSocket relay support enabled - running in web browser
WebSocket localhost support (EspruinoHost) enabled - running in web browser
serial_frame: Running in a frame - enabling frame messaging
No chrome.storage API - disabling Offline mode
Initialising SettingsConsole
Initialising Utils
Initialising Config
Initialising Notifications
Initialising Status
Initialising App
Initialising File
Initialising Code
Initialising Serial- Initialising Serial Web Audio
- Initialising Serial Web Bluetooth
- Initialising Serial Websocket Relay
- Initialising Serial Websocket to EspruinoHost
- Initialising Serial window.postMessage
Initialising SerialWebSocketRelay
Initialising SerialWebSocketLocal
Initialising Terminal
Initialising CodeWriter
Initialising Modules
Initialising Env
Initialising Flasher
Initialising EditorBlockly
Initialising EditorJavaScript
Initialising Send
Initialising MenuPortSelector
Initialising MenuSettings
Initialising MenuFlasher
Initialising SettingsAbout
Initialising SettingsFlasher
Initialising BoardJSON
Initialising VersionChecker
Initialising Compiler
Initialising Assembler
Initialising GetGitHub
Initialising Unicode
Initialising Minify
Initialising SaveOnSend
Initialising SetTime
Initialising Tutorial
Initialising Webcam
Initialising FontSize
Initialising UiMode
Initialising URLHandler
Initialising CodeLink
Initialising Project
Initialising Testing
Initialising Notification_Sound
Initialising Tern
Initialising Debugger
Initialising Tour
Initialising HelpLinks
Initialising Arrows
Loaded code from storage.
serviceworker> active
Handling URL "https://www.espruino.com/ide/"
- Initialising Serial Web Audio
-
Chrome Version 50.0
Ok, I enabled the following:
Type in chrome browser:
chrome://flags
Then enable:
Experimental Web Platform Features
and
Web BluetoothNow when I click the connect button, the IDE shows the "Select a Port" window.
When I click it, it does not find the puck. I have it in pairing mode, but no pairing.
Oh, and I turned Wi-Fi off (reading some past posts) -
-
I am using an android 6.0 tablet.
It show the puck.js b80e is paired.When I go to the Espruino Web IDE and hit the connect button, it shows No Ports Found.
Here is a dump of the console.I noticed "Web Bluetooth not enabled"
I can't seem to find a setting in Android to turn web Bluetooth on.No chrome.serial - Chrome Serial disabled
No chrome.sockets - Chrome Socket disabled
serial_audio: Audio Sample rate : 44100
serial_audio: Audio Serial Baud 9600 Bit time 4.59375
WebSocket relay support enabled - running in web browser
WebSocket localhost support (EspruinoHost) enabled - running in web browser
serial_frame: Running in a frame - enabling frame messaging
No chrome.storage API - disabling Offline mode
Initialising SettingsConsole
Initialising Utils
Initialising Config
Initialising Notifications
Initialising Status
Initialising App
Initialising File
Initialising Code
Initialising Serial- Initialising Serial Web Audio
- Initialising Serial Web Bluetooth
- Initialising Serial Websocket Relay
- Initialising Serial Websocket to EspruinoHost
- Initialising Serial window.postMessage
Initialising SerialWebSocketRelay
Initialising SerialWebSocketLocal
Initialising Terminal
Initialising CodeWriter
Initialising Modules
Initialising Env
Initialising Flasher
Initialising EditorBlockly
Initialising EditorJavaScript
Initialising Send
Initialising MenuPortSelector
Initialising MenuSettings
Initialising MenuFlasher
Initialising SettingsAbout
Initialising SettingsFlasher
Initialising BoardJSON
Initialising VersionChecker
Initialising Compiler
Initialising Assembler
Initialising GetGitHub
Initialising Unicode
Initialising Minify
Initialising SaveOnSend
Initialising SetTime
Initialising Tutorial
Initialising Webcam
Initialising FontSize
Initialising UiMode
Initialising URLHandler
Initialising CodeLink
Initialising Project
Initialising Testing
Initialising Notification_Sound
Initialising Tern
Initialising Debugger
Initialising Tour
Initialising HelpLinks
Initialising Arrows
No code in storage.
Handling URL "https://www.espruino.com/ide/"
serviceworker> active
No navigator.bluetooth - Web Bluetooth not enabled
Couldn't connect to wss://localhost:31234 - disabling websockets for this session
ERROR: serial_frame: getPorts timeout, disabling
ERROR: getURL("/serial/ports") error : Not Found
/serial/ports doesn't exist - disabling WebSocket support
- Initialising Serial Web Audio
Gordon, thanks for your incredible support. I am now looking at BLE coding on RPI to pick up the adverts. I hope you might help me in that area once I get over there.
.net / asp.net / sql server etc dev. This \IOT js dev is a new area for me and its taking a bit to get my head around it.