0

Solar Fountain Controller
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Solar Fountain Controller

by mhigbee on Wed Sep 27, 2017 8:12 pm

The Trinket help me finish a project. In the process I noticed there are few example code of an analog input controlling an output. I hope this might help others in their projects.

The project started as a landscape project. We wanted a bubbling fountain. It runs off a boat bilge pump in a basin under the fountain and recirculates the water. The system runs off a solar cell on the roof. Inside the fountain is a float switch, if the water level drops below a point, the switch interrupts power to to the pump. When the sun goes down, the fountain is off.

Building this was a little more difficult. My float switches could not handle the amp draw for the pump. A simple solution was to use a relay and have the switch able to interrupt the relay. This created a new problem...The coil created an inductive load, at low power, the coil would oscillate.

One possible solution would be to try to tune a RCL circuit by adding resistors and capacitors but that is a lot of extra work and frustration. This should be an easy project...if ok, turn on pump.

I then cam across the Trinket. Small, very few pins, some what limited but perfect for this project. I can now evaluate the situation and make decisions in software. I can also fine tune with out scraping and making new circuits fighting the inevitable difference between bread-board and soldered projects.

My circuit sends the power through the float switch and then to Trinket. Low water turns the Trinket off by killing power. Power also branches and goes though a voltage divider to make sure a 12V input is sampled between 0 and 5 Volts. If the test is met, I turn on a Mosfet switching the ground of the coil. If the voltage drops below a set point, coil turn off. Voltage must recover well above the cutoff point before it can turn back on.

I added capacitors to the sampled voltage to even out the sample voltage, but it was hard to get an even performance. The solution was to add delays to the samples giving the capacitors time to recover.

Code:
Code: Select all | TOGGLE FULL SIZE
          /*
            Check for sufficient voltage to hold coil open. Voltage
            is through a divider for a range between 5 and 0 volts.
            When voltage from the power supply drops below 6.5V, the
            system shuts down. Coil can re-energize if voltage recovers
            above set point of 8V. R1 measured value is 670 Ohms
            and R2 measured value is 466 Ohms.
           
            Table of calculated values of output to pin #2
            12V   = 4.923V = 1007        6.5V = 2.666V  = 545         
            11.5V = 4.717V = 965         6V   = 2.461V  = 504           
            11V   = 4.512V = 923         5.5V = 2.256V  = 462   
            10.5V = 4.307V = 881         5V   = 2.051V  = 420   
            10V   = 4.102V = 839         4.5V = 1.846V  = 378     
            9.5V  = 3.897V = 797         4V   = 1.641V  = 336
            9V    = 3.692V = 755         3.5V = 1.436V  = 294
            8.5V  = 3.487V = 713         3V   = 1.231V  = 252
            8V    = 3.282V = 671         2.5V = 1.026V  = 210
            7.5V  = 3.077V = 630         2V   = 0.820V  = 168
            7V    = 2.871V = 587         1.5V  = 0.615V = 126
                 
          */
     
    #define COIL       1
    #define VOLTS      2
    int VOLTvalue = 0;
     
    // the setup routine runs once when you press reset:
    void setup() {
      // initialize the COIL pin as an output.
      pinMode(COIL, OUTPUT);
      // Red LED for trouble shooting, should turn on with relay
      // activation
      pinMode(LED_BUILTIN, OUTPUT);
           
    }
     
    // the loop routine runs over and over again forever:
    void loop() {
        // read the input on analog pin:
        VOLTvalue =analogRead(1);

        //  Turn coil on if Voltage is above set point 10.5V
        if(VOLTvalue > 881){
          (COIL, HIGH);
          digitalWrite(LED_BUILTIN, HIGH);
          //  Wait 15000 milliseconds (15 second)
          delay(15000);
       }
       
       //Turn coil off if Voltage is below set point 7V
       if(VOLTvalue < 587){
          (COIL, LOW);
          digitalWrite(LED_BUILTIN, LOW);
          //  Wait 60000 milliseconds (60 second)
          delay(60000);
       }     
    }
       

Attachments
FOUNTAIN.png
FOUNTAIN.png (14.21 KiB) Viewed 412 times
Last edited by mhigbee on Wed Sep 27, 2017 8:30 pm, edited 1 time in total.

mhigbee
 
Posts: 2
Joined: Wed Sep 27, 2017 6:39 pm

Re: Solar Fountain Controller

by mhigbee on Wed Sep 27, 2017 8:16 pm

Additional Picture
Attachments
1-IMG_2869.JPG
1-IMG_2869.JPG (75.61 KiB) Viewed 410 times

mhigbee
 
Posts: 2
Joined: Wed Sep 27, 2017 6:39 pm

Please be positive and constructive with your questions and comments.