Arquivo da categoria: Programação

How to install node modules offline?

I had this difficulty and it took me a while to figure out how to install nodejs modules offline.

I always imagined that it would be simple …. In the back of my head I thought that the gap is as simple as this:

First download the github module into a folder;
Then run the code replacing the path to the folder the module was saved to (when you downloaded from github) and the modulo name;

npm install modulo_name –offline-installers=”C:\your\folder”

Very simple!! 🙂

npm install – erro “VCBuild.exe”

Se você usa windows, tentou instalar um package nodejs e teve o seguinte erro:

Eu resolvi da seginte forma:

1º instale o .NET Framework 2.0 SDK

2º instale também o Visual Studio 2005

Por ultimo abra o prompt de comamando com administrador e execute o seguinte código: npm install –global –production windows-build-tools

Espere a instalção finalizar (tenha paciência… vai demorar um pouco)

Gif

Referência:  https://www.npmjs.com/package/windows-build-tools

 


Using ACR122u on Windows


First you need to install Libnfc:
  1. Installing TDM-GCC MinGW CompilerGoto http://sourceforge.net/projects/tdm-gcc/ and download the TDM-GCC MinGW Compiler.
    For example: tdm64-gcc-4.7.1-3.exe
    More information about this compiler: http://tdm-gcc.tdragon.net/
    Note: MinGW = Minimalist GNU for Windows
  2. Double click the executable and press the Create button.TDM-GCC setup
  3. Select “MinGW-w64/TDM64 Experimental (32-bit and 64-bit)” and press Next button.Note:
    You need to install this version instead of “MinGW/TDM (32 bit)”.
    The “MinGW-w64/TDM64 Experimental” version will run on 32-bit and 64-bit operating systems.Select MinGW-w64/TDM64 Experimental( 32-bit and 64-bit) edition
  4. Select TDM-GCC installation directory, for example C:\tools\MinGW64 and press Next button.Select TDM-GCC installation directory
  5. Select your nearest TDM-GCC download server and press Next button.Select TDM-GCC download server
  6. Choose “TDM-GCC Recommended, All Packages” and press Install button.Choose TDM-GCC components to be installed
  7. Wait until TDM-GCC is installed and press Next button.Installing TDM-GCC components
  8. Presh Finish button to complete the TDM-GCC setup.Finish the TDM-GCC setupMore information needed about TDM-GCC, read the README-gcc-tdm64.txt file.
  9. Installing libusb-win32Goto http://sourceforge.net/projects/libusb-win32/ and download libusb-win32.
    For example: libusb-win32-bin-1.2.6.0.zip
    More information about this library: http://sourceforge.net/apps/trac/libusb-win32/wiki
  10. Download and unzip the file, for example: C:\tools\libusb-win32-bin-1.2.6.0
    No further action is required.
  11. Installing PCRE for WindowsGoto http://sourceforge.net/projects/gnuwin32/files/pcre/7.0/ and download the PCRE setup wizard (Perl-compatible regular-expression).
    For example: pcre-7.0.exe
    More information about PCRE: http://www.pcre.org
  12. Double click the executable and press the “Next” button.PCRE setup wizard
  13. Accept the agreement and press the “Next” button.PCRE accept agreement
  14. Select PCRE installation directory, for example C:\tools\GnuWin32 and press Next button.PCRE installation location
  15. Select “Full installation” and press Next button.PCRE components
  16. Enter PCRE shortcut in Start menu and press Next button.PCRE shortcut
  17. Select additional tasks to be performed and press Next button.PCRE additional tasks
  18. Press Install button.PCRE install
  19. Press Finish button.PCRE finish
  20. Installing CMakeGoto http://www.cmake.org/ and download CMake binary distribution for Windows platform (Win32 Installer). CMake is a cross-platform, open-source build system.
    For example: cmake-2.8.11.2-win32-x86.exe
  21. Double click the executable and press the “I Agree” button.CMake setup
  22. Select “Add CMake to the system PATH for current user” and press “Next” button.CMake install options
  23. Select CMake installation directory, for example C:\tools\CMake 2.8 and press Next button.Select CMake installation directory
  24. Choose start menu folder and press Install button.Choose start menu folder
  25. Wait until CMake is installed and press Next button.Installing CMake
  26. Presh Finish button to complete the CMake setup.Finish the CMake setup
  27. Installing DoxygenGoto http://www.doxygen.org/ and download doxygen.
    For example: doxygen-1.8.4-setup.exeNote:
    It is not required to install Doxygen.
    If not installed, Doxygen warning messages will be displayed when you configure libnfc using CMake.
    You can ignore these warning messages.
  28. Double click the executable and press the “Next” button.Doxygen setup
  29. Accept the agreement and press the “Next” button.Doxygen accept agreement
  30. Select Doxygen installation directory, for example C:\tools\doxygen and press Next button.Doxygen installation location
  31. Select “Full installation” and press Next button.Doxygen components
  32. Enter Doxygen shortcut in Start menu and press Next button.Doxygen shortcut
  33. Press Install button.Doxygen install
  34. Doxygen is installing.Doxygen is installing
  35. Read Doxygen information and press Next button.Doxygen information
  36. Press Finish button.Doxygen finish
  37. Installing libnfcGoto http://code.google.com/p/libnfc/ and download the free Near Field Communication library (libnfc).
    For example: ibnfc-1.7.0-rc7.tar.gzAnd unpack the file.
    For example: C:\tools\libnfc-1.7.0-rc7More information about this library: http://nfc-tools.org


  38. Configure libnfcLibnfc currently only supports communication over UART, using any inexpensive USB to UART adapter like the FTDI Tool. Before compiling you will need to configure libnfc to include support for UART and the PN532 chipset.Make the following changes:
    • Due to a bug you will get the error message below when you later use the command “mingw32-make”.C:\libnfc-build\windows\libnfc.rc:25:37: warning: missing terminating ” character [enabled by default] Edit file: C:\tools\libnfc-1.7.0-rc7\CMakeLists.txt Change:MACRO (GET_CURRENT_YEAR RESULT)
      EXECUTE_PROCESS(COMMAND “cmd” ” /C date /T” OUTPUT_VARIABLE ${RESULT})
      STRING(REGEX REPLACE “.*(..)/(..)/(….).*” “\\3” ${RESULT} ${${RESULT}})
      ENDMACRO (GET_CURRENT_YEAR)

      into

      MACRO (GET_CURRENT_YEAR RESULT)
      EXECUTE_PROCESS(COMMAND “cmd” ” /C date /T” OUTPUT_VARIABLE ${RESULT})
         STRING(REGEX REPLACE “\n” “” ${RESULT} ${${RESULT}})
         STRING(REGEX REPLACE “.*(..)/(..)/(….).*” “\\3” ${RESULT} ${${RESULT}})
      ENDMACRO (GET_CURRENT_YEAR) 

    • The default timeouts in the pn532 driver are not long enough and unless you patch the driver, the NFC reader will not show up.
      It is important to wait a time long enough to pass the pn532 wake up sequence, so do send a 0x55, 0x55 followed by some 30 0x00.Edit file: C:\tools\libnfc-1.7.0-rc7\libnfc\drivers\pn532_uart.c Change:const uint8_t pn532_wakeup_preamble[] = { 0x55, 0x55, 0x00, 0x00, 0x00 }; into

      const uint8_t pn532_wakeup_preamble[] = { 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 

    • If you copy c:\tools\libnfc-1.7.0-rc7\libnfc.conf.sample into c:\toolslibnfc-1.7.0-rc7\libnfc.conf, this file will not be read. Do not copy libnfc.conf.sample. Here is an alternative way.Edit file: C:\tools\libnfc-1.7.0-rc7\libnfc\nfc-internal.c Change:res->allow_intrusive_scan = false; into

      res->allow_intrusive_scan = true; 

  39. Set Windows System PathOpen the Windows “System Properties” window:
    • Press the windows “Start” button
    • Right click Computer
    • Select Properties
    • Click “Advanced system settings” which opens the “System Properties” window and press “Environment Variables…”Windows system properties
    • In the “System variables” subwindow select variable “Path” and press “Edit…” buton.Windows environment variables
    • Edit your System variable “Path”. Add the following paths (if they were not already created) at the end:
      • C:\tools\doxygen\bin;      (Only if you installed Doxygen)
      • C:\tools\MinGW64\bin;
      • C:\tools\MinGW64\x86_64-w64-mingw32\lib32;
      • C:\tools\MinGW64\x86_64-w64-mingw32\include;
      • C:\tools\CMake 2.8\bin;
      • C:\tools\GnuWin32\bin;

      Windows edit system variable PATH

  40. To test if all required software/libraries are installed and the System PATH is set correctly, open a Dos window and type: cmakeYou should see:cmake version 2.8.11.2
    Usage
    cmake [options] <path-to-source>
    cmake [options] <path-to-existing-build>
    :See the complete cmake output.
  41. Configure CMake libnfc project
    • Create a folder libnfc-build.
      For example: c:\libnfc-build
    • Open a dos window and goto folder “libnfc-build”.
      Type: cmake-gui .CMake is used to configure and generate build files for software projects.
      The basic steps for configuring a project are as follows:

      • Select the source directory for the project.
        This should contain the CMakeLists.txt files for the project.
        In this tutorial the libnfc source directory is: C:\tools\libnfc-1.7.0-rc7
      • Select the build directory for the project.
        This is the directory where the project will be built.
        It can be the same or a different directory than the source directory.
        For easy clean up, a separate build directory is recommended.
        CMake will create the directory if it does not exists.
        In this tutorial the build directory is: c:\libnfc-buildConfigure CMake libnfc project
      • Once the source and binary directories are selected, it is time to press the Configure button.
        A window will open:

        • Select the “MinGW Makefiles” generator.
        • Select option: Use default native compilers.
        • Press Finish button.

        Select MinGW Makefiles generator

        This will cause CMake to read all of the input files and discover all the variables used by the project. The first time a variable is displayed, it will be in Red. Users should inspect red variables making sure the values are correct.
        For some projects the Configure process can be iterative, so continue to press the Configure button until there are no red entries.

        Errors shown when pressing configure button

        To fix the errors mentioned above:

        • Click on the PCRE_INCLUDE_DIRS value and goto:
          C:\tools\GnuWin32\include
        • Click on the PCRE_LIBRARIES value and select file:
          C:\tools\GnuWin32\lib\libpcre.dll.a
        • And press the Configure button again.

        Errors shown when pressing configure button again

        To fix the errors mentioned above:

        • Click on the LIBUSB_INCLUDE_DIRS value and goto:
          C:\tools\libusb-win32-bin-1.2.6.0\include
        • Click on the LIBUSB_LIBRARIES value and select file:
          C:\tools\libusb-win32-bin-1.2.6.0\lib\gcc\libusb.a By doing the above, you are building a 32bit application.
          For 64bit system, either 32bit application or 64bit application will work.
          64bit application can not work on 32bit Windows OS.For a 64bit system, you need to use a 64bit driver.
          A 32bit driver will not work under 64 bit system, and vice versa,
          64bit driver will not work under 32bit system.

          • 32bit MinGW GCC
            libusb-win32-bin-1.2.6.0\lib\gcc\libusb.a
          • 64bit MinGW GCC
            directly link to libusb0.dll or create your own import lib
          • 32bit MSVC (=Microsoft Visual C++)
            libusb-win32-bin-1.2.6.0\lib\msvc\libusb.lib
          • 64bit MSVC
            libusb-win32-bin-1.2.6.0\lib\msvc_x64\libusb.lib
          • 64bit MSVC for IA64
            libusb-win32-bin-1.2.6.0\lib\msvc_i64\libusb.lib
          • Borland C (32bit only)
            libusb-win32-bin-1.2.6.0\lib\bcc\libusb.lib
          • Other compiler, use dynamic
            libusb-win32-bin-1.2.6.0\lib\dynamic\libusb_dyn.c
        • And press the Configure button again.

        No errors shown when pressing configure button again

      • Once there are no longer red entries, configure libnfc according to your need.
        In my situation I will later connect an Adafruit PN532 RFID/NFC Shield to an FTDI board to a laptop running Windows Vista.
        Because libnfc currently only supports communication over UART I make the final changes:

        • Set CMAKE_BUILD_TYPE=Debug
        • Set CMAKE_INSTALL_PREFIX=C:/tools/libnfc-1.7.0-rc7
        • Set LIBNFC_DEBUG_MODE=ON
        • Set LIBNFC_DRIVER_PN532_UART=ON
        • Set all LIBNFC_DRIVER_NNN=OFF
        • Set LIBNFC_SYSCONFDIR=C:/tools/libnfc-1.7.0-rc7/config

        Press Generate button

        Click the Configure button and then the Generate button.
        This will create files to the build directory: c:\libnfc-build

    • Build windows executable files and libnfc.dll with mingw32-make
      • Goto folder C:\libnfc-build and type: mingw32-makemingw32-make creates executablesSee the complete mingw32-make outputExecutables (.exe) are created and can be found in the folders:C:\libnfc-build\utils
        • nfc-emulate-forum-tag4.exe
        • nfc-list.exe
        • nfc-mfclassic.exe
        • nfc-mfultralight.exe
        • nfc-read-forum-tag3.exe
        • nfc-relay-picc.exe
        • nfc-scan-device.exe

        C:\libnfc-build\examples

        • nfc-anticol.exe
        • nfc-dep-initiator.exe
        • nfc-dep-target.exe
        • nfc-emulate-forum-tag2.exe
        • nfc-emulate-tag.exe
        • nfc-emulate-uid.exe
        • nfc-mfsetuid.exe
        • nfc-poll.exe
        • nfc-relay.exe

        File C:\libnfc-build\libnfc\libnfc.dll is also created.

    • Copy libnfc.dll to C:\Windows\System32If you run the above mentioned executables, for example:C:\libnfc-build\utils\nfc-list.exethe following error message is shown:This application has failed to start because libnfc.dll was not found. Re-installing the application may fix this problem. 

      libnfc.dll not found

      To fix this error copy the generated C:\libnfc-build\libnfc\libnfc.dll to
      C:\Windows\System32
      Do this each time if you use the command “mingw32-make”.

Auto-run LXTerminal from LXDE desktop at startup



The script may be running to completion and the terminal closes before you see it. Test to see if it works using a script that waits for input, so the terminal will stay open until you close it.

Create a test script. I just named it “test.sh”, make it executable.

sudo chmod +x filename.ext

Code:

#!/bin/bash

pause(){
 read -n1 -rsp $'Press any key to close the terminal...\n'
}

echo Script is running

pause

Then edit the autostart file

Code:

nano ~/.config/lxsession/LXDE-pi/autostart

Add this line at the bottom

Code:

lxterminal -e /path/to/test.sh

Then log out and back in, or reboot. When the desktop starts you should see the terminal open in the middle of the screen, waiting for you to press a key. That will confirm everything’s working, then edit the autostart file and replace “/path/to/test.sh” with the script you want to use.

inspirational quotes:  https://www.raspberrypi.org/forums/viewtopic.php?t=65607

Linux commands


LS

The ls command lists the content of the current directory (or one that is specified). It can be used with the -l flag to display additional information (permissions, owner, group, size, date and timestamp of last edit) about each file and directory in a list format. The -a flag allows you to view files beginning with . (i.e. dotfiles).

CD

Using cd changes the current directory to the one specified. You can use relative (i.e. cd directoryA) or absolute (i.e. cd /home/pi/directoryA) paths.

PWD

The pwd command displays the name of the present working directory: on a Raspberry Pi, entering pwd will output something like /home/pi.

MKDIR

You can use mkdir to create a new directory, e.g. mkdir newDir would create the directory newDir in the present working directory.

RMDIR

To remove empty directories, use rmdir. So, for example, rmdir oldDir will remove the directory oldDir only if it is empty.

RM

The command rmremoves the specified file (or recursively from a directory when used with -r). Be careful with this command: files deleted in this way are mostly gone for good!

CP

Using cp makes a copy of a file and places it at the specified location (this is similar to copying and pasting). For example, cp ~/fileA /home/otherUser/would copy the file fileA from your home directory to that of the user otherUser (assuming you have permission to copy it there). This command can either take FILE FILE (cp fileA fileB), FILE DIR(cp fileA /directoryB/) or -r DIR DIR (which recursively copies the contents of directories) as arguments.

MV

The mv command moves a file and places it at the specified location (so where cp performs a ‘copy-paste’, mv performs a ‘cut-paste’). The usage is similar to cp. So mv ~/fileA /home/otherUser/ would move the file fileA from your home directory to that of the user otherUser. This command can either take FILE FILE (mv fileA fileB), FILE DIR (mv fileA /directoryB/) or DIR DIR (mv /directoryB /directoryC) as arguments. This command is also useful as a method to rename files and directories after they’ve been created.

TOUCH

The command touch sets the last modified time-stamp of the specified file(s) or creates it if it does not already exist.

CAT

You can use cat to list the contents of file(s), e.g. cat thisFile will display the contents of thisFile. Can be used to list the contents of multiple files, i.e. cat *.txt will list the contents of all .txt files in the current directory.

HEAD

The head command displays the beginning of a file. Can be used with -n to specify the number of lines to show (by default ten), or with -c to specify the number of bytes.

TAIL

The opposite of headtail displays the end of a file. The starting point in the file can be specified either through -b for 512 byte blocks, -c for bytes, or -n for number of lines.

CHMOD

You would normally use chmod to change the permissions for a file. The chmodcommand can use symbols u (user that owns the file), g (the files group) , and o (other users) and the permissions r (read), w (write), and x (execute). Using chmod u+x *filename* will add execute permission for the owner of the file.

CHOWN

The chown command changes the user and/or group that owns a file. It normally needs to be run as root using sudo e.g. sudo chown pi:root *filename* will change the owner to pi and the group to root.

SSH

ssh denotes the secure shell. Connect to another computer using an encrypted network connection. For more details see SSH (secure shell)

SCP

The scp command copies a file from one computer to another using ssh. For more details see SCP (secure copy)

SUDO

The sudo command enables you to run a command as a superuser, or another user. Use sudo -s for a superuser shell. For more details see Root user / sudo

DD

The dd command copies a file converting the file as specified. It is often used to copy an entire disk to a single file or back again. So, for example, dd if=/dev/sdd of=backup.img will create a backup image from an SD card or USB disk drive at /dev/sdd. Make sure to use the correct drive when copying an image to the SD card as it can overwrite the entire disk.

DF

Use df to display the disk space available and used on the mounted filesystems. Use df -h to see the output in a human-readable format using M for MBs rather than showing number of bytes.

UNZIP

The unzip command extracts the files from a compressed zip file.

TAR

Use tar to store or extract files from a tape archive file. It can also reduce the space required by compressing the file similar to a zip file.

To create a compressed file, use tar -cvzf *filename.tar.gz* *directory/* To extract the contents of a file, use tar -xvzf *filename.tar.gz*

PIPES

A pipe allows the output from one command to be used as the input for another command. The pipe symbol is a vertical line |. For example, to only show the first ten entries of the ls command it can be piped through the head command ls | head

TREE

Use the tree command to show a directory and all subdirectories and files indented as a tree structure.

&

Run a command in the background with &, freeing up the shell for future commands.

WGET

Download a file from the web directly to the computer with wget. So wget https://www.raspberrypi.org/documentation/linux/usage/commands.mdwill download this file to your computer as commands.md

CURL

Use curl to download or upload a file to/from a server. By default, it will output the file contents of the file to the screen.

MAN

Show the manual page for a file with man. To find out more, run man man to view the manual page of the man command.

Search

GREP

Use grep to search inside files for certain search patterns. For example, grep "search" *.txt will look in all the files in the current directory ending with .txt for the string search.

The grep command supports regular expressions which allows special letter combinations to be included in the search.

AWK

awk is a programming language useful for searching and manipulating text files.

FIND

The find command searches a directory and subdirectories for files matching certain patterns.

WHEREIS

Use whereis to find the location of a command. It looks through standard program locations until it finds the requested command.

Networking

PING

The ping utility is usually used to check if communication can be made with another host. It can be used with default settings by just specifying a hostname (e.g. ping raspberrypi.org) or an IP address (e.g. ping 8.8.8.8). It can specify the number of packets to send with the -c flag.

NMAP

nmap is a network exploration and scanning tool. It can return port and OS information about a host or a range of hosts. Running just nmap will display the options available as well as example usage.

HOSTNAME

The hostname command displays the current hostname of the system. A privileged (super) user can set the hostname to a new one by supplying it as an argument (e.g. hostname new-host).

IFCONFIG

Use ifconfig to display the network configuration details for the interfaces on the current system when run without any arguments (i.e. ifconfig). By supplying the command with the name of an interface (e.g. eth0 or lo) you can then alter the configuration: check the manual page for more details.

PowerPoint report with data from MYSQL



Hello!
Some times we need make a report with information that can’t be changed, and other situations better if the report informations can be changed and improved!
In this post I’m gonna show you, an library on javascript that give us, the flessible tools to do it.

So, to make it more easy, please watch the video series below, and don’t forget, please, help me to make it better give me you opinion and coments

Thank you so motch for your vist!!

Introduction: (A little introduction at how this javascript library work)
Imagem de Amostra do You Tube

Step 1: (Creating the pptx presentation without mysql connection)
Imagem de Amostra do You Tube

Step 2: (Creating the system to generate the data and reports)
Imagem de Amostra do You Tube

Step 3: (Populating database and creating the upload button)
Imagem de Amostra do You Tube

Lux monitoring – LDR Arduino and Nodejs




Hello guys! How are you? I hope everything’s ok!

So, in this post I’ll try explain, how you can do the lux monitoring system, using:

– Arduino Uno,

Photo-resistor LDR,

Two led (green and red) to visual status indicator

Nodejs and chart.js module,  to show the lux range in real time.

Step 0 > Install Nodejs and NPM

To make this task you need install before the nodejs and npm

Step 1 > Electrical connections

See the electrical connections bellow:

protoboard

Step 2 > Installation of dependencies:

Create the folder the folder Node_LDR;

Into this folder create the packagejson.js:

Into the packagejson.js file, write the code below:

{
    "name": "LDR_Aduino_Nodejs",
    "version": "0.0.1",
    "dependencies": {
      "chart.js": "^2.2.1",
      "express": "^4.14.0",
      "serialport": "^4.0.1",
      "socket.io": "^1.4.8"
    }
 }

Save and close!

After, open your prompt command and run npm install:

npminstall

When the installation is finished look into the folder   Node_LDR:

– Node_LDR

— node_modules

— package.json

If your folder it’s the same that format, everything’s ok!!

Step 3 > Installation of Arduino IDE:

Click here and install the IDE

IDE_Arduino

Step 4 > C++ code:

Open your arduino IDE and write the follow code:

int portaledred = 10;
int portaledgreen = 11;
int pinoport = 5;
int valorport = 0;
float luminosidade = 0;

void setup() {
 Serial.begin(9600);
 pinMode(portaledred, OUTPUT);
 pinMode(portaledgreen, OUTPUT);
}

void loop() {
 valorport = analogRead(pinoport);

 luminosidade = map(valorport, 0, 1023, 0, 255);
 Serial.print("Valor do LDR : ");
 Serial.println(valorport);
 Serial.print(" = Luminosidade : ");
 Serial.println(luminosidade);
 

 if (valorport &amp;gt; 900)
 {
 digitalWrite(portaledred, HIGH);
 digitalWrite(portaledgreen, LOW);
 }
 else
 {
 digitalWrite(portaledred, LOW);
 digitalWrite(portaledgreen, HIGH);
 }
delay(3000);
}

Make Upload the code on Arduino board:

uploadArd

After the upload is done make a test

Step 5 > Communication between Arduino, Nodejs and Web page:

Open the text editor of your preference and create the app.js with code below:

var app = require('express')();
var express = require('express');

app.use(express.static(__dirname + '/public'));

var http = require('http').Server(app);
var io = require('socket.io')(http);

app.get("/", function(req, res){
 res.sendFile("/cygwin64/home/pablo.binotto/node/arduino/index.html");//here is necessary the all url of folder into the c:/
});

var mySocket;

var serialport = require('serialport');
var SerialPort = serialport.SerialPort;

var mySerial = new SerialPort("COM5", {
 baudrate: 9600,
 parser: serialport.parsers.readline("\n")
});

mySerial.on('open', function(){
 console.log("Porta aberta.");
});

mySerial.on("data", function(data){
 //console.log(dados);
 io.emit("dadoArduino", {
 valor: data
 });
});

io.on("connection", function(socket){
 console.log("Usuario conectado")
});

http.listen(3000, function(){
 console.log("Server running on 3000 port");
});

Save this file on Node_LDR folder and on the same folder, create the file index.html follow the code below:

<!DOCTYPE html>
<html lang="">
 <head>
 <meta charset="utf-8">
 <meta http-equiv="X-UA-Compatiblr" content="IE=edge">
 <meta name= "viewport" content="width=device-width, initial-scale=1">
 <title>Node_Arduino_IO_SerialPort</title>
 <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20src%3D%22%2Fsocket.io%2Fsocket.io.js%22%3E%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />
 </head>
 <body>
 <canvas id="myChart" width="400" height="400"></canvas>
 <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20type%3D%22text%2Fjavascript%22%3E%0A%20var%20ctx%20%3D%20document.getElementById(%22myChart%22)%3B%0A%20%0A%20var%20myLineChart%20%3D%20new%20Chart(ctx%2C%20%7B%0A%20type%3A%20'line'%2C%0A%20data%3A%20data%2C%0A%20options%3A%20options%0A%20%7D)%3B%0A%20%0A%20%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />
 <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20type%3D%22text%2Fjavascript%22%3E%0A%20var%20socket%20%3D%20io()%3B%0A%20socket.on(%22dadoArduino%22%2C%20function(dado)%7B%0A%20console.log(dado)%3B%0A%20%7D)%3B%0A%20%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />
 </body>
</html>

On your prompt command write: node app.js and click enter…

Open a new web page and go to localhost:3000…

In this video below, you can see the communication happening

Step 6 > Show the result on line graph into the web page:

See you again!