Skip to main content
100%

Express server and serial port reading

✓ Published0🌍 Public
SServuc
Last edited Sep 29, 2017
Created on Sep 29, 2017

This example shows a live data pipeline that reads sensor values from an Arduino over a serial port and exposes them through a simple HTTP endpoint. The Arduino sketch generates random temperatures between -5 and 15 degrees Celsius every five seconds and prints them to the serial monitor. Two JavaScript libraries, `serialport` and `express`, handle the communication: the serial port parser (`serialport.parsers.Readline`) captures each line of incoming data, while the Express server responds to root requests with the latest stored value. The result is a minimal web page displaying the current temperature reading.

AI-generated description

Express server and serial port reading

This JS file demonstrate how open a serial port to read it, and display read value over HTTP server.

Copy/Paste the script will display value at : http://localhost:3000 enjoy.

Install

yarn add serialport
yarn add express

Or

npm install serialport
npm install express

Run

node yourFile.js

Similar vizzes