Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
dwblair committed Mar 3, 2020
1 parent 78f54f4 commit 5584c14
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 12 deletions.
8 changes: 4 additions & 4 deletions node_lsn50/lsn50_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ app.get("/api/user/id", (req, res, next) => {
app.get("/api/user/latest", (req, res, next) => {
console.log('all')
//var sql = "select * from user order by timestamp desc LIMIT 10"
var sql = "select * from user order by id desc LIMIT 100"
var sql = "select * from user order by id desc LIMIT 2000"
var params = []
db.all(sql, params, (err, row) => {
if (err) {
Expand Down Expand Up @@ -109,9 +109,9 @@ app.post("/api/user/", (req, res, next) => {

console.log(object);

var tempc= object.TempC;
var batv = object.BatV;
var adc = object.ADC_CH0V;
var tempc= object.temperatureSensor[2];
var batv = object.analogInput[3];
var adc = object.humiditySensor[1];

console.log(tempc);
console.log(batv);
Expand Down
62 changes: 56 additions & 6 deletions node_lsn50/plotting/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ for (i in data) {
// reference for styles: https://plot.ly/javascript/line-and-scatter/

var temp_trace = {
x: xvals,
x: xvals,
// x: timestamp,
y: tempc,
//mode: 'markers',
mode: 'lines+markers',
Expand All @@ -53,20 +54,67 @@ var batt_trace = {
//marker: { size: 6, color: 'red'}
};

var humidity_trace = {
x: xvals,
y: adc,
//mode: 'markers',
mode: 'lines+markers',
type: 'scatter',
//marker: { size: 6, color: 'red'}
};

var layout_humidity = {
title:'Volumetric Water Content (%)',
yaxis:{
title: {
text: 'VWC (%)',
},
range:[0,100]
},
xaxis: {
title: {
text: 'index',
}
}
};
var layout_temp = {
/* xaxis: {
range: [ 0.75, 5.25 ]
range: [ 15, 25 ]
},
yaxis: {
range: [0, 3.3]
range: [15, 25]
},
*/
*/
title:'Temperature',
yaxis: {
title: {
text: 'Temp (C)',
},
range: [15,32]
},
xaxis: {
title: {
text: 'index',
}
}
};

var layout_voltage = {
/* xaxis: {
range: [ 15, 25 ]
},
yaxis: {
range: [15, 25]
},
*/
title:'Battery Voltage',
yaxis: {
title: {
text: 'Voltage (V)',
},
range: [3,5]
},
xaxis: {
title: {
Expand All @@ -77,13 +125,15 @@ var layout_temp = {

var temp_traces = [temp_trace];

//var resistance_traces = [resistance_trace];
var voltage_traces = [batt_trace];

var water_traces = [humidity_trace];

Plotly.newPlot('myDiv_a', temp_traces,layout_temp);

//Plotly.newPlot('myDiv_b', resistance_traces,layout_resistance);
Plotly.newPlot('myDiv_b', voltage_traces,layout_voltage);

Plotly.newPlot('myDiv_c', water_traces,layout_humidity);

});

Expand Down
5 changes: 3 additions & 2 deletions node_lsn50/plotting/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

<script src="get.js"></script>

<div id='myDiv_a'><!-- Plotly chart will be drawn inside this DIV --></div>

<div id='myDiv_c'><!-- Plotly chart will be drawn inside this DIV --></div>
<div id='myDiv_a'><!-- Plotly chart will be drawn inside this DIV --></div>
<div id='myDiv_b'></div>

</body>
</html>

0 comments on commit 5584c14

Please sign in to comment.