Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ethymoney/kaluma-mqtt
Kaluma library for the MQTT protocol
https://github.com/ethymoney/kaluma-mqtt
javascript kaluma mqtt mqtt-client pico-w raspberry-pi-pico
Last synced: about 1 month ago
JSON representation
Kaluma library for the MQTT protocol
- Host: GitHub
- URL: https://github.com/ethymoney/kaluma-mqtt
- Owner: EthyMoney
- License: mit
- Created: 2023-08-24T16:59:46.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-25T14:48:28.000Z (over 1 year ago)
- Last Synced: 2024-11-02T11:23:09.831Z (3 months ago)
- Topics: javascript, kaluma, mqtt, mqtt-client, pico-w, raspberry-pi-pico
- Language: JavaScript
- Homepage: https://kalumajs.org
- Size: 12.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kaluma-mqtt
Kaluma library for the MQTT protocol### This library is NOT stable and still very much active development. DO NOT use until this is updated to say so.
# Basic Example:
```javascript
const { WiFi } = require('wifi');
const { MQTTClient } = require('mqtt');const wifi = new WiFi();
cont mqttClient = new MQTTClient('myClientId', 'myBrokerIp');// Connect to WiFi and then connect to MQTT broker
wifi.connect({ ssid: 'my-wifi-name', password: 'my-password' }, (err) => {
if (err) {
console.error(err);
} else {
console.log('connected to wifi, connecting to MQTT broker');
mqttClient.connect();
}
});// MQTT client event handlers
mqttClient.on('connect', () => {
console.log('Connected to MQTT broker');
mqttClient.publish('my-topic', 'hello world!');
});// data is an object that contains the message and topic as properties
mqttClient.on('message', (data) => {
console.log('Received message:', data.message.toString(), 'on topic:', data.topic);
});mqttClient.on('disconnect', () => {
console.log('Disconnected from MQTT broker');
});mqttClient.on('error', (err) => {
console.error('Error:', err);
});```