Posts

Showing posts with the label nodejs

Forward serial data between virtual serial ports in Node.js using socat

Image
I'm sharing this with you because I have faced some difficulties when I try to get data from virtual serial ports to my backend in the project . It's easy Part 1 . Installation: Download the tty0tty package from one of these sources: http://sourceforge.net/projects/tty0tty/files/ clone the repo  https://github.com/freemed/tty0tty git clone https://github.com/freemed/tty0tty Extract it tar xf tty0tty-1.2.tgz Build the kernel module from the provided source cd tty0tty-1.2/module make Copy the new kernel module into the kernel modules directory sudo cp tty0tty.ko /lib/modules/$(uname -r)/kernel/drivers/misc/ Load the module sudo depmod sudo modprobe tty0tty You should see new serial ports in /dev/ ( ls /dev/tnt* ) Give appropriate permissions to the new serial ports sudo chmod 666 /dev/tnt* You can now access the serial ports as  /dev/tnt0  (1,2,3,4 etc) Note that the consecutive ports are interconnected. For example, /dev/tnt0 and /

Node.js how to work with Serial ports and display data on a beautiful frontend using Highcharts API Part 2

Image
Now you have some basic idea of the technologies we are using here. So let's get our hands dirty. First, we have to set up the Node js libraries correctly to handle the serial data and open a WebSocket. So simple what we here going to do is getting data from USB and put them into a GUI to visualize our data nicely. So for this tutorial, I'm going to use Arduino as my data source. Piratically this will be your sensor or devices which you are using. Here http://www.highcharts.com/  Highcharts makes it easy for developers to set up interactive charts in their web pages. This has good community support and this is best for our works. 1. First step clone this repository https://github.com/akilawickey/nodejs-serial-frontend/tree/master Here is the Arduino sketch sample.ino which I'm using to emulate data which you can find inside the repository 1: /* 2: * This code will emulate USB data 3: * 4: * 5: */ 6: // the setup function run