Espruino
JavaScript for Things
Niko Köbler (@dasniko)
JavaScript
as the
Language
of the
Web!
Write once,
run everywhere!
It is already used everywhere!
Clients
Desktops, Laptops, Smartphones,
Tablets, TVs, etc.
Servers
etc.
And now:
Microcontollers & USB-SticksEspruino Project
Founder: Gordon Williams (@espruino), UK
Open Source Hardware (CC-BY-SA)
Open Source Software (MPLv2)
Crowdfunded on Kickstarter!
Espruino
Goal: 20k GBP, Pledged: 100k GBP
by 1.692 backers in September 2013
by 1.692 backers in September 2013
Pico
Goal: 15k GBP, Pledged: 75k GBP
by 1.448 backers in November 2014
by 1.448 backers in November 2014
The Board
54 x 41 mm (half of business card!)
STM32F1 chip family
The STM32 Chip
STM32F103RCT6
32-bit, 72MHz
256kB Flash Memory
48kB RAM
Only 1 Chip,
therefore less power consumption!
(this is kind of "green IT")
GPIOs
Board-Features
Battery Connector
Micro-USB Connector
SD-Card Slot
Bluetooth Pads
Prototyping-Area
2 Buttons, 3 LEDs
The Pico
STM32F401C chip, 384kB Flash, 96kB RAM
less (22) GPIOs than Espruino Board
USB powered
The Interpreter
Because JavaScript is interpreted,
the code can be changed while it is running!
the code can be changed while it is running!
You don't have to compile/install anything anymore.
No deployment-cycles, faster delivery!
Instant feedback on every code/function execution:
good (ok) / bad (error)
Event-based Model
Evented I/O like Node.js, Vert.x, Play, Akka
and other popular approaches.
and other popular approaches.
(even NPM modules can be used!)
More interactive and understandable,
because it's the way people naturally describe tasks:
because it's the way people naturally describe tasks:
"When it's dark, turn on the light."
Code is only processed on events and if necessary,
this saves energy!
this saves energy!
Power Saving
The interpreter knows when it can go to sleep,
and how deeply.
and how deeply.
Even the WiFi module doesn't need power while sleeping!
Example:
LED-flashing with a 700mAh Li-Ion battery:
- Raspberry PI: 1 - 2 hours
- Arduino: 1 - 2 days
- Espruino: ~6 months
Documentation
Getting Startet
Web IDE (Chrome App)
Example 1: Toggle LED
digitalWrite(LED1,1);
digitalWrite(LED1,0);
function toggle() {
on = !on;
digitalWrite(LED1, on);
};
toggle();
var interval = setInterval(toggle, 500);
clearInterval(interval);
Example 2:
Switch LEDs with Button
LED1.set();
LED1.reset();
setWatch(function () {
LED1.set();
setTimeout("LED1.reset(); LED2.set();", 500);
setTimeout("LED2.reset(); LED3.set();", 1000);
setTimeout("LED3.reset()", 1500);
}, BTN, {
repeat : true,
edge : "rising"
});
Example 3: HTTP-Server
var wlan = require("CC3000").connect();
var http = require("http");
wlan.connect("mySSID", "mySecret", function (s) {
if (s == "dhcp") {
console.log("My IP is " + wlan.getIP().ip);
http.get("http://www.pur3.co.uk/hello.txt", function(res) {
res.on('data', function(data) {
console.log(">" + data);
});
});
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('Hello World');
res.end();
}).listen(80);
}
});
Where to next?
Sensor Networks
small form-factor
low energy consumption
(needs energy only when doing something, not while sleeping)
MQTT + socket support
HTTP support already built-in!
USB HID support
Allowing Espruino (Pico) to act like a USB keyboard, mouse or joystick.http://forum.espruino.com/conversations/127079/
Make your own input devices for you PC, or make Espruino "play back" a series of keypresses.
"Programming" with Audio
TV-Output
Thank you!
Questions?
Contact: @dasniko
Espruino
By Niko Köbler
Espruino
Espruino - JavaScript for Things - Open Source JavaScript Microcontroller - www.espruino.com
- 4,677