Skip to content

A RESTful API implementation to control an RGB LED Strip using an ESP8266 microcontroller.

License

Notifications You must be signed in to change notification settings

c-klinger/esp8266-arduino-wifirgb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

esp8266-arduino-wifirgb

A RESTful API implementation to control an RGB LED Strip using an ESP8266 microcontroller. Supports RGB or HSV color model. There is a german post on my blog containing more details about the project.

Schematics

WifiRGB Schematics

The circuit uses an LD1117V33 voltage regulator with two capacitors as specified in the datasheet. The connection of the ESP-12 is spoecified in th the improved stability schematic of the ESP8266 for Arduino. Three IRLB8721 N-channel MOSFETs (one per RGB Stripe channel) are used as power transistors to save our ESP-12 from an early death. The two tactile switches are added for easier programming.

Code

Dependencies

The following dependencies have to be installed in Arduino IDE using library or board manager (see project readme) to compile this project. The mentioned versions are tested, other may work as well but may lead to compile issues.

The following dependencies will be loaded using a CDN for the web ui. There is no need to install them, but an internet connection is needed for the ui to display.

Configuration

In the main Arduino Sketch WifiRGB.ino some changes need to be done before uploading to the ESP8266 microcontroller.

Wifi Network Settings

Required network settings are the Network SSID and password:

const char* ssid = "your_ssid";
const char* password = "your_wifi_password";
const char* deviceName = "wifi-rgb";

You can choose between a static or -with DHCP- dynamic IP adress. Default is an static IP adress configured in the following code block:

IPAddress clientIP(192, 168, 178, 250); //the IP of the device
IPAddress gateway(192, 168, 178, 1); //the gateway
IPAddress subnet(255, 255, 255, 0); //the subnet mask

If you want to use DHCP just ignore those settings and comment or remove the following line:

WiFi.config(clientIP, gateway, subnet);

Internal LED

The internal microcontroller LED is used to indicate the Wifi connection status.

#define BUILTIN_LED 2 // internal ESP-12 LED on GPIO2

RGB Output Pins

If you want to use own schematics you can adjust the different output channels in the following code block.

#define REDPIN 12
#define GREENPIN 14
#define BLUEPIN 5

Usage

RESTful API

The controller accecpts POST request at http://ip-adress/api/v1/state. The request must contain one of the following JSON objects in body.

RGB

{
  "state": "ON",
  "brightness": 100,
  "color": {
    "mode": "rgb",
    "r": 255,
    "g": 125,
    "b": 75
  },
  "mode": "SOLID"
}

HSV

{
  "state": "ON",
  "brightness": 100,
  "color": {
    "mode": "hsv",
    "h": 250,
    "s": 50,
    "v": 50
  },
  "mode": "SOLID"
}

Graphical User Interface

A User Interface using iro.js is available at http://ip-adress/ui. An Internet connection is required to load additional Javascript libraries from CDN (see dependencies section).

License

Copyright (c) 2018 Chris Klinger. Licensed under MIT license, see LICENSE for the full license.

Bugs

See https://github.com/c-klinger/esp8266-arduino-wifirgb/issues.

About

A RESTful API implementation to control an RGB LED Strip using an ESP8266 microcontroller.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published