Program a Raspberry Pi from your browser with Windows 10 IoT Core Blockly

By: Madeleine Dean
2 minute read

Microsoft recently introduced a new UWP app that allows users to program a Raspberry Pi 2Raspberry 3 or a Raspberry Pi Sense Hat from their browsers. Windows 10 IoT Core Blockly lets users create a program with interlocking blocks which can then control a Raspberry Pi mini-computer.

Microsoft took inspiration from four different projects when designing this new tool, including Google’s Blockly open source block editor, BBC’s micro:bit, and its own block editor.

Windows 10 IoT Core Blockly has a simple structure: the main app starts a web server which serves the Blockly editor page on port 8000. Users can access the Blockly editor by browsing to their Raspberry Pi <ip-address>:8000 from a browser. Microsoft also created custom blocks for specific Sense Hat functionalities which can be found under specific categories Basic, Input, LED, Images, Pin, and more.

Other features include:

  • Blockly makes it simple to translate blocks to JavaScript, so we could generate a runnable JavaScript snippet. You can see what your block program translates to in JavaScript by pressing the blue button “Convert to JavaScript” – note: to enable “events” like “on joystick button pressed” we have a few helper JavaScript functions and we pay special attention to the order of the various functions.
  • At this point, we have a block editor that can generate a runnable JavaScript snippet: We need something that can execute this JavaScript snippet on a different thread without interfering with the web server.
  • To run the snippet, we instantiate the Chakra JavaScript engine (which is part of every Windows 10 edition) and start the snippet. Chakra makes it easy to stop the snippet at will.
  • Many of the blocks interact directly with the Sense Hat. We could have written a bunch of JavaScript code to control the Sense Hat, but we leveraged the complete and easy to use C# SenseHat library from EmmellSoft. Bridging between JavaScript and C# was extremely easy leveraging a wrapper UWP library.
  • Last, we added some machinery to make sure the last “run” snippet is saved on the Raspberry Pi (both the blocks layout and the JavaScript snippet are cached) and run again the next time the IoT Core Blockly app starts (e.g. when you restart your device).

For more information on how to set up IoT Core Blockly on your Raspberry Pi, check out Microsoft’s blog post.

RELATED STORIES YOU NEED TO CHECK OUT:

For various PC problems, we recommend this tool.

This software will repair common computer errors, protect you from file loss, malware, hardware failure and optimize your PC for maximum performance. Fix PC issues now in 3 easy steps:

  1. Download this PC Repair Tool rated "Excellent" on TrustPilot.com.
  2. Click “Start Scan” to find Windows issues that could be causing PC problems.
  3. Click “Repair All” to fix all issues with Patended Technologies (requires upgrade).

Next up

Best Windows 10 antivirus software to use in 2018

By: Radu Tyrsina
7 minute read

Update – 2018 will soon come to an end and we already have a guide on what is the best antivirus you should get in […]

Continue Reading

These features are out for good with Windows 10 version 1809

iamsovy@gmail.com' By: Sovan Mandal
2 minute read

Microsoft is all set to launch its next big update, Windows 10 version 1809 in October. While that should be a nice piece of news […]

Continue Reading

Windows 10 18H2 builds no longer receive new features

By: Matthew Adams
3 minute read

The Windows 10 October 2018 Update (otherwise 18H2) rollout might now be two to three weeks away. For the last few months, new build previews […]

Continue Reading

Discussions