[ESP8266] Commercial H801 WiFi RGB-dimmer topic

Everything about esp8266 and more.
User avatar
ledfreak3d
Posts: 79
Joined: Sunday 01 November 2015 16:30
Target OS: Linux
Domoticz version: 3.8025
Location: Hoorn
Contact:

Re: [ESP8266] Commercial H801 WiFi RGB-dimmer topic

Post by ledfreak3d » Saturday 12 November 2016 13:33

DarkFoxDK wrote:
deennoo wrote:
MadBanana wrote:ledfreak3d

Code: Select all

...
   runcommand = "curl 'http://" .. IP .. "/control?cmd=PWM,"  ..PIN.. "," .. CalcValue .. "'";
...
How does os.execute curl compare to the OpenURL command in speed?
Edit: Should've just tested it. It's much faster. Script below updated.


This is my current script for driving my ESPEasy lights, including a way to simulate white on RGB-only strips. It also uses a curve to get higher resolution at the lower end, where the brightness changes are more noticeable.

Code: Select all

local lights = {
  ['Stuereol Spots'] = {ip = '192.168.33.61', pin = '14', rgb = false},
  ['Stuereol Skab'] = {ip = '192.168.33.61', pin = '4', rgb = false},
  ['Vitrineskab'] = {ip = '192.168.33.62', pin = '13', rgb = false},
  ['Kontorreol'] = {ip = '192.168.33.64', pin = '13', rgb = false},
  ['Skrivebord'] = {ip = '192.168.33.67', pin = '14', rgb = false},
  ['Sengelys'] = {ip = '192.168.33.66', pin = '14', rgb = false},
  ['Kontorhylde W'] = {ip = '192.168.33.67', red = '15', grn = '13', blu = '12', rgb = true},
  ['Stuereol W'] = {ip = '192.168.33.61', red = '15', grn = '13', blu = '12', rgb = true},
  ['Seng W'] = {ip = '192.168.33.66', red = '15', grn = '13', blu = '12', rgb = true}
}

function setlight (ip, pin, dvalue)
    os.execute("curl 'http://" .. ip.. "/control?cmd=PWM,".. pin .."," .. tostring(dvalue) .. ",128'")
end

commandArray = {}

for deviceName,deviceValue in pairs(devicechanged) do
    if (lights[deviceName]) then
        if (deviceValue == 'Off') then
            dvalue = 0
        elseif (deviceValue == 'On') then
            dvalue = 1024
        else
            inputValue = tonumber(otherdevices_svalues[deviceName])
            
            curve = 1.5848931924611
            normalizedCurVal  =  (inputValue - 1.0) / 99.0
            rangedValue =  (math.pow(normalizedCurVal, curve) * 1023.0) + 1.0
            
            dvalue = math.ceil(rangedValue)
        end
    
        if (lights[deviceName]['rgb']) then
            setlight(lights[deviceName]["ip"], lights[deviceName]["red"], dvalue)
            setlight(lights[deviceName]["ip"], lights[deviceName]["grn"], dvalue)
            setlight(lights[deviceName]["ip"], lights[deviceName]["blu"], dvalue)
        else
            setlight(lights[deviceName]["ip"], lights[deviceName]["pin"], dvalue)
        end
    end
end
return commandArray
2nd edit: Cleaned up the code a bit.
humz keep getting a error in domotiz when I try this one

[string "local lights = { ..."]:12: bad argument #1 to 'pairs' (table expected, got nil)
cant realy figure out why
Unleashe the magic smoke ;)

DarkFoxDK
Posts: 30
Joined: Saturday 02 January 2016 3:22
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Re: [ESP8266] Commercial H801 WiFi RGB-dimmer topic

Post by DarkFoxDK » Saturday 12 November 2016 15:42

ledfreak3d wrote: humz keep getting a error in domotiz when I try this one

[string "local lights = { ..."]:12: bad argument #1 to 'pairs' (table expected, got nil)
cant realy figure out why
Did you create it as a device-type script? Otherwise, the deviceschanged table is empty.

Oh, and there's a trick to get the full 1-100 steps on a dummy dimmer switch (Normally it'll round it to something like only 12 steps).
1. Create a dummy Selector switch.
2. Edit it and make sure everything is as you want it (Due to a bug, you can't edit it later*).
3. Set the switch type to dimmer.

Now the dummy switch will have the full 100 steps available.


* Unless you use your browser's debugging tool, to change the switch type to "Dimmer" in the edit link.

User avatar
ledfreak3d
Posts: 79
Joined: Sunday 01 November 2015 16:30
Target OS: Linux
Domoticz version: 3.8025
Location: Hoorn
Contact:

Re: [ESP8266] Commercial H801 WiFi RGB-dimmer topic

Post by ledfreak3d » Saturday 12 November 2016 19:21

yea that was my mistake I did not add it as a device script
managed to find that adding it as a selector first and then changing it to a dimmer fixed the issue that it wont go tom100 % brightness
Unleashe the magic smoke ;)

Reley
Posts: 12
Joined: Wednesday 03 August 2016 8:25
Target OS: Raspberry Pi
Domoticz version: 3.4834
Location: Netherlands
Contact:

Re: [ESP8266] Commercial H801 WiFi RGB-dimmer topic

Post by Reley » Friday 25 November 2016 23:00

Crap... Even with the FTDi I receive an error

Uploading 416064 bytes from C:\Users\Remco\AppData\Local\Temp\arduino_build_539286/ESPEasy.ino.bin to flash at 0x00000000
................................................................................ [ 19% ]
.......................Er is een fout opgetreden bij het uploaden van de schets

I have tried many settings, but all the time the same error...
How the h*ll did you upload the ESPeasy firmware... :roll:

User avatar
ledfreak3d
Posts: 79
Joined: Sunday 01 November 2015 16:30
Target OS: Linux
Domoticz version: 3.8025
Location: Hoorn
Contact:

Re: [ESP8266] Commercial H801 WiFi RGB-dimmer topic

Post by ledfreak3d » Friday 25 November 2016 23:04

what settings did you use in the Arduino ide to compile and upload
and whats the size if your esp's flash ?
Capture.PNG
Capture.PNG (178.38 KiB) Viewed 4083 times
Unleashe the magic smoke ;)

Reley
Posts: 12
Joined: Wednesday 03 August 2016 8:25
Target OS: Raspberry Pi
Domoticz version: 3.4834
Location: Netherlands
Contact:

Re: [ESP8266] Commercial H801 WiFi RGB-dimmer topic

Post by Reley » Saturday 26 November 2016 10:38

How can I check the size of the h801's flash?
I will make a screenshot this evening...

MadBanana
Posts: 28
Joined: Thursday 13 October 2016 21:45
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Kent, England
Contact:

Re: [ESP8266] Commercial H801 WiFi RGB-dimmer topic

Post by MadBanana » Saturday 26 November 2016 12:14

Reley wrote:How can I check the size of the h801's flash?
I will make a screenshot this evening...
My settings are the same as the post from ledfreak3d except that my Flash Mode is "DIO" - no idea why though, but it works! My baud rate is 115200, not had any problems with any of my three H801s ...

My H801 flash looks to be a 25Q80 - I think all mine are the same so these settings should be ok for you too.

MadBanana
Posts: 28
Joined: Thursday 13 October 2016 21:45
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Kent, England
Contact:

Re: [ESP8266] Commercial H801 WiFi RGB-dimmer topic

Post by MadBanana » Saturday 26 November 2016 12:38

MadBanana wrote:
Reley wrote:How can I check the size of the h801's flash?
I will make a screenshot this evening...
My H801 flash looks to be a 25Q80 - I think all mine are the same so these settings should be ok for you too.
And ESPEasy reports .. Flash Size: 1024 kB

Reley
Posts: 12
Joined: Wednesday 03 August 2016 8:25
Target OS: Raspberry Pi
Domoticz version: 3.4834
Location: Netherlands
Contact:

Re: [ESP8266] Commercial H801 WiFi RGB-dimmer topic

Post by Reley » Saturday 26 November 2016 12:58

See attachment
I have tried allmost all flash sizes... none is working.
I even tried to upload a small sketch to determine the size, but that also does not work...

I have connected 4 wires to my ftdi, (3,3 gnd tx/rx) and shorted J3 on the 801..
Naamloos.jpg
Naamloos.jpg (50.9 KiB) Viewed 4047 times

Tried with the same settings, no go. 115200 baud is not working as well. It needs 9600....

MadBanana
Posts: 28
Joined: Thursday 13 October 2016 21:45
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Kent, England
Contact:

Re: [ESP8266] Commercial H801 WiFi RGB-dimmer topic

Post by MadBanana » Saturday 26 November 2016 13:33

Reley wrote:See attachment
I have tried allmost all flash sizes... none is working.
I even tried to upload a small sketch to determine the size, but that also does not work...

I have connected 4 wires to my ftdi, (3,3 gnd tx/rx) and shorted J3 on the 801..

Naamloos.jpg


Tried with the same settings, no go. 115200 baud is not working as well. It needs 9600....
That's strange, I have had no issues at all. A couple of points to check - don't feed the H801 off the FTDI as there may not be enough current to reliably flash. My H801 header has TX and RX swapped - so you need to join TX to TX and RX to RX (and not swapped as you'd expect). You've probably already found this though!

Reley
Posts: 12
Joined: Wednesday 03 August 2016 8:25
Target OS: Raspberry Pi
Domoticz version: 3.4834
Location: Netherlands
Contact:

Re: [ESP8266] Commercial H801 WiFi RGB-dimmer topic

Post by Reley » Saturday 26 November 2016 18:44

MadBanana wrote:
Reley wrote:See attachment
I have tried allmost all flash sizes... none is working.
I even tried to upload a small sketch to determine the size, but that also does not work...

I have connected 4 wires to my ftdi, (3,3 gnd tx/rx) and shorted J3 on the 801..

Naamloos.jpg


Tried with the same settings, no go. 115200 baud is not working as well. It needs 9600....
That's strange, I have had no issues at all. A couple of points to check - don't feed the H801 off the FTDI as there may not be enough current to reliably flash. My H801 header has TX and RX swapped - so you need to join TX to TX and RX to RX (and not swapped as you'd expect). You've probably already found this though!

Tried everything... but with an external power supply he won't upload at all. He can't connect.

MadBanana
Posts: 28
Joined: Thursday 13 October 2016 21:45
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Kent, England
Contact:

Re: [ESP8266] Commercial H801 WiFi RGB-dimmer topic

Post by MadBanana » Saturday 26 November 2016 19:56

Reley wrote:Tried everything... but with an external power supply he won't upload at all. He can't connect.
Ok, I've not read your previous posts so apologies if you've already tried:-

1) flash original firmware using esptool

2) flash ESPEasy using esptool

3) a different USB --> serial unit

do you get the same errors?

deennoo
Posts: 937
Joined: Wednesday 10 December 2014 14:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: [ESP8266] Commercial H801 WiFi RGB-dimmer topic

Post by deennoo » Saturday 26 November 2016 20:04

With external power : don't forget to join gnd to your programmer
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / ESP8266 / MQTT / BLE
http://domo-attitude.fr

Reley
Posts: 12
Joined: Wednesday 03 August 2016 8:25
Target OS: Raspberry Pi
Domoticz version: 3.4834
Location: Netherlands
Contact:

Re: [ESP8266] Commercial H801 WiFi RGB-dimmer topic

Post by Reley » Monday 28 November 2016 15:57

With external power and ground connected it gives another error:

Code: Select all

warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed
[/s]

Working!
Don't know how, but its working now!

Now trying to create some nice hardware in domoticz...

MadBanana
Posts: 28
Joined: Thursday 13 October 2016 21:45
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Kent, England
Contact:

Re: [ESP8266] Commercial H801 WiFi RGB-dimmer topic

Post by MadBanana » Monday 28 November 2016 22:57

Reley wrote: Working!
Don't know how, but its working now!

Now trying to create some nice hardware in domoticz...
Well done - enjoy!!

frankv
Posts: 1
Joined: Wednesday 07 December 2016 23:05
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [ESP8266] Commercial H801 WiFi RGB-dimmer topic

Post by frankv » Wednesday 07 December 2016 23:13

Hi all,
Apologies for resurrecting an old thread, and being somewhat off-topic for Domotocz, but this does seem to be the centre of knowledge on this subject...

I have a couple of H801s connected to RGB strings. Everything works fine (LEDs work, I can control both H801s from my phone) except that I can't connect to either of them from my PC.

When I attempt to connect to UDP port 30977 on an H801, I get a "Connection Refused" error message. I'm working in Java on Linux... the code works fine for connecting to other WiFi devices. Has anyone encountered anything like this with H801s? And have a solution?

Thanks

Frank

MadBanana
Posts: 28
Joined: Thursday 13 October 2016 21:45
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Kent, England
Contact:

Re: [ESP8266] Commercial H801 WiFi RGB-dimmer topic

Post by MadBanana » Thursday 08 December 2016 0:04

frankv wrote:I have a couple of H801s connected to RGB strings. Everything works fine (LEDs work, I can control both H801s from my phone) except that I can't connect to either of them from my PC.

When I attempt to connect to UDP port 30977 on an H801, I get a "Connection Refused" error message. I'm working in Java on Linux... the code works fine for connecting to other WiFi devices. Has anyone encountered anything like this with H801s? And have a solution?
Is this using the original firmware? I couldn't even get it to work reliably using the app - so probably won't be of much help, but will try!

secteur
Posts: 1
Joined: Tuesday 24 January 2017 5:17
Target OS: OS X
Domoticz version:
Contact:

Re: [ESP8266] Commercial H801 WiFi RGB-dimmer topic

Post by secteur » Tuesday 24 January 2017 5:52

If anyone wants to use the original firmware and control programmatically:

After having "Linked" the device using the Android app https://drive.google.com/open?id=0B1gzq ... ERBUndCU28 Default password 88888888

I was able to send commands via UPD from shell using https://nmap.org/ncat/

Code: Select all

echo fbeb00ff00000096509900 | xxd -r -p | ncat -4u -p 30978 192.168.1.255 30977
and from Python

Code: Select all

from socket import *
import binascii

cs = socket(AF_INET, SOCK_DGRAM)
cs.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
cs.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
cs.sendto(binascii.unhexlify('fbebffe200000096509900'), ('192.168.1.255', 30977))


Vojta
Posts: 2
Joined: Sunday 05 March 2017 21:33
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [ESP8266] Commercial H801 WiFi RGB-dimmer topic

Post by Vojta » Sunday 05 March 2017 21:44

ledfreak3d wrote:
DarkFoxDK wrote:
deennoo wrote:
How does os.execute curl compare to the OpenURL command in speed?
Edit: Should've just tested it. It's much faster. Script below updated.


This is my current script for driving my ESPEasy lights, including a way to simulate white on RGB-only strips. It also uses a curve to get higher resolution at the lower end, where the brightness changes are more noticeable.

Code: Select all

local lights = {
  ['Stuereol Spots'] = {ip = '192.168.33.61', pin = '14', rgb = false},
  ['Stuereol Skab'] = {ip = '192.168.33.61', pin = '4', rgb = false},
  ['Vitrineskab'] = {ip = '192.168.33.62', pin = '13', rgb = false},
  ['Kontorreol'] = {ip = '192.168.33.64', pin = '13', rgb = false},
  ['Skrivebord'] = {ip = '192.168.33.67', pin = '14', rgb = false},
  ['Sengelys'] = {ip = '192.168.33.66', pin = '14', rgb = false},
  ['Kontorhylde W'] = {ip = '192.168.33.67', red = '15', grn = '13', blu = '12', rgb = true},
  ['Stuereol W'] = {ip = '192.168.33.61', red = '15', grn = '13', blu = '12', rgb = true},
  ['Seng W'] = {ip = '192.168.33.66', red = '15', grn = '13', blu = '12', rgb = true}
}

function setlight (ip, pin, dvalue)
    os.execute("curl 'http://" .. ip.. "/control?cmd=PWM,".. pin .."," .. tostring(dvalue) .. ",128'")
end

commandArray = {}

for deviceName,deviceValue in pairs(devicechanged) do
    if (lights[deviceName]) then
        if (deviceValue == 'Off') then
            dvalue = 0
        elseif (deviceValue == 'On') then
            dvalue = 1024
        else
            inputValue = tonumber(otherdevices_svalues[deviceName])
            
            curve = 1.5848931924611
            normalizedCurVal  =  (inputValue - 1.0) / 99.0
            rangedValue =  (math.pow(normalizedCurVal, curve) * 1023.0) + 1.0
            
            dvalue = math.ceil(rangedValue)
        end
    
        if (lights[deviceName]['rgb']) then
            setlight(lights[deviceName]["ip"], lights[deviceName]["red"], dvalue)
            setlight(lights[deviceName]["ip"], lights[deviceName]["grn"], dvalue)
            setlight(lights[deviceName]["ip"], lights[deviceName]["blu"], dvalue)
        else
            setlight(lights[deviceName]["ip"], lights[deviceName]["pin"], dvalue)
        end
    end
end
return commandArray
2nd edit: Cleaned up the code a bit.
humz keep getting a error in domotiz when I try this one

[string "local lights = { ..."]:12: bad argument #1 to 'pairs' (table expected, got nil)
cant realy figure out why

Hi guys,
Sorry, to be dumbo, but I dont have any experience with lua scripts.
I have h801 flashed on espeasy with RGB milight plugin and using applamp, colours works great but I would like to simulate white as well.

Could you please advise how to amend script for my ip device 192.168.0.106 and add to Applamp group one dimmer?

Thanks

Sorry for annoying
Vojta

User avatar
ledfreak3d
Posts: 79
Joined: Sunday 01 November 2015 16:30
Target OS: Linux
Domoticz version: 3.8025
Location: Hoorn
Contact:

Re: [ESP8266] Commercial H801 WiFi RGB-dimmer topic

Post by ledfreak3d » Wednesday 08 March 2017 22:41

actualy with above script you don't need to use the milight plugin
it will just dim using the build in pwm dimmer function.
Unleashe the magic smoke ;)

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests