Skip to content

Instantly share code, notes, and snippets.

@joewalnes
Created March 2, 2017 23:33
Show Gist options
  • Save joewalnes/a7cc2986de8d5f62d7396be60de4f779 to your computer and use it in GitHub Desktop.
Save joewalnes/a7cc2986de8d5f62d7396be60de4f779 to your computer and use it in GitHub Desktop.
thingy
https://www.sparkfun.com/products/8688
http://bildr.org/2011/06/temt6000_arduino/
http://playground.arduino.cc/Interfacing/LinuxTTY
http://websocketd.com/
http://smoothiecharts.org/
-- sensor
: sig -> a0
: vcc
: gnd
-- code
int pin = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
int value = analogRead(pin);
Serial.println(value);
delay(20);
}
-- bash
cat /dev/cu.usbmodem1411
websocketd --port=1234 --staticdir=. -- cat /dev/cu.usbmodem1411
---
<!DOCTYPE html>
<script src="http://www.smoothiecharts.org/smoothie.js"></script>
<style>
body {
background-color: #000;
color: #ccc;
font-family: sans-serif;
margin: 20px;
}
</style>
<h1>It's a chart!</h1>
<canvas id="chart" width="800" height="200"></canvas>
<script>
let chart = new SmoothieChart()
chart.streamTo(document.getElementById('chart'), 0)
let series = new TimeSeries()
chart.addTimeSeries(series, { strokeStyle: 'rgba(0, 255, 0, 1)', fillStyle: 'rgba(0, 255, 0, 0.2)', lineWidth: 4 })
let ws = new WebSocket('ws://localhost:1234/')
ws.onopen = () => console.log('connect')
ws.onclose = () => console.log('close')
ws.onmessage = ({data}) => series.append(Date.now(), parseInt(data))
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment