Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sending messages to Tessel

This shows how to send messages to a connected Tessel over USB and how to log messages that the Tessel writes to console.log().

You'll need to do a tessel push tessel-code.js to push the script to the Tessel first as it seems you can only have one connection at a time (unless there's another way I'm not aware of).

Then run node host-code.js to send the message to Tessel. You should see Tessel log back the message it received.

var tessel =require('tessel');
tessel.listDevices(function(err,devices) {
if(!devices || devices.length == 0) {
console.error("Couldn't find any Tessels");
} else {
serial: devices[0].serial
function(err, client) {
if(!err) {
// client emits log messages when tessel does console.log
client.on('log', function(level,msg) {
console.log("Tessel:" + msg);
// send tessel a message - could be JSON as well I think
client.send("Hello from Mac");
} else {
console.error("Could not find Tessel");
var tessel = require('tessel');
process.on('message', function(msg) { console.log("Got message: " + msg); });
// hacky timeout here to stop script exiting long enough to send the message
setTimeout(function() { console.log('done'); },30000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment