Author: fillycheezstake

  • My DIY Roof-Mounted Solar Installation

    My DIY Roof-Mounted Solar Installation

    This is something I have wanted to do for a long time, and now that we own a house, this was the year we made it happen. We got permission to operate from the local power company on March 27th, 2024. I probably started my plans/design and applying for permitting in mid-January of that year.

    What’s all involved in doing a DIY, grid-tied rooftop solar installation?

    Well, that’s what I’ll get into here – I’ve tried to document my process. Not sure who the audience here is, but figured I’d write some stuff down.

    Keep in mind that the requirements vary on where you live – power companies, states, municipalities, and counties all can impose their own requirements. Thankfully, I’m in unincorporated King County in Washington, and the requirements here made things easy – at least permitting wise.

    Permitting and Utility Company Permission to Operate

    This part of the process is important to do in tandem with your design phase, so you can gather and apply the necessary information to your permits, utility company generation site application, and design.

    Building Permit

    Do the building permit research early on in your design process. Many of the parameters like roof setbacks, maximum allowable size or power, electrical requirements, etc are crucial to getting it approved.

    Washington State Building Code Council publishes what codes we follow here in WA, basically amended versions of the IRC/IBC. See https://sbcc.wa.gov/state-codes-regulations-guidelines. Counties and municipalities can also amend these. I did some reading to make sure my design would meet the code, even though it turns out we don’t need a full building permit for rooftop solar here.

    In my jurisdiction, rooftop solar installations are exempt from a building permit if you document meeting a few criteria and retain the completed form, in case anyone comes asking. See below.

    Note things like meeting IRC sections, keeping it under 3psf additional roof load, keeping each attach point under 50lbs point load, and a few other things. We’ll talk more about this during racking design.

    Gather your design loads. You’ll need this for racking design, and definitely your building permit application if your area requires that.

    Power Company ‘Permission to Operate’

    Most power companies have a website or similar process for applying to be a solar generation site. Puget Sound Energy (PSE) the electric utility in my area, has a website where they talk about it and lay out the requirements for applying.

    • Requirements include a one-line diagram, disclosing your panel and inverter models, and a few other tidbits. I’ll talk about the one-line diagram a bit later.
    • The application website is here. You’ll eventually have to upload proof of your electrical permit being approved, a few signatures, and some system design specifications.
    • Because you’ll need quite a bit of info for this, you can’t (or shouldn’t apply for this right away, do some system design first!).

    Electrical Permit

    Because I found out that the utility company requires an approved electrical permit prior to granting ‘permission to operate’ (PTO), I had to do some research here on who grants electrical permits in my area. Since I’m in unincorporated King County, the Washington State Department of Labor and Industries issues these.

    The WA Dept of L&I also publishes what version/amendments they make to the NFPA 70. See https://lni.wa.gov/licensing-permits/electrical/laws-rules-policies. We are on NFPA 2023 here, so do some reading to make sure your electrical installation will meet all those requirements so your inspection will go smoothly. Some power utilities also have requirements for disconnects and other required electrical features.

    Do some research on what parts of the code you’ll have to meet – you’ll need to size breakers, wire gauges, etc to ensure you’re meeting this. You’ll also need to read to see if you need a dedicated disconnect switch outside, and a few other things. Since the permit is good for a year, I applied/purchased the permit right away, and then after it was all installed I submitted to have it inspected (which I passed first try, by the way).

    My inspector also wanted a copy of my one-line diagram that I submitted to the power company. I had a paper copy available for their review.


    High Level Design – Picking Panels/Inverter(s), Roof Placement, One-Line Diagram

    First – have a rooftop that is conducive to solar. Some houses have wild rooflines, no good south-facing roof, etc. Here’s what my current roofline looks like:

    Our roofline as of August 2022. I used our south-facing garage roof for the solar install.

    In the northern hemisphere, it’s best if solar arrays (if tilted) face south, for maximum capture of the available solar irradiance. I picked our south-facing garage roof.

    Measure your roof (you can either do this in something like Google Maps/Earth, or just get up there and measure. I went up and measured to get the exact dimensions, and to measure the slope of my roof. Since I planned to place panels on the south-facing garage roof, I measured those dimensions and also the pitch. That roof is a 4:12 pitch. You’ll need this information a lot for your design, so write it down!

    I used the super-nice IronRidge configurator website to lay everything out and help with research and design. Check out the below image and the full report in the racking design section of this post.

    A sample of the online IronRidge configuration tool. The tool lets you pick panels, layouts, and will help you with code compliance.

    Because the IronRidge configurator has a large database of solar panels and their dimensions, you can cross check to what equipment and panels are available in your area, and iterate with different panels to get the most wattage of panels on your roof. I ended up sourcing panels from an electrical supply house here in the PNW called Platt, but more on that later.

    • Use panels that you can actually get. Preferably locally, to save on freight.
    • Experiment with different layouts, orientations, panel sizes, panel models, etc.
    • Keep in mind that the most utilization of your roof may not be the largest wattage panel – you may be able to tetris in more smaller panels better than fewer larger panels. It’s all about the best usage of the available square footage.

    I landed on a locally available (and locally made, actually) solar panel – the Silfab SIL-370HC. Turns out those panels are made just north of where I live here in Washington. For now we’ll ignore any racking hardware – just use the configurator to play with solar panel layouts only.

    Now that I knew about what my system would consist of – Twelve (12) 370 watt panels (that means 4.44kW DC capacity) – I could start to research or pick inverters, microinverters or string inverters. For this, I used both the inverter vendor websites and software available from the National Renewable Energy Laboratory (NREL).

    The System Advisor Model (SAM) software available from NREL is basically the extremely detailed version of PVWatts. SAM includes databases of solar panel performance data, inverter performance data, solar irradiance data, and much more. You can input cost data, actual or simulated usage data, and the software calculates outputs including ROI or payback time scales, total output, clipping data, and much, much more.

    System Advisor Model (SAM) – You can see that the software comes with built-in databases of performance data of many inverters.

    After doing a lot of internet research, hearing coworker experiences, and analysis in SAM, I decided to go with microinverters – or a single inverter for each panel. They are located under each panel on the roof. Based on my location, panel size, and other factors, I picked the IQ8+ Microinverter, part number IQ8PLUS-72-M-US. Why did I choose microinverters?

    • Ease of installation – they attach to the racking under the solar panel (no big inverter to mount inside or on the side of the house)
    • No high voltage DC (>100 VDC) wires that I can’t deenergize on my roof. It’s decently safe to set these up in full sunlight.
    • Cool per-panel metrics and data
    • Wiring simplification – since the microinverters output 240VAC, all you need to do is run two wires into your main electrical distribution panel from the inverters
    • They are a bit more expensive per watt than a single inverter or string inverters, but I think that is outweighed by the above

    You’ll notice that my panels are rated at 370 watts nominal, and the microinverters I picked are rated at 290VA continuous or 300VA peak – why?

    Basically, a solar panel rarely operates at the nominal or peak output that the panels are rated for. Only during low ambient temperatures and high solar irradiance (think July sun, but 55degF outside) are panels operating at their maximum rated power. Normally in July with the most solar energy hitting the earth, ambient temperatures are also high. As temperatures rise, solar panels decrease in efficiency – so now a 370 watt panel is only going to output 330 watts, for example. You can see those curves in the data available from the solar panel manufacturer, and SAM uses that data to calculate what is known as ‘clipping’, or when your microinverter will saturate, leaving a bit of that solar panel capacity on the table. You can do more reading on solar panel ‘clipping’ from various places, I know NREL has produced some papers on it.

    Essentially, that tiny bit of energy you lose by sizing smaller microinverters is more than offset by the reduction in cost of the smaller capacity inverters. SAM showed clipping losses for me was <1% with this configuration.

    So Twelve (12) 290VA microinverters means 3.48kW of AC capacity.

    We have spec’d out our panels and our microinverters – the two main components of a rooftop solar array. Keep in mind that this data will be required for the electric utility PTO application.

    So now that we know our components, it’s time to put together a ‘one-line’ diagram. Not only does the utility company require this as part of the application, my electrical inspector asked for a copy when they arrived onsite, and it generally just helps you understand what’s going on. The below is an example (not exactly what I submitted, but very close). Keep in mind it’s just a ‘one-line’, we are not showing each individual electrical conductor here.

    I’d go ahead and apply for the utility company permission now, as we have initial sizing and component selection done, and have our one-line complete.


    Racking Design and Bill of Materials

    For the racking design, I went with IronRidge, partly because of their awesome website, and partly because a coworker had recently used them and had a good experience. Overall, I was super impressed with the IronRidge setup – it truly did make everything very easy, the components were very high quality, and I felt really good about the install itself.

    Since we’ve got all the research done on the building code requirements, and know our design loads from research earlier, we can input all that data into the IronRidge tool.

    You’ll need to verify a few things during your planning in the tool. First, meet any applicable building codes – for my area, I had to ensure the total distributed load was less than 3psf, and any individual point load was <50lb. My installation ended up being around 2.5psf, and a maximum of 37.1lb point load.

    If you look a the last page 8 of the above report, you can see the tool even gives you a bill of materials for your racking! I used this and purchased all the components at a local electrical supply house, except for the wire clips, which I found online.

    The Enphase System Builder website helped with knowing about those extra components required, as well as a bunch of research there.

    I went ahead and put together my Enphase-related bill of materials, since I was going to order most of that stuff online. The below is an output from the Enphase System Builder, linked above.

    From the Enphase System Builder website.

    I ordered the microinverters, the IQ cable (the cable that connects the AC output sides of all the inverters), and the associated IQ cable caps and seals all directly from Enphase. I found they had the best or most competitive pricing for that stuff. I did not order any IQ cable clips from them, nor the disconnect tool. For the clips (these are used to attach cables to the racking) I found some stainless trailer wire clips on Amazon, and for the IQ disconnect tool, I found one on Ebay.

    • Keep in mind that there are different type of the Enphase IQ Cable depending on your panel layout and orientation. I went with portrait cable.
    • Have a rough idea of where you’ll be placing the junction box on the roof. I ordered a couple extra connector lengths of the IQ cable to plan for that. There will be photos of the installation later.
    • I didn’t end up getting any ‘IQ raw cable’ or IQ female connectors. My IQ Cable was long enough to reach my rooftop combiner box.

    Procurement and Installation

    I now had an electrical permit from WA L&I, and approval to construct from PSE in hand, so it was time to get to work.

    My box from Enphase was packaged well, and had all my inverters and cabling.

    I drove over to Platt, a local electrical supply house, and ordered everything I needed in person. Ordering through their website doesn’t allow you to pick up orders, only ship them (for extra cost). Everything was available to pick up the next business day. No solar panels were broken or cracked, and they even forklifted them into the back of my F-150. l ended up keeping them back there until the weather was nice enough to start the installation. A photo of my sales receipt from Platt is in the photos portion of this post.

    Ah yes – in the state of Washington, residential rooftop solar installations are exempt from sales tax. You can either show the retailer/wholesaler you form, or go back and apply for a refund from the state after the fact. See https://dor.wa.gov/taxes-rates/tax-incentives/tax-incentive-programs#Solarenergysystemsalestaxexemption

    Total Material Cost and ROI

    I need to add this spreadsheet, and talk about it here.

    Photos

  • Raspberry Pi Upgrade – WordPress Behind a Proxy

    Recently, I upgraded my Raspberry Pi that serves this website, my instance of EmonCMS, and a few other projects I use at home.

    As a part of that, I also use an instance of Home Assistant on a different Raspberry Pi.

    These things need to be available externally, which I struggled with at first. WordPress didn’t like responding in HTTP when it was hit with proxied/forwarded HTTPS requests over HTTP. This is post is to document what I had to do to fix this when future me has to fix the same problem.

    Made in a free version of some Visio Online Tool

    As you can see, I used the first Raspberry Pi running Home Assistant responds to the domain ‘ha.philipahlers.com’. Nginx Proxy Manager sees other domains, like ’emon.philipahlers.com’ and ‘philipahlers.com’ and forwards them to the other Raspberry Pi. It’s getting HTTPS requests on port 443, handles the SSL certificates, and forwards the request, now HTTP and port 80 to that second Raspberry Pi.

    So to fix WordPress – I had to add some code to the WordPress wp-config.php file located in the WordPress installation folder:

    if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) {
    $_SERVER['HTTPS'] = 'on';
    }

    This lets WordPress respond to requests forwarded from HTTPS over HTTP correctly.

  • Current Sensing Transformers & EmonESP

    Current Sensing Transformers & EmonESP

    I’ve been upgrading my home power monitoring software a bit, as it looks like there are some new options out there for the ESP8266.

    Previously, I was using an ESP8266 with the Espressif AT firmware, available at their website: https://www.espressif.com/en/support/download/at

    Espressif also publishes an API reference for said firmware on their website as well. It looks like it’s even still being maintained – the AT Firmware API reference was last updated in August of 2020.

    You can see the code I used to interface with this AT firmware at my Github repository. Currently, that code runs on a Teensy 3.2 and pushes data using the AT firmware on the ESP8266 to an Emoncms server hosted on a Raspberry Pi. This method requires the generation of all sorts of AT commands and gibberish to get the ESP8266 to make a HTTP GET request to publish data to the Emoncms server. The main issue with this method was the fact that I was never able to get the ESP8266 to reliably reconnect to Wifi if the power went out. Essentially the ESP8266 would come up first, look for the Wifi network, get confused and just not play nice.

    I’ve been watching the development of EmonESP for a while – essentially the folks over at OpenEnergyMonitor wrote some great stuff that runs directly on the ESP8266 and provides a web UI that works great. What I’ve really been loving is the fact that there is a passthrough serial connection – so I can talk directly to my Teensy 3.2. This means I can remotely calibrate channels on the unit without re-flashing the unit, like I did before (great code writing by me… not).

    So after firing up Visual Studio Code with PlatformIO, I compiled the EmonESP for my device… and found a couple of issues. First, the path to the Emoncms server functionality was broken, so I made a fix and a pull request to get that fixed. Another issue was the fact that ArduinoJson (a great way to easily work with JSON on your Arduino or other microprocessor, FYI), declares sizing for objects up front – so the EmonESP implementation wasn’t cut out for my 20+ channels of data. Before, in src.ino in the EmonESP codebase:

      StaticJsonDocument<512> data;
    
      boolean gotInput = input_get(data);

    512 bytes got me about 16 channels of data + EmonESP diagnostic data. I’d like to keep the EmonESP diagnostic data it adds, plus some extra data for channels of temperature or other data. I sized it at 1024.

    This worked great! I’ve rewrote my code that runs on the Teensy 3.2 to hand off data in key:value pairs to the ESP8266 running the modified EmonESP software. That new sketch is located here.

  • Fusion 360 / Eagle PCB

    Fusion 360 / Eagle PCB

    It’s been a while since my last post! Every once and a while, I get a chance to sit down and work more on my power monitoring project. Previous versions of this project have been operational and collecting data for well on three years now, but I’ve wanted to clean up the physical design a bit and make it more usable.

    A quick recap of this project – my dad and I wanted something to monitor power usage in the home by each individual circuit in the house. Read about how these type of systems work at https://learn.openenergymonitor.org/.

    • I selected the Teensy 3.2 as my primary microprocessor to do ADC sampling and conversions as it has 21 ADCs
    • Selected the ESP8266 WiFi module to send gathered data to a database somewhere (using a local installation of EmonCMS on a Raspberry Pi)
    • Selected the Texas Instruments REF2033 as a voltage bias source (it’s expensive, but very nice for this application)
    • Used EAGLE to create schematics and the PCB layout
    • Sent PCB design files to SeeedStudio to be manufactured
    • Designed an enclosure in Fusion 360 with a snap-fit lid
    • Wrote (well, writing…) the code in the Arduino IDE

    A while back, North Carolina State University cut me off from using their Solidworks license – which makes sense – I graduated five years ago! In lieu of Solidworks, I picked up Fusion 360 at home (I use CATIA V5 at work).

    Since I last used EAGLE, it was purchased by Autodesk and woven into their portfolio. As such, EAGLE now supports some 3D CAD integrations with Fusion 360. I’ve completed a revised version of my power monitor PCB layout – shown below in both EAGLE and Fusion 360. The combo of these two programs makes modeling PCBs and their supporting enclosure/structure very easy.

    A page from the schematic
    The EAGLE PCB Layout

    Once you have the PCB design complete, you can go in and update the 3D model of each component in EAGLE. You upload and position a custom model in the EAGLE interface. The interface to do this is a bit confusing, but I hear it will be getting better and more straightforward in the future.

    Then, you click a button in EAGLE that pushes the model to Fusion 360. As you can see below, if you’ve routed all your traces, it even shows them on the board, as well as all vias and other tiny details. It’s actually pretty sweet.

    Looks pretty good, right? It’s all in the setup in EAGLE to get the push to Fusion to look great.

    This is what makes modeling enclosures super easy. In Fusion, you can actually project the board components onto sketches to drive geometry. Here’s a simple box I was able to come up with after couple of nights tinkering around:

    In reality, the box will be orange (that’s the only color of filament I have for the 3D printer at the moment)

    And for reference a section analysis:

    Section analyses are great for verifying you’ve got everything to fit!

    Sliced it up and printed it on my Qidi Tech I (A Flashforge/Makerbot clone):

    Orange.

    Now to update the software that runs on this bad boy…

  • PCB SolidWorks 3D modeling

    PCB SolidWorks 3D modeling

    This is actually work from a while ago – but I wanted to share this. I’ve been working on a new version of the Power Monitor PCB that uses an ESP8266 and Teensy 3.2. Here’s the board mocked up in SolidWorks CircuitWorks:

    And here’s the board in real life, with only a couple of components on it:

    Pretty neat, right?  You can spend as much time as you want in SolidWorks CircuitWorks to get everything as photo-realistic as possible. The important thing is to get component heights, sizes, and locations right to make the design of an enclosure easier.

  • Moments of Inertia

    Moments of Inertia

    I recently came across this old aerospace senior design report I wrote, and thought it was pretty cool.

  • WebSocket Apache Proxy

    WebSocket Apache Proxy

    I recently installed a cool tool called Node-RED which is a neat visual coding tool for IoT-type devices. It uses node.js, and listens on port 1880.  However, I wanted Node-RED to function over port 80, to avoid having to type a port as part of the URL. I struggled getting the WebSocket connection to function correctly. I kept getting a HTTP response of 500.

     

    I figured I might be able to save some other folks the trouble (and help me remember for next time). To get this to work on a system running Apache, you’re going to need to enable a few modules.  I’m running Apache 2.4 on Raspbian Jessie for context.

    sudo a2enmod proxy
    sudo a2enmod proxy_http
    sudo a2enmod proxy_wstunnel
    sudo a2enmod proxy_html
    sudo a2enmod proxy_fcgi

     

    And configure your site listener to include the lines:

    ProxyPreserveHost On

    ProxyRequests Off


    ProxyPass /nodered http://localhost:1880

    ProxyPass /nodered/comms ws://localhost:1880/comms


    ProxyPassReverse /nodered http://localhost:1880

    ProxyPassReverse /nodered/comms ws://localhost:1880/comms

     

    I learned where the WebSocket connection failed by watching the Javascript console in Chrome – it points you to the /comms directory, so you need to enable the WebSocket proxy there.

    This way, you can simply navigate to your Node-RED installation on port 80 by simply using the URL http:///nodered/

  • Motorcycle Computer Revisit

    About a year ago, I made this motorcycle computer that mounts to the dash of my 2012 V-Strom 650. It controlled my heated jacket and my heated grips.

    I have access to a 3D printer at work, so I modeled some housings in Solidworks and printed them out. It’s awesome – 3D printers make prototyping and hobby projects really easy! The housing is held in place to the anodized aluminum plate with standard automotive RTV.

    Front
    Rear

    The below box housed the ‘brains’ and resided under the seat. This left the signal lines to the screen and rotary encoders exposed to a LOT of interference. My new plan is to move the Teensy 3.2 into the same housing as the screen, and make a much smaller box to house only the MOSFETs, 12v-5v DC-DC converter, and a logic-level converter to ensure the MOSFETs see a signal that is above their minimum spec to ensure the gate is pulled high.

    Spaghetti.

    This setup has been on the motorcycle for about a year – and no real ill effects were noticed. I never once had to fix anything. The code could use a bit of work to make the interface a more intuitive, but that’s also part of this revisit.

    I’m also planning on adding some new sensors to the setup. I’ve got a 10DOF board from Adafruit laying around, which will allow me to use a magnetometer, accelerometer, gyroscope, and barometer. It communicates via I2C and each device on the board has a unique ID. I actually wrote drivers for this board myself in Python a while ago – the should be available on my Github. I have a GPS module that I’d also like to give a try – it will allow me to get velocity and position data. It communicates over a UART connection.

    GPS, 6DOF Sensor, Teensy 3.2

    I set about making a new housing for this configuration in Solidworks. I’m planning on only using one CAT5 cable (8 conductors) to bring power, MOSFET PWM signals, and a 3.3v reference voltage back to the rear module.

    I do have a few problems/questions I need to work out – for instance – will the GPS be able to get a reliable lock from this position, or do I need an external antenna? How about easy firmware updates? Do I need to keep both encoders and buttons?

    I began to take apart the old setup. Here’s a quick picture after I took off the 3D printed cover and one of the CAT5 connectors.

    More Spaghetti.
  • Json-enabled WiFi screen

    Json-enabled WiFi screen

    Along with the power monitoring project I’ve been working on, I’ve also developed a simple Internet-enabled screen. It uses another ESP8266, a few wires, and a 16×4 LCD display.

    Not the worst looking thing, but not exactly cute, either.
    Seems like a good candidate for 3D printing.

    The display used is one of the standard HD44780 compatible ones – so you can use the LiquidCrystal library, which is one of the standard libraries in the Arduino IDE.  Wiring diagram to a standard Arduino is available here, as well as the library reference and documentation. You can find these types of displays in various sizes, ranging from $5 to $20. You’ll also need a 10k potentiometer to control the display’s contrast.

    The ESP8266 variant used is the WeMos D1 Mini – http://www.wemos.cc/Products/d1_mini.html.  It’s available online for about $4.

    For the box, I used a couple of scrap pieces of 1/4 inch oak plywood, and a scrap piece of 1×8 pine board. I measured the screen, cut, and gave the USB wire a small hole. Here it is painted and all put together:

    To help parse JSON, I used this fantastic library, called Arduino JSON (clever name). It’s pretty easy to use and is well documented.

    To program an ESP8266 using the Arduino IDE, you can also use a custom board type available here.

    My simple code is available on my Github page. It interprets the JSON, formats it to fit on the screen, and scrolls through it.  Someday I might add a button or rotary encoder to help control it.

  • Power Monitoring Code

    There are two chips that make up this board – the Teensy 3.2 and the ESP8266. The ESP8266 in this setup runs the AT firmware, which allows communication over serial using a published API. The API documentation is available here. To flash the ESP8266 with the AT firmware, Expressif (the manufacturer) has a tool available on their website.

    The default baud rate of the most recent AT firmware is 115200. This can be changed, but the faster the better, right?

    To use the Arduino IDE to program the Teensy 3.2, you can download Teensyduino, available from here.

    So now our environment for programming this combo is ready!

    To test the connection between the ESP8266 and the Teensy 3.2, you can throw on a simple passthrough sketch, and manually type in AT commands into the serial monitor. (also for some reason I can’t figure out the WordPress code formatting)

     

    void loop() {
    // Send bytes from ESP8266 -> Teensy -> Computer
    if ( Serial1.available() ) {
    Serial.write( Serial1.read() );
    }
    // Send bytes from Computer -> Teensy -> ESP8266
    if ( Serial.available() ) {
    Serial1.write( Serial.read() );
    }
    }

    Make sure you put initialize both serial ports to 115200 in setup().

    The complete code is available at https://github.com/fillycheezstake/PowerMonitor. It’s a WIP, so don’t judge too hard.