Last active
August 20, 2016 05:30
-
-
Save vshymanskyy/67b6782b7c2cddaf02ec881a41f88b57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
/* | |
1. Install Blynk App for iOS and Anrdoid | |
2. Login or Create new account in the Blynk App | |
3. Add project by scanning this QR: | |
http://tiny.cc/joule-blynk | |
4. Send Auth Token to your email, and update AUTH variable in this sketch | |
5. On the board, install Blynk library and run this script | |
# npm install -g blynk-library | |
# chmod a+x intel-joule-blynk.js | |
# ./intel-joule-blynk.js | |
*/ | |
var AUTH = 'Your Auth Token'; | |
var BlynkLib = require('blynk-library'); | |
var blynk = new BlynkLib.Blynk(AUTH); | |
// Terminal widget | |
var log = new blynk.WidgetTerminal(0); | |
blynk.on('connect', function() { | |
log.write("Blynk started on Joule 570x\n"); | |
}); | |
// Stress test button | |
var v1 = new blynk.VirtualPin(1); | |
const exec = require('child_process').exec; | |
var m = require('mraa'); | |
var myLed = new m.Gpio(103); | |
myLed.dir(m.DIR_OUT); | |
v1.on('write', function(param) { | |
if (param[0] == 1) { | |
log.write("Heat ON\n"); | |
myLed.write(1); | |
for (var i = 0; i < 4; i++) { | |
exec('sha1sum /dev/zero'); // Simulate load | |
} | |
} else { | |
log.write("Heat OFF\n"); | |
myLed.write(0); | |
exec('killall sha1sum'); // Kill load | |
} | |
}); | |
// Update 2 temperature plots every 3 seconds | |
var v2 = new blynk.VirtualPin(2); | |
var v3 = new blynk.VirtualPin(3); | |
var fs = require('fs'); | |
setInterval(function() { | |
var t = fs.readFileSync('/sys/class/thermal/thermal_zone5/temp', 'utf8'); | |
t = parseInt(t)/1000; | |
v2.write(t); | |
t = fs.readFileSync('/sys/class/thermal/thermal_zone2/temp', 'utf8'); | |
t = parseInt(t)/1000; | |
v3.write(t); | |
}, 3000); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment