Potential E1.31 / WiFi mod for dumb strips & floods.

Barnabybear

Active member
Hi all, hope you’ve had a good Christmas and wish you all health and happiness for the new year.
This on the face of it is the most useless hack of the year, but it’s a proof of concept that could be quite useful to some people. It combines work from ‘ukewarrior’ (RGB LED hack) and ‘sporadic’ (software).

Someone gave me a colour changing light bulb (with IR remote) for Christmas and said “I bet you can do something with that” http://www.ecolight.pl/media/wysiwyg/E27.pdf the last one.

So in true DIYC style I fitted in a lamp, played with the remote for 2 minutes and headed for the internet. It appears that there are various hacks for them most using Arduinos to send or simulate the IR commands that are limited to 16 different colour / levels. Something more drastic was called for, out with the knife and off with the top.
IMG_0606.jpg
Back to the internet to find out what was on the board, the important bits:
A HT68F002 http://img.ozdisan.com/ETicaret_Dosya\455462_2776624.pdf
And some Si2302DS http://www.vishay.com/docs/70628/70628.pdf
We have something to play with and its 5v. I’m sure that if I could have been bothered to read the 177 pages and done some research on the HT68F002 I could have done something cool with it. But I couldn’t be bothered, so out with the knife cut the legs off and de-solder the feet. Solder some cat5 onto GND and the 3 output pads to the FETs (R,G and B) and into my parts box for a ESP8266-01 (you might have guessed from my posts I like these), 2 off 10K SMT resistors and 2 off 1n4005s (bought a lot others will work).

Rebuilding:
The ESP8266 is a 3.3V device but is quite tolerant, so I put the two diodes together from the 5V supply on the board to the ESP Vcc, given that the diodes will each drop 0.7V that should give me 3.6V at the ESP.
Ground from the ESP to Ground on the board.
GPIO 0 on the ESP to the Red FET on the board. Also GPIO 0 on the ESP to Vcc via a 10k resistor.
GPIO 2 on the ESP to the Green FET on the board. Also GPIO 2 on the ESP to Vcc via a 10k resistor.
GPIO 3 on the ESP to the Blue FET on the board.

Now I hear some of you shout – The ESP8266-01 only has 2 GPIOs 0 & 2. That’s sort of correct it only has 2 labelled as GPIOs, Tx and Rx are also GPIOs (1 & 3 respectively) you have to change them from their boot configuration using ‘pinMode(<PIN>, FUNCTION_<FUNCTION>);’ all the functions can be found here http://www.esp8266.com/wiki/doku.php?id=esp8266_gpio_pin_allocations
Anyway we need ‘pinMode(3, FUNCTION_3);’ to set Rx as a GPIO. I chose to sacrifice Rx so that I could still have Tx available for a serial connection to find out the IP address acquired and to debug. That sorted, what happens if we want to re-flash the ESP? In flash mode all pins are returned to their boot state, so Rx will still be Rx, plus you can now OTA update.

We need some code:
This is based on ‘sporadic’ ESP8266_Test.ino https://github.com/forkineye/E131/blob/master/examples/ESP8266_Test/ESP8266_Test.ino
To get any sort of decent control we are going to need 3 channels of PWM that can respond to 0 to 255 as commands. Fortunately the ESP is capable of PWM, the down side is that its rubbish at it. Every time you change the PWM ratio you have to stop and restart the output for it to take effect, with one exception – ‘analogWrite(<output>, <value>)'. The ESP doesn’t have a digital to analog converter, it uses a high frequency square wave output and relies on circuit capacitance to convert this to an analog signal. As this is PWM there is no reason why it shouldn't work with FETs and LEDs particularly as the parameters for an analogWrite with the ESP are 0 to 255 (don’t you just love this ?).
Finally to the sketch:
Code:
/*
* ESP8266_Test.ino - Simple sketch to listen for E1.31 data on an ESP8266 
*                    and print some statistics.
*
* Project: E131 - E.131 (sACN) library for Arduino
* Copyright (c) 2015 Shelby Merrick
* http://www.forkineye.com
*
*  This program is provided free for you to use in any way that you wish,
*  subject to the laws and regulations where you are using it.  Due diligence
*  is strongly suggested before using this code.  Please give credit where due.
*
*  The Author makes no warranty of any kind, express or implied, with regard
*  to this program or the documentation contained in this document.  The
*  Author shall not be liable in any event for incidental or consequential
*  damages in connection with, or arising out of, the furnishing, performance
*  or use of these programs.
*
*/

#include <ESP8266WiFi.h>
#include <E131.h>

const char ssid[] = "YOUR_SSID";         /* Replace with your SSID */
const char passphrase[] = "YOUR_PASSWORD";   /* Replace with your WPA2 passphrase */
const int universe = 1;   /* Replace with your universe number */
const int channel = 1;   /* Replace with your channel number */

E131 e131;

void setup() {
    // prepare GPIOs
    pinMode(0, OUTPUT);
    analogWrite(0, 0);
    pinMode(2, OUTPUT);
    analogWrite(2, 0);
    pinMode(3, FUNCTION_3);
    pinMode(3, OUTPUT);
    analogWrite(3, 0);

    Serial.begin(115200);
    delay(10);

    /* Choose one to begin listening for E1.31 data */
    e131.begin(ssid, passphrase);               /* via Unicast on the default port */
    //e131.beginMulticast(ssid, passphrase, universe); /* via Multicast for Universe 1 */
}

void loop() {
    /* Parse a packet */
    uint16_t num_channels = e131.parsePacket();
    
    /* Process channel data if we have it */
    if (num_channels) {
        Serial.print("Universe ");
        Serial.print(e131.universe);
        Serial.print(" / ");
        Serial.print(num_channels);
        Serial.print(" Channels | Packets: ");
        Serial.print(e131.stats.num_packets);
        Serial.print(" / Sequence Errors: ");
        Serial.print(e131.stats.sequence_errors);
        Serial.print(" / CH");
        Serial.print(channel +0);
        Serial.print(": ");
        Serial.print(e131.data[channel -1]);
        Serial.print(" / CH");
        Serial.print(channel +1);
        Serial.print(": ");
        Serial.print(e131.data[channel -0]);
        Serial.print(" / CH");
        Serial.print(channel +2);
        Serial.print(": ");
        Serial.println(e131.data[channel +1]);
        //output
        analogWrite(0, e131.data[channel -1]); 
        analogWrite(2, e131.data[channel +0]); 
        analogWrite(3, e131.data[channel +1]);         
    }
}
IMG_0607.jpg
The end result, 256 dimmable on all 3 colours, full mixing and WiFi controlable, with one down side, on power up the one colour of the device lights up untill a WiFi connection is found. It's a coding issue that is simple to sort (WiFi connection is called before the outputs are declared and set to 0), but was quite usefull for testing as when the bulb went dark I knew it had connected. It might even be a feature, for the first 2 mins at power up, Yellow connecting, Green connected and Red failed to connect. You could power up your display and watch the colour cycle through to all green before all going off.

I said at the start, this was only a proof of concept but is working really well and has demonstrated:
You can use more than two GPIOs, in practice 3, theory 4.
analogWrite works as PWM, they go off at Zero and everything.
On this unit the FETs seemed happy with the voltage and frequency supplied by the ESP.

In theory other dumb RGB strip, DC SSR or my next development, an RGB flood could be converted to E1.31 / WiFi provided you have access to the FETs.

Again thanks to ‘ukewarrior’ & ‘sporadic’ for doing most of the work and enabling me to have lots of fun.
 
Last edited:
Wow! Fun read! Looking forward to what else you come up with. :) Love those ESPs. Thinking I should have 50 lying around just for fun ideas. :)
 
Hi I have 4 of them just waiting for a genius to come with something like this
Keep it up geniuses and thank you
 
Hi Barnaby.
A little help with this sketch please.
I want to use a wemos running 2 rgb strips. Should I start with flashing espixelstick and overwrite with your sketch?


Verzonden vanaf mijn iPhone met Tapatalk
 
Hi, no do not use the espixelstick code. That code is only for pixels, renard or DMX use the code below. This will give you 6 outputs, D1, D2, D5, D6, D7 & D8, these can be used to drive the red green and blue of each strip. I would not connect any leds at this time, if you get it wrong you will damage the Wemos outputs.

Set the SSID and Password and flash the code to the Wemos.
Open a serial screen at 115200.
Then download da_E131 Test source from the link below.
Set universe to start 1 end 1.
Set channel start 1 end 6.
Set frame delay to 1000.
Set IP Host / Port to Multicast.
Now when you move the RGB sliders the serial values should change as well.
If you put a volt meter on the output it should move between 3.3V for 255 and 0V for 0.

Once that works we can look at connecting some leds without blowing up the outputs. You can try setting up Vixen or xlights to send out the E1.31 data if you want (having more than one data source open at one time will cause you problems).


http://www.da-share.com/software/da_e131/

Code:
// Wemos D1 Mini E1.31 - 6 channel dumb RGB led sketch.

#include <ESP8266WiFi.h>
#include <E131.h> // Copyright (c) 2015 Shelby Merrick http://www.forkineye.com

// ***** USER SETUP STUFF *****
const char ssid[] = "<YOUR_SSID>";  // replace with your SSID.
const char passphrase[] = "<YOUR_PASSWORD>"; // replace with your PASSWORD.
const int universe = 1; // this sets the universe number you are using.

// this sets the channel number used by the output.
const int channel_1_red = 1; // the channel number to link to output 1 red.
const int channel_1_green = 2; // the channel number to link to output 1 green.
const int channel_1_blue = 3; // the channel number to link to output 1 blue.
const int channel_2_red = 4; // the channel number to link to output 2 red.
const int channel_2_green = 5; // the channel number to link to output 2 green.
const int channel_2_blue = 6; // the channel number to link to output 2 blue.

// this sets the pin numbers to use as outputs.
const int output_1_red = 4; // the pin to use as output 1 red (D2).
const int output_1_green = 5; // the pin to use as output 1 green (D1).
const int output_1_blue = 12; // the pin to use as output 1 blue (D6).
const int output_2_red = 13; // the pin to use as output 1 red (D7).
const int output_2_green = 14; // the pin to use as output 1 green (D5).
const int output_2_blue = 15; // the pin to use as output 1 blue (D8).


E131 e131;

void setup() {
  Serial.begin(115200);

  // set the pins chosen above as outputs.
  pinMode(output_1_red, OUTPUT);
  pinMode(output_1_green, OUTPUT);
  pinMode(output_1_blue, OUTPUT);
  pinMode(output_2_red, OUTPUT);
  pinMode(output_2_green, OUTPUT);
  pinMode(output_2_blue, OUTPUT);

  // set the pins chosen above to low / off.
  analogWrite(output_1_red, 0);
  analogWrite(output_1_green, 0);
  analogWrite(output_1_blue, 0);
  analogWrite(output_2_red, 0);
  analogWrite(output_2_green, 0);
  analogWrite(output_2_blue, 0);

  /* Choose one to begin listening for E1.31 data */
 //e131.begin(ssid, passphrase);               /* via Unicast on the default port */
   e131.beginMulticast(ssid, passphrase, universe); /* via Multicast for Universe 1 */
}

void loop() {
  /* Parse a packet */
  uint16_t num_channels = e131.parsePacket();

  /* Process channel data if we have it */
  if (num_channels) {
  Serial.println("we have data");

    Serial.println(e131.data[channel_1_red -1]);
    Serial.println(e131.data[channel_1_green -1]);
    Serial.println(e131.data[channel_1_blue -1]);
    Serial.println(e131.data[channel_2_red -1]);    
    Serial.println(e131.data[channel_2_green -1]);
    Serial.println(e131.data[channel_2_blue -1]);
  
  // set the outputs to the data value.
  analogWrite(output_1_red, e131.data[channel_1_red -1] );
  analogWrite(output_1_green, e131.data[channel_1_green -1] );
  analogWrite(output_1_blue, e131.data[channel_1_blue -1] );
  analogWrite(output_2_red, e131.data[channel_2_red -1] );
  analogWrite(output_2_green, e131.data[channel_2_green -1] );
  analogWrite(output_2_blue, e131.data[channel_2_blue -1] );

  }
}
 
Hi,

I tried to setup the Wemos, I do get proper output in the serial monitor:
we have data
175
107
207
175
107
207

I wired everything as described in this page using irf540N mosfets.
https://learn.adafruit.com/rgb-led-strips/usage

But the output to the RGB strip is too low; measured by multimeter.
0v - RED - OFF
0.82V - RED - ON

Double checked the pinout, but this seems fine:
http://escapequotes.net/esp8266-wemos-d1-mini-pins-and-diagram

How can I spice up the output off the GPIO?
#analogWrite(output_1_red, e131.data[channel_1_red -1] );
 
Hi, that’s good news. The first thing that comes to mind is that the IFR540N may be the issue. These FETs are great with 5V systems but are really close to their lower limits in 3.3V systems.

If you look at the data sheet https://www.infineon.com/dgdl/irf540n.pdf?fileId=5546d462533600a4015355e396cb199f
Page 2; Electrical characteristics; VGS(th); this is the voltage difference between the Gate (Wemos) and the Source (Ground) and is 2V to 4V. What the manufacturer is saying is that the FET (depending on its construction) needs a voltage of between 2V and 4V in order to switch on. As the Wemos is a 3.3V device it is more down to the batch of FETs than circuit design. Some may switch fully on at 2.8V where as some may need 3.8V.

I would do a simple test to check the FETs you have. Remove the Wemos from the circuit (we don’t want to damage it) and use 1.5V batteries in its place.
3x 1.5V batteries (4.5V) will fully switch on the FET and prove the circuit works.
2x 1.5V batteries (3.0V) may switch on the FET but not fully and the LEDs will be dimmer and the FET may run much warmer than with 3 batteries. If this is the case you will have to look at a different FET.

If you look at the one they use in that example
https://cdn-shop.adafruit.com/datasheets/irlb8721pbf.pdf
Page 2; Electrical characteristics; VGS(th); this is the voltage difference between the Gate (Wemos) and the Source (Ground) and is 1.35V to 2.35V. This will fully switch on with the 3.3V of the Wemos outputs.

If this is the case and you have already purchased FETs that you don't think you'll use for anyting else there are some tricks we can use. Let me know how you get on.
 
Last edited:
Hi, that’s good news. The first thing that comes to mind is that the IFR540N may be the issue. These FETs are great with 5V systems but are really close to their lower limits in 3.3V systems.

If you look at the data sheet https://www.infineon.com/dgdl/irf540n.pdf?fileId=5546d462533600a4015355e396cb199f
Page 2; Electrical characteristics; VGS(th); this is the voltage difference between the Gate (Wemos) and the Source (Ground) and is 2V to 4V. What the manufacturer is saying is that the FET (depending on its construction) needs a voltage of between 2V and 4V in order to switch on. As the Wemos is a 3.3V device it is more down to the batch of FETs than circuit design. Some may switch fully on at 2.8V where as some may need 3.8V.

I would do a simple test to check the FETs you have. Remove the Wemos from the circuit (we don’t want to damage it) and use 1.5V batteries in its place.
3x 1.5V batteries (4.5V) will fully switch on the FET and prove the circuit works.
2x 1.5V batteries (3.0V) may switch on the FET but not fully and the LEDs will be dimmer and the FET may run much warmer than with 3 batteries. If this is the case you will have to look at a different FET.

If you look at the one they use in that example
https://cdn-shop.adafruit.com/datasheets/irlb8721pbf.pdf
Page 2; Electrical characteristics; VGS(th); this is the voltage difference between the Gate (Wemos) and the Source (Ground) and is 1.35V to 2.35V. This will fully switch on with the 3.3V of the Wemos outputs.

If this is the case and you have already purchased FETs that you don't think you'll use for anyting else there are some tricks we can use. Let me know how you get on.

Hi.
Sorry for the confussion.
When I measure voltage I did measure it directly on the gpio pin out. So wemos is limiting output of the analog output somehow.


Verzonden vanaf mijn iPhone met Tapatalk
 
Hi.
Sorry for the confussion.
When I measure voltage I did measure it directly on the gpio pin out. So wemos is limiting output of the analog output somehow.


Verzonden vanaf mijn iPhone met Tapatalk

On second thought the issue might be with the analog write. When the output is sent its just treated as output value. Shouldn’t this be:
5v/255*output ??


Verzonden vanaf mijn iPhone met Tapatalk
 
How can I spice up the output off the GPIO?
#analogWrite(output_1_red, e131.data[channel_1_red -1] );

Hi, sorry - my bad. Arduinos only have a 8 bit analog output (0 to 255) the ESPs / Wemos are 10bit (0 to 1023). An easy fix *4.
Code:
analogWrite(output_1_red, e131.data[channel_1_red -1] );

analogWrite(output_1_red, (e131.data[channel_1_red -1] *4));

I must go back and try that bulb again - I never realy did anything with it as it wasn't very bright - it looks like it was me that wasn't very bright.
 
Last edited:
Hi, sorry - my bad. Arduinos only have a 8 bit analog output (0 to 255) the ESPs / Wemos are 10bit (0 to 1023). An easy fix *4.
Code:
analogWrite(output_1_red, e131.data[channel_1_red -1] );

analogWrite(output_1_red, (e131.data[channel_1_red -1] *4));

[emoji1320] I will try tonight! Many thanks sofar.
Did make some changes, will upload a working sketch if all works out!!

Thanks. Martijn


Verzonden vanaf mijn iPhone met Tapatalk
 
Hahaha, no problem dude :)

I tried the 4* multiplier. This gives me a proper 3.3v output.
This is however too low for the irf540 mosfet.
The led lights up but not very bright. I meassure 7V output as where it should be 12V.

Easiest way is put another arduino (nano) between the in- and output, but far from ideal.
Pretty stuck, is there a way to juice up the voltage from 3 to 5v?
 
Hahaha, no problem dude :)

I tried the 4* multiplier. This gives me a proper 3.3v output.
This is however too low for the irf540 mosfet.
The led lights up but not very bright. I meassure 7V output as where it should be 12V.

Easiest way is put another arduino (nano) between the in- and output, but far from ideal.
Pretty stuck, is there a way to juice up the voltage from 3 to 5v?


The proper way is to use the correct MOSFET IRLB8721, if you really must cheat put a silicon diode between the ground on the Wemos and the ground of the FETs, Anode to the Wemos.

IMPORTANT when you power the Wemos you use the normal 5V terminal and the FET side of the diode not the ground terminal on the Wemos. What it does is make the ground of the Wemos 0.7V higher than the ground of the FET. Instead of the FET seeing 0 to 3.3V it sees 0.7 to 4V. As 0.7V is low enough to switch the FET off this doesn’t matter.

EDIT: ANODE to the Wemos.
 
Last edited:
This is really useful. Just wondering if some one could upload a circuit diagram of how to hook up led to a esp 8266?

Thanks
 
This is really useful. Just wondering if some one could upload a circuit diagram of how to hook up led to a esp 8266?

Thanks

Hi, more than happy to. Can you give me / us an idea of what your wanting to drive with this (any link are good).
 
Hi, hand drawn schematic below. The 270R resistor is to protect the wemos outputs, if you don’t have one 330R or 220R will do. This switches the connection to ground (low side) so can be used for voltages greater than 5V if needed. There are 6 GPIOs that I would start with: 12, 13, 14, 15, 4 & 5. You can repeat this circuit for each GPIO / channel you wish to control; you may need current limiting resistors for the LEDs dependant on which you use.


Once you get some bits wired up if you need help with the sketch let me know.

IMG_0786.JPG

EDIT:
I didn't lable the pins on the FET.
Top = Drain.
Side = Gate.
Bottom = Source.
 
Last edited:
Thank you for the wiring diagram. I've got it hooked and working.

I'm trying to add the wifi manager code for fun. However because I deleted the code for the wifi config I get error frm this code:

/* Choose one to begin listening for E1.31 data */
//e131.begin(ssid, passphrase); /* via Unicast on the default port */
e131.beginMulticast(ssid, passphrase, universe); /* via Multicast for Universe 1 */

My SSID and passphrase is sorted by the wifi manager... Can anybody help me?
 
Just wanted to say thank you for the code. I'm using it to drive rudolph's 100w red nose with a mosfet and light up the reindeer with 8 relays.

Sent from my SM-G930V using Tapatalk
 
Just wanted to say thank you for the code. I'm using it to drive rudolph's 100w red nose with a mosfet and light up the reindeer with 8 relays.

Sent from my SM-G930V using Tapatalk

Hi, thanks. Glad it was of use, can you put up some pics when you get chance please the 100W red nose has my interest.
 
Back
Top