Scripts & Things Recap: 9/19/18

Scripts and Things banner

Earlier this week Moddable hosted the second meeting of Scripts & Things, our meetup about embedded software development using JavaScript on microcontrollers and other embedded systems. We were pleased to have a diverse group of web developers, embedded developers, and even some brand new programmers join us and get excited about JavaScript for embedded.

Demos

In contrast to last month's meeting, which featured presentations by industry experts, this month's meeting was all about demos. Four presenters shared unique demos featuring JavaScript on microcontrollers and IoT devices.

Laundry system

I shared a demo of a laundry system inspired by two of the major problems that anyone who uses a laundromat or lives in a dorm/apartment complex with one laundry room per floor is familiar with:

  1. Other people moving your clothes
  2. Other people leaving their clothes in the machine long after the washing/drying cycle has ended

This laundry system has three devices: a washing machine, an ESP8266 connected to an Arducam camera and a small OLED screen, and a Moddable Zero. The washing machine broadcasts information about itself using mDNS. The ESP8266 connected to the camera listens for updates and displays the time the last cycle started and when it ends. It also takes a photo whenever the door is closed, uploads it to an AWS S3 bucket, and broadcasts the URL of the most recent photo using mDNS. The Moddable Zero listens for updates to the photo URL and displays the new image on screen.

If you're facing problem 1 mentioned above, the picture on screen is the person who moved your clothes and the time displayed on the screen connected to the camera is when they moved them. If you're facing problem 2, the picture on screen is the person whose clothes are in the machine and the time displayed on the screen connected to the camera is how long they've been there.

This demo was meant to be a fun example of wireless communication between several devices. I was also pleased that it led to follow-up conversations with audience members who wanted to add additional features like text updates when your laundry is done (which would be easy to add by reusing code from our twilio example app), and that others were entertained by the idea of taking self portraits with a washing machine.

ConnectaBLE.js

Shotaro Uchida demoed two Node.js apps that use ConnectaBLE.js, his JavaScript Bluetooth LE stack. ConnectaBLE.js allows developers to write JavaScript code that interacts with existing BLE devices or create their own. It is written almost entirely in JavaScript and is designed so it will theoretically work in any ECMAScript 2015 environment.

This demo featured two devices: a STAR Tech Colorific light bulb and a MESH Button Block. Like most IoT products, both devices are compatible with iOS/Android apps created by their manufacturers. Shotaro's JavaScript applications offer an alternative way to interact with them. The first app he showed us simply changes the color of the light every few seconds. The second prints a message to the terminal when the MESH button is tapped, double clicked, or held for a few seconds. The devices in the demo connected as fast as any Bluetooth devices, even with the entire BLE protocol stack written in JavaScript instead of C.

These demos may sound simple, but they are exciting because they demonstrate a much bigger idea: the idea of customizing the devices you buy to suit your own needs. This is an idea we at Moddable embrace and want to see become standard for IoT devices. We talk about it every chance we get whether it's at other meetups, trade shows like Maker Faire, or conferences like Sketching in Hardware.

Curling timing gates

Andy Carle shared a project he is working on for his ice curling club. His goal is to build a low-cost system of devices that tells curlers information about the speed of their delivery.

The first device is an iOS app that displays the timing information. For this demo, it was a quick prototype of the app running on an ESP32 with a small screen attached. The second device is a timing gate that consists of a laser, a photoresistor, a compact mirror, and an ESP32. The mirror is attached to a box a few feet away from another box with the laser, photoresistor, and ESP32. The laser points at the mirror, which reflects the beam of light at the photoresistor. The ESP32 reads the photoresistor to determine when something (a curler) breaks the path of the laser beam.

In the final setup, there will be two timing gates. Each will send the iOS app a timestamped message when the curler crosses its path. The iOS app will calculate how much time elapsed between the two messages and display it on screen.

Products that do the same thing are available on the market already, but it would cost tens of thousands of dollars to purchase enough for an entire curling club. Andy's project makes use of inexpensive materials and will significantly reduce the cost.

ESP32-based dev boards

Peter Hoddie showed us several ESP32-based dev boards: M5Stack Fire, LilyGo TAudio, Simple Alexa, LilyGo T5S, oddWires, and a prototype Moddable Zero using ESP32. He then explained some of the challenges developers face when trying to bring up a new board, such as the tedium of figuring out each device's pin configuration and changing applications every time you want to run them on a different board.

For example, the M5Stack Fire and Lily Go TAudio both have built-in NeoPixels. However, their configuration is completely different, so doing something conceptually simple like turning all the lights on ends up being considerably more complicated to code because you have to figure out the pin numbers, count the number of lights on each strand, etc.

He then demonstrated how the Moddable SDK solves this problem for developers by taking care of the configuration behind the scenes and creating a single API for the NeoPixels. Developers can write one JavaScript application that works across all devices supported by the Moddable SDK and simply specify at build time which device they are running it on.

Peter also took the opportunity to show the audience how quick the build process is and how to use xsbug for live, source-level JavaScript debugging.

See You Next Month

It was great to share our demos with an engaged audience and hear their ideas about things they would like to build and how they would like to see our demos extended. We look forward to the next edition of Scripts & Things in October!