Node package for Respeaker 4-mic hat?

info about ReSpeaker series products

Moderators: lily.li, violet, seth.welday

Post Reply
donhoellein
Pre-kindergarten
Pre-kindergarten
Posts: 3
Joined: Mon Jun 25, 2018 6:24 am

Node package for Respeaker 4-mic hat?

Post by donhoellein » Mon Jun 25, 2018 6:27 am

Looking for a node package to use to integrate the 4-mic hat. I haven't found anything so far - do you know of anything?

hong.jiang
Staff
Staff
Posts: 200
Joined: Tue Apr 17, 2018 11:03 am

Re: Node package for Respeaker 4-mic hat?

Post by hong.jiang » Thu Jun 28, 2018 2:43 pm

Hi, Sorry we do not have the node package for respeaker 4-mic hat. thanks.

Seeed techsupport team
Bill

donhoellein
Pre-kindergarten
Pre-kindergarten
Posts: 3
Joined: Mon Jun 25, 2018 6:24 am

Re: Node package for Respeaker 4-mic hat?

Post by donhoellein » Sun Jul 01, 2018 7:07 am

Thanks for the response. Is there any reason that the Respeaker would not work with node packages for Raspberry Pi? I'm assuming that this is essentially GPIO control (which I'm new at). I'm trying some node.js code that uses a package for APA102 LEDs, but no luck so far.

Any tips on control of the LEDs and mics would be appreciated.

hong.jiang
Staff
Staff
Posts: 200
Joined: Tue Apr 17, 2018 11:03 am

Re: Node package for Respeaker 4-mic hat?

Post by hong.jiang » Mon Jul 02, 2018 1:41 pm

Hi I tested the LED with nodejs successfully. the LED uses the SPI and audio uses the I2S. we have to enable te spi first by following https://www.w3schools.com/nodejs/nodejs_raspberrypi.asp.

1. install dependiences

sudo apt-get update
sudo apt-get dist-upgrade
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
node -v
npm install apa102-spi

2. please create a led.js file with below code.

var Apa102spi = require('apa102-spi')

// Apa102spi(number of leds, clock divider)
var LedDriver = new Apa102spi(9, 100)

// setLedColor(n, brightness 0-31, red 0-255, green 0-255, blue 0-255) , n=0 led1; n=1, led2; n=2, led3;
LedDriver.setLedColor(0, 1, 255, 0, 0)

// send data to led string
LedDriver.sendLeds()


3. run node led.js and see the led turned on.

For the I2S, i do not test it. thanks.

Seeed techsupport team
Bill

donhoellein
Pre-kindergarten
Pre-kindergarten
Posts: 3
Joined: Mon Jun 25, 2018 6:24 am

Re: Node package for Respeaker 4-mic hat?

Post by donhoellein » Wed Jul 04, 2018 10:43 pm

Thanks - got the LEDs working. Now on to figuring out the mics!

pirpamer
Pre-kindergarten
Pre-kindergarten
Posts: 2
Joined: Sun Dec 23, 2018 1:27 am

ReSpeaker 6-Mic Circular Array kit for Raspberry Pi

Post by pirpamer » Sun Dec 23, 2018 1:37 am

I found the code for ReSpeaker 6-Mic Circular Array kit for Raspberry Pi as well:

Code: Select all

var onoff = require('onoff');
var Gpio = onoff.Gpio;
led = new Gpio(5, 'out'); 

// turn on (required for ReSpeaker 6-Mic Circular Array)
led.write(1, function() { console.log("Changed LED state to: 1"); });

// npm install apa102-spi --save
var Apa102spi = require('apa102-spi'); // requires to run the node in as root (sudo node index.js)
// Apa102spi(number of leds, clock divider)
var LedDriver = new Apa102spi(12, 100);

function ledPower(power) {
	if (power != 1) power = 0;
	led.write(power, function() { console.log("Changed LED state to: " + power); });
	LedDriver.setLedColor(0, 0, 255, 0, 0);
	LedDriver.sendLeds(); 
}
function ledPowerOn() { ledPower(1); }
function ledPowerOff() { ledPower(0); }

ledPowerOn();

me842
Pre-kindergarten
Pre-kindergarten
Posts: 1
Joined: Tue Sep 04, 2018 4:41 am

Re: Node package for Respeaker 4-mic hat?

Post by me842 » Fri Mar 08, 2019 11:35 pm

pirpamer wrote:
Sun Dec 23, 2018 1:37 am
I found the code for ReSpeaker 6-Mic Circular Array kit for Raspberry Pi as well:

Code: Select all

var onoff = require('onoff');
var Gpio = onoff.Gpio;
led = new Gpio(5, 'out'); 

// turn on (required for ReSpeaker 6-Mic Circular Array)
led.write(1, function() { console.log("Changed LED state to: 1"); });

// npm install apa102-spi --save
var Apa102spi = require('apa102-spi'); // requires to run the node in as root (sudo node index.js)
// Apa102spi(number of leds, clock divider)
var LedDriver = new Apa102spi(12, 100);

function ledPower(power) {
	if (power != 1) power = 0;
	led.write(power, function() { console.log("Changed LED state to: " + power); });
	LedDriver.setLedColor(0, 0, 255, 0, 0);
	LedDriver.sendLeds(); 
}
function ledPowerOn() { ledPower(1); }
function ledPowerOff() { ledPower(0); }

ledPowerOn();
@piparmer I'm trying this now with the 6 mic array and no LEDs are turning on. I managed to install all dependencies & run it as sudo. Am I missing anything?

I confirmed that LEDs work, because I managed to get them all working with the python demo. I also tried using hooloovoo with the ReSpeaker, but was only able to get 10/12 LEDs lighting up.

Post Reply