-
-
-
-
Ok so here our resting voltage is 0v, and with the pullup set, we're getting 1v - 2.5v.
Espruino says:
0.00585946440
0.00585946440
0.00585946440
0.00585946440
0.00585946440
0.00585946440
0.00585946440
0.00585946440
0.00585946440
0.00585946440
0.00585946440
0.00585946440
0.00585946440
0.00585946440
0.00585946440when using
analogRead(A5)
I've gotta be doing something stupid here...
-
-
-
I got the guys in the shop to look at it with an oscilloscope, there is definitely voltage on the line, with about 1.5v swing.
analogRead
without pinMode set (i.e after a reboot):setInterval(function () { console.log(analogRead(A5)); }, 1000);
=1
0.39795529106
0.28686961165
0.27002365148
0.42871747920
0.01000991836
0.13598840314
0.16748302433
0
0
0
0 -
@Gordon hmm, I've tried setting the pinMode but I'm not getting any response out of setWatch. I've used various tone generators but nothing ever seems to trigger.
setWatch(function(e) { console.log(e.time-e.lastTime); }, A5, { repeat:true, edge:'falling' });
I'm relatively sure my circuit is right, can you think of anything I might be missing?
-
@Gordon just realised I can't really use audio-to-serial directly as my WiFi pins for USART are taken up with something else.
I see there is code for going from audio-to-serial https://espruino.github.io/EspruinoOrion/serial_to_audio.js, do you have anything for using the ADC pins and
analogRead
to get data out of an audio signal? -
-
Well, amusingly, my prints are actually throttled, I just didn't want to overcomplicate the code
function throttle(func, wait, options) { var context, args, result; var timeout = null; var previous = 0; if (!options) options = {}; var later = function() { previous = options.leading === false ? 0 : Date.now(); timeout = null; result = func.apply(context, args); if (!timeout) context = args = null; }; return function() { var now = Date.now(); if (!previous && options.leading === false) previous = now; var remaining = wait - (now - previous); context = this; args = arguments; if (remaining <= 0 || remaining > wait) { if (timeout) { clearTimeout(timeout); timeout = null; } previous = now; result = func.apply(context, args); if (!timeout) context = args = null; } else if (!timeout && options.trailing !== false) { timeout = setTimeout(later, remaining); } return result; }; } function printDeviceData(device) { try { Bluetooth.println(JSON.stringify(device)); } catch (err) {} } function getDevices() { const throttledPrint = throttle(printDeviceData, 1000); NRF.setScan(function(device) { if (device.name && device.name.indexOf('Puck.js') >= 0) { const data = device.data.toString().substr(-1); if (!devices[device.name]) { devices[device.name] = { name: device.name, rssi: device.rssi, data: data, }; } const oldDevice = devices[device.name]; if (device.rssi !== oldDevice.rssi) { devices[device.name].rssi = device.rssi; throttledPrint(devices[device.name]); } } }); }
-
-
Simplified version is:
var devices = {}; NRF.setScan(function(device) { if (device.name && device.name.indexOf(‘Puck.js’) >= 0) { const data = device.data.toString().substr(-1); if (!devices[device.name]) { devices[device.name] = { name: device.name, rssi: device.rssi, data: data, }; } const oldDevice = devices[device.name]; if (device.rssi !== oldDevice.rssi) { devices[device.name].rssi = device.rssi; Bluetooth.println(JSON.stringify(device)); } } });
Is that receiving advertising packets from a single Puck or having many advertising at the same time?
-
-
-
Well, whaddaya know, you've already done what I was gonna do:
http://www.espruino.com/Headphone
this will work fine :D
-
Probably another of my edge cases, but if I have an Interval set in my code of about 100ms or so, and then try to upload new code to my Espruino WiFi I can quite often get the Espruino and the IDE stuck, the upload progress bar is about 1/16th in, the Espruino is otherwise unresponsive and I have to unplug and replug.
However if I connect, run
reset()
and then upload new code, everything works.Could the code upload function run
reset()
by itself? Or otherwise interrupt the running program before it tries to upload? -
-
I don't understand the RSSI readings I get on the Pucks... I get a better signal from a Puck 2 meters away than the one 1 meter away...
I'm the grey splodge, the blue Puck is 2 meters away, the red puck is 1 meter away, yet the blue puck gives me consistently better RSSI readings. I know there should be some variance but this seems way out of whack.
-
@Gordon this seems to get worse the more beacons I have online. With 1 beacon the problem barely ever happens, with 3 its every few seconds.
Just wondering if https://www.espruino.com/Reference#t_l_NRF_setAdvertising calls some code on the NRF and the 'interval' setting is then sufficiently randomised by the NRF? i.e if I set interval to 100, the actual intervals are +- 10ms of 100? Or do I need to be including the randomness required for the advertisements to not conflict?
https://devzone.nordicsemi.com/question/22684/random-delay/?answer=22917#post-id-22917
-
@Gordon more interesting behaviour. I have the following code running:
function getDevices() { LED1.set(); NRF.findDevices(function(foundDevices) { LED1.reset(); foundDevices.forEach(function (device) { if (device.name && device.name.indexOf('Puck.js') >= 0) { const data = device.data.toString(); Bluetooth.println(JSON.stringify({ name: device.name, rssi: device.rssi, data: data, })); } }); }, 250); } setInterval(getDevices, 2000);
This can run fine for ages, but sometimes I get the edge case where the LED remains on (so NRF.findDevices is never returning), which requires me to reset the device as it is no longer discoverable via the IDE.
Equally, if I am connected to the device via the IDE and then disconnect, about 25% of the time the device gets stuck, either with the LED on or off.
Any idea what might be going on?
-
-
-
Bummer didn't realise it would be so difficult I assumed it was basically just setting https://wicg.github.io/webusb/#webusb-platform-capability-descriptor and away we go.
My use case was not to use it for flashing code to the board but rather being able to connect to the Espruino though a web-ui in Chrome and be able to update files on the SD card. This would let me have someone configure the Espruino WiFi with their WiFi credentials via a web-app and then send this info into the Espruino.
@Gordon I'm getting fairly reliable readings now.
I guess my next question is how do I generate sounds of varying length. Out of my depth here I think.
I thought that this would generate 0.5seconds of...something, and then 0.5 seconds of silence, but I just get a click