
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
arduino-nodejs
Advanced tools
Module for arduino-nodejs communication
const arduino_node = require("arduino-nodejs")
// Returns a promise
// Example of result: ["COM9", "COM3", "COM1"]
// The lower on the list, the bigger is the chance
// Of it being a arduino board
arduino_node.list()
// COM_port should be a port returned by list()
// Baud_rate should be one of the rates
// Here: https://arduino.stackexchange.com/questions/296/
// Baud rates higher than 115200 may not work on
// Devices using CH430G/CH430 or other non-standard
// USB to Serial converters
// Delay should be a number in milliseconds to wait
// After sending a message.
// With lower baud rates it may be neccesary to include
// A number bigger than 10
arduino_node.connect(COM_port, Baud_Rate, Delay?)
// Sends a object to the Arduino
await arduino_node.write(object)
// Reads a value. Should be in a interval
// As small as possible to get the
// information fast
arduino_node.read()
// The arduino code should be like this:
#include <ArduinoJson.h>
void setup()
{
Serial.begin(115200); // Should be the same baud rate as using in the nodejs file
}
void loop()
{
if (Serial.available()) {
DynamicJsonDocument doc(1024);
deserializeJson(doc, Serial);
if (doc["fingerprint"] == "X-Node-Fingerprint") {
// Arduino detected the serial write and that it is from a nodejs script
// Do something cool here
}
}
}
// Example of code that displays the views and likes of a youtube video:
// NodeJS
await arduino_node.connect(list[0], 115200, 10)
const arduino_node = require("arduino-nodejs")
const gaxios = require("gaxios")
let video_id = "aKkVqmvs4NA"
let youtube_key = ""
let link = `https://www.googleapis.com/youtube/v3/videos?part=statistics&id=${id}&key=${youtube_key}`
function scrapeData(id) {
return new Promise((resolve, reject) => {
gaxios.request({ method: "GET", url: link})
.then((data) => {
resolve(data.data.items[0].statistics)
})
.catch((err) => {
reject(err)
})
})
}
function printToScreen(){
scrapeData(video_id)
.then(async (data) => {
await arduino_node.write({ type: "lcd_clear" })
await arduino_node.write({ type: "setCursor", "pos1": 0, "pos2": 0 })
await arduino_node.write({ type: "lcd_print", "text": `views: ${data.viewCount}` })
await arduino_node.write({ type: "setCursor", "pos1": 0, "pos2": 1 })
await arduino_node.write({ type: "lcd_print", "text": `likes: ${data.likeCount}` })
})
}
arduino_node.list().then(async (list) => {
arduino_node.connect(list[0], 115200, 10)
printToScreen()
setInterval(async () => {
printToScreen()
}, 8100);
}).catch((err) => {
console.log(err)
})
// Arduino
#include <LiquidCrystal_I2C.h>
#include <ArduinoJson.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // This is using the I2C version, change this if you want the normal one
void setup()
{
Serial.begin(115200);
lcd.init();
lcd.backlight();
}
void loop()
{
if (Serial.available()) {
DynamicJsonDocument doc(1024);
deserializeJson(doc, Serial);
if (doc["fingerprint"] == "X-Node-Fingerprint") {
if (doc["type"] == "lcd_print") {
lcd.print(doc["text"].as<String>());
} else if (doc["type"] == "lcd_clear") {
lcd.clear();
} else if (doc["type"] == "setCursor") {
lcd.setCursor(doc["pos1"].as<int>(), doc["pos2"].as<int>());
}
}
}
}
FAQs
Module for arduino-nodejs communication
The npm package arduino-nodejs receives a total of 4 weekly downloads. As such, arduino-nodejs popularity was classified as not popular.
We found that arduino-nodejs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.