-
-
Thank you Gordon. I have the following code:
function Timer() { [... some more code ...] setTimeout(Timer, 60000); E.kickWatchdog(); } E.enableWatchdog(10, false); setTimeout(Timer, 60000);
This is supposed to run some code once per minute.
But the dog seems to never let it happen this way ... do I need to set the watchdog's timeout higher than my code timeout? The timeout function is not considered "idle" by the watchdog so I need to add this to the time I want to let the code do its thing? -
-
I have a puck running a simple script that is set to advertise every 2000 ms. There is a timeout set that checks battery every 10 minutes, attaches the value to the name of the device so I can see the status of puck's battery by using a BLE scanner on my phone.
I am not sure why but sometimes (after days) the advertising string doesn't change anymore (or keeps being empty), puck is still advertising, but the script is obviously not working anymore.
I believe this is because of some script error that breaks the 10 minutes routine.
So I would like to put the code in some "try-catch" loop that restarts the whole thing in case something odd happens. How to?
Thank you! -
Thanks, makes no difference unfortunately ... this is what the list looks like (filter set to 4C):
[ BluetoothDevice: { "id": "68:8e:9f:41:ed:04 private-resolvable", "rssi": -85, "data": new Uint8Array([2, 1, 26, 2, 10, 12, 12, 255, 76, 0, 16, 7, 61, 31, 172, 239, 186, 118, 120]).buffer, "manufacturer": 76, "manufacturerData": new Uint8Array([16, 7, 61, 31, 172, 239, 186, 118, 120]).buffer }, BluetoothDevice: { "id": "55:9d:8f:7b:45:a1 private-resolvable", "rssi": -62, "data": new Uint8Array([2, 1, 26, 26, 255, 76, 0, 12, 14, 8, 3, 143, 238, 224, 193, 184, 184, 230, 42, 244, 112, 20, 89, 16, 5, 75, 28, 13, 209, 32]).buffer, "manufacturer": 76, "manufacturerData": new Uint8Array([12, 14, 8, 3, 143, 238, 224, 193, 184, 184, 230, 42, 244, 112, 20, 89, 16, 5, 75, 28, 13, 209, 32]).buffer }, BluetoothDevice: { "id": "31:7e:10:d1:55:67 private-nonresolvable", "rssi": -45, "data": new Uint8Array([2, 1, 26, 11, 255, 76, 0, 9, 6, 3, 58, 192, 168, 20, 104]).buffer, "manufacturer": 76, "manufacturerData": new Uint8Array([9, 6, 3, 58, 192, 168, 20, 104]).buffer }, BluetoothDevice: { "id": "36:c2:b6:c2:32:23 private-nonresolvable", "rssi": -90, "data": new Uint8Array([2, 1, 26, 11, 255, 76, 0, 9, 6, 3, 5, 192, 168, 1, 47]).buffer, "manufacturer": 76, "manufacturerData": new Uint8Array([9, 6, 3, 5, 192, 168, 1, 47]).buffer }, BluetoothDevice: { "id": "54:24:6f:a9:f3:a0 private-resolvable", "rssi": -49, "data": new Uint8Array([2, 1, 26, 2, 10, 12, 10, 255, 76, 0, 16, 5, 71, 28, 200, 62, 162]).buffer, "manufacturer": 76, "manufacturerData": new Uint8Array([16, 5, 71, 28, 200, 62, 162]).buffer }, BluetoothDevice: { "id": "73:c9:92:18:1f:b6 private-resolvable", "rssi": -28, "data": new Uint8Array([2, 1, 26, 2, 10, 7, 11, 255, 76, 0, 16, 6, 87, 30, 133, 239, 171, 122]).buffer, "manufacturer": 76, "manufacturerData": new Uint8Array([16, 6, 87, 30, 133, 239, 171, 122]).buffer }, BluetoothDevice: { "id": "e5:a2:61:4d:88:81 random", "rssi": -28, "data": new Uint8Array([7, 255, 76, 0, 18, 2, 0, 3]).buffer, "manufacturer": 76, "manufacturerData": new Uint8Array([18, 2, 0, 3]).buffer }, BluetoothDevice: { "id": "74:be:34:49:3d:37 private-resolvable", "rssi": -28, "data": new Uint8Array([2, 1, 26, 13, 255, 76, 0, 22, 8, 0, 143, 10, 199, 38, 46, 176, 112]).buffer, "manufacturer": 76, "manufacturerData": new Uint8Array([22, 8, 0, 143, 10, 199, 38, 46, 176, 112]).buffer }, BluetoothDevice: { "id": "c4:b1:75:d5:55:41 random", "rssi": -47, "data": new Uint8Array([30, 255, 76, 0, 18, 25, 32, 249, 117, 54, 221, 67, 90, 101, 94, 4, 49, 34, 203, 36, 161, 116, 116, 86, 147, 200, 222, 188, 59, 1, 65]).buffer, "manufacturer": 76, "manufacturerData": new Uint8Array([18, 25, 32, 249, 117, 54, 221, 67, 90, 101, 94, 4, 49, 34, 203, 36, 161, 116, 116, 86, 147, 200, 222, 188, 59, 1, 65]).buffer }, BluetoothDevice: { "id": "de:c3:1d:ad:f1:ed random", "rssi": -47, "data": new Uint8Array([7, 255, 76, 0, 18, 2, 36, 0]).buffer, "manufacturer": 76, "manufacturerData": new Uint8Array([18, 2, 36, 0]).buffer }, BluetoothDevice: { "id": "f4:36:f6:2b:1d:7b random", "rssi": -56, "data": new Uint8Array([7, 255, 76, 0, 18, 2, 0, 3]).buffer, "manufacturer": 76, "manufacturerData": new Uint8Array([18, 2, 0, 3]).buffer }, BluetoothDevice: { "id": "6d:8f:cd:d6:fb:9f private-resolvable", "rssi": -88, "data": new Uint8Array([2, 1, 26, 2, 10, 4, 11, 255, 76, 0, 16, 6, 77, 29, 159, 243, 222, 40]).buffer, "manufacturer": 76, "manufacturerData": new Uint8Array([16, 6, 77, 29, 159, 243, 222, 40]).buffer }, BluetoothDevice: { "id": "fe:ab:ab:74:da:31 random", "rssi": -85, "data": new Uint8Array([7, 255, 76, 0, 18, 2, 0, 0]).buffer, "manufacturer": 76, "manufacturerData": new Uint8Array([18, 2, 0, 0]).buffer }, BluetoothDevice: { "id": "48:f0:f4:6b:28:58 private-resolvable", "rssi": -85, "data": new Uint8Array([2, 1, 26, 13, 255, 76, 0, 22, 8, 0, 129, 159, 50, 7, 139, 249, 66]).buffer, "manufacturer": 76, "manufacturerData": new Uint8Array([22, 8, 0, 129, 159, 50, 7, 139, 249, 66]).buffer } ]
How come there is no "name" at all?
-
Hehe, after some more trying it works ... the IDE is sometimes a bit "unruly" ... thank you @fanoush!
-
Hi again,
I want my puck to wait a little longer before going into code that changes its name and advertising behaviour. But want it to wait only if a certain device is around (e.g. my iPhone).
So I tried to do a scan or a request ... but this never returns ANY names of the devices, even with higher timeouts and "active" being true?!
"namePrefix" does not make a difference when using findDevices – it just lists all, regardless of what I set. "namePrefix" does the opposite when using requestDevice – it never finds any, even if I just set one letter. Yes, I can see plenty of devices around using nRF-Connect including the ones I want the Puck to find.
This is what I have tried:NRF.findDevices(function(devices) { console.log(devices);}, {timeout : 5000, active : true, filters : [{ manufacturerData:{0x004c:{}} }] });
--> puts out a rather large list, but without names
NRF.findDevices(function(devices) { console.log(devices);}, {timeout : 5000, active : true, filter : [{ namePrefix: 'S' }] });
--> shows the same full list without names, although only two devices would fit.
NRF.requestDevice({timeout : 5000, active : true, filters : [{ namePrefix: 'S' }] });
--> times out without any result
I have tried setting timeout to 10 or even 30 seconds – no difference. I must be doing something fundamentally wrong. Please advise.
-
Understand ... and I have tried to do so:
I can see it starting up, advertising as Espruino, let's me choose to connect via IDE, tries to, says "Connected to BLE" but does not finish let alone me programming it / uploading new code. It just hangs there until the timeout comes and executes my "old code" ... which sets a new name, non-connectable etc.
Am I missing something?
Shall I set advertising to something specific to make it "more willing" to connect before the timeout runs my other code?
And if the connecting works, will it stop the timeout or will I have to upload before to avoid further execution? -
Hi,
I know it is not official: I have the E73 from Ebyte flashed with Espruino successfully, it works like a charme.
When I load my code via IDE to RAM, I can easily get back by disconnecting power so the device gets into bootloader (I believe) waiting to get new code.
The code makes the device non-connectable on purpose. So when I save() it to "Flash" changing the code needs a reset.
Now I am having big trouble resetting it by applying power or GND to a specific pin (E73 datasheet says RST is pin 26 which corresponds to P0.18 of nRF52840). Whenever I do this I can see the device advertising as Espruino but just for a few (milli)seconds ... it quickly "falls back" and executes my old code instead. Or I am doing something wrong / not long enough / whatever.
But even if this would work, resetting the device by fiddling with a specific PIN is a real pain, especially if it is already built in somewhere.
Long talk short question: can I instead code it so when powered up to stay in "waiting for IDE connection" for maybe 10 seconds after that it goes on switching to not-connectable and continues with whatever it is used for? So every time I power it up, I get a chance to upload new code?
Maybe this is super easy I have just not found how to do it?
Any help is appreciated. -
Although it seems to work okay, I may have indeed screwed something ... I surely once mixed +/- and I have fiddled around with the Puck quite a lot (bought it in 2021 I believe). I'll buy another one and try more. However, I have seen that taking the average of three measurements comes very close to what the battery actually has. Still need to check lower voltages though. Actually, I only need to know when battery is close to its lower limit to know when to charge.
Someone I talked to about the measurements asked me "how do you use the ADC? Any voltage divider resistors, filter capacitors?" ... guess Puck does not?
-
-
-
-
Strange. I have tested different batteries now including the original CR2032, which shows correct values! The LFP batteries I use have over-& undervoltage protection AND they have a small circuit connected for charging. The circuit output is connected directly to the battery and therefor to the puck as well. This one is supposed to be "doing something" only when a charging cable is connected but seems to interfere nevertheless. Need to think how I can prevent it from doing so.
-
-
Thank you Gordon,
when I use a single E.getAnalogVRef() it returns a much to high value (measured 332 with multimeter). But when I add multiple values and check average, it gets lower the more I use, e.g.:
E.getAnalogVRef() = 382 ( E.getAnalogVRef() + E.getAnalogVRef() + E.getAnalogVRef() ) / 3 = 274 ( E.getAnalogVRef() + E.getAnalogVRef() + E.getAnalogVRef() + E.getAnalogVRef() + E.getAnalogVRef() + E.getAnalogVRef() + E.getAnalogVRef() + E.getAnalogVRef() + E.getAnalogVRef() + E.getAnalogVRef()) / 10 = 236
How come? Shall I make a delay between?
-
Another question ... I'll put it here because it has similar subject.
I have attached a LFP cell (3.2v nominal voltage), working great for weeks now.
Now I need to check battery status regularly but I am having trouble with the results.When using NRF.getBattery() the result differs everytime in such ranges that make it hard to consider them real. So I have tried checking multiple times and using the average like this (found it somewhere here in a post):
(analogRead(D3)+analogRead(D3)+analogRead(D3)+analogRead(D3)+analogRead(D3)+analogRead(D3)+analogRead(D3)+analogRead(D3)+analogRead(D3)+analogRead(D3))/10*72
However, this results in values much to high most of the time. What would be the right calculation to get a decent value for LFP cells?
Any hint is appreciated. -
-
Me again ... I am trying to add some services to let my puck look like an AirTag, without actually implementing the function behind them. I have set one like this:
NRF.setServices(undefined, {uart:false, advertise: ['7dfc9000-7d1c-4951-86aa-8d9728f8d66c']});
Works okay, the UUID gets displayed when I scan around. But I probably need to add three more and tried this:
NRF.setServices(undefined, {uart:false, advertise: ["7dfc9000-7d1c-4951-86aa-8d9728f8d66c","7dfc8000-7d1c-4951-86aa-8d9728f8d66c","7dfc7000-7d1c-4951-86aa-8d9728f8d66c","7dfc6000-7d1c-4951-86aa-8d9728f8d66c"]});
This doesn't seem to work, the device will not show up anymore ... what am I doing wrong?
I am also setting a custom advertisement, maybe these collide??
const adv = [ 0x1e, 0xff, 0x4c, 0x00, 0x12, 0x19, 0x08, key[6], key[7], key[8], key[9], key[10], key[11], key[12], key[13], key[14], key[15], key[16], key[17], key[18], key[19], key[20], key[21], key[22], key[23], key[24], key[25], key[26], key[27], key[0] >> 6, key[5]]; NRF.setAdvertising([adv, {}],{interval:1000,name:ble_name,showName:true,discoverable:true,connectable:true,scannable:true});
-
Thank you @Gordon: works!
-
I am using a puck.js to advertise like an AirTag working good:
NRF.setAdvertising([adv, {}],{interval:1500,name:ble_name,showName:true,discoverable:true,connectable:false,scannable:true});
Somehow it also "offers" the service "Nordic UART", although it is not connectable and I also do not use DFU. I have tried to disable this by adding "uart:false" to the options list – no change.
How can I disable NUS? -
Ok, I have now edited build.yml at Github, added NRF52840DK and removed all other boards.
I have also made changes to NRF52840DK.py like @fanoush advised.
And run the build action, I don't know if anyone else can see this, but it has built a espruino_2v19.119_nrf52840.hex now. :-)
First thing I have noticed: it loads MUCH faster via IDE than the older hex I have tried.
Thanks again! -
-
So I have flashed two of my devices using STLink and the binary of Bangle using openocd. It looked good, program verify ... but after reconnecting power they both don't advertise. Unfortunately openocd is now unable to connect to them to re-flash them with a working firmware. Guess I have killed both.
I have given up on trying this, simply wasn't reliable enough.