User Tools

Site Tools


xmas:esp8266

Xlights with ESP8266 as an Infrared Transmitter

WARNING: This article is going to be HUGE.. Huge Jerry .. Huge !!!

Terminology:

IR - Infrared Hacks will be denoted by:

Target Audience: You got these cool piece of LED hardware (in my case, floodlights), and you want to control them with Xlights, but Don’t want to open them up, so you need to be able to control them with Xlights and IR.

Grabbing the IR Codes

NOTE: The setup is totally throw-away. You only need the IR codes

  • Tools Needed:
  • A computer
  • A breadboard and some jumper wires
  • An IR receiver module (Amazon)

  • An arduino of some kind (I used the Nano Every - I could have probably used the ESP8266, but I didn’t want to)
  • Arduino IDE
  • Your piece of crap IR transmitter

Wiring the breadboard

EE people.. Please don’t beat up on me.. For the love of Pete.

Arduino Sketch

My sketch isn’t mine. It was written by someone FAR FAR smarter than me.. I have a slightly modified version of it here:

Code

Once you have everything running, go to your serial monitor and record the hex codes.

WARNING: Each transmitter will be different. For my reference, the codes were as follows:

Color Code
Red 0xC
Yellow 0x5E
Green 0x4A
Blue 0x42
On 0x47
Off 0x43
Brighter 0x45
Dim 0x46
Red Built in Effect 0x16
Blue Built in Effect 0x19
Green Built in Effect 0xD
Bright White 0x1C
Cycle Colors 0x40
Teal 0x15
Orange 0x7

Cool Feature: The sketch will give you the instructions on how to transmit

Wiring the ESP8266

Again EE people.. I know.. I know..byte me. Pin D6 transmits at 3.3V, and just putting that resistor seemed to keep the diode from blowing up. The transmitter is weaker than I’d like, but I’d rather protect it and it’s tolerable. Programing the ESP8266

“My pain is your gain”

The ESP8266 will act as a web-server and an IR transmitter. The codely goodness can be found here: https://github.com/mlivolsi63/Arduino-with-Infrared/blob/master/IR_nodeMCU_OPC.ino

IF YOU DONT WANT TO READ THE COMMENTS BELOW, FINE.. BE LIKE THAT.. JUST REMEMBER TO CHANGE THE WIFI SID AND PASSWORD

There are plenty of examples of running a web server on the NodeMCU, just some notes about the web aspect. Xlights “talks” when using OPC on port 7890 The manufacturer of my unit (esp8266) specifies a baud rate of 9600 bits. OPC - Open Pixel Control

Before writing the program above, ChatGPT gave me an example program to run on Linux as an OPC server. I took that code, tested it with Xlights, and then modified it for the NodeMCU.

There’s a good article about OPC here: http://openpixelcontrol.org and it will explain the protocol. Caveats: Xlights will always send a command of 0 - so there’s no way to control that. Data lengths should always be a multiple of 3. In my case, I specified 12, but I’m only using 3 bytes

Hack: Since I can’t send commands, the above code does the following: In the first set of RGB colors (the 3 integers), if the first int (red) is less than or equal to 5, that’s an instruction to turn ON the LEDS. In the first set of RGB colors (the 3 integers), if the third (blue) int is less than or equal to 5, that’s an instruction to turn OFF the LEDS.

Programing Xlights

The Arduino script gave me the IP address, but you can also check your router for the IP address (dhcp). NOTE: The message data size is 12, but I only configured 2 models, so I’m only sending 6 bytes in the message (see OPC protocol above)

Mode Specification

Sequencing:

In Xlights, I start the channel with a value of ‘1’ using the fade tool with a color of RED. This instructs the code to run the LED command to power on the floodlights I end with a value of ‘1’ for color blue, which instructs the code to send an “off” command to the floodlights.

Other thoughts

I should have added an LED to my box to give me a visual if I’m connected to the Internet. I created these tamponish looking devices to transmit to the RGB floodlights. I split the signal in two to control two flood lights (and that way, they’ll always be synched).

xmas/esp8266.txt · Last modified: by mlivolsi