All Projects → p5-serial → P5.serialport

p5-serial / P5.serialport

Licence: mit
Serial Port API and Server for p5.js

Programming Languages

javascript
184084 projects - #8 most used programming language
processing
702 projects
p5js
31 projects

Projects that are alternatives of or similar to P5.serialport

Node Serialport
Access serial ports with JavaScript. Linux, OSX and Windows. Welcome your robotic JavaScript overlords. Better yet, program them!
Stars: ✭ 5,015 (+4079.17%)
Mutual labels:  serial, serialport
Pulsesensorstarterproject
The Best Way to Get Started with your PulseSensor and Arduino
Stars: ✭ 38 (-68.33%)
Mutual labels:  arduino, serial
Pyquino
python3 serial port with PyQt5 Gui
Stars: ✭ 19 (-84.17%)
Mutual labels:  arduino, serial
Cserialport
基于C++的轻量级开源跨平台串口类库Lightweight cross-platform serial port library based on C++
Stars: ✭ 296 (+146.67%)
Mutual labels:  serial, serialport
Noduino
JavaScript and Node.js Framework for controlling Arduino with HTML and WebSockets
Stars: ✭ 1,202 (+901.67%)
Mutual labels:  arduino, serial
Heatpump
Arduino library to control Mitsubishi Heat Pumps via connector cn105
Stars: ✭ 327 (+172.5%)
Mutual labels:  arduino, serial
Eprom
Python script and Arduino code for burning eproms
Stars: ✭ 35 (-70.83%)
Mutual labels:  arduino, serial
serial2mqtt
Serial to MQTT adapter serivce
Stars: ✭ 21 (-82.5%)
Mutual labels:  serial, serialport
Serial Studio
Multi-purpose serial data visualization & processing program
Stars: ✭ 1,168 (+873.33%)
Mutual labels:  arduino, serial
Koduino
Arduino code for STM32 microcontrollers
Stars: ✭ 63 (-47.5%)
Mutual labels:  arduino, serial
Blynk Library
Blynk library for embedded hardware. Works with Arduino, ESP8266, Raspberry Pi, Intel Edison/Galileo, LinkIt ONE, Particle Core/Photon, Energia, ARM mbed, etc.
Stars: ✭ 3,305 (+2654.17%)
Mutual labels:  arduino, serialport
Usbserial
Usb serial controller for Android
Stars: ✭ 1,301 (+984.17%)
Mutual labels:  serial, serialport
pySerialTransfer
Python package to transfer data in a fast, reliable, and packetized form
Stars: ✭ 78 (-35%)
Mutual labels:  serial, serialport
Scriptcommunicator serial Terminal
Scriptable cross-platform data terminal which supports: serial port, UDP, TCP, SPI, I2C and CAN.
Stars: ✭ 462 (+285%)
Mutual labels:  serial, serialport
netty-transport-purejavacomm
A netty serial pipeline using JNA and PureJavaComm
Stars: ✭ 30 (-75%)
Mutual labels:  serial, serialport
Ninjaterm
A serial port terminal that's got your back.
Stars: ✭ 24 (-80%)
Mutual labels:  arduino, serialport
Serial Assistant
一款使用 C# 及 WPF 框架编写的串口调试助手,界面优雅、简洁,易于使用。
Stars: ✭ 212 (+76.67%)
Mutual labels:  arduino, serialport
Adalight Fastled
Adalight with FastLED support
Stars: ✭ 232 (+93.33%)
Mutual labels:  arduino, serial
Victron.arduino Esp8266
Code to read the VE.Direct-Protocol from serial into a value array. Uses a non-blocking read loop and does checksum verification before adding the data.
Stars: ✭ 54 (-55%)
Mutual labels:  arduino, serial
Arduino Robust Serial
A simple and robust serial communication protocol. It was designed for Arduino but can be used for other purposes (e.g. bluetooth, sockets). Implementation in C Arduino, C++, Python and Rust.
Stars: ✭ 83 (-30.83%)
Mutual labels:  arduino, serial

p5.serialport

A p5.js library that enables communication between your p5 sketch and Arduino (or another serial enabled device).

What Does it Do?

p5.serialport more or less clones the Processing Serial Library API. As JavaScript in a browser can not interact directly with a serial port, this library solves this. p5.serialport comes in two flavors; one is a simple app, this is good for all skill levels and is the easiest to use; second is Node.js based WebSocket server, this is for more skilled advanced users or someone who needs heavy customization.

p5.serial App

To begin download and run a release of p5.serialcontrol. This application incorporates p5.serialserver in a GUI application for MacOS and Windows.

Once you have the application launched load one of the examples in your browser to see it in action.

  • You'll likely have to change the name of the serial port in the examples to the one your Arduino is using.

p5.serial Node.js

To Use:

Connect an Arduino or other serial device to your computuer.

Clone or download this repo and install the dependencies with: npm install and start the server with: node startserver.js

Alternatively, you can install the server globally via npm with sudo npm install -g p5.serialserver and then run it with p5serial or locally with npm install p5.serialserver and run it from the node_modules directory with node startserver.js

Then load one of the examples in your browser to see it in action.

  • You'll likely have to change the name of the serial port in the examples to the one your Arduino is using.

Getting Started

After running either the p5.serialcontrol application or p5.serialserver, you need to include the client side library in your html file. You can download the p5.serialport.js client library and include this as a script tag as below:

<script language="javascript" type="text/javascript" src="p5.serialport.js">

or, you can use a CDN link available via jsdelivr:

<script language="javascript" type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.serialport.js"></script>

API

Examples

Basic Example

let serial;

function setup() {
  // Instantiate our SerialPort object
  serial = new p5.SerialPort();

  // Let's list the ports available
  let portlist = serial.list();

  // Assuming our Arduino is connected, let's open the connection to it
  // Change this to the name of your arduino's serial port
  serial.open("/dev/cu.usbmodem1421");

  // Register some callbacks

  // When we connect to the underlying server
  serial.on('connected', serverConnected);

  // When we get a list of serial ports that are available
  serial.on('list', gotList);

  // When we some data from the serial port
  serial.on('data', gotData);

  // When or if we get an error
  serial.on('error', gotError);

  // When our serial port is opened and ready for read/write
  serial.on('open', gotOpen);
}

// We are connected and ready to go
function serverConnected() {
    print("We are connected!");
}

// Got the list of ports
function gotList(thelist) {
  // theList is an array of their names
  for (let i = 0; i < thelist.length; i++) {
    // Display in the console
    print(i + " " + thelist[i]);
  }
}

// Connected to our serial device
function gotOpen() {
  print("Serial Port is open!");
}

// Ut oh, here is an error, let's log it
function gotError(theerror) {
  print(theerror);
}

// There is data available to work with from the serial port
function gotData() {
  let currentString = serial.readStringUntil("\r\n");
  console.log(currentString);
}

// Methods available
// serial.read() returns a single byte of data (first in the buffer)
// serial.readChar() returns a single char 'A', 'a'
// serial.readBytes() returns all of the data available as an array of bytes
// serial.readBytesUntil('\n') returns all of the data available until a '\n' (line break) is encountered
// serial.readString() retunrs all of the data available as a string
// serial.readStringUntil('\n') returns all of the data available as a tring until a (line break) is encountered
// serial.last() returns the last byte of data from the buffer
// serial.lastChar() returns the last byte of data from the buffer as a char
// serial.clear() clears the underlying serial buffer
// serial.available() returns the number of bytes available in the buffer

function draw() {
  // Polling method
/*
  if (serial.available() > 0) {
    let data = serial.read();
    ellipse(50,50,data,data);
  }
*/
}

Documentation

To generate documentation, install jsdoc (npm install -g jsdoc) and run npm run doc

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].