Tunsworthy / 2-Wire-Controller

Code to load onto an ESP8266 to control a l293d

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

2-Wire LED Controller

This project provides a firmware for a 2-wire LED controller based on the L293D mini H-bridge motor driver. The controller is designed to work with a 2-wire LED strip and is controllable via MQTT.

Getting Started

Prerequisites

  • Arduino IDE or PlatformIO
  • An ESP8266-based development board, such as the NodeMCU v2 or the Wemos D1 mini
  • A 2-wire LED strip
  • An MQTT broker

Hardware Setup

  1. Connect the 2-wire LED strip to the L293D mini H-bridge motor driver as follows:
    • LED strip positive (+) wire to INPUT_1
    • LED strip negative (-) wire to INPUT_2
  2. Connect the L293D mini H-bridge motor driver to the ESP8266-based development board as follows:
    • ENABLE_A to D1 (GPIO5)
    • INPUT_1 to D2 (GPIO4)
    • INPUT_2 to D3 (GPIO0)
  3. Power the development board and the LED strip.

Software Setup

  1. Clone or download this repository.
  2. Update the Wi-Fi and MQTT configurations in config.h to match your setup.
  3. Update the pin assignments in hardware.h to match your hardware configuration.
  4. Compile and upload the firmware to your development board using the Arduino IDE or PlatformIO.

Usage

Once the firmware is uploaded to your development board and the hardware is set up, you can control the LED strip using MQTT messages. The firmware subscribes to the following topics:

  • cmnd/<device_id>/power: Controls the power state of the LED strip. Accepted values are ON and OFF.
  • cmnd/<device_id>/effect: Controls the effect of the LED strip. Accepted values are:
    • Combination
    • In Waves
    • Sequential
    • Slo Glo
    • Chasing /Flash
    • Twinkle
    • SteadyOn
    • Slow Fade Alternate
  • tele/<device_id>/effect: Returns the current effect
  • tele/<device_id>/status: Returns the current power state

Examples

  • To turn on the LED strip, publish the message ON to the topic cmnd/<device_id>/power.
  • To set the effect of the LED strip to "slow glow", publish the message slowGlo to the topic cmnd/<device_id>/effect.

About

Code to load onto an ESP8266 to control a l293d


Languages

Language:C++ 90.5%Language:C 9.5%