0

My goal is to read data from multiple analog light sensors with an Arduino, and send a float (some number between 0 and 1) to a Raspberry Pi 3 via a Serial USB connection (ideally, data would be sent near-constantly).

I want to update a webpage that displays a live-streamed graph of the data, by adding the new data point. So far, I've been able to get either Smoothie Charts or Plotly working offline with Math.random() in my static HTML/js webpage. I've been playing around with Plotly over the last week or so but can't wrap my head around how to get it to work offline with actual data.

My question is this: how do I take a single numerical value from my Python script, and feed it into the js script that takes care of the live-charting?

I'm new to all of this - from what I've read, it seems like I should use Flask or something like Socket.io to take care of the constant updates, but I'm not sure how to even begin. If someone could point me in the right direction, I'd appreciate it greatly!

joswei
  • 11
  • 6
  • [How to transfer variable data from python to javascript without a web server](https://stackoverflow.com/questions/11547150/how-to-transfer-variable-data-from-python-to-javascript-without-a-web-server) - This S.O. question / answer also seems relevant. If I convert the variable in the Python script to JSON, and then access it in the js script...? I'm not sure if this is the right solution though. – joswei Aug 19 '17 at 08:42

1 Answers1

0

I poked around some more and found this Raspberry Pi/Sensor project by Matthew Perry that reads sensor data & plots it real-time using Smoothie Charts + websocketd.

joswei
  • 11
  • 6