John Shovic's Google Plus Switch: 2014

Wednesday, March 26, 2014

Project Curacao Operational

Project Curacao has now been down in the Caribbean for two weeks now.  We've had some issues but they have been resolved.  We are writing an article for MagPi magazine describing all of our issues with the box and the wind turbine.  Major points are:

1) Minor problems with the box and shipment.  Loose grounds, unplugged sensors (looks like the TSA picked up the box by the outside temperature sensor).  No problem at all with the TSA.  We put in a letter in the box describing the project and copies of articles we had written and it went through with no problems.
Pre-installation Checkout

2) The special hardware to mount the box to the tower did not fit.  We had to strap it to the tower and orient the solar panels perpendicular to the ground.  
Mounting Platform
Installation
Installed Project Curacao





3) Lower solar power than design.  The strapping on the side of the tower would work in Idaho (45 degrees latitude) but gives very little power in Curacao (12 degrees latitude).  The problem with this was not with the Raspberry Pi.  It was with the Battery Watchdog Arduino.  We adjusted the run time of the Pi with the Arduino to fit the available power.  However, the Arduino is meant to run 100% of the time and the behavior of the Arduino is ill-defined in very low battery conditions.  It would glitch the real time clock which gave some very random behavior. 

We fixed this by moving the box down off the tower and onto the roof until we get a new mounting platform.

Arduino Control Screen
Note on the RasPiConnect  (www.milocreek.com) screen above you can see the Arduino battery voltage going down and down and down until we turned it off for a few days and moved it to the roof.

Here is a picture from the box's new location (again from RasPiConnect):


Camera Subsystem Control Screen

Here is a picture of the box in it's new happy place.




Relaxing in the Caribbean - but with Power


4) The wind turbine worked as predicted by our models.   We switched on the turbine at night to provide a trickle charge to the main computer. We got about 60 - 90ma of current at 15MPH.  No where close to the 200-300ma it takes to run the Pi.  However, a wind storm came through and destroyed the turbine about a week after installation.  Note that the turbine popped out of the stand and throughly destroyed itself.  We think that is was a sympathetic vibration with a particular wind speed (much like the "Galloping Gertie" Tacoma Narrows bridge) since we observed that the stand was flexing in the wind.  We will either prevent the next turbine from popping out or stiffen the stand to prevent the flexing or possibly both.
Destroyed Wind Turbine

We plan to replace the turbine and get a new mounting platform for our September 2014 maintenance trip to Curacao.

Wednesday, March 19, 2014

Software Description Done

We have published the description and architecture of the software system used for Project Curacao. Check out our Project Curacao Software Description page above.

Thursday, March 13, 2014

Project Curacao Installed

Today was the big day.  We mounted the Project Curacao wind turbine and the box up on the tower.  March 13, 2014.

It's running fine.  You can see the graphs and latest picture on http://www.milocreek.com/projectcuracaographs.  Thank you MiloCreek for hosting this page.

The tilt of the box is different than design due to mismatched tower parts.  It's flat rather than tilted up.  Hence the camera shows a lot of roof!  (We are calling it roofcam around here).

It is up and connected to the wireless router even through the metal roof.  The different tilt angle also reduces the solar power to the main unit, so it only runs about 7 hours a day.  The wind turbine may make up the difference.  We will see in a few days.



RasPiConnect Camera Screen




Final Charge before the Installation



The Wind Turbine being Hoisted up the Tower

Installation of the Wind Turbine
Bringing the Box up the Tower
Attaching the Box and the Wind Turbine Wiring
Working in the Sun
The Complete System Installed


Sunday, March 9, 2014

Project on Site

All of our equipment has arrived here on the island.  TSA inspected the box twice, but aside from picking up the box with the outside temperature sensor, pulling the wires off, it survived.  The temperature sensor was fixable.  There were also a couple of loose grounds to be tightened.  A group of sensors were giving odd readings so I knew to look for a loose ground.  One bad sensor, might be the sensor, a bad group likely a ground. 

Remember, you can always trust your mother, but you can never trust your ground.

We have put the box outside for the first time yesterday and the solar cells are working. The wind turbine needs to up on the tower to really roar.  It currently is only generating about 40ma but on the tower it will 200ma or so according to my curves. 

RasPiconnect connected to the box and the first Caribbean picture:



Here is box and turbine enjoying the sun:





Here is John writing this blog entry.  Note that someone stole 200 meters of phone line about a mile from the house and so we have lost our internet correction for some time.  







Wednesday, February 19, 2014

Software Status (02/19/14)

Our release software is done.  It's been in final test for the past week now.  Here is the list of  issues and latest additions.

As of today (02/19/14), the current state of the software in Project Curacao is as follows:

- Arduino Battery Watchdog:  
  1. Control of the wind turbine (selection between solar and turbine).   The Battery Watchdog turns the solar off and the wind turbine on at sunset and turns the solar on at sunrise.  This is time based and not luminosity based.  We will add more smarts to the Pi to look at cloudy days (via luminosity and color sensors) after the system is deployed to Curacao (to be deployed in early March, 2014).
RasPiConnect Screen modified for Wind/Solar Selection


- Project Curacao Pi main program:  The main program is generating all the graphs, camera pictures, environment sensing as required.  It is also regulating the Fan automatically now.    Reading log files from the Arduino Watchdog.  Next  things to be implemented:
  1. Improving sensor error detection (Vastly improved, but still needs more).  We still have an issue with the DHT22 sensor (Humidity Spike as shown below from RasPiConnect).  We believe that we will have to buckle down and figure out the checksum to detect these.  This is a Pi software problem, so we can do it after deployment.


- RasPiConnect:  Complete.  We use this all the time now to monitor what is going on in the project remotely.   
Here's the newest main screen (1 of 6 at this point):

Sunday, February 16, 2014

50W Wind Turbine Loaded Results

Update (03/26/14):  The Wind Turbine was deployed down in Curacao two weeks ago.  The actual data from the Turbine matched this article quite well.  About 60-90ma at 15 MPH.  Not much (and not nearly enough to run the box - takes about 300ma) but it did provide a trickle charge at night.  A windstorm took out the turbine about a week later.  See the blog posting about Project Curacao Operational.


We have now completed the 50W Wind Turbine characterization.  During the test of three weeks ago, we blew out the DC/DC voltage regulator with an over voltage condition. The damage was limited to the regulator.

Why did this happen?

The open loop voltage measurement on the 50W Turbine gives us a clue. The regulator is specified as a maximum 19V input. When the turbine hits more than about 25MPH, we started to generate more than 22V, even loaded. This eventually fried the regulator.

What did we miss in our test setup?

The 50W Wind Turbine very minimal specifications say in perfect conditions we can get 2A at 25V which is 50W. However, if we aren't taking 2A (which is 2X to 4X our maximum), the voltage goes up. Eventually, it killed our regulator. We did not think that one through.

How to fix it?


We added an over voltage circuit on the Wind Turbine side of the DC/DC regulator. The wind turbine is rated at 50W, but we aren't going to trust the number. We built one using TVS diodes and made sure we sized it for about 4A@25V (100W) to cover hurricanes (although in a hurricane, that will be the least of our problems - We would expect the Turbine to be halfway to Aruba by then). We did this by getting a 50W 5 Ohm resistor and putting 10-5W TVS diodes in parallel. TVS diodes operate by shunting excess current when the induced voltage exceeds the avalanche breakdown potential. It is a clamping device, suppressing all over voltages above its breakdown voltage. Like all diodes of this type, it automatically resets when the over voltage goes away.

We set the over voltage protection at 20V to avoid this problem in the future.

A good link for a diode based over voltage protection circuit is http://www.electronics-tutorials.ws/diode/diode_7.html




Completed Overvoltage Circuit


We ran another set of loaded tests for the 50W Turbine after the over voltage circuit was added and got the following curve (without generating any smoke).


Conclusion

We are going to go with the 50W wind turbine for this project down in the Caribbean. Our curve shows some power generation at 15 MPH and it gets really good at about 25 MPH. When we get the box down to Curacao, we are going to further characterize both the 50W and 15W wind turbines.

Our control system takes the weather into account on cloudy days (low luminosity and solar voltage) and turn the wind turbine on. Of course, we will turn the wind turbine on at night all the time. As our curves show, generating even 10W on an ongoing basis from the wind poses a set of special problems. Our next wind powered system will use better (and more expensive) turbines but as this is a secondary source of energy, the chosen 50W turbine will work for Project Curacao.

Friday, February 14, 2014

BM017 / TCS34725 Color Sensor I2C Python driver

We have made one more addition to the hardware on Project Curacao.  We have added a BM017 / TCS34725 RGBC color sensor to the device.  Here is the device attached to the back of the top of the box and then a picture of it peeking through (with the LED turned on for emphasis - it normally operates with the LED off).





This device was purchased from solutions-cubed.com (excellent service and documentation).  Another version (compatible) can be had from Adafruit.

We wrote a Python driver for the BM017 / TCS34725 as we could not find one on the net that met our needs.

It has been posted on github under https://github.com/projectcuracao/PC_BM017CS for anyone who needs such a driver.

We connected the INT line to the LEDON pin (and the VDD_LED to VDD) and now we can switch the interrupt on and off and turn the white LED on and off without burning another GPIO pin.


The example code to test the library and the TCS34725 is below:


#!/usr/bin/python
# example driver for BM017 and TCS34725
import time
import smbus
from Adafruit_I2C import Adafruit_I2C
from PC_BM017CS import BM017
bm017 = BM017(True)
bm017.debug = True
bm017.readStatus()
bm017.isBM017There()
bm017.getColors()
bm017.readStatus()
bm017.disableDevice()
bm017.setIntegrationTimeAndGain(0x00, 0x03)
bm017.getColors()
bm017.readStatus()
bm017.readStatus()
# this will turn on the LED if LEDON is connected to INT and LEDVDD is connected to VDD_LED
bm017.setInterrupt(True)
time.sleep(5.0)
bm017.setInterrupt(False)
And the results:
pi@projectCur ~/PC_BM107CS $ sudo python example.py
BM017 initialized
('BM017 Status=', 17)
BM017 / TCS34725 is present
('ColorList = ', [2, 0, 1, 0, 1, 0, 0, 0])
('clear_color= ', 2)
('red_color= ', 1)
('green_color= ', 1)
('blue_color= ', 0)
('BM017 Status=', 17)
('IT set to:', 0)
('Gain set to:', 3)
('ColorList = ', [8, 15, 157, 7, 105, 5, 151, 3])
('clear_color= ', 3848)
('red_color= ', 1949)
('green_color= ', 1385)
('blue_color= ', 919)
('BM017 Status=', 17)
('BM017 Status=', 17)
Interrupt On
Interrupt Off
We pointed the sensor at a spool of red wire.  That's why the "red_color" is higher than the green and blue.

Friday, February 7, 2014

Final Box for Project Curacao


As we ramp up to the last few weeks before deployment, our last task is to put Project Curacao in the final box.  Here is the NEMA enclosure purchased on Amazon (BUD Industries NBB-15253 Style B Plastic Outdoor NEMA Box with Solid Door).  I highly recommend this type of enclosure.  The plastic is easy to work with and the dimensions of the box are given in multiple forms and CAD files.







We are giving a talk at Spokane Create on February 19th so we have to get to work on finishing the box conversion and write a presentation.


Monday, January 27, 2014

Loaded 15W/50W Micro Wind Turbine Characterization

This past weekend we did the loaded testing for the two potential configurations for the wind turbines for Project Curacao.  


Two 15W Wind Turbine Configuration


We first tested a two 15W Wind Turbine configuration.  Our guess is that we could get at least a trickle charge out of these turbines at wind speeds of 15MPH.


Two 15W Turbines

We loaded the 15W turbines down with the actual Project Curacao charging circuitry.  This consisted of a DROK 3A/18W DC Buck Converter Car Regulated Power SuppIies 9-22V 12V to 6V wired to a relay that switches between the solar panels and the Wind Turbines and then to the solar battery charger,  LiPo Rider Pro.  This is the actual configuration used in Project Curacao.

This configuration is my "Load".   Please understand that your "Load" may not have the same impedance or characteristics of my "Load".  A better way of measuring this generally would be to discharge the Wind Turbine into a resistive load (a 65 ohm load in this case based on the data below) and measure the voltage.












The voltage was measured in the car at the wind speed shown.  

After the test outside, a variable power supply was connected to the Project Curacao box and the currents were read from the power supply current screen and from the Raspberry Pi RasPiConnect screen.   This is done on the assumption that a voltage is a voltage is a voltage when it is DC with little ripple.  Thus, I can put the measured voltage in to the system and read the currents from the software.  This avoids carrying a laptop, wireless connection, iPad, etc. in the car during test.



50W Wind Turbine Test

Based on some fragmentary data from a previous test run and the last test run it is clear that  the 50W Wind Turbine does far better than the smaller turbines at low wind speed.  No surprise there.  Clearly, at about 15MPH we can produce all the power we need.  We can generate a loaded regulated voltage of 6.4V at 15MPH (based on two measurements).  This gives us plenty of current to charge the battery, even when the Pi is running.
50W Wind Turbine

During the test photographed to the left, we blew out the DC/DC voltage regulator with an over voltage condition.  The damage was limited to the regulator.

Why did this happen?  


The open loop voltage measurement on the 50W Turbine gives us a clue.  The regulator is specified as a maximum 22V input.  When the turbine hits more than about 25MPH, we started to generate more than 22V, even loaded.  This eventually fried the regulator.  

What did we miss in our test setup?  


The 50W Wind Turbine very minimal specifications say in perfect conditions we can get 2A at 25V which is 50W.  However, if we aren't taking 2A (which is 2X to 4X our maximum), the voltage goes up.  Eventually, it killed our regulator.  We did not think that one through.


How to fix it?  


Add an over voltage circuit on the Wind Turbine side of the regulator.  We will build one of zener diodes and make sure we size it for about 4A to cover hurricanes (although in a hurricane, that will be the least of our problems - We would expect the Turbine to be halfway to Aruba by then).

We will set the over voltage protection at 20V to avoid this problem in the future.  We have ordered a new power supply and will build a over voltage circuit and re-run the tests in the next couple of weeks.


Conclusions



This leads us to several conclusions:

1) We need a wind speed of 20 MPH to generate power in our system using the two 15W Wind Turbine System.  We are sure there are better low speed turbines for our system.

2) The average wind speed in Curacao is about 14 MPH.  This means a substantial part of the time we won't be generating power.  How do we fix this?  We move the wind turbine higher on the tower as the wind speed is generally higher the higher you are above the ground.  We want the turbine as high as we can reasonably get it.  We gain about 15% in wind speed going up 10 meters (http://wind-data.ch/tools/profile.php), so we will see what can do.  We don't have a good number on the spread of wind speeds in but it looks like the bulk of the wind is between 10 MPH and 25 MPH so we will get some power.  Good thing we have solar cells.

3) Note how the voltage flattens out as we approach 50 MPH at about 16.5V on the open loop 15W turbine test.   Our system is designed to measure up to 17V (a voltage divider down to 5V for the Arduino) and tolerate up to 18.7V (no more than 5.5V into the Arduino).  This looks good.  If we have more than 50 MPH winds, the analog inputs will be the least of our problems.

Our control system will take this into account on cloudy days (low luminosity and solar voltage) and turn the wind turbine on.  Of course, we will turn the wind turbine on at night all the time.

Matplotlib, Raspberry Pi, MySQL and Project Curacao

One of the things we are using the Raspberry Pi on Project Curacao for is to generate graphs.  Yes, We know we could ship the data to another server and generate the graphs there, but since we have a nice linux platform, we decided to make the graphs on site.  Then we ship the graphs both to a webpage and also over to the RasPiConnect directory for display on the RasPiConnect App (www.milocreek.com).

Here's a picture of the embedded graph (in RasPiConnect):




The RasPiConnect Local.py code for a graph follows:


#W-11 is Pi System Status 
if (objectServerID == "W-11"):

                #check for validate request
                if (validate == "YES"):
                        outgoingXMLData += Validate.buildValidateResponse("YES")
                        outgoingXMLData += BuildResponse.buildFooter()

                        return outgoingXMLData

            # normal response requested



imageName = "systemstatistics.png"



               responseData = "<html><head>"
                responseData += "<title></title><style>body,html,iframe{margin:0;padding:0;}</style>"
                responseData += "</head>"
                responseData += "<body><img src=\""
                responseData += Config.localURL()
                responseData += "static/"
                responseData += imageName
                responseData += "\" type=\"jpg\" width=\"800\" height=\"300\">"

                responseData +="</body>"
                responseData += "</html>"


                outgoingXMLData += BuildResponse.buildResponse(responseData)


      outgoingXMLData += BuildResponse.buildFooter()

                return outgoingXMLData


Note that if you want to use a button to select different type of graphs for the same RasPiConnect control, you write the graph name to a file and the read the file to get what graph to display.  Make sure you assign the Web Control to refresh when you push the button.  Then you get an immediate response.  

You can select a different graph by using a feedback control button to write that file (that contains the graph name) and cycle through graphs (see my video on this blog for an example) as below:


# FB-11 - change the graph display 
if (objectServerID == "FB-11"):

                #check for validate request
# validate allows RasPiConnect to verify this object is here 
                if (validate == "YES"):
                        outgoingXMLData += Validate.buildValidateResponse("YES")
                        outgoingXMLData += BuildResponse.buildFooter()
                        return outgoingXMLData

# not validate request, so execute

               responseData = "XXX"

if (objectName is None):
objectName = "XXX"
               lowername = objectName.lower()


                if (lowername == "display voltages"):

                        responseData = "display currents" 
                        responseData = responseData.title()


                f = open("./local/GraphSelect.txt", "w")
                f.write(lowername)
                f.close()


                elif (lowername == "display currents"):

                        responseData = "display solar/wind" 
                        responseData = responseData.title()

                f = open("./local/GraphSelect.txt", "w")
                f.write(lowername)
                f.close()

                elif (lowername == "display solar/wind"):

                        responseData = "display voltages" 
                        responseData = responseData.title()

                f = open("./local/GraphSelect.txt", "w")
                f.write(lowername)
                f.close()

# defaults to display currents 
                else:
                        lowername = "display currents" 
                f = open("./local/GraphSelect.txt", "w")
                f.write(lowername)
                f.close()

                        responseData = "display voltages" 
                        responseData = lowername.title()

                outgoingXMLData += BuildResponse.buildResponse(responseData)
                        outgoingXMLData += BuildResponse.buildFooter()
                 return outgoingXMLData

We decided to use the excellent python based matplotlib package.  Here are the steps to get the necessary packages:


$ sudo apt-get install libblas-dev        ## 1-2 minutes
$ sudo apt-get install liblapack-dev      ## 1-2 minutes
$ sudo apt-get install python-dev        ## Optional
$ sudo apt-get install libatlas-base-dev ## Optional speed up execution
$ sudo apt-get install gfortran           ## 2-3 minutes
$ sudo apt-get install python-setuptools  ## ?
$ sudo easy_install scipy                 ## 2-3 hours

$ sudo apt-get install python-matplotlib  ## 1 hour
Thank you http://wyolum.com/numpyscipymatplotlib-on-raspberry-pi/

We run graphs on our pi system based upon entries in apschedule:
    scheduler = Scheduler()
   

    job = scheduler.add_cron_job(powerdatacollect.datacollect5minutes, minute="*/5", args=['main', 0])
    job = scheduler.add_cron_job(watchdogdatacollect.watchdogdatacollect, minute="*/5", args=['main', 30])
    job = scheduler.add_cron_job(environdatacollect.environdatacollect, minute="*/15", args=['main', 10])
    job = scheduler.add_cron_job(systemstatistics.systemstatistics15minutes, minute="*/15", args=['main', 20])




    job = scheduler.add_cron_job(doallgraphs.doallgraphs, minute="*/15", args=['main',10,60])


    # camera
    job = scheduler.add_cron_job(useCamera.takeSinglePicture, hour="*", args=['main',50])
    # send daily picture
    job = scheduler.add_cron_job(sendPictureEmail.sendPictureEmail, hour="22",minute="20", args=['main',0])



One good thing about running tasks like this in another thread, is that a hang in one of the threads does not stop the whole system.  Just that thread.


Here is the example matplotlib code and graph for one of the graphs (including the call to MySQL to get the data).  We are using the Solar/Wind line to show which power source is selected.  Reg Wind Volt gives the voltage on the regulated side of the DC/DC 12V - 6V Buck converter (fed to the solar power charging circuitry) and Unreg Wind Volt is on the Wind Turbine side of the converter.  We choose to use just points because of the intermittent nature of the wind.  See the post on the wind storm we had a couple of weeks ago.  This was the graph generated after a couple of trips in the car with various wind turbines.




# solar wind graph generation
# filename: solarwindgraph.py
# Version 1.4 01/12/14
#
# contains graphing routines
#
#

import sys
import time
import RPi.GPIO as GPIO

import gc
import datetime

import matplotlib
# Force matplotlib to not use any Xwindows backend.
matplotlib.use('Agg')

from matplotlib import pyplot
from matplotlib import dates

import pylab

import MySQLdb as mdb

sys.path.append('/home/pi/ProjectCuracao/main/config')

# if conflocal.py is not found, import default conf.py

# Check for user imports
try:
        import conflocal as conf
except ImportError:
        import conf

def  solarwindgraph(source,days,delay):



        print("solarwindgraph source:%s days:%s delay:%i" % (source,days,delay))
        print("sleeping :",delay)
        time.sleep(delay)
        print("solarwindgraph running now")


        # blink GPIO LED when it's run
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(22, GPIO.OUT)
        GPIO.output(22, False)
        time.sleep(0.5)
        GPIO.output(22, True)

        # now we have get the data, stuff it in the graph

        try:
                print("trying database")
                db = mdb.connect('localhost', 'root', conf.databasePassword, 'ProjectCuracao');

                cursor = db.cursor()

                query = "SELECT TimeStamp, RegulatedWindVoltage, UnregulatedWindVoltage, SolarWind FROM batterywatchdogdata where  now() - interval %i hour < TimeStamp" % (days*24)
                cursor.execute(query)


                result = cursor.fetchall()
                t = []
                s = []
                u = []
                v = []

                for record in result:
                        t.append(record[0])
                        s.append(record[1])
                        u.append(record[2])
                        v.append(record[3])

                print ("count of t=",len(t))

                # scale array for Solar =0 Wind = 1

                for i in range(len(v)):
                        v[i] = v[i] * 10

                #dts = map(datetime.datetime.fromtimestamp, t)
                #print dts
                fds = dates.date2num(t) # converted
                # matplotlib date format object
                hfmt = dates.DateFormatter('%m/%d-%H')

                fig = pyplot.figure()
                fig.set_facecolor('white')
                ax = fig.add_subplot(111,axisbg = 'white')
                ax.vlines(fds, -200.0, 1000.0,colors='w')

                ax.xaxis.set_major_locator(dates.HourLocator(interval=6))
                ax.xaxis.set_major_formatter(hfmt)
                ax.set_ylim(bottom = -200.0)
                pyplot.xticks(rotation='vertical')
                pyplot.subplots_adjust(bottom=.3)
                pylab.plot(t, s, color='b',label="Reg Wind Volt",linestyle="",marker=".")
                pylab.plot(t, u, color='r',label="Unreg Wind Volt",linestyle="",marker=".")
                pylab.plot(t, v, color='g',label="Solar/Wind",linestyle="-",marker=".")
                pylab.xlabel("Hours")
                pylab.ylabel("Voltage")
                pylab.legend(loc='upper left')

                pylab.axis([min(t), max(t), 0, 20])
                pylab.figtext(.5, .05, ("Solar / Wind System Last %i Days" % days),fontsize=18,ha='center')

                pylab.grid(True)

                pyplot.show()
                pyplot.savefig("/home/pi/RasPiConnectServer/static/solarwindgraph.png")

        except mdb.Error, e:

                print "Error %d: %s" % (e.args[0],e.args[1])

        finally:   

                cursor.close()
                db.close()

                del cursor
                del db

                fig.clf()
                pyplot.close()
                pylab.close()
                del t, s, u, v
                gc.collect()
                print("solarwindgraph finished now")