-
Thanks for your help Gordon. This is a nice little example to do with the puck by itself.
For anyone else, finished code to be used along with the adafruit bluefruit app is below.NRF.on('connect', function(addr) { LoopbackA.setConsole(); }); setWatch(function() { Bluetooth.setConsole(); }, BTN, {repeat:true, edge:"rising", debounce:50}); Bluetooth.on('data', function(d) { if (d[0]=="!" && d[1]=="B") { var b = d.substr(2,2); if (b[0]=="1") LED1.write(0|b[1]); if (b[0]=="2") LED2.write(0|b[1]); if (b[0]=="3") LED3.write(0|b[1]); if (b[0]=="4") digitalWrite([LED1, LED2, LED3], b[1]*7); } });
Just remeber to press the btn on the puck if you want to send some new code to the puck
-
How can I detect once a connection has estabilished then run a
LoopbackA.setConsole()
.
I thinking it should automatically switch to LoopbackA.setConsole() then press the button on the puck to return to Bluetooth.setConsole(). I tried the following but it didn't work and I'm assuming it has something to do with switching toLoopbackA.setConsole()
before a Bluetooth connection has been established.LoopbackA.setConsole(1); setWatch(function() { Bluetooth.setConsole(); }, BTN, {repeat:true, edge:"rising", debounce:50}); Bluetooth.on('data', function(d) { if (d[0]=="!" && d[1]=="B") { var b = d.substr(2,2); if (b[0]=="1") LED1.write(0|b[1]); if (b[0]=="2") LED2.write(0|b[1]); if (b[0]=="3") LED3.write(0|b[1]); } });
-
I get it now thanks @Gordon and sorry @Wilberforce you were correct.
Gordon you're correct, copy and pasting does allow it to be sent as one packet. -
-
Excellent explanation! Thank you for explaining the LoopBack to me, I was really scratching my head over how to stop the JS interpreter intercepting incoming data.
It works really well with the app, however, I tried to use the WebIDE to pass a command string instead of using the app.
When I press the button on the puck to activate the LoopBackA the WebIDE console locks up, the console logs-> LookbackA
then it does not let me type anymore. -
The adafruit Bluefruit has a control pad the sends strings such as:
!B41CRC
I want to parse this into its component parts such as:[‘!’] [‘B’] [‘4’] [‘1’] [CRC]
I think I can do this, but I don't know how to set a watch event that actually parses the string once it's received.
It is not like the bluefruit app calls a functionparse(!B41CRC)
. How do I watch for incoming data then do something with it? -
@Gordon, in CPU monitor tutorial you use the following batch file.
@echo off :start (@for /f "skip=1" %%p in ('wmic cpu get loadpercentage') do (@echo draw^(%%p^) > \\.\COM32)) @timeout 1 > nul goto start
How can I change the com port to access a puck?
I know the full Bluetooth device instance ID is:
BTHLE\Dev_ff445c88d44e\7&3208b348&0&ff445c88d44e
The native web IDE displays it asff:44:5c:88:d4:4e
-
Yes, it's crazy. To be honest, I should know better than to run something admin hasn't installed, but hey.
Have you ever considered creating a package/wrapper for use with the Atom editor? I use Atom as my default editor, it would be amazing to be able to send commands from there. I would imagine it would be fairly easy for you considering it's built using Node.js -
-
ahh. I was using the IDE from the Chrome webstore. When I was reading about issues with the IDE on Chrome via Web Bluetooth I thought it meant this IDE https://www.espruino.com/ide/.
I cannot install things to the PC because of admin privileges. can the 'native IDE' be run portably? -
So I've read through as many posts as I could before asking this but I cannot connect via windows 10.
1) I have paired with the puck, then tried using the web IDE to connect but it states "No ports found".
2) I have paired with the puck then tried to establish a com connection in windows but the device does not appear.
3) I have used the nrfToolbox app and reflashed the firmware to version espruino_1v92_puckjs.zip and tried again.
I am not using a Bluetooth dongle, I am using the built-in Bluetooth 4.2.
I am able to communicate with the puck via the nrf and adafruit apps.
Am I missing a step? -
Sorry about that, I was looking for it in here http://www.espruino.com/Reference#Puck
-
@Gordon
The Puck.js page says it has a built in thermometer. Is there a method for reading the temperature? -
-
-
I was using the Chrome App and not the Web IDE or Web Bluetooth.
It's a Samsung Chromebook 303C. I did try shutting down the Chromebook and rebooting so I would hope that would sever the connection completely on the laptop side.
I hadn't been trying to connect any other device to the Puck, solely just the Chromebook.
I did have a dongle for a wireless keyboard plugged in, but I unplugged that and the problem still persists.The signal wasn't easily blocked but it can be done if you really try.
What should do the puck do if it loses the connection? Should it default back to discoverable?
-
Review
I received my Puck a few days ago, it's a great product. I'm really impressed by the quality of both the PCB and the plastic/silicone case. The assembly fits together really well.I got started really quickly as described in your Puck-Js unboxing video. I've run through the basics, your puck2.html example, Puck.mag() and Puck.light(). Everything was quick and easy as advertised.
Problem
I have hit one snag as a result of playing with Puck.light() (not directly related to that function though). While trying to block the light to the sensor I must have blocked the signal because I lost the connection. Once the signal was re-established I couldn't pair with the device again.I'm using a Chromebook to pair with it, so I disabled/enable the Bluetooth hoping it would reset the connection. I also tried restarting my Chromebook, both attempts were unsuccessful. I could still see the Puck in the device list but it just wouldn't pair.
Eventually, I removed the battery from the Puck and all was well again. I repeated the problem several times with the exact same result.
My novice guess would be that once the Puck has paired with a device it will persist with that connection and not timeout or enable another connection. Or is it a problem with my Chromebook?
-
@Gordon So you mentioned the Espruino WiFi on you last Puck.js update.
Is it going to be called that or can you tell me what you are naming the Kickstarter so I can keep an eye out for its launch? -
-
@Jorgen what do I have to search for to find one those displays?
-
@DrAzzy Thank you for the suggestions. I tried both but it still doesn't work. The code i used was
Serial2.setup(9600, { rx: B6, tx : B7 }); var wifi = require("ESP8266WiFi").connect(Serial1, function(err) { if (err) throw err; wifi.reset(function(err) { if (err) throw err; console.log("Connecting to WiFi"); wifi.connect("WiFi_Name","WPA2_Key", function(err) { if (err) throw err; console.log("Connected"); // Now you can do something, like an HTTP request require("http").get("http://www.pur3.co.uk/hello.txt", function(res) { console.log("Response: ",res); res.on('data', function(d) { console.log("--->"+d); }); }); }); }); });
and to be sure I swaps the pins to
Serial2.setup(9600, { rx: B7, tx : B6 });
But I still get an error that reads
echo(0);
ERROR: Pin B7 is not capable of USART RX
Suitable pins are:
A3
=undefined -
@Gordon Can you use any other RX & TX pins on the Pico other than A3 & A2?
I wanted to use pins B6 and B7 but i get an error message saying the pins are not suitable.As a bit of a slightly related side note, why is USART1 RX listed twice on the Pico pinout?
-
I was reading about these x27.168 automotive stepper motor gauges and noticed that adafruit suggests that you may be able to drive directly from a microcontroller (allowing for the appropriate kickback diodes.)
Would anybody know if its possible to do directly from the puck.js?