Poolside Music Player


  • Hero Member

    I built a pool thermometer to keep track of the water temperature but the node could not reliably connect to the closest repeater.
    The repeater node was not that far away so I think maybe the closeness of the water and perhaps the pool fence were causing some problems. The easiest solution was to just deploy another repeater node to bridge the gap.

    I didn't wan't to have a node just for repeating the temp data so decided to make use of it as a music player for the pool area as well.

    To keep it simple I settled on a cheap Bluetooth enabled amplifier module and a couple of marine speakers, The node just turns power on and off to the amp and I can control the volume and stream music from my phone via the bluetooth connection.

    For convenience I have set up a button on my Touch switch so I can turn the amp on/off when walking down to the pool area.

    The circuit is just a simple single switch type node to control power to the amp.

    0_1514807588204_pool player.jpg

    The sketch is a standard relay control with a timer to shut down the amp after 3hrs. We are seldom in the pool for longer than that and wanted a way to ensure the amp is not left switched on by accident.

    /**
     *Node to control pool music player 
     *
     *Auto turns off after preset time
     *
     */
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    #define MY_RF24_CHANNEL 84
    #define MY_REPEATER_FEATURE
    
    #include <MySensors.h>
    
    #define PLAYER_PIN  6                          // Arduino  pin number for Player power control
    #define PLAYER_ID  1                          // Id of the player control child
    
    unsigned long millisNow = 0;                  // holder for the current time
    unsigned long startMillisA = 0;
    unsigned long activeTimeA = 180;             // how long the player will stay on, in minutes
    const int switchOn = 1; 
    const int switchOff = 0;
    int timerMarkerA = 0;                       // Used to tell if timer A is active
    bool stateA = false;                        // State holder for player
    
    MyMessage msgA(PLAYER_ID, V_STATUS);
    
    void setup()
    {
     pinMode(PLAYER_PIN, OUTPUT);               // set player pin in output mode 
     digitalWrite(PLAYER_PIN, switchOff);       // Make sure player is off when starting up
    }
    
    void presentation()
    {
    	// Send the sketch version information to the gateway and Controller
    	sendSketchInfo("Pool Player", "1.3");
    	present(PLAYER_ID, S_BINARY,"Pool Player");
    	}
    
    
    void loop()
    {
    poolTimer();
    }
    
    void receive(const MyMessage &message){	
    	if (message.type==V_STATUS) {                                     // check that message is for binary switch
    		if (message.sender == 0) {                                      // check if message is from gateway (node 0)
          stateA = message.getBool();
          digitalWrite(PLAYER_PIN,  stateA ? switchOn : switchOff);
    		}
        else  {                                                         // message is not from gateway so must be from a remote
          stateA = !stateA;                                             // toggle player state
          digitalWrite(PLAYER_PIN,  stateA ? switchOn : switchOff);
          wait (10);
          send( msgA.set(stateA),false) ;                               // Notify controller of change  
       }   
      }
    }
    
    void poolTimer() {
      millisNow = millis();           // get the current time  
      if (digitalRead(PLAYER_PIN) == switchOn && timerMarkerA == 0 ) {        //Check relayPinA status and start timer event if relay is on.
        timerMarkerA = 1;                                                   
        startMillisA = millisNow;
      }
      if (timerMarkerA == 1 && (millisNow - startMillisA) > (activeTimeA*60000)) {   // check to see if timeout has been reached
        digitalWrite(PLAYER_PIN, switchOff);                                         // turn off player
        send(msgA.set(false),false );                                                // send message to controller so it knows the player is now off
        timerMarkerA = 0;                                                            //reset marker
        stateA = false;
      }
        if (digitalRead(PLAYER_PIN) == switchOff && timerMarkerA == 1 ) {            //if  player has been turned off by user, cancel timer event
        timerMarkerA = 0;
        Serial.println("timer A cancelled" );
      }
    
    }
    
    

    The node was constructed on a small prototype board with the nrf mounted well clear at the top.

    0_1514808205998_board.jpg

    Here it is shown with the amp and speakers during testing.
    0_1514808353051_testing.jpg

    The node was housed in a section of 90mm water pipe.

    0_1514808572491_controller.jpg

    The speakers were fitted to an existing seat/storage area. Just a bit of tidying up of the wiring etc to do.

    0_1514808657929_setup.jpg



  • @boots33 Where is it that you live? I want to move there. I see the sun and green grass in your pics. To give you some perspective on things, for the past few days we have had average temps in the single digits (°F). That is less than -12°C; The wind chills here have gone as low as -25°F (-31.6°C).


  • Hardware Contributor

    @dbemowsk said in Poolside Music Player:

    @boots33 Where is it that you live? I want to move there. I see the sun and green grass in your pics. To give you some perspective on things, for the past few days we have had average temps in the single digits (°F). That is less than -12°C; The wind chills here have gone as low as -25°F (-31.6°C).

    Don't complain when you have a real winter !
    In my current place beginning of year is the driest season and very warm (>30°C). We had an exceptionally cold period a few weeks ago, temperature went down to 20°C at night/morning and people were starting to wear winter clothes 😄
    But most people here have never seen snow and are dreaming about visiting a cold place in winter, enjoy it for them please 😛



  • @nca78 said in Poolside Music Player:

    enjoy it for them please

    I can enjoy some winter days, but when it gets so cold that a breath of air nearly freezes your lungs, that's kind of tough to do.


  • Hero Member

    Ha ha... no white Christmas in the land down under @dbemowsk 🙂 Pool temp is pretty stable at around 30c at the moment so that should thaw you out. At the moment we spend our weekends wakeboarding at the lake or

    Going to the Beach

    0_1514838380426_beach.jpg

    @Nca78 is right though, I have to drive over 1500km if I want to see some snow and there is only snow there in winter. Temps have already been up to 37c here so it does get a bit toasty at times!



  • @boots33 said in Poolside Music Player:

    Temps have already been up to 37c here so it does get a bit toasty at times!

    I'd say that's toasty. Right now I'd take that over -31°C. When it's that cold, it doesn't seem like any amount of clothing is enough to stay warm. The key is to enjoy the season no matter the weather outside.


  • Hero Member

    @dbemowsk I can't even imagine those sort of temps! Don't think my freezer can go that low 🙂



  • @boots33 said in Poolside Music Player:

    @dbemowsk I can't even imagine those sort of temps! Don't think my freezer can go that low 🙂

    If I could upvote that twice I would


  • Mod

    0_1514843628282_IMG_2234.PNG


  • Hardware Contributor

    @dbemowsk said in Poolside Music Player:

    I can enjoy some winter days, but when it gets so cold that a breath of air nearly freezes your lungs, that's kind of tough to do.

    Yes I was just joking, lowest I ever had was around -15°C but with low/no wind and it was already a pain to walk outside.

    Would switch with @Boots33's place anyway too, it seems we are the same weather but I don't have all those trees. Nice house, warm weather, garden, pool, lots of trees around, and workshop when the MySensors virus makes a comeback. Sounds like a perfect place, any chance you're on AirBnb @Boots33 ? 😄


 

284
Online

7.6k
Users

8.5k
Topics

91.3k
Posts