Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 10 of 10
  1. #1

    ESP8266 Remote Volume Knob

    ESP8266 is a really cheap (<ú5) microcontroller with built in WiFi. I loaded up a D1 Mini with ESPEasy and added a Rotary Encoder to make a Volume control.

    Name:  IMG_0714.jpg
Views: 890
Size:  235.4 KB

    Code:
    on System#Boot do
        TimerSet_ms,1,1
        Pulse,2,0,10
    endon
    
    on Rules#Timer=1 do
     
     Let,1,[Rotary#Count]
    
      if [Var#1]!=[Var#2]
         if [Var#1]>[Var#2]
            let,3,([Var#1]-[Var#2])*6
            sendtoHTTP,192.168.1.100,9000,/?player=Computer&p0=mixer&p1=volume&p2=%2b[Var#3]
        else
            let,3,([Var#2]-[Var#1])*6
            sendtoHTTP,192.168.1.100,9000,/?player=Computer&p0=mixer&p1=volume&p2=%2d[Var#3]
         endif
    
        Let,2,[Var#1]
        Pulse,2,0,10
        TimerSet,2,10
      endif
    
      TimerSet_ms,1,100
    endon
    
    on Rules#Timer=2 do
       Pulse,2,0,30
       DeepSleep,0
    endon
    Name:  Screen Shot 2020-10-26 at 18.12.36.png
Views: 875
Size:  100.5 KB

    I can provide more details if anyone is interested.

    Tony

  2. #2
    Junior Member
    Join Date
    Apr 2019
    Posts
    22
    I understand the pieces-parts, but what would this be used for? A volume control of what and how?

  3. #3
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    4,429
    Quote Originally Posted by meq123 View Post
    I understand the pieces-parts, but what would this be used for? A volume control of what and how?
    any LMS player (where volume has not been locked).
    Would allow you to put the volume controller anywhere convenient. It is configured to control a single nominated player.
    Paul Webster
    http://dabdig.blogspot.com
    Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, Supla Finland, ABC Australia, CBC/Radio-Canada and RTE Ireland

  4. #4
    Junior Member
    Join Date
    Jun 2016
    Location
    Bretagne
    Posts
    22

    I can provide more details if anyone is interested.

    Tony
    Yes please, looks like a nice lockdown project

    Cordialement, Strebor

  5. #5
    More details:

    I used a D1 Mini that you can buy from Ebay / Amazon etc. There are various clones that are functionally equivalent.

    I used the experimental firmware in this post: https://www.letscontrolit.com/forum/...p=47456#p47456
    because it includes Wake on Lan. You will need a device driver: https://escapequotes.net/esp8266-wem...indows-driver/ or MAC https://kig.re/downloads/CH341SER_MAC.ZIP

    This is an easy tool to flash the firmware: https://github.com/marcelstoer/nodem...asher/releases

    If you have problems flashing, try a different USB lead.

    Have fun!

  6. #6
    Junior Member
    Join Date
    Jun 2016
    Location
    Bretagne
    Posts
    22
    Quote Originally Posted by Wiredcharlie View Post
    More details:

    I used a D1 Mini

    Have fun!
    Thanks, I found the Rules tutorial pages on the easy site. I'll hack about with one of the esp's I've got in the gache box..
    Strebor

  7. #7
    Member
    Join Date
    Apr 2019
    Location
    Finland
    Posts
    71
    Awesome project!

    I have a few questions. How does the player start the playback when your turn on volume? Have you set it up from lms settings?

    And is it possible to use the push button on the rotary encoder to change a song? Do you have a code for that?

    And I guess it is not battery powered?

    Thanks!

  8. #8

    another Wemos D1 mini controller

    this inspired me to finally solve a long standing (minor) frustration I had.

    We have 3 squeezeboxes in the main living area (1x Touch, 1x Radio and 1x Receiver). The Receiver is connected to another 'receiver', but this one a of the home theater Onkyo variety. Both receivers are connected to ethernet and are hidden out of view. However since the power consumption is a bit high, the Onkyo receiver is set to automatically shut down. But getting it running again requires pushing the power button, connecting over the network with an app or using the IR remote. So while installing it, I figured having a separate IR 'receiver' (this may be getting confusing) semi-hidden, but with a line of sight, would be OK. However, the IR remote ends up in the same cupboard as the (Onkyo) receiver itself and it's usually too much of a hassle to get it out. In practice, and this was the frustration, the Onkyo receiver was rarely used and that zone was covered by very one-sided sound from the Radio instead.

    Based on the parent post, I ordered a Wemos D1 mini. I intended to directly send commands to LMS and the Onkyo similar to what Wiredcharlie proposed. However, it turns out the Onky doesn't listen to HTTP or UDP, only TCP, which isn't available in ESPEasy. And since I got a ~1 EUR screen (0.96" OLED) with the D1, it would be nice to have some feedback on that as well. So in the end I had to go with this configuration:
    Wemos D1 mini <--> MQTT broker <--> Home Assistant <--> LMS | Onky Receiver
    with the MQTT broker, Home Assistant and LMS all running as containers on a NanopiNeo3. I am sure a more efficient approach is possible, but with my very limited understanding of the ESP, linux and all the protocols, this is what I finally got working.

    I managed to fit the Wemos D1 mini in a standard light switch faceplate. The central area is 45x45mm with a ~70mm wall box. It fits just barely. I had to modify (cut away) some of the metal bits from the frame, which is now far less rigid, but sufficient for this use. Since my machining skills are nonexistent, I oversized the hole for the screen and covered the rough edges with a 3D printed bezel. WAF is good enough.
    Power is through a long USB cable from a USB port on a wifi access point mounted in the ceiling. That also provides console/serial access to the D1 (this was an afterthought).

    Functionality is:
    - rotation: volume up/down (max. limit for each player hard coded in Home Assistant)
    - single click: switch between 3 players (to set individual volumes)
    - double click: toggle play/pause
    - long click: toggle Onkyo receiver on/off

    Anyway, thanks Wiredcharlie for the idea, and everyone else here for keeping the squeezeboxes working and very relevant.

    Wouter

    Name:  3_TestOpstelling.jpg
Views: 404
Size:  69.2 KBName:  5_SAM_1957.jpg
Views: 396
Size:  74.8 KBName:  8_SAM_1968.JPG
Views: 387
Size:  198.2 KB

  9. #9
    Junior Member
    Join Date
    Jan 2017
    Posts
    4

    Building instcructions?

    Wouter,

    this is really impressive, and a nicely mounted!

    It would be really nice and informative if you could share some of your code and/or design decisions.

    For me i'm very curious to see where you put the logic for al the push and turn options? single click, double, long enz

    And how do you get the info from the lms on your oled display?

    Marnix

  10. #10
    Quote Originally Posted by Marnix View Post
    It would be really nice and informative if you could share some of your code and/or design decisions.
    To be honest, design decisions were based on what I could get to work with my limited knowledge.

    For me i'm very curious to see where you put the logic for al the push and turn options? single click, double, long enz
    I found following limitations in ESPEASY and Home Assistant:
    - ESPEASY can't use TCP to talk to the receiver, hence the need for Home Assistant
    - ESPEASY can't seem to store strings that are sent to it over MQTT, hence the player names are hard-coded on the ESP
    - Home Assisant can only understand 1 variable parameter in an MQTT message, so sending player id or name together with a volume change isn't possible. I made seperate MQTT channels for each player.

    Regarding the actions:
    - The 'change player' action is handled on the ESP. The ESP keeps track of which player it is controlling, updates the display. It also requests an update of the volumes, just in case.
    - Volume change is sent to Home Assistant as +1 or -1, which HA then converts into an absolute value and sends to LMS.
    - play/pause and powering on the receiver also sent to HA.

    And how do you get the info from the lms on your oled display?
    Upon any of the volumes changing, HA sends an update. That MQTT message triggers an update of the screen on the ESP. This also happens if the state is changed by any other means (e.g. on the players themselves).
    There is some obvious lag in volume changes becoming effective , but not too bad.

    It works pretty well, but I am not entirely happy with how the logic is split over the ESP and HA, and how I had to hard-code the player names in the ESP. I am considering experimenting with micropython, which should it make possible to communicate to LMS and the receiver directly and, more importantly to put all logic on the ESP itself.

    ESPEASY rules:
    Code:
    on System#Boot do
      let,1,0    // volume of player 1 (Veranda)
      let,2,0    // volume of player 2 (Keuken)
      let,3,0    // volume of player 3 (Veranda)
      let,4,0    // state of receiver
      let,5,1    // player being controlled
      let,10,0
      let,15,1   // timeout keeper for rotary encoder
    endon
    
     // on MQTT#Connected do
     //   Publish,ESPStatusUpdate/status,request
     // endon
    
    on UpdateDisplay do
      if [VAR#5]=1
        oledframedcmd,1,"Veranda"
        oledframedcmd,2,[VAR#1#F]%
        oledframedcmd,3,"Receiver [VAR#4#O]"
      elseif [VAR#5]=2
        oledframedcmd,1,"Keuken" 
        oledframedcmd,2,[VAR#2#F]%
        oledframedcmd,3,""
      elseif [VAR#5]=3
        oledframedcmd,1,"Living"
        oledframedcmd,2,[VAR#3#F]%
        oledframedcmd,3,""
      else
        oledframedcmd,1,"ERROR"
      endif
      oledframedcmd,Display,on
    endon
    
    on MQTTfromHASS do
      oledframedcmd,3,"MQTT"
      Let,1,%eventvalue1%*100
      Let,2,%eventvalue2%*100
      Let,3,%eventvalue3%*100
      Let,4,%eventvalue4%*100
      asyncevent,UpdateDisplay
    endon
    
    on Switch#State=1 do
      timerSet,2,1
    endon
    
    on Rules#Timer=2 do
      if [VAR#5]=1
        let,5,2
      elseif [VAR#5]=2
        let,5,3
      elseif [VAR#5]=3
        let,5,1
      endif
      asyncevent,UpdateDisplay
    endon
    
    on Switch#State=3 do
      timerSet,2,0
      Publish,ESPStatusUpdate/play,[VAR#5#F]
    endon
    
    on Switch#State=11 do
      timerSet,2,0
      if [VAR#4]=0
        let,5,1
      endif
      asyncevent,UpdateDisplay
      Publish,ESPStatusUpdate/receiver,toggle
    endon
    
    on Rules#Timer=1 do
      let,15,1
      let,11,[Rotary#Counter]  
    endon
    
    on Rotary#Counter do
      if [VAR#15]=1
        let,10,[Rotary#Counter]
        let,12,[Var#10]-[VAR#11]
        let,11,[VAR#10]
        Publish,ESPStatusUpdate/volume[VAR#5#F],"[VAR#12#F]"
        asyncevent,UpdateDisplay
        Let,15,0 
        timerSet,1,1   
      endif
    endon
    Suggestions very welcome, obviously.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •