Bidirectional audio streaming between Particle microcontrollers and Node.js servers. Build voice assistants, intercoms, and audio IoT devices with real-time push-to-talk communication.
Microstream provides two components that work together:
| Component | Package | Installation |
|---|---|---|
| Server | microstream-server | npm install microstream-server |
| Firmware | microstream | particle library add microstream |
flowchart TB
subgraph Server["☁️ Node.js Server"]
direction LR
S1["Transcribe"] --> S2["Process"] --> S3["Synthesize"]
end
subgraph Device["Particle MCU (Photon/Argon)"]
direction LR
Mic["🎤 Microphone"]
Speaker["🔊 Speaker"]
end
Mic -- "PCM @ 16kHz" --> S1
S3 -- "PCM Response" --> Speaker
npm install microstream-serverconst { MicrostreamServer } = require('microstream-server')
const server = new MicrostreamServer({ port: 5000 })
server.on('session', (session) => {
console.log(`Device connected: ${session.id}`)
session.on('audioEnd', (wavBuffer) => {
// Process audio (speech-to-text, AI response, etc.)
// Then send audio back to device:
session.play(responseAudioBuffer)
})
})
server.listen(() => console.log('Listening on port 5000'))particle library add microstream
#include "Microstream.h"
#define MIC_PIN A0
#define SPEAKER_PIN A3
#define BUTTON_PIN D3
Microstream stream;
bool buttonDown = false;
void setup() {
pinMode(BUTTON_PIN, INPUT_PULLUP);
MicrostreamConfig cfg;
cfg.sampleRate = 16000;
cfg.bitDepth = 16;
cfg.micPin = MIC_PIN;
cfg.speakerPin = SPEAKER_PIN;
stream.begin("YOUR_SERVER_IP", 5000, "/", cfg);
}
void loop() {
stream.update();
bool pressed = (digitalRead(BUTTON_PIN) == LOW);
if (pressed && !buttonDown && stream.isConnected()) {
buttonDown = true;
stream.startRecording();
}
if (!pressed && buttonDown) {
buttonDown = false;
stream.stopRecording();
}
}| Component | Connection | Notes |
|---|---|---|
| Electret mic + MAX4466 amp | A0 | Any analog pin |
| Speaker + amp | A3 (Photon) or A6 (Argon) | DAC output |
| Push button | D3 | Optional, active low |
- Server API Reference - Full Node.js API, events, protocol details
- Firmware API Reference - Particle library API, hardware wiring, callbacks
| Example | Description |
|---|---|
| Basic Firmware | Minimal push-to-talk |
| Chatbot Firmware | Voice assistant with LED feedback |
| Voice Assistant Server | OpenAI Whisper + GPT + TTS integration |
| Echo Server | Loopback testing |
Server
- TCP and WebSocket on same port (auto-detected)
- Automatic PCM → WAV conversion
- Multiple concurrent device sessions
- Event-driven API
Firmware
- Interrupt-driven audio capture
- Ring-buffered playback
- Automatic reconnection with backoff
- Playback level callbacks for visualizations
MIT License - see LICENSE