← Descripción general | Contenido | Next: Hardware Connection →
Inicio rápido
Esta guía le ayudará a poner en marcha DimmerLink en pocos minutos.
What You'll Need
- DimmerLink — placa controlador
- Dimmer — módulo TRIAC con soporte de control externo
- Microcontrolador o SBC — Arduino, ESP32, Raspberry Pi, etc.
- Cables de conexión
- Lámpara para pruebas (incandescente o LED regulable)
Paso 1: Elegir una interfaz
| Característica | UART | I2C |
|---|---|---|
| Cableado | TX/RX cruzado | SDA/SCL directo |
| Complejidad del código | Paquetes de comandos | Acceso a registros |
| Recomendación | Para usuarios avanzados | Para principiantes |
💡 Tip: We recommend I2C for most projects — simpler code, easier debugging, and more robust than UART.
⚠️ Important — DimmerLink ships in UART mode. Out of the box the board listens on UART. To use I2C, first send the switch-to-I2C command over UART once (
02 5B); the setting is stored, so you only do this one time. See I2C Communication for details.🔌 I2C wiring: I2C requires 4.7 kΩ pull-up resistors on both SDA and SCL to the bus voltage (3.3 V). Without them the device will not be detected by an I2C scan.
ℹ️ You can test communication with no AC connected. DimmerLink powers from its logic VCC, so it responds to UART/I2C commands (including the frequency-request check) even before mains is wired. The on-board status LEDs, however, only light when AC is present.
Paso 2: Cableado
Conectores de DimmerLink
Entrada (a su proyecto):
| Pin | Función |
|---|---|
| VCC | Alimentación 3.3V |
| GND | Tierra |
| TX/SDA | UART TX o I2C SDA |
| RX/SCL | UART RX o I2C SCL |
Salida (al módulo dimmer):
| Pin | Función |
|---|---|
| VCC | Alimentación |
| GND | Tierra |
| Z-C | Señal de cruce por cero |
| Dim | Control TRIAC |
Diagrama de conexión
[Your Project] ←→ [DimmerLink] ←→ [Dimmer] ←→ [Mains + Lamp]
Diagramas detallados de conexión de dimmer y carga (lámparas, calefactores): Conexión de potencia y carga de los dimmers
Paso 3: Cargar el código
Opción A: I2C (recomendado)
Arduino:
#include
#define DIMMER_ADDR 0x50
#define REG_LEVEL 0x10
void setup() {
Wire.begin();
}
void loop() {
// Smooth brightness change
for (int level = 0; level <= 100; level += 10) {
setLevel(level);
delay(500);
}
for (int level = 100; level >= 0; level -= 10) {
setLevel(level);
delay(500);
}
}
void setLevel(uint8_t level) {
Wire.beginTransmission(DIMMER_ADDR);
Wire.write(REG_LEVEL);
Wire.write(level);
Wire.endTransmission();
}
MicroPython (ESP32, Raspberry Pi Pico):
from machine import I2C, Pin
import time
# ESP32: scl=22, sda=21
# Raspberry Pi Pico: scl=5, sda=4
i2c = I2C(0, scl=Pin(22), sda=Pin(21), freq=100000)
DIMMER_ADDR = 0x50
REG_LEVEL = 0x10
def set_level(level):
i2c.writeto_mem(DIMMER_ADDR, REG_LEVEL, bytes([level]))
# Smooth brightness change
while True:
for level in range(0, 101, 10):
set_level(level)
time.sleep(0.5)
Python (Raspberry Pi):
from smbus2 import SMBus
import time
bus = SMBus(1)
DIMMER_ADDR = 0x50
REG_LEVEL = 0x10
def set_level(level):
bus.write_byte_data(DIMMER_ADDR, REG_LEVEL, level)
# Set brightness to 50%
set_level(50)
Opción B: UART
⚠️ UART is timing-sensitive. If you see random bytes, dropped replies, or disconnects: give the board time to answer (allow ~100–200 ms between sending a command and reading the reply), and read all returned bytes for each command — a leftover unread byte desynchronizes the next exchange. Fixed 115200 8N1, raw HEX packets. If UART stays unreliable, switch to I2C (see note in Step 1) — it is the more robust interface.
Arduino:
// Use Serial1 (or SoftwareSerial for Uno)
#define DIMMER_SERIAL Serial1
void setup() {
DIMMER_SERIAL.begin(115200);
checkConnection();
}
void loop() {
setLevel(50); // 50%
delay(2000);
setLevel(100); // 100%
delay(2000);
}
void setLevel(uint8_t level) {
uint8_t cmd[] = {0x02, 0x53, 0x00, level};
DIMMER_SERIAL.write(cmd, 4);
// Wait for response
delay(10);
if (DIMMER_SERIAL.available()) {
uint8_t response = DIMMER_SERIAL.read();
// 0x00 = OK
}
}
// Connection check — request mains frequency
void checkConnection() {
uint8_t cmd[] = {0x02, 0x52};
Serial1.write(cmd, 2);
delay(50);
if (Serial1.available() >= 2) {
uint8_t status = Serial1.read();
uint8_t freq = Serial1.read();
if (status == 0x00) {
Serial.print("OK! Mains frequency: ");
Serial.print(freq);
Serial.println(" Hz");
}
}
}
Python:
import serial
import time
ser = serial.Serial('/dev/ttyUSB0', 115200, timeout=0.1)
def set_level(level):
cmd = bytes([0x02, 0x53, 0x00, level])
ser.write(cmd)
response = ser.read(1)
return len(response) > 0 and response[0] == 0x00
# Set brightness to 50%
if set_level(50):
print("OK")
else:
print("Error")
Paso 4: Verificar el funcionamiento
- Cargue el código en su microcontrolador
- Encienda DimmerLink
- Observe — la lámpara debería cambiar de brillo
Verificación de la conexión
I2C — Escaneo de dispositivos
Arduino:
#include
void setup() {
Serial.begin(115200);
Wire.begin();
Serial.println("Scanning for I2C devices...");
Wire.beginTransmission(0x50);
if (Wire.endTransmission() == 0) {
Serial.println("DimmerLink found at 0x50");
} else {
Serial.println("Device not found!");
}
}
void loop() {}
Raspberry Pi (línea de comandos):
# Install if not present:
sudo apt install i2c-tools
# Scan for devices:
i2cdetect -y 1
Resultado esperado — 50 en la intersección de la fila 5 y la columna 0.
UART — Verificación de respuesta
Envíe el comando de solicitud de frecuencia de red:
HEX: 02 52
Expected response:
- 00 32 — OK, frequency 50 Hz
- 00 3C — OK, frequency 60 Hz
¿No funciona?
| Problema | Solución |
|---|---|
| Sin respuesta | Verificar cableado y alimentación |
| Error 0xFC | Error de escritura EEPROM |
| I2C doesn't see device | Verificar conexiones y resistencias pull-up |
| Brillo incorrecto | Verificar niveles lógicos (3.3V/5V) |
What's Next?
← Descripción general | Contenido | Next: Hardware Connection →