Announcement

Collapse
No announcement yet.

Under kitchen cabinet LED lamps with mcsMQTT control

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

  • Pete
    replied
    Thank you Michael.

    Worked connecting the center post to ground.

    Yes here using one channel and the pot just controls the brightness and it works great.

    Turning the pot shows the following in debug. (skipping a few lines). on an

    [190438] [MQTT] Sending Kitchen-LED1/data => {"channel/0":32,"channel/1":32,"channel/2":32,"channel/3":32,"brightness":32,"time":"2018-12-25 22:57:29"

    [192028] [MQTT] Sending Kitchen-LED1/data => {"channel/0":62,"channel/1":62,"channel/2":62,"channel/3":62,"brightness":62,"time":"2018-12-25 22:57:31"

    I installed the DHT22 inside of the case and noticed that it is a bit warmer than outside of the case such that I probably will move it to the side of the case.

    After working with Tasmota and Espurna it is clear to me that Espurna is geared to those would work at the source code level to define the configuration at build time. Tasmota is oriented to the end user where MQTT or console is used to configure at run time.

    Understood.

    Personally as mentioned earlier I like the base feature set of Espurna over that of Tasmota.

    I have switched all of the SonOff WiFi basics now to using Espurna except the the GDO stuff.

    BTW tinkering a bit with Thingspeak. Very nice stuff.

    Leave a comment:


  • Michael McSharry
    replied
    I had not previously looked at John's mods. I looked now. While there was many differences which is likely due to when he started vs. the version that I pulled last week. He defined 3 encoders. The 1 channel one looks to have the same definitions as I used expect he has a rate of 4 vs. 1 in my case.
    Code:
               // 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
    What the firmware should be looking at are the number of high/low transitions over a given period of time. As long as your device is able to achieve both states as it is spun then it should not matter. If GPIO 1 & 3 are pulled up and you bring them to ground in the encoder center pole then I would expect it to work. Of course I have never worked with an encoder before so I many be wrong on its working principle.

    What may be different is what channel gets updated if only 1 channel light control is defined. In my case R, G, B and brightness are all updated and I changed the encoder logic so that is only updates the brightness. If brightness is not controlled on 1 channel setup then turning the knob would have no effect.

    After working with Tasmota and Espurna it is clear to me that Espurna is geared to those would work at the source code level to define the configuration at build time. Tasmota is oriented to the end user where MQTT or console is used to configure at run time.

    Leave a comment:


  • Pete
    replied
    Apologies Michael.

    I missed this part of the thread.

    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.


    So your edited firmware did not utilize John's posted adds above (zipped) hardware.h and platformio.ini files?

    But you mention the logic should be the same such that I can put a ground wire to the center post instead of the 3.3VDC and it should work ?

    Leave a comment:


  • Michael McSharry
    replied
    The lower knob pictured in the above post looks to be the same as what I have. I believe when I did voltage check on the CLK / DT pins it was around 3 volts. I did not look with scope as the knob was turned. The setup I used in the firmware was previously posted in this thread #135. I changed only the pins being used from the desk lamp where the stock frimware had used the encoder. I did not do anything with programming of any pull-up vs. pull-down resistors. John has looked into it more than me so he should be able to provide better guidance.

    Looking at MQTT transmissions I see brightness parameter changing as the knob is moved.

    Leave a comment:


  • Pete
    replied
    These are the rotary encoders I used. There are no markings on it and appear to be the one's that John got from Amazon.

    Description on adafruit site:

    This rotary encoder is the best of the best, its a high quality 24-pulse encoder, with detents and a nice feel. It is panel mountable for placement in a box, or you can plug it into a breadboard (just cut/bend the two mechanical side tabs.) We also include a nice soft-touch knob with an arrow in it, fits perfectly and looks great. This encoder also has a push-button built into it so you can press onto the knob to close a separate switch. One side has a 3 pin connector (ground and two coding pins) and the other side has two pins for a normally-open switch.


    Click image for larger version  Name:	RE.jpg Views:	1 Size:	54.6 KB ID:	1269367

    I did see an encoder similiar to the one you are using.

    It has a PC board connected to it and 5 pins on one side of the board and uses 5VDC for center lead and is in description.

    Staying out of the kitchen and wife's way this morning and virtually in the UK now doing some server stuff there...
    • Location: London, ENG GB
    • ISP: SKY UK Limited
    The LED controller near the stove is showing: (2 feet or so from the oven)

    [597938] [MQTT] Sending Kitchen-LED2/temperature => 80.6 (PID 1)
    [597942] [MQTT] Sending Kitchen-LED2/humidity => 29 (PID 1)

    Just outside of the kitchen it is 70.

    Click image for larger version  Name:	5VDC encoder.jpg Views:	1 Size:	103.9 KB ID:	1269371
    Guessing if I disconnect the 3.3VDC center and connect ground to center then the firmware will not work.

    Took it off line and using the controller with temperature sensor but no digital pot connected to it.

    xxx

    Leave a comment:


  • Pete
    replied
    Using the same encoder as John used above with 3 pins on one side and 2 pins on the other side.

    Connected as follows.

    My encoder has 5 pins. The center post is + (3.3V pad), the two directional pins go to RX and TX pad. The SW pin and GND pin are the pushbutton to IO0 and Gnd pads.

    The on and off button works fine. Turning the knob doesn't do anything. Confirming this watching the GUI and watching the single color LED strip.

    Above in post #74 John mentioned:

    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

    This is what I see in debug when pressing switch. I do not see anything in debug when turning the knob.

    [108345] [RELAY] #0 scheduled OFF in 0 ms
    [108358] [RELAY] #0 set to OFF
    [108467] [MQTT] Sending Kitchen-LED1/data => {"button/0":2,"channel/0":0,"channel/1":0,"channel/2":0,"channel/3":0,"brightness":119,"relay/0":0,"time":"2018-12-25 00:01:19"
    [108505] [MQTT] Publish ACK for PID 20
    [109365] [RELAY] Setting relay mask: 0
    [118227] [BUTTON] Button #0 event 1
    [118728] [BUTTON] Button #0 event 2
    [118731] [RELAY] #0 scheduled ON in 0 ms
    [118745] [RELAY] #0 set to ON
    [118855] [MQTT] Sending Kitchen-LED1/data => {"button/0":2,"channel/0":119,"channel/1":119,"channel/2":119,"channel/3":119,"brightness":119,"relay/0":1,"time":"2018-12-25 00:01:30","mac":"DC:4F:22:C5:A1:0C","host":"ESPURNA-KitchenLED1","ip":"192.168.244.224","id":657915012} (PID 21)
    [118920] [MQTT] Publish ACK for PID 21
    [119753] [RELAY] Setting relay mask: 1

    Leave a comment:


  • Michael McSharry
    replied
    Same 24 button one that came with the little controller. Just cut the three wires shorter to fit the case. Pulled out the plastic cover over the battery to activate it.

    Leave a comment:


  • Pete
    replied
    Michael McSharry

    Are you using the same IR remote for multiple magic home controllers?

    Leave a comment:


  • Pete
    replied
    Thank you Michael.

    Leave a comment:


  • Michael McSharry
    replied
    My encoder has 5 pins. The center post is + (3.3V pad), the two directional pins go to RX and TX pad. The SW pin and GND pin are the pushbutton to IO0 and Gnd pads.

    Leave a comment:


  • Pete
    replied
    Connected a DHT22 and now seeing the temperature and humidity. Was going to try the IR reciever next with the IR firmware.

    So are you using ground for middle wire on rotary encoder? What is the second button wire? Ground too?

    Click image for larger version

Name:	DHT22.jpg
Views:	111
Size:	6.3 KB
ID:	1269145

    xxx

    Leave a comment:


  • Michael McSharry
    replied
    Yes, RX, TX pads are used for the rotary encoder. The encoder button to IO0 pad. Completed project box with connectors, control and IR shown. I see your screen has the Temp and Humidity boxes, but timeout so I assume you do not have the sensor installed.Click image for larger version

Name:	LEDstripDone.jpg
Views:	112
Size:	43.9 KB
ID:	1269143

    Leave a comment:


  • Pete
    replied
    Thank you Michael.

    I did notice just now with the old firmware I could not get to the web interface. I powered it off and on and it came back.

    Updated test MagicHome RGB controller #2 with your DHT-22 firmware. Boots up fine.

    How do you have the digital pot and on off button wired? Did you use the RX (3), TX (1), ground? And the button (0)?

    Yes this and the other will be controlling one LED channel (SMD5050 LEDs).

    It is showing Device: LED_CONTROLLER_20

    Click image for larger version

Name:	RGB2.jpg
Views:	122
Size:	49.3 KB
ID:	1269139

    xxx

    Leave a comment:


  • Michael McSharry
    replied
    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

    Leave a comment:


  • Michael McSharry
    replied
    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.

    Leave a comment:

Working...
X