Solar Monitor

Solar Monitor Project

Background: Each year when we see generators on sale at Costco we say to ourselves “This is probably the year that we’ll have a big ice storm and regret not buying a generator…” but then we think twice about spending a few hundred dollars and the thought passes.

A few months back we were having the same sort of thoughts when I happened on an article about the cost of residential solar power installations continuing to drop over time.  One web link led me to another and I soon saw that the tax credits for residential solar installations (35% up to $10.5K in NC & 30% no max Federal) would be expiring at the end of 2015 (NC) and 2016 (Fed). (Some good info here: Solar Tax Incentives) We get a lot of good North Carolina sun on our roof and it got me to thinking about whether it would be a worthwhile investment to try to put in a solar system that could both offset our current electric expense but also provide some backup in the event of a power outage (Grid Inter-tied Residential Solar Power System with Battery Backup) See here: Residential Solar System Types

We’re fairly lucky in that our electric use is fairly constant and rates are not too bad in our area. We manage it fairly well (time of use discounts, programmable thermostats and water heater timer, etc.) but we still run around $180 per month on average. Thinking ELECTRIC BILL GRAPH3about overall pay-back time horizons I just started with the concept of halving the current electric bill. At this point I don’t really know if that is reasonable or complete pie-in-the-sky but saving $90 per month on the electric bill would roughly be $1000 savings per year so in 10-15 years we could get payback on a fairly hefty investment (accounting for the tax credits of course also!)  Here is some additional data that I’m able to get from our power company (Duke Energy):KWH USAGE KWH vs TempI also found some useful info here that indicates we receive ~111 “full sunny” days per year with ~217 days per year that are at least partially sunny (>40%).  Once I get to the point of trying to analyze and size a potential system this will be helpful data also!

Problem: Could I figure out a way to determine if this sort of system would really pay for itself in a reasonable amount of time (ie maybe 10 years or so).  In other words, on average how efficient would a panel be at our house based on the amount of sun, orientation of the roof, typical weather, etc?  If I had data like that then I could look at our power needs (max kilowatt usage from our electric bill in a typical year) and determine if I could put in a system to meet that need without completely breaking the bank (or having to put in more roof!)

A Project is Born: A few other ideas had been bouncing around in my head that all fit nicely around this problem:

  1. Find a real use for the  Raspberry Pi I had bought a few months back just to tinker with it.  If you’re not familiar with this take a quick look here: Raspberry Pi  This thing is pretty amazing considering it’s a $35 investment – you have to love their teaching mission also.
  2. I had been wanting to learn to code in Python.  I’ve learned Perl and PHP in the last 10 years or so but haven’t gotten any experience with the newer languages yet.
  3. The “Internet of Things” and home automation both seem to be poised to explode – every time I read an article about these topics I then wind up wasting time following countless other related links.  Lots to learn and a big future in this space I think.

Solution Components:

  1. Raspberry Pi Linux Server: I already owned one of these and knew it could function as the “brains” of the project – storing the data and providing a web-interface to view it.

    The Raspberry Pi Server velcro'd to the wall net to my desk with an XBEE connected to it via USB.  Note the XBEE is about the size of a US quarter coin.  The other connections are power on the left, HDMI monitor on the bottom, ethernet on the lower right, and a second USB under the XBEE which hooks to a USB hub that has keyboard, mouse and external hard drive!

    The Raspberry Pi Server velcro’d to the wall next to my desk with an XBEE radio connected to it via USB cable. For scale, note the XBEE is about the size of a quarter. The other connections are power  and SD card on the left, HDMI monitor on the bottom, ethernet on the lower right, and a second USB under the XBEE which connects to a USB hub that has keyboard, mouse and external hard drive!  There are also an audio and RCA video port on the top but I’m not currently using them – quite a gadget!

  2. XBEE Radios:  – as I googled around looking for ideas on how to remotely monitor a solar panel I found a lot of info that mentioned these devices (What is an XBEE?) and quickly realized that they were ideal for the job.  They communicate via radio frequency over short distances using the 802.15.4 protocol and with a number of pins for analog and digital input/output they can be adapted to lots of uses.  Here are some good examples: http://gallery.digi.com/category/xbee-projects/
  3. Analog Sensors: In addition to measuring the solar panel efficiency I also found some inexpensive sensors that would let me measure some other variables at the same time:
    1. Temperature – http://www.adafruit.com/products/165
    2. Light Sensor – http://www.adafruit.com/products/1384
    3. Solar Panel (Voltage/Watts) – http://amzn.com/B00CBT8A14

At this point I was ready to start buying stuff (being an Amazon Prime member can get a bit dangerous at times!)

Parts List:

ITEMDESCRIPTIONCOSTPIC
Total cost = $183
Raspberry PiCredit-card sized linux server that runs Apache and MySQL and hosts the various php and python code files – I already had this but decided to consider the cost within this project$35RPI
XBEE RadioThese are the little wireless gadgets that enable the transmission of data collected from various sensors connected to its pins. I needed 2 – 1 connects to the Raspberry Pi sever so it can receive data from the other remote unitqty 2 @ $29 eachxbee
XBEE ShieldThis isn’t necessarily required but made life a lot easier (saves soldering and handles the power mgmt on the board)qty 2 @$19 eachxbee_shield
5V Solar PanelThis will be the stand-in for a full blown system and used to try to determine how efficient an installation at our house might be.  This is pretty bare bones (I had to solder leads on to the back of it) but its specs say it generates 5V at 500milliamps (ie in theory a 2.5 watt panel)  I measured it with my multimeter and see it generating ~5.4 volts and ~95 milliamps under full direct sunlight.  This calculates to~.5watts which would mean it’s about 20% efficient and that seems right in line with what I believe should be expected$9SOLAR PANEL3
TMP35 Analog temperature sensorThis will let me check the ambient temp near the panel and then collect data that can be graphed to check the relationship between temp and production/efficiency on the panel$2TMP35
Analog Light SensorWith this I can measure the “lux” hitting the panel and thus add a measure of how “sunny” it is in relation to panel performance$6light sensor
Electronics Parts KitNeeded a breadboard and some jumper wires and I figured that no matter what I bought I would break something or need more so I bought a kit$16ELECTRONICS KIT
5V RegulatorThe XBEE shield takes 5volts in (and regulates that down to 3.3volts).  I use this to take the 9v battery down to 5v to power the whole mess$6VOLTAGE REGULATOR
9V Rechargeable BatteryProbably could have done this without a rechargeable but it makes the whole thing self-sustaining as the solar panel can recharge the battery$99v Rechargeable
9V Battery HolderDidn’t really need this but it made things cleaner!$49VBATTHOLDER
EnclosureNot sure what this will turn out to be yet – perhaps a recycled plastic case as in the garage monitor project but might also need something a bit more weatherproof and with the ability to mount and change the angle of the solar panel – so TBD for now!$0

Of course if I actually wind up installing a solar system and saving money on the electric bill then I’ll include this $183 in the payback calculation! 🙂

Putting It All Together:

  1. Web code: I took a somewhat backwards approach – since I had experience with writing database and web code I decided to build all that first.  I populated a MySQL database running on the Raspberry Pi with dummy data and built out the web code in PHP to display it easily through the Apache web server also running on the Pi.  When looking around for how to easily graph the data I came upon  Google Visualizations and had a lot of fun learning how to leverage it.  Here’s a look at the current web page view.  This will likely continue to evolve but for now it’s a simple view of the latest reading (the 3 gauges at the top) plus an interactive histogram graph that lets you plot production of the panel over various time slices against either temperature or light:
    Dynamic web page that pulls the captured data from the MySQL database on the Raspberry Pi server and then uses Google Visualizations to graph it. Note that the histogram chart at the bottom has a pick-list box to allow the viewer to easily change the time slice on the x-axis or the secondary y-axis from temp to lux. This is currently running on the local Apache web server and only available from my local home private network.

    Dynamic web page that pulls the captured data from the MySQL database on the Raspberry Pi server and then uses Google Visualizations to graph it. Note that the histogram chart at the bottom has a pick-list box to allow the viewer to easily change the time slice on the x-axis or the secondary y-axis from temp to lux. This is currently running on the local Apache web server and only available from my local home private network.

    The PHP web code for displaying the data stored in the MySQL database:

    There is a second piece of code that is called to query the database and return a JSON data set to the function that builds the combo bar-line graph. It looks like this:

  2. Electronics: Now came the tricky part – cobbling
    SOLAR MONITOR PROTOTYPE

    The initial prototype solar panel monitor cobbled together on my desk

    the electronics together and writing the code to read the sensors and put the readings into the database.  The database part was trivial but the electronics and code to read sensors were areas that I had zero experience with.  As I started working on this (and getting more and more frustrated) the project took a fork in the road and I morphed it temporarily into the Garage Door Monitor Project which gave me a lot more experience for when I eventually got back to this part!

  3. Monitoring Code: The key to this was first understanding the equations and calculations needed to translate the readings coming over the XBEE into real data to put into the database.   After a lot of digging around and reading I eventually got it figured out.  The analog pins on the XBEE give readings that scale from 0 to 1023 so you can use that value to figure out a voltage reading and then plug it in to various equations for the sensors as follows:
      1. Voltage = (XBEE_PIN_READING /1023) * XBEE_REF_VOLTAGE
      2. Temperature:
        1. Temp_C = ( Voltage – 500 ) / 10
        2. Temp_F = (((Temp_C*9)/5)+32)
      3. Lux = (XBEE_PIN_READING /1023) * XBEE_REF_VOLTAGE
      4. Solar Panel Amps = (VOLTAGE_DROP_ACROSS_RESISTOR * VOLTS_PER_XBEE_ADC_POINT) / RESISTANCE
      5. Solar Panel Watts = SOLAR_PANEL_VOLTAGE * SOLAR_PANEL_AMPS

    Python code for gathering the remote sensor readings via the XBEEs, converting them to useful data and then loading into the MySQL db:

Key Challenges:

  • I struggled a lot with getting consistent readings from the sensors and learned a bit about electronic “noise” that shows up when you have cheap parts and/or loose wiring in the system –  After cleaning up the wiring and adding a few capacitors to smooth things out things have improved significantly.  I’ve also started discarding the first reading as I sometimes see it flaky and assume there may be some timing issue or something when things first power up.  The temp sensor will still occasionally flake out and give a reading that is off by + or – 40 degrees or so – I’m still wrestling with trying to figure out the cause for that.
  • Figuring out the solar panel output also proved quite tricky.  I’m a complete novice when it comes to circuits and electronics so the concept of measuring the voltage drop across a resistor was a bit foreign.  Ohm’s law made perfect sense but the readings that I initially got never seemed to sync up with expectations and I spent a lot of time scratching my head.

Next steps:

  1. The breadboard is still a bit messy and things need to be cleaned up and packaged a bit more professionally – I might even try moving it on to a PCB board and trying to solder everything cleanly – maybe this will help to clear up some of the flaky readings
  2. Right now the database and web code are on my Raspberry Pi server and thus are only accessible on my private network.  I don’t know if there’s any value in being able to get to it from the public internet but I might consider moving those pieces to my GoDaddy host.
  3. Once we have a few months of useful data then if it makes sense it will be time to engage a Solar Installation company and start getting some estimates!

Acknowledgements:

These web sites gave me some great insights:

And of course, thanks to Dad for inspiring me to try DIY projects like this and for teaching me that you can eventually figure out and fix anything if you just keep at it and use your noggin!

 

Leave a Reply