Most recent activity
-
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.
pro:pixltests i511648$ node puckjs.js Noble: stateChange -> poweredOn Found device: 80-82-23-2d-de-d5 Found device: 80-82-23-2d-de-d5 Found device: ef-22-d8-d6-2e-71 BT> Connecting Found device: ef-22-d8-d6-2e-71 BT> Connecting BT> Connected BT> Connected
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 :-)
-
-
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?
-
- 4 comments
- 3,370 views
-
- 10 comments
- 6,753 views
-
-
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});
Working on stuff that matters.