I'm not sure the latching power circuit design I've used here will help
you, as fundamentally to get the rotary encoder to work during playing,
you'll need to leave the board powered up. 

In saying this, I've added my code below in case it helps. This isn't
actually my direct code, rather a slimmed down version removing the
extra OTA functionality I put in - I've not tested it, but it should
work as it's pretty straight forward.

Note: the LMS command (IP address, player name and action) are hard
coded at the end of the setup() function as it was just easier. You'll
need to change your player name


Code:
--------------------
    /*********
  Self powering off Squeezebox script. Uses a combination of:
  The latching power circuit and code from 
  
https://randomnerdtutorials.com/latching-power-switch-circuit-auto-power-off-circuit-esp32-esp8266-arduino/
  and the standard http functionality in the library ESP8266WiFI.h (as per the 
examples included in that library)
  
https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/src/ESP8266WiFi.h
  *********/
  
  #include <ESP8266WiFi.h>
  #include <ESP8266HTTPClient.h>
  
  //--------------------VARIABLES TO UPDATE-----------------------------
  
  // Replace with your network credentials
  const char* ssid = "WIFI_SSID";
  const char* password = "PASSWORD";
  
  // Define power latch pin for ESP32 (GPIO 5) / ESP8266 (GPIO 5) / Arduino 
(Digital 5)
  const int powerLatch = 5;
  
  //---------------------------------------------------------------------------
  
  void setup() {
  // Define pin as an OUTPUT
  pinMode(powerLatch, OUTPUT); 
  
  // Keeps the circuit on
  digitalWrite(powerLatch, HIGH);
  
  // A number of LMS functions can be called by URL, examples are available at 
http://arduino-projects4u.com/squeezebox/
  
  //-----------UPDATE THIS URL FOR YOUR NEEDS-----------------------
  // URL call to toggle the power status of the relevant player
  callURL("http://192.168.0.1:9000/index.html?player=PLAYERNAME&p0=power";);
  //---------------------------------------------------------------------------
  
  // Wait 3 seconds to let URL call complete
  delay(3000);
  
  // Turns the power latch circuit off
  digitalWrite(powerLatch, LOW);
  }
  
  void loop() {
  //This should never run, as the button powers itself off at the end of 
setup() by turning the powerLatch GPIO to low, collapsing the power circuit.
  }
--------------------


------------------------------------------------------------------------
s2kiwi's Profile: http://forums.slimdevices.com/member.php?userid=63950
View this thread: http://forums.slimdevices.com/showthread.php?t=110408

_______________________________________________
diy mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/diy

Reply via email to