Announcement

Collapse
No announcement yet.

Under kitchen cabinet LED lamps with mcsMQTT control

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Alexbk66,
    yes WS2812 is a neat device. Kind of like 1-wire devices all strung along on the same wire and each has their own address. In the WS2812 they are simpler because they have relative rather than absolute address. I have used them in Fake TV. The next one I am thinking about is a set of 8 x 8 led panels that can be stacked edge on edge. These could make a large display similar to what Beta Bright gave us last generation. It would make for a prominent notification sign.

    For grneral lighting, however I do not see where they would play a role. It is hard enough to have a simple UI for general color space. Compound this with individual LED rather than strip control.

    Comment


    • Originally posted by Michael McSharry View Post
      For grneral lighting, however I do not see where they would play a role. It is hard enough to have a simple UI for general color space
      Michael, there's growing choice of libraries for addressable leds, but I just started looking into it. My point is - if I invest time and money into this now - I better make it feature proof. To begin with you can use it as normal RGB led strip, but having luxury of adding effects later.

      Comment


      • Here is a picture of Magic Home RGB controller #2. This one installed a 12VDC barrel connector for input and an LED barrel connector for output. Note using the first channel and VCC. First channel is actually channel #2 for single LED control. The wires are soldered for the digital pot and switch and forgot one VCC 3.3 for the DHT22 sensor.

        BTW for flashing left the GPIO 0 and ground wires together which is different than the Sonoff WiFi basic device. With the WiFi basic device booted up connecting GPIO 0 and ground then disconnected these two wires to update firmware.

        Soldered to the tabs pre tinning the stripped ends of wires then used painters tape to hole the wire to the solder tab and used a small tip soldering iron and my illuminated magnifying glass to solder.

        For now using painters tape over the board. Later will just use hot melt glue. Left the wires with just stripped ends and twisted the wires for uploading firmware which was a PITA. This is why I am waiting for the updated firmware from John as it is easier to just update current Espurna firmware using GUI.

        Note too that I just cut the wires from the IR sensor.

        I have left it running with a 12VDC power supply for time bean.

        Click image for larger version  Name:	MagicHome2.jpg Views:	1 Size:	114.3 KB ID:	1268223
        - Pete

        Auto mator
        Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU - Mono 6.4X
        Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro - Mono 6.4X

        X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

        Comment


        • It looks as if my rotary encoder is different that what Pete/John is using or the stock firmware I loaded is expecting something different.

          I have +, CLK, and DT plus the Gnd and SW pins on my encoder. I connected + to 3.3V pad. I connected CLK and DT to TX and RX pads. I also swapped between the two. No effect on brightness or any other LED channel when the encoder is spun.

          Temporarily grounding GPIO0 produces no effect. LEDs do not turn off or on by this mechanism. My encoder switch is float high and momentary connect to ground when pressed.

          I did unsolder the three IR wires and left the pad bare. I printed a little case for it with design objective as making it a thin case much like the original MagicHome case. Don't know if I am going to use velcro or screws so made provisions for both with chamfered holes in the case bottom.

          I could download the Espurna source and try to debug that way, but I was hoping this would be an out of the box solution. Any suggestions?

          Comment


          • Relating to first controller just left analog pot as a space holder until I solder the digital pot. I have have not done anything yet with second Magic Home Controller.

            Both are running stock Espurna Magic Home firmware still.

            John modified the following pieces (attached) of the base Espurna Magic Home firmware so that the light control works with one channel.

            I realized you are already messing with Espurna so you must be OK with Platformio and compiling. What I figured I would do is just upload those 2 files and let you see exactly what I did, they are unchanged except for my additions at the top of the hardware file and the bottom of the platformio file.

            Will substitute this two files in the source code and upload the files and if they work then will save it as a bin file. Just reread the above and see that the changes are there except for the DHT22 stuff.

            espurna mods(1).zip

            I went ahead a compiled a bin for you with 1 channel (gpio 12) for led and gpio 0 for the button with gpios 1 and 3 for the encoder (just swap if backwards dim) if you want to test it out. I left off the DHT22 but thats just 3 lines added back.

            This is what the new edited firmware looks like ....ESP128

            Click image for larger version  Name:	fetch?id=1261109&d=1542824153.jpg Views:	1 Size:	75.5 KB ID:	1268701

            I wanted to use a compiled version mentioned by John that included the DHT22 sensor. Left a PM for John.

            Might try use what John posted relating to modifications and the Visual Studio

            - Pete

            Auto mator
            Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU - Mono 6.4X
            Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro - Mono 6.4X

            X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

            Comment


            • When I look at the Espurna source download I find the following mapping:

              C:\Users\Dell\Downloads\espurna-dev\code\espurna\config\hardware.h(3026): #define ENCODER1_PIN1 12
              C:\Users\Dell\Downloads\espurna-dev\code\espurna\config\hardware.h(3027): #define ENCODER1_PIN2 13
              C:\Users\Dell\Downloads\espurna-dev\code\espurna\config\hardware.h(3028): #define ENCODER1_BUTTON_PIN 2 // active low by default, with software pullup

              Comment


              • Yeah here copied / replaced two files.

                GPIO 12 and 13 are channel on the other side of the board.

                Not sure what RX and TX GPIO pins are (maybe 1 and 3)

                GPIO 12 is channel 2 pin and GPIO 13 is channel 1 pin.

                I just want to see if the firmware boots first using:

                ~/espurna/code$ pio run -t upload -e magichome20-encoder-1ch

                Looking here:

                #elif defined(MH20_ENCODER_1CH)

                // Info
                #define MANUFACTURER "LJ"
                #define DEVICE "1CH LED_ENCODER"

                // Buttons
                #define BUTTON1_PIN 0

                #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH | BUTTON_SET_PULLUP

                // This button doubles as switch here and as encoder mode switch below
                // Clicking it (for less than 500ms) will turn the light on and off
                // Double and Long clicks will not work as these are used to modify the encoder action
                #define BUTTON1_RELAY 1
                #define BUTTON_LNGCLICK_DELAY 500
                #define BUTTON1_DBLCLICK BUTTON_MODE_NONE
                #define BUTTON1_LNGCLICK BUTTON_MODE_NONE
                #define BUTTON1_LNGLNGCLICK BUTTON_MODE_NONE

                // Light
                #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER
                #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT
                #define DUMMY_RELAY_COUNT 1
                #define LIGHT_STEP 4
                #define LIGHT_CHANNELS 1
                #define LIGHT_CH1_PIN 5 // WHITE
                #define LIGHT_CH1_INVERSE 0

                // Encoder
                // If mode is ENCODER_MODE_RATIO, the value ratio between both channels is changed
                // when the button is not pressed, and the overall brightness when pressed
                // If mode is ENCODER_MODE_CHANNEL, the first channel value is changed
                // when the button is not pressed, and the second channel when pressed
                // If no ENCODERX_BUTTON_PIN defined it will only change the value of the first defined channel
                #define ENCODER_SUPPORT 1
                #define ENCODER1_PIN1 1
                #define ENCODER1_PIN2 3

                //#define ENCODER1_BUTTON_PIN 0 // active low by default, with software pullup
                #define ENCODER1_CHANNEL1 0 // please note this value is 0-based (LIGHT_CH1 above)
                //#define ENCODER1_CHANNEL2 1 // please note this value is 0-based (LIGHT_CH2 above)
                //#define ENCODER1_MODE ENCODER_MODE_RATIO
                - Pete

                Auto mator
                Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU - Mono 6.4X
                Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro - Mono 6.4X

                X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

                Comment


                • I have found the issue with the encoder. The pre-built magichome bin does not have an encoder defined. It is defined for the xiaomi desk lamp which uses different GPIO mapping for everything. To make this work a custom build from source is needed to include encoder support for magichome. Now I need to setup my environment to be able to compile from source.

                  Comment


                  • Yeah original endeavor here was using the H801 RGB controller cuz it was easier to work on. John mentioned that he was using the Magic Home controller such that I purchased one to tinker with. He experiemented a lot with the creation of the firmware and accommodation of the digital dimmer and on and off pot.

                    Yes John mentioned that here ==>

                    Pete, I figured it out using a rotary encoder, works nice. I flashed Espurna using gpio's 0,2,4 for the encoder on a Magic Home controller.
                    On/Off and dimming all on one knob for a couple bucks.


                    I went ahead and brought all four gpio's (0,1,3,4) out of the controller along with ground, if I need to reflash it will be simple and I might be able to use the 0 pin also.

                    This is the rotary encoder I used, already had for a Squeezebox project, has five pins, 3 on side you can see here and two opposite for the push button, the 3 pins are simple again center to ground and 2 others to a gpio each, it all gets set up in the Espurna code. The hardware was really simple


                    Ok, I had just setup a new Raspberry running Picoreplayer and used a rotary encoder to handle to the volume and thought this would be perfect for these led controllers. Next step I searched Espurna and rotary encoder, seems there is a light out there that has a rotary encoder built in with a esp8266 running it, the Xiaomi Smart Desk Lamp. It has White leds and Warm white leds. Following the search I found he added support for it in the latest build, not sure if it was tested but it was there.

                    When you build your own firmware in Arduino you edit the arduino.h file and setup the build. The device you define in that file reads definitions from the hardware.h file (these are in the config folder under Espurna code) and you set your gpio's buttons, relays and such. Looking at the code for the Xiaomi lamp I just copied the parts I needed and setup my own device at the end of that file. I went back to the arduino.h file and defined the new device i created MH_ENCODER with my settings.

                    Pete you may like this part, in the code for the Xiaomi lamp the rotary encoder sets the brightness of all channels, when the knob is held pressed and turned it varies the first 2 channels opposite each other, one up the other down, kinda nice for getting right shade of white I guess but not so good for RGB. Also it has code for a hidden button that resets device, I just commented button 2 out all was good there.

                    The other thing was, I did not install the functions for serial comms to use gpio's 1 and 3, I learned that when the device is booted with gpio 0 grounded the Rx And Tx functions are activated and it flashes the same. I need to check the exact setting I used and post them, it took a few times to get the build I wanted.
                    I'm not a programmer but I can cut and paste with the best of them, basically lots of trial and error. There are other settings in the encoder.ini file but I have not messed with that yet.


                    Then went I went off on a tangent a bit mentioning that my el cheapo initial LED power supply burned up after a couple of weeks of using it. It was only one that burned up. John mentioned that he used the same el cheapo power supplies for all of his LED lamps (which was much more than what I was doing).

                    Okay I think I was making this harder than it needed to be, I thought I had changed more than I actually had inside Espurna, so I just started over to make sure. I downloaded the Espurna zip again and put it inside my PlatformIO projects folder where I re-added my devices with my settings to the hardware.h file in the config folder and the added those devices to the platformio ini file in the code folder. Then I ran the build task for that device and grabbed the new firmware bin from the new device folder created inside the pioenvs folder inside the code folder, rename to something better and the upload over wifi or flash it if it is new.

                    I realized you are already messing with Espurna so you must be OK with Platformio and compiling. What I figured I would do is just upload those 2 files and let you see exactly what I did, they are unchanged except for my additions at the top of the hardware file and the bottom of the platformio file.

                    An RGB setup that the encoder dims brightness and turns on and off with a click, the double click and long click can be used with MQTT also and it has a DHT22 on GPIO 4.

                    A single color led with encoder working channel 0, I just leave the brightness set at 255, Espurna only subscribes to brightness if it is color or 3 channels and the button handling on/off

                    A Nodemcu with a single encoder used with MQTT.


                    A Nodemcu that just has buttons attached sending MQTT to HS3


                    This is where I was waiting for the bin file such that I could just update the Espurna firmware over the air.

                    None the less I decided just to try using the two files substituting them for the ones included in the source files.

                    I followed Tinkerman's documented methodology line command mode. Only thing is that it doesn't create a BIN file that way. It just uploads via JTAG and I didn't want to do this.

                    On my new magichome boards I used a 4 pin female jumper cut in half for (gpio 0,gnd,1,3) and a 3 pin jumper for (+v, gpio 4, gnd). The wiring on the 3 pin allows direct connection to a dht22 and the other is for flashing and then an encoder or buttons or whatever. I never need to open them again as everything is there now and when doing the first flash I just power it up with 12 volts while grounding gpio 0, no power from the TTL unit is needed. After the first flash I reflash new firmware through Espurna over wifi.

                    I went ahead a compiled a bin for you with 1 channel (gpio 12) for led and gpio 0 for the button with gpios 1 and 3 for the encoder (just swap if backwards dim) if you want to test it out. I left off the DHT22 but thats just 3 lines added back.



                    This is what I did with the new Magichome RGB controller. I did mention buying them on sale on Amazon and John mentioned maybe purchasing them in bulk. Then I didn't hear anything else from John. GPIO's 1 and 3 are the RX and TX wires. DHT22 using GPIO4 or 14 which is the IR receiver wire.

                    John did not post this bin file though.

                    Got 4 more for 12 bucks, Sat delivery. If they are right I'm gonna get 100 and sell them here cheap flashed and ready.
                    John


                    Then I didn't hear anything more from John. Maybe he has reclused himself to update 100 of these magic home controllers???

                    Here all I did was wire up two new Magic home controllers, updated the firmware to what Tinkerman (Espurna) has posted.

                    Removed the dead Sonofff SV from the little controller box I was using and replaced it with the magic home controller. Left the pot disconnected and it is running fine. I did automate it to dim and brighten but not shut off.

                    I also wired a second one in a box and went to using coaxial connectors on the box and that one is on line but not connected to LED lamps at this time.

                    So in retrospect all you need to do is use the two files posted above and JTAG the magic home controller with the new custom firmware. I am only worried that the firmware now uses the JTAG RX and TX pins for the digital pot such that if you need to upload a new firmware via JTAG you have to disconnect the digital pot and I really didn't want to go through that again anyhow. That is why I was just trying to create a bin file to do the over the air update to the Espurna firmware.

                    I am ok though with my undercounter LED lamps using the wall switch minus the controller for 100% brightness. I did burn up the wires to the new box trying to install the the higher amperage power supply as it is exactly 4" long and very tight inside of the metal box. I trimmed the ends of the box and have the wires coming off of the top and it works fine this way. The box though looks a bit trashed now but works fine. The Leviton combo switch and outlet did fall apart when shoving it in and pushing on on the 120VAC wires with the mounting screws.

                    The whole configuration of two LED strips is high on the WAF and for time being will probably leave it alone as we are mostly in Christmas mode now.
                    - Pete

                    Auto mator
                    Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU - Mono 6.4X
                    Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro - Mono 6.4X

                    X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

                    Comment


                    • I did a source compile by copying the encoder block of defines to the magichome section and changed the three pins to 0, 1 and 3. After upload it worked for a few minutes and now I can no longer get to the controller via browser. It also worked different than I expected. The momentary switch on the encoder is not an on/off control but affects the channels that are changed by knob motion. This is getting to be more work than I expected. Need to reconfigure the wiring for JTAG flashing again to get life back into the device.

                      Comment


                      • Well I am glad you tried it. I have been afraid and spent way too much time soldering the tiny wires to the pads on the magic home controller. That is why I am currently just running the stock Espurna Magic Home RGB firmware and only have it configured for one channel righ tnow.

                        I did PM John and originally wanted to validate my wiring of the digital pot and button and wait on his BIN file to use standard Espurna OTA upload of said bin.

                        changed the three pins to 0, 1 and 3

                        Not sure what you changed here because John had defined a new device with these PINs on the bottom of the second file (IE: hardware one). The changes were already there listed under the MH20_ENCODER_1CH. That too was where John mentioned using the RX and TX wires that were already there. He did comment out the DHT22 stuff for optional use on the two files. The assumption there was to use one of the 3 cut IR reciever wires which is GPIO X?

                        When it booted did it show the version of firmware for the MH20_encoder_1CH?
                        - Pete

                        Auto mator
                        Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU - Mono 6.4X
                        Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro - Mono 6.4X

                        X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

                        Comment


                        • I have been playing with the source configuration but no matter what I do I do not get reliable operation for the encoder. It seems to me there is just some basic handling of encoder inputs that are not working for the magichome configuration. I do note that the xiaomi desk lamp is wam / cold white control while magichome is RGBW control.

                          I have changed the light step (#DEFINE LIGHT_STEP) at various values from 32 to 1. I have changed the encoder channels between 0 and 3.

                          If I move knob one detent then I see the brightness level change usually 4 times with a brightness level change total of 16. I expect that one detent move should produce one level change, not 4. If I go slowly I will reach limits of 0 or 255. If I spin the knob I get a restart of some form which may or may not disconnect the WiFi but the On/Off state returns to Off so I know the restart happened.

                          For this to be useful for me the handling of encoder inputs needs to be more robust and the firmware modified so the switch on the encoder is a toggle that effects the dummy relay state such as occurs from Alexa, MQTT or Browser control.

                          Comment


                          • Gonna wait here for John's firmware. Maybe he changed it such that the digital pot worked fine.

                            I noticed that the current Espurna Magic Home firmware didn't remember the settings until I rebooted the device a couple of times.

                            That and Tinkerman has mentioned that there are a few different variants of the same controllers out there. They all have the exact same covers except that the insides are different.

                            The current set up was just using an older analog dimmer pot connected to the output for the LED same as the Sonoff SV. It did though not shut off or turn on the controller. For that using the wall switch. It does remember the dim level. Automating too if I leave the switch in on mode and it remembers last dim level.

                            Other than the soldering to the small pads rest of the stuff should be easy with the right firmware.

                            I am already at the production pieces of the LED lamps under the counters and it is functional and the controller piece is just icing on the cake of the counter LEDs.

                            not disconnect the WiFi but the On/Off state returns to Off so I know the restart happened.

                            It doesn't save the settings? In the beginning of playing with the Espurna firmware I would keep forgetting to save the settings.

                            Click image for larger version  Name:	switch.jpg Views:	1 Size:	56.9 KB ID:	1268880


                            xx
                            - Pete

                            Auto mator
                            Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU - Mono 6.4X
                            Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro - Mono 6.4X

                            X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

                            Comment


                            • I submitted issue on github. For testing I left the switch at OFF on boot. The browser page also was not responsive to changes in the controller. I had to establish a new connection which was further evidence that the reboot happened. Sometimes also needed to reconnect to its SSID.

                              Comment


                              • I identified where the rotary decoder was causing the reboot. It was in the web server trying to keep up with the rotary encoder updates. I posted my diagnostics on the Espurina forum on github.

                                I made two builds that made some source changes that averted the reboot, made the encoder only change brightness, and the pushbutton on the encoder provided an on/off control. One build has GPIO4 for IR. I decided to put the IR sensor in the lid of the case I printed. The other build has GPIO4 for DHT22. I don't have this sensor so untested, but follows pattern for the IR sensor. It is at http://mcsSprinklers.com/mcsEspurnaMagicHome.zip

                                The encoder is setup for 1 level change per detent. This results in 30% brightness change per 360 degree of knob turn. The default used for desk lamp was 8 and that was too course for my taste.

                                Since this was done for RGB I'm not certain how it will do on a monochrome light. I think it should be transparent with ability to use any of the three channels being controlled. You are welcome to try if you desire or you can wait for John with his version of the build.

                                Code:
                                    // IR
                                    #define IR_SUPPORT          1
                                    #define IR_RX_PIN           4
                                    #define IR_BUTTON_SET       1
                                
                                    // DHT Sensor
                                    //#define DHT_SUPPORT         1
                                    //#define DHT_PIN             4
                                    //#define DHT_TYPE            DHT_CHIP_DHT22
                                        // Encoder
                                      // If mode is ENCODER_MODE_BRIGHTNESS, the knob controls overall brightness
                                        // If mode is ENCODER_MODE_RATIO, the value ratio between both channels is changed
                                        // when the button is not pressed, and the overall brightness when pressed
                                        // If mode is ENCODER_MODE_CHANNEL, the first channel value is changed
                                        // when the button is not pressed, and the second channel when pressed
                                        // If no ENCODERX_BUTTON_PIN defined it will only change the value of the first defined channel
                                        #define ENCODER_SUPPORT     1
                                        #define ENCODER1_PIN1       1
                                        #define ENCODER1_PIN2       3
                                        #define ENCODER1_BUTTON_PIN 0   // active low by default, with software pullup
                                        #define ENCODER1_CHANNEL1   0   // please note this value is 0-based (LIGHT_CH1 above)
                                        #define ENCODER1_CHANNEL2   1   // please note this value is 0-based (LIGHT_CH2 above)
                                      #define ENCODER1_MODE       ENCODER_MODE_BRIGHTNESS
                                      // Light Dimmer
                                      #define LIGHT_STEP          1
                                
                                      // Button (on encoder)
                                      #define BUTTON1_PIN         0
                                      #define BUTTON1_MODE        BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
                                      #define BUTTON1_RELAY       1

                                Comment

                                Working...
                                X