Skip to content

MQTT Authentication

SiliconWit.IO requires authentication for all MQTT connections to ensure your data stays secure.

Every device uses username/password authentication:

FieldValue
UsernameYour Device ID
PasswordYour Access Token
Client IDYour Device ID
  1. Log in to your Dashboard
  2. Go to Devices → Select your device
  3. Find your Device ID (always visible)
  4. Click Reveal Token to see your Access Token
const char* device_id = "dev_a1b2c3d4e5f6";
const char* access_token = "tok_xxxxxxxxxxxxxxxxxxxxxxxx";
// Connect with authentication
client.connect(device_id, device_id, access_token);

For production deployments, use TLS to encrypt your connection:

#include <WiFiClientSecure.h>
WiFiClientSecure secureClient;
PubSubClient mqtt(secureClient);
void setup() {
// For testing (accepts any certificate)
secureClient.setInsecure();
// For production (verify server certificate)
// secureClient.setCACert(root_ca_cert);
mqtt.setServer("mqtt.siliconwit.io", 8883);
}

For browser or WebSocket clients:

wss://mqtt.siliconwit.io:8084/mqtt

Devices can only access their own topics:

AllowedNot Allowed
devices/{your-id}/telemetrydevices/{other-id}/telemetry
devices/{your-id}/commandsdevices/+/telemetry
devices/{your-id}/status#

Attempting to publish or subscribe to unauthorized topics will fail silently or disconnect the client.

  • Store tokens in secure storage or environment variables
  • Use TLS in production
  • Rotate tokens periodically
  • Use unique tokens per device
  • Hardcode tokens in source code (use config files)
  • Share tokens between devices
  • Log or print tokens
  • Send tokens over unencrypted connections

If a token is compromised:

  1. Go to Dashboard → Devices → Select device
  2. Click Security tab
  3. Click Regenerate Token
  4. Update your device with the new token

Regenerating a token immediately invalidates the old one. Your device will disconnect until updated.

For server-to-server communication, use API keys instead:

Terminal window
curl -X POST https://api.siliconwit.io/v1/devices/abc123/telemetry \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"temperature": 25.5}'

API keys are managed in Dashboard → Settings → API Keys.

PlanConcurrent Connections
Starter3
Business50
EnterpriseUnlimited

Each device can have one active MQTT connection. Opening a new connection with the same credentials will disconnect the previous one.

  • Cause: Invalid username or password
  • Fix: Verify Device ID and Access Token are correct
  • Cause: Another client using same credentials
  • Fix: Ensure only one connection per device
  • Cause: Certificate verification failed
  • Fix: Update device time (NTP), or use setInsecure() for testing