RGB Controller with Wemos D1 Mini

192 views
Skip to first unread message

vampiris

unread,
Dec 3, 2018, 10:49:41 AM12/3/18
to Loxone English

Hi guys,

I have made two RGB controllers with Wemos d1 mini. I have flash the Wemos with the ESP Mega and controlling them with the RGB Lighting Controller fuction block and three virtual outputs, one analogue output for red, one for the blue and one for the green. Since i am not a guy that knows a lot about programming, i choose the easy way and just controlling each GPIO of the controller with the following commands, for on: http://<espeasyip>/control?cmd=PWM,13,500 (to able to dim the led strip) and for off: http://<espeasyip>control?cmd=GPIO,13,0, the same for the other outputs. No rules, no devices, no coding on the Esp Mega.

But i am facing two problems. The first is that when, for example, the color of the controller is white and i am choosing the red with the app, i can see for a fraction of time that the controller flashes another color from a different scene and then goes to red. The second and bigger is that there is a big delay when i am scrolling through different colors from the color picker. I can see a 5 to 10 seconds delay.

So, i was wondering if there is a way to use the AQa output of the RGB Lighting Controller and control at the same time the three GPIO's of the Wemos D1? Do you think that this will solve the problems or is it something normal, since this is a homemade RGB controller?

Duncan

unread,
Dec 3, 2018, 11:42:30 AM12/3/18
to Loxone English
espeasy and the wemos d1 is single threaded - asking it to do anything else is likely to see a pause or change in the pwm output

if you are asking it to run pwm on 3 outputs at once, i suspect you are probably reaching the limits of the hardware capability

vampiris

unread,
Dec 3, 2018, 1:58:07 PM12/3/18
to Loxone English
OK, forget the pwm of the three outputs for the moment. Lets say that i want to switch between the basic colors (red, blue, green, cyan, white) without facing the first problem i described in my previous message. I want the three outputs to be "1" or "0" at the same  time. Do you think that this is possible with a single htpp command? As you can see in the picture, each color has a virtual output with a http command for on and off. So if the RGB controller is off and i want to turn on the White color, then three command will be send at the same time. That's exactly the moment that i see the Red color coming on for a fraction of a second.

RGB.png

Duncan

unread,
Dec 3, 2018, 2:38:12 PM12/3/18
to loxone-...@googlegroups.com
im not that familiar with all espeasy commands, but im fairly sure you have to send each output command separately.

i dont know the speed of processing these commands but cant imagine that you should be able to visually see the time taken i.e. 1/50 second or longer

areas of delays or slowdowns to exclude:

loxone speed of sending 3 separate commands
speed of transmission - poor wifi for instance
speed of espeasy
speed of adjusting the output - solid state i assume driven by the wemos io pin

just as a little experiement, swap round the 3 loxone virtual outputs and see if it still flashes red or another colour

if you dim up each colour at the same time i.e 1 step r, 1 step g, 1 step b and so on, the relative changes in colour away from the target colour should be impereceptable - this is achievable if the 3 virtual outputs send the brightness value as a <v> in the virtual output - each change of the value resends the virtual output again with the new value:

http://<espeasyip>/control?cmd=PWM,13,<v>
the rgb output from loxone use 0-100(%), but the pwm needs values from 0-1023, so you will need to multiply the output values by 10 to get the full range of brightness from your strip

you could add a very slight fade rate to the VI to smooth things out if necessary

John Verdicchio

unread,
Dec 4, 2018, 5:45:10 AM12/4/18
to Loxone English
if the sending of 3 http requests is causing a delay then one can send the 3 values as a single value:
red=10
green=20
blue=30
### Will work up to values of 255 for each of red, green, blue
combined = 256*256*red+256*green+blue <<< send the "combined" value via the http
### then to untangle at the other end
redOut = combined >>16
shift1 = combined-redOut*256*256
greenOut = shift1 >> 8
blueOut = shift1 - greenOut*256

I believe EasyESP does support the ">>" or bit-shift operator.

vampiris

unread,
Dec 4, 2018, 7:55:15 AM12/4/18
to Loxone English
Duncan, thanks for the answer, but i can't understand the sentence "just as a little experiment, swap round the 3 loxone virtual outputs and see if it still flashes red or another colour"!  Can you give more details about what should i do?


John, as i wrote in my first message i am not a programming guy. Can you give a more detailed instructions of what should i do?  I believe that your idea is closer to what i want, but i can not figure out the configuration of the Virual Output (or outputs) of the Miniserver and if i must use a Rule on the ESP Mega?!
 

John Verdicchio

unread,
Dec 4, 2018, 9:50:01 AM12/4/18
to Loxone English


On Tuesday, 4 December 2018 12:55:15 UTC, vampiris wrote:
Duncan, thanks for the answer, but i can't understand the sentence "just as a little experiment, swap round the 3 loxone virtual outputs and see if it still flashes red or another colour"!  Can you give more details about what should i do?


John, as i wrote in my first message i am not a programming guy. Can you give a more detailed instructions of what should i do?  I believe that your idea is closer to what i want, but i can not figure out the configuration of the Virual Output (or outputs) of the Miniserver and if i must use a Rule on the ESP Mega?!
 
You can use a maths block to code the RGB values into a single output parameter. Then send the parameter as a virtual output to the ESP.

HTTP call

When you enter this first command with the correct IP address in the URL of your browser:

 http://<espeasyip>/control?cmd=event,startwatering
 http://<espeasyip>/control?cmd=event,stopwatering

And have this rule in the addressed ESP:

On startwatering do 
  gpio,12,1 //start watering (open valve)
  timerSet,1,600 //timer 1 set for 10 minutes
endon
 
On stopwatering do 
  timerSet,1,0 //timer 1 set to halt, used to stop watering before the timer ends!
  gpio,12,0 //stop watering (close valve)
endon
 
On Rules#Timer=1 do  
   gpio,12,0 //stop watering (close valve)
endOn
 One can send values like this:

Now send this command to the ESP:

http://<espeasyip>/control?cmd=event,remoteTimerControl=5

Hope this helps. 

vampiris

unread,
Dec 5, 2018, 12:12:55 PM12/5/18
to loxone-...@googlegroups.com
I spent some time with the code you gave me, but i had no result. I wasn't able to find how to define the gpio,1 = redout, to define the combined value = %eventvalue%, etc, also Wemos outputs on pwm is between 1 to 1023, not 0 to 256 and a lot of other problems.

At least i tried to control all the three outputs with a single "Event" and see if Duncan was right and the hardware couldn't switch on and off the three outputs at the same time. I made the "White Event", "Blue Event" (etc) and then i switch on the different "Events". And i didn't see any time delay between the colors, each color turned on immediately. I am 90% sure that the RGB controller is capable to control the led strip as it should.

If someone has any idea about the code, i am willing to try it.

Duncan

unread,
Dec 5, 2018, 2:28:09 PM12/5/18
to Loxone English
can you post the code you used for your loxone virtual outputs please

vampiris

unread,
Dec 5, 2018, 4:09:53 PM12/5/18
to Loxone English
What code do you mean?

Duncan

unread,
Dec 5, 2018, 4:48:02 PM12/5/18
to Loxone English
the virtual output command you created in loxone to send the commands to the wemos, and any manipulation of the rgb data you did in loxone between the light block and the virtual output

John Verdicchio

unread,
Dec 6, 2018, 5:17:36 AM12/6/18
to Loxone English


On Wednesday, 5 December 2018 17:12:55 UTC, vampiris wrote:
I spent some time with the code you gave me, but i had no result. I wasn't able to find how to define the gpio,1 = redout, to define the combined value = %eventvalue%, etc, also Wemos outputs on pwm is between 1 to 1023, not 0 to 256 and a lot of other problems.
I used a range of 0->255 in my example. If you really want 1024 levels then you could change the 256->1024 and then bit shift by 10 and 20 rather than 8 and 16. However, I doubt the human eye can detect 1024 different levels. So, easier to scale the values e.g.
newRedLevel = 1022*(oldRedLevel-255)/255+1023 etc.

fred.png

For the ESPEasy code, can you tell me what GPIO you have ; which devices you have (from Devices menu on ) ; which version of ESPEasy (see Tools/Info).  I'll try and have a look for you.

You may be able to get some help configuring your Wemos from the https://www.letscontrolit.com/forum/ ; this forum is very active as well and I suspect your post may get a quicker answer from that forum (the ESP question is slightly off topic for a Loxone forum). 

vampiris

unread,
Dec 6, 2018, 7:23:04 AM12/6/18
to Loxone English
First of all i don't believe my question is off topic, because if i make the RGB controller work as supposed, then i will upload the PCB schematic and everyone with basics skills on soldering and a power outlet near by, will have the opportunity to use an RGB led strip with a cost of few euros.

Second, i thought to post my question to the forum of Letscontrolit, but since i don't speak very well English, maybe i must answer questions about the Miniserver, i will have to answer question about coding, etc, etc, so it is not an option for me right now. And as i said the RGB controller is working fine for my needs, except the two "problems" i mentioned. I thought that for a person with knowledge of coding and how Miniserver works, it will be something easy. That's why i posted my question here.

I am using GPIO14 for Red color, GPIO 0 for Green and GPIO 4 for Blue. I don't use any Devices, i just control the GPIO's with three Virtual Outputs. Each VO sends http commands for ON and OFF. For Blue Color the commands are for ON: http://<espeasyip>/control?cmd=PWM,4,<v.1> and for OFF: http://<espeasyip>//control?cmd=GPIO,4,0. I am using each VO as an analogue output with the following correction Input Value 1=0, Output Value 1=0 and Input Value 2=10, Output Value 1=1023.

John Verdicchio

unread,
Dec 7, 2018, 5:34:26 AM12/7/18
to loxone-...@googlegroups.com
I got this working on my Sonoff TH16:
Under the Rules

On startheater do
  TaskValueSet,3,1,%eventvalue%*60 
  gpio,12,1 //turn heater on
  timerSet,1,[TimeForHeater#time] //timer 1 set for x minutes
endon
 
On stopheater do 
  gpio,12,0 //timer 1 set to halt, used to stop heater before the timer ends!
 endon

On Rules#Timer=1 do  
   gpio,12,0 // turn heater off
endOn

Under devices, add a dummy device, see 

fred3.png

Configure device like this:

fred4.png


Then to turn on the heater for 2 minutes send the command:


http://ip_address_of_sonoff://control?cmd=event,startheater=2

The "startheater" after event is the name of the "on startheater" in the rule.

What it lacks at the moment is the maths to untangle the RGB signal that could be sent. One can add multiple gpio commands within the "On" block. e.g.
On startheater do
  TaskValueSet,3,1,%eventvalue%*60 
  gpio,14,1 //turn heater on
  gpio,4,1 
  gpio,0,1 
  timerSet,1,[TimeForHeater#time] //timer 1 set for x minutes
endon

I'm going to see if I can get the untangling to work. I suspect you may only get 10 levels of brightness per channel as it looks like I'm restricted to decimal arithmetic (no bit shifting as I thought there was). Use an encode of valueToSend = 100*R + 10*G +B where R,G,B range from 0->9

Then , one just has to untangle %eventvalue% in ESPeasy.

vampiris

unread,
Sep 5, 2019, 4:57:27 PM9/5/19
to Loxone English
A small update here for those who are interested. I must say that i was able to make the RGB controller with the Wemos D1 mini, but i had some minor problems. I won't get into details, but for almost a year it worked very good for my needs.

Three weeks ago i thought to give a try with the Shelly RGBW2 controller. The company has published the HTTP commands for the communication with the controller and i must say that it works excellent, no extra programming with the Loxone configuration software or with the ESP easy is needed.

Now the good news is that you can use the RGBW2 as a dimmer for some 24V or 12V bulbs or to controll independently four white led strips. The truth is that i ordered only one to test it as a RGB controller and i haven't test it with GU10 or MR16 spot lights. But i know that many of you are using 24V dc lighting circuits, so if you need a simple solution to dim some lights, maybe the Shelly RGBW2 is a solution for your needs. It supposed that can  handle 90W per channel at 24 volts. I can only confirm that the the http commands are working and you can control the four channels independently.

As an RGB controller is working perfect for three weeks now. It has never lost connection with my WiFi network and the commands are executed immediately.

There are also many other products, like the Shelly 1 a WiFi operated relay switch and the Shelly 2.5 a double relay switch for shutters etc.

Reply all
Reply to author
Forward
0 new messages