Zoekresultaten : puck.js

apr 092017
 

I still wasn’t out of “what if…” scenario’s for the devices I had been playing with in relation to The Things Network / LoRaWAN. Because, although I had used the WiFi (and of course LoRA) capabilities of the LoPy a lot, I had not yet played with its BLE (Bluetooth Low Energy) capabilities. For that I needed something else that could use BLE to connect to it. My iPad Mini, the micro:bit, my desktop machine (thanks to the BLE USB adapter), they all could do that. But I wanted to use the Puck-js buttons that I had for that.

The use-case:  If I press the button on the Puck.js (I have two of them, I can press either of them), then the Puck.js connects over bluetooth to the LoPy. After the connection has been made, the Puck.js sends 1) its device-id 2) the measurement of the light sensor of the Puck.js 3) the measurement of the temperature sensor of the Puck.js and 4) the battery voltage of the Puck-js. Once the LoPy has received those 4 values (encoded as a single HEX-string), it sends it to The Things Network (TTN) via LoRaWAN.

Like with the Adafruit Circuit Playground, one of the challenges was that both devices (the LoPy and the Puck.js) use different programming languages and there were no existing examples that handles the cross platform connection.

I uploaded all code to github.com

Programming the Puck.js

To program the Puck.js, you need the Espruino IDE. I have had my fair share of problems connecting to the Puck.js from within that IDE. It is probably one of the challenges of using BLE as a connection to program. But in the end it got the job done. I wasted most time trying to understand how I can send data from the Puck.js to the LoPy after connecting to it. There was an example using 2 Puck.js to send data, but I could not figure out what the UUID of the PrimaryService and the UUID of the Characteristic for the LoPy that allowed me to write data to it where.

I tried to figure that out using code on the Puck.js, but that didn’t work. In the LoPy code that I found, the service and characteristic were defined like this:

srv1 = bluetooth.service(uuid=b'1234567890123456', isprimary=True)

chr1 = srv1.characteristic(uuid=b'ab34567890123456', value=5)

I finally discovered how these needed to be added in the Puck.js code by using nRF Connect, a free tool for iOS. After setting up the LoPy so that it broadcasts using BLE (see the code below), I connected to the LoPy using the nRF Connect app. It then shows you the correct UUID’s that are in the Send_BT_to_LoPy.js script:

return d.getPrimaryService("36353433-3231-3039-3837-363534333231");

return s.getCharacteristic("36353433-3231-3039-3837-363534336261");

Easy, once you know it.

Note #1:  The Puck.js connects to a device named “LoPy01” so if you change the name of the device in main.py for the LoPy, you also have to change it in the code for the Puck.js
Note #2:  I added the id for the Puck.js in the code, first line. You need to change that to the code for your Puck.js if you have more than 1 Puck.js and want to be able to keep the transmitted values apart afterwards.

Let’s continue with the LoPy.

Lees verder….

Deel dit bericht:

Circuit Playground Express

 Gepubliceerd door om 07:25  Algemeen
mei 282017
 

Before the Circuit Playground Express, there was the Circuit Playground Developer Edition (now: “Classic). They look almost the same, but there are some small, yet important, differences between the two iterations (see the table with the overview). One is very important: the processor is different and the Express has got 2 MB of flash memory.

Because of this difference, the Circuit Playground Express, unlike the Classic can be programmed using this online programmer. It uses a Blockly like language, in an environment very similar to what you can use for the Micro:bit. This of course makes it more suitable for use in schools and with younger students with less experience in programming. With the Classic you had to use the Arduino environment to program it.

Another difference between the two versions is the infrared receiver and transmitter, allowing for data transmission using infrared light, similar to what the Puck.js does. It also can be used as a proximity/distance sensor. You can hear lady Ada explain how that works here.

 

Now, just as with the Classic, for me the use-cases for the Express are a bit harder to find. I can understand that it is a cool device to get children programming. And of course, a lot of the use-cases of the Micro:bit, where you attach peripherals using alligator clips and do cool stuff based on values that you measure with either the build in sensors or other external sensors. The Express then allows you to have a nice mix of programming languages: either the Blockly variant with the one-on-one switch to JavaScript in the editor and CircuitPython, the microPython fork that Adafruit is developing (see this video where Tony demos CircuitPython on the Express).

Resources for the Express are still somewhat limited, the board is still very limited in availability which was one of the reasons why I was very glad that after it actually was in stock for a couple of hours last week, it was sent and transferred from the US to Europe in exactly 7 days. Not bad. It is a bit more expensive than a Micro:bit, which you currently can buy direct in the Netherlands. We’ll see how this develops. If you’ve got any questions related to stuff that I could test with the Circuit Playground Express, let me know.

Deel dit bericht:
apr 152017
 

Now that Alex explained everyone how to use MQTT in combination with the LoPy, I thought it was time to show some more advanced uses of MQTT in case you still had no idea why you would bother learning to understand it.
The nice thing about MQTT (MQ Telemetry Transport or Message Queue Telemetry Transport) as a protocol, is that it is not tied to the LoPy or WiPy that Alex used in his example. You can use it in combination with many different devices, tools and applications. For example, in our house, I use a Mosquitto MQTT broker as the central backbone for the home automation. For those that can understand Dutch, see this blogpost I did in 2014, or the one about the lights in my Christmas tree.

MQTT is also supported by The Things Network (TTN) meaning that you can retrieve all the data that your nodes send to TTN using MQTT. This also means you can use MQTT as a way to create a local backup of the data that your nodes send this way.
You can also use it in combination with the KPN LoRaWAN network, but the setup is slightly different. So in this post I am going to focus on TTN, although like before I will be using both the Marvin board and the LoPy board (in combination with Puck.js although that is completely optional of course).

I will be using Node-RED installed on one of my Raspberry Pi devices and I will be using MySQL as the database backend. I will be posting about MySQL versus MongoDB versus InfluxDB one of these days, but on a Raspberry Pi for now this was the quickest and easiest solution.

Let’s dive in:

Lees verder….

Deel dit bericht:
apr 102017
 

Als het in het onderwijs in Nederland over “programmeren” gaat worden eenvoudige vragen al heel snel ingewikkeld. Dus een vraag als “Welke programmeertalen zouden onze leerlingen/studenten moeten kennen?” (bron) is niet helemaal zonder risico. Immers, je moet dan gaan nadenken over het doel dat je daarmee hebt. Wil je ze leren programmeren? Of juist coderen? Of software ontwikkelen? Ik ga niet eens proberen naar bronnen te linken die ze op één hoop of op juist heel verschillende hopen (en dan per bron ook verschillend) gooien.

Dus laat ik het maar even veilig houden in deze blogpost. Zo’n 9 jaar geleden vroeg ik me af welke programmeertalen ik allemaal zou moeten leren. Zoals ik toen beschreef:   Basic was mijn eerste kennismaking met programmeren, maar daar kon je (toen) zo weinig mee dat ik er niet veel interesse voor had. Op de universiteit leerde ik Turbo Pascal om daar vervolgens nooit meer wat mee te doen. Daarna kwam ik in de Windows omgeving en Visual Basic (binnen Office!) en Active Server Pages (ASP) terecht. Mijn eerste kennismaking met JavaScript was in de browser, ASP werd vervangen door PHP toen ik weblogtools ging gebruiken op basis van die taal. En daarna werd het een opeenvolging van “wat heb ik nodig”. Zo kwam er een beetje Python bij, een heel klein beetje .NET en eveneens een klein beetje Java. Dat was toen. Sindsdien zijn er dingen gewijzigd en gelijk gebleven.

Lees verder….

Deel dit bericht:
mrt 262017
 

De Puck.js is een nogal eigenaardig apparaat. Het is een soort knop (je kunt hem ook echt indrukken) met ingebouwd een programmeerbare chip met ondersteuning voor Bluetooth Low Energy (BLE), GPIO poorten, een infraroodzender, een thermometer, ingebouwde lichtsensor, een sensor voor magnetisme, een rode/groene/blauwe LED.

Je programmeert hem met behulp van Javascript via BLE. En in dat laatste zit hem eigenlijk wel de uitdaging. De maker gaat er namelijk vanuit dat je daarvoor Web Bluetooth gebruikt. Handig, gewoon ingebakken in de browser. Alleen….op iOS / de iPad is dat nog niet standaard aanwezig en op Windows 7 of 10 ook nog niet. Op een Chromebook overigens wel weer. Idem voor Android, maar het 5,5 inch scherm van mijn telefoon is daar toch net wat klein voor.

Er is nu een soort van alternatieve manier beschikbaar op iOS en dat is via de applicatie WebBLE. Die is niet gratis, je betaald er €1,99 voor, maar dan kun je vanaf je iPad ook programmeren. Gaat net wat beter vanwege de optie om daar een toetsenbord bij te gebruiken.
De schermindeling is echter nog niet helemaal optimaal voor gebruik op een iPad Mini in liggende weergave.

Er zou een optie moeten zijn via https://www.espruino.com/ide/relay om de verbinding van de iPad te delen met mijn Windows laptop zónder Web Bluetooth ondersteuning. Maar ondanks de stap voor stap instructie in deze video is me dat nog niet gelukt.

Zoals gezegd, het is een intrigerend apparaatje. Ik heb 2 van de pucks aangeschaft maar voorlopig leveren ze vooral nog veel frustratie ehm leermomenten op en heb ik ze nog niet echt voor iets nuttigs in kunnen zetten.
De vraag over de relay functie heb ik op het forum uitgezet, dus wie weet wordt dat nog opgelost.

p.s. Gordon heeft in het verleden heel snel op andere vragen gereageerd en heeft dus wel wat credit opgebouwd, sowieso omdat ik de puck.js niet écht voor productiedoeleinden nodig heb. Ik kan wachten terwijl het product zich verder ontwikkeld.

 

Deel dit bericht:
jul 282016
 

About a week ago my BBC micro:bit arrived from Pimoroni and since then I have been figuring out what I can do with it. I usually blog in Dutch about that but since my write-up is much more useful if people that actually own a BBC micro:bit can read it. Which probably mostly means people from the UK at the moment. And also, this hadn’t been done in English yet (unlike the one for iBeacon).

The video shows the full process and demonstrates the process, I will limit myself here to some background info and the links + code that are mentioned in the video:

One time steps:

  • Install the mBed seriel driver if you are on Windows;
  • Install the most recent Espruino .hex (unless you reprogrammed the micro:bit for other languages);
  • Install the web IDE extension for Chrome.

After that you us the web IDE if you want to set/change the URL that is being broadcasted.

Note that you can much more with Espruino and the micro:bit than set it as a Eddystone URL beacon! You can read and write the GPIO pins etc just like you can with the other languages. Have a look at the documentation on the site.
One Idea suggested by Gordon Williams was that you can read these values and then transmit these as part of the URL. There is a problem with that though. You can only use 17 bytes for the URL which means it has to remain short. Also, you would have to build a URL shortener into the code since I cannot add parameters after a URL that has been shortened with goo.gl.

Lees verder….

Deel dit bericht: