-
-
I've found the python3 example code by now -but somehow this does not work on my pi:
pi@millow:~ $ python3 bluepi_uart.py c4:f0:3e:4d:c2:9d Traceback (most recent call last): File "bluepi_uart.py", line 34, in <module> nustx.write(command[0:20]); File "/home/pi/.local/lib/python3.5/site-packages/bluepy/btle.py", line 200, in write return self.peripheral.writeCharacteristic(self.valHandle, val, withResponse) File "/home/pi/.local/lib/python3.5/site-packages/bluepy/btle.py", line 542, in writeCharacteristic self._writeCmd("%s %X %s\n" % (cmd, handle, binascii.b2a_hex(val).decode('utf-8'))) TypeError: a bytes-like object is required, not 'str'
This is on a pi with python 3.5, bluepi itself seems to work and run. Also I would like to use python3 - but I am really not an expert here. Any ideas?
-
-
Hi @Gordon, I've not set "automatic sampling" - to be honest I've got no idea. Can you point me to some sample code somewhere?
-
So, got the latest results for my free-fall trials. It's working, but it's a tiny bit strange. The behavior is like this:
I let the puck with ADXL345 fall for like 1.5 meters or so
IF I pick it up soon thereafter, I get the Free Fall event
IF I let it be, pick it up after some seconds, nothing is triggered.To me it looks like the interrupts are only activated once new accelerometer data is received. Would that make somehow sense? Below is the latest code for reference.
var i2c = new I2C(); i2c.setup({sda:D1, scl:D2}); var accel = require("ADXL345").connect(i2c,D31); accel.ff(600,10); accel.interrupts(4,0); //INT1 accel.measure(true); setWatch(function() { console.log("Free Fall"); }, D30, {edge:"rising", debounce:250, repeat:true}); setWatch(function() { console.log("BTN"); }, BTN, {edge:"rising", debounce:50, repeat:true});
-
-
Thx for the thoughts, you're right that probably the accelerometer is the best choice of course. ADXL345 has free fall detection, I am currently investigating this. The problem is that the puck is such a nice package, even a lanyard can be attached. Now the extra cables for the accelerometer will require new 3d printing for another case, etc.
-
-
I have connected puck to an external ADXL345 accelerometer and reading the values XYZ works just fine. I am now trying to detect a free fall, which seems a bit more complicated.
INT1 is connected to D30, but is never triggered. I assume my accel.interrupts call is wrong, but I cannot figure it out how to enable it correctly.
Anyone?
var i2c = new I2C(); i2c.setup({sda:D1, scl:D2}); var accel = require("ADXL345").connect(i2c,D31); accel.ff(300,25); accel.measure(true); accel.read(); accel.ff(600,10); accel.interrupts(2,0); //INT1 setWatch(function() { console.log("Free Fall"); }, D30, {edge:"rising", debounce:10, repeat:true});
-
-
Hi all,
I've now setup a rpi3 with EspruinoHub. Instead of using the minimal raspbian image as before, I chose the full image and pretty much followed all instructions. Instead of installing node the way it is described in the tutorial, I went with the node version mananger, which worked very nicely. Now the issues:
- if there is no puck in reach or no ble devices, the hub will stop after a few seconds. What is the reason for this? I can well imagine that sometimes no devices are in reach, I would want the hub to stay active all the time and wait for a device to appear.
I've used the sample code given in the tutorial, but I get some issues:
NRF.requestDevice({ filters: [{ services: ['1823'] }] }).then(function(device) { require("ble_http").httpRequest(device, "pur3.co.uk/hello.txt", function(d) { print("GET:",JSON.stringify(d)); }); });
Once I connect to my (whitelisted) puck and upload the code with the Espruino IDE, I get this:
| __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v91 Copyright 2016 G.Williams > =undefined Connected Uncaught Error: Unhandled promise rejection: Disconnected. >
In the EspruinoHub console, I see that a device connected, but after this short intermezzo and no other significant error message (almost nothing, I see that my puck got scanned and it's RSSI), the hub then also terminates. Any idea?
- if there is no puck in reach or no ble devices, the hub will stop after a few seconds. What is the reason for this? I can well imagine that sometimes no devices are in reach, I would want the hub to stay active all the time and wait for a device to appear.
-
I've successfully recorded some IR commands and played them back via Puck.IR, but I need to hold the Puck very closely to the receiver. Is there a way to increase the reach of the IR LED?
If not, what is the recommended way yo create a multi IR-LED panel with increased power/reach? I would like to send the same signal via multiple IR leds, if possible in each direction (like a roudn panel and every few degrees a new IR LED). Has someone done this before?
-
-
Hi @Gordon, I might reverse the logice based on the feedback received, but the idea was to scan for the strongest beacon every minute or so. The code that does this is fairly simple and worked fine in a simple test. see below.
In this scenario, an home for elderly or our setup for an event, we're effectively able to control the BLE devices in the environment. So per section that I want to have a location reported, I would place one beacon right now. But again, maybe I am just turning this around, I need to think about it. In the end it needs to be fairly simple to setup and demonstrate, I might still have tendency to go with the scanning on the puck directly.
setInterval(function() { NRF.findDevices(function(devices) { var nearestDevice = null; devices.forEach(function(device) { if (nearestDevice === null) { nearestDevice = device; } else if (device.rssi > nearestDevice.rssi) { nearestDevice = device; } }); if (nearestDevice) { console.log(nearestDevice.id, nearestDevice.name, nearestDevice.rssi); } }, 2000); }, 5000);
@Gordon do you have a recommendation for the accelerometer that I need to connect as well as for doing free-fall detection?
-
-
thx for pointing that out, I am thinking of adding one. Is there an accelerometer that you would recommend based on great APIs that are available on espruino? I think these adxl accelerometers are cheap, but of course even the smallest board adds to the overall size. But this is where the 3d files come in handy, as I can design a bigger enclosure with the same fitting puck in the middle for example.
so, wiht an accelerometer - I would every few ms check for the gravity and if that dramatically decreases, your either in an elevator or falling... any ideas?
-
OK, it's really a bit weird. Things first started working again, but then again did not. I've now written some small interval that changes the URL every 5 seconds, I was able to get the first url transferred to my mobile via NFC, but then nothing else worked. But I still see the log outputs in the espruine web console.
var url = "https://api.yaas.io/bullseye/"; var counter = 0; setInterval(function() { NRF.nfcURL(url + counter++); console.log(url + counter); }, 5000);
-
I also just looked into NFC and I had similar observations as @trezm. I configured a NFC url, which worked fine the first time, but then even after closing my android devices browser or using a totally different device, it did not work any more. What works is taking out the battery and configuring the url again.
I assume the NRF.nfcURL() is not one-shot, eg. it does not clear itself after it has been used. I have the latest firmware 1.91 btw.
thx
Sven -
Hi Gordon & Community,
I am currently looking into a eHealth prototype using the puck. The idea is that elderly people wear the puck as akind of necklace and it can be used for things like:
- via BLE beacon scanning, we roughly know where the person is
- it detects a person falling via the accelerometer
- it detects a person having an issue if has not been moving for a certain time
- pressing the puck once will call for assistance
- double-pressing will call for immediate help
- if care is taken of a patient, the caretaker will scan the puck via an NFC smartphone to record the care actions
This is also the reason I am looking into the http proxy with EspruinoHub. I want puck to scan for ble beacons every few seconds, then the closest beacon should be reported to an HTTP api. The same for button presses or the fall detection.
This is very early, we're just beginnging to look into it. From a technical point of view, I think it is very much possible. Could I get some comments and ideas from @Gordon and the rest of the community?
- via BLE beacon scanning, we roughly know where the person is
-
Hi all,
I am looking into EspruinoHub to get some basic HTTP capabilities with Puck explored. I used the minimal raspbian image and then initially had some issues with the node installation - but I managed using the nodesource installation guide. doing a sudo apt-get install node basically did not work for me, it installed but node was not available in the end.
I am trying to understand why node-red and mqtt are part of the installation guide. All I need is HTTP features, .e.g. I want to use http from the puck.js js code. Is there a recommendation when it comes to setting up a headless version of the EspruinoHub?
Thx
Sven -
-
@Gordon would you consider a kickstarter? MicroPython just did it and I am sure many here would give a few dollars to support an even better implementation. I'd love see that!
-
Thx so much @user65089, @DrAzzy and @Gordon. I've changed to baudrate to 115200, something I've done naturally with other apps like Serial Term (Chrome OS). I think it belongs mentioned in red letters in the esp8266 espruino docs somewhere! Now all is fine.
I'd have one more generic question(s): what is the current state of the build & will it be officially supported in the future, too? Are all the basics working (PINs, PWN, libraries?)...
I am mainly looking for a dirt cheap dev board for school workshops. That's why I've bought the esp8266 based WeMo boards. With the help of Espruino I can now use the kick-ass Chrome OS based Web IDE for teaching javascript. The espruini Web IDE is really core, I cannot mention it more. The kids at school all have Chrome OS based laptops, they are cheaper and maintenance/admin is not such a hazzle.
Thx!
Sven -
Thx @DrAzzy for the direct link. It would be great if these files would soon be under a link like latest_esp8266.zip :-) I am flashing the build in a moment. It would be amazing to get the espruino web ide and with a wemo esp8266 to work. It would be a $2.5 dev board, perfect for schools and kids. thx for your help!
Hi Gordon,
that's the code I used - initially. I added some () for the prints to make them python3 compatible, the version I have on the pi is 3.5 (not the latest, also complicated, as string substitution with these fStrings - yeah - is not possible for example...).
I'll give the python3 recommendations a try back in the office (wed), for now I tried to go with useing node.js - to start with I wanted to use my macbook with mojave. So the whole noble lib seems a mess - as the docs suggest I went with noble-mac now.
Interestingly, I was able to use my new pixl.js with the example - the code example found the device, connected, sent the command and disconnected. I did need to switch from : to - in the device address -somehow the devices addresses have - for me...
Now at home tried it with a puck, latest version.
All I changed in my code, see below, is the device address. I connected via the web ide, NRF.getAddress() and replace the : with - so the device is found.
Really the same code (https://www.espruino.com/Interfacing#node-js) except the address line changed to:
var ADDRESS = "ef:22:d8:d6:2e:71".replace(/:/g, "-");
BTW find it super amazing that the browser with web bluetooth now seems to be the most stable BLE api you can find out there :-)