-
Thanks @Gordon. I can't make the above work, the Eddystone url doesn't show up (the manufacturer data do), and at some point I couldn't connect to the puck, EspruinoHub couldn't see it at all (took the battery out to reset it). The code below worked, not sure if is the best way, but as long as it works, all good :)
NRF.setAdvertising([ NRF.getAdvertisingData({},{manufacturer: 0x0590, manufacturerData:data}), NRF.setScanResponse(require("ble_eddystone").get("goo.gl/B3J0Oc")) ], {interval:1000});
-
What would be the best way to advertise manufacturer data and Eddystone at the same time? I can't figure how to do something like this (obviously not working):
var bUrl = "stackoverflow.com"; // Updated from Node-Red function updateAdv() { var data = [JSON.stringify(Puck.light().toFixed(3) * 1000), Math.round(E.getTemperature())]; console.log(data); NRF.setAdvertising([ {manufacturer: 0x0590, manufacturerData:data}, require("ble_eddystone").advertise(bUrl) ], {interval:1000}); } updateAdv(); setInterval(updateAdv, 5000);
Thanks.
-
@Gordon probably is something related to my system then, not a big deal anyway :)
-
I'm controlling puck through EspruinoHub on Raspberry Pi Zero W, and raspberrypi.local:1888/ide/ on Chrome (on my pc). As I said, it's probably nothing, just mentioned it because it used to take some seconds for the bar to complete (depending on the size of the code), it would fill gradually, while now it goes instantly to full and then disappears.
-
Something I have noticed is that the upload progress bar (right down corner) is almost instant in the new version (0.68.6), while previously it would go more slowly if I remember correctly. I'm just mentioning this because it may reflect some of the problems I'm having when uploading code (>2000 bytes), where I'd get frequent exceptions (even with code that doesn't run while uploading).
Of course this may be related to my code or have something to do with my system, so it's more possible that this is not related to anything, just a thought. I'm controlling puck through Raspberry Pi btw.
-
Hi. Is there a limit to the size of code we can upload on puck? I am having problems uploading 4767 bytes (with minification around 3030 bytes) of code, usually I'd get an "Uncaught SyntaxError: Got ')'expected EOF" or something similar. From what I can tell the code itself it's not at fault, because if I delete some of it (randomly), I can upload it with no issues. I am controlling puck through Raspberry Pi and using the latest firmware and webIDE. Have tried with and without minification(s).
The code is a bit lengthy so I am not posting it, but I can do so if needed. Thanks.
-
-
-
That kit is fine, a little bit expensive though if you are not planning to connect the board on a screen (and the card is 4GB, which can be a problem if you install lot of things). All you need is the bare board and a microUSB->USB cable (same you use to charge the phone) if you are going to connect it to a laptop/PC, or a 5V wall charger if you want to plug it on mains.
I don't know anything about android, but the general idea is that you would advertise temperature and light level of the Puck every 30 minutes, and read those values from Raspberry Pi. That is done by installing and running EspruinoHub on the Pi. Then you use Node-Red, which make it super easy to take those values coming from the Puck and do something with them, for example store them on Firebase and use them from there on your app.
I am struggling myself with all these as I am new to most of it, but EspruinoHub + Node-Red help a lot, once you start using them things will come along.
-
Hi. Some good information that helped me can be found at Puck.js and Node-RED with MQTT. You can use a Raspberry Pi (I am using "Zero W" which has wi-fi and bluetooth, and costs around 10 euro), and send the information you want from Puck to the Pi (and vice-versa).
-
@Gordon thanks a lot for your time. I am using the code on Controlling Bluetooth Lights with Puck.js to control the bulb. Can you please elaborate on how to keep a reference to the characteristic variable. By instant I wanted to say more like having the 2 bulbs turning on/off at the same time
I spent some (newbie) hours with advertising/scanning, couldn't make NRF.setScan() work at all, got some success with NRF.findDevices(), but it takes around 2 seconds to turn on/off the bulb on the scanning Puck2. On Puck1 ('middle') I have this running at some point:
NRF.setAdvertising({},{manufacturer: 0x0590, manufacturerData:[0]}); // Node-Red lights off // or NRF.setAdvertising({},{manufacturer: 0x0590, manufacturerData:[1]}); // Node-Red lights on
On Puck2, I run this code to scan and use manufacturerData:
var lastState = 0; // Scan and call flashLeds() based on 'manufacturerData' setInterval(function () { NRF.findDevices(function(e) { for (var i = 0; i < e.length; i++) { if((e[i].manufacturer === 1424) && (e[i].manufacturerData)) { // Check for 0x590 and manufacturerData if(e[i].manufacturerData[0] !== lastState) { // Check to see if the state has changed lastState = e[i].manufacturerData[0]; flashLeds(e[i].manufacturerData[0]); console.log(lastState); } } } }, 500); }, 600);
Probably (surely) I am approaching the whole issue the wrong way, but that's all I came up with that worked. The value 500 and 600 are random, I tried different values without any difference I could tell. Any suggestions how to speed things up? Thanks.
-
@Gordon I am trying to have 2 pucks controlling each one bulb. One puck is taking instructions from Node-Red dashboard on the Raspberry Pi, and it must relay the instruction to the other puck. I need all the system to react instantly, power-consumption is not important. What will be the faster way, do you think I should use advertising-scanning between the 2 pucks and have each puck have a constant uart connection with the bulbs?
-
Hi. Is it possible for the puck to control at the same time another puck and a magic blue light? I am using the code from here (the faster version) and here, but I get error "BLE task 5 is already in progress". Is it possible to have 2 uart connection (if that is the right term) at the same time? Thanks.
-
Hi. In the Eddystone beacon tutorial it says that we can broadcast beacon url together with other advertising by using
NRF.setScanResponse(require("ble_eddystone").get("goo.gl/B3J0Oc"));
Which works fine, but I cannot find a way to turn off beacon advertising,
NRF.setAdvertising({});
doesn't seems to work, is there another command I should use? Thanks.
-
Thanks @Gordon, I am experimenting with Node-Red for a start, and we'll see where that gets me :)
-
Hi. I am trying to figure out how to proceed with a small project I need to complete. What I want to do is having a simple web-app that will control 2 Bluetooth bulbs, each Puck essentially will control one bulb. The first puck will connect to a Raspberry Pi Zero W and the second puck will communicate through the first puck (something like Bluetooth Mesh but as simple as possible). I need some advice about what do I need to use to achieve this.
So from I understand, I need a server on the Pi, that will be linked with a cloud service (is Google Cloud IoT Core a good choice?, or Firebase maybe?) and the web-app will be connected with the cloud service. Do I understand this right? What would you suggest as the best approach, in terms of tools that I can find tutorials and documentation about, since I am new and will need to learn mostly all of them.
Btw, Gordon have you seen these starters kits at Google cloud IoT Core page? Why not offering a Espruino kit there?
-
-
-
@Gordon I just tried it now and it worked on Chrome at "raspberrypi.local:1888/ide/". Maybe resetting the router and PC did it. Of course now I don't have internet on the Pi for some reason, oh well, you can't have it all. I followed the instructions at http://www.circuitbasics.com/raspberry-pi-zero-ethernet-gadget/, but used ethernet instead of Wi-Fi.
The reason I cannot connect it via Wi-Fi is that when my wife was pregnant she didn't like the idea having the router so near in the living room and we use ethernet cables on desktop and laptop from then, 2 years later we still use them.
Cheers.
-
@Wilberforce thanks. I tried that but it still says the site can't be reached. I used "ping raspberrypi.local" on windows cmd and it works, if that means anything. I disabled also the antivirus, no luck still.
Do I need to add something to PuTTY maybe for this to work?
-
-
Hi. I'm trying to figure out how to control puck via Raspberry Pi Zero W, connected to my desktop PC (which doesn't have Bluetooth btw) via usb, connected to Internet by sharing local area network with it (not WiFI). I followed the steps on the EspruinoHub page and (after tons of problems with installing nodered due to some problem with the time/date on the Pi) finally I am at the point where typing "./start.sh" on putty finds and displays the 2 pucks I have.
I am totally at a loss now how to start the Web IDE on the Raspbian Stretch Lite using putty. How/where do I run espruino-server, it says command not found. Would I need to upgrade to "Stretch with desktop" version so I can run Chromium using VNC? Is there any magical way I can run Web IDE from my desktop PC? Thanks.
-
-
Hi. I am not able to type in the console (the left side) of the web ide. I am using Chrome Canary 66 on Windows 10 on my laptop, I did successfully connected to my puck, I can upload code to it from the right side, and it works, I can turn on the LED. Probably I am doing something wrong, but cannot figure out what.
By the way I can type in the console if I connect to puck through my android smartphone, so it's somethign related to chrome or windows maybe. Any idea what the problem may be? Thanks.
@Gordon thanks, your help is much appreciated. The reason I was getting results with NRF.setScanRespose was probably because I am using Google's "Nearby" (Settings->Google->Nearby on android), which is scanning for Eddystone links, but I see now that it's not exactly what I need.
For reasons I don't understand, the above code doesn't work correctly for me (have tried it on 2 pucks). Manufacturer data are advertised properly, but I don't see the url. I am checking with nRF Connect and 0x0590 is there, very rarely 0xFEAA may pop up very shortly and disappear again. Same on Nearby, if I refresh constantly I may see it at some point, but it's gone once I refresh again. EspruinoHub on console (PuTTY) is showing feaa and the link for the puck though.
Stringifying data is not the way to go, I know, but I start using it when I couldn't figure out how to send code to change color on a ble bulb from one puck to another, got a little confused with all the conversions among different bases. But it's kind of working, slice and parseInt ftw. I still cannot understand though how you can represent, lets say 1000 states, with 255 numbers.