Simple Home Networking

I thought it would be a good idea for me to give a a small tutorial on basic home networking issues, which many may find useful when diagnosing connectivity issues.

A modern, typical home network may look something like this:

Typical Network (click to enlarge)

Most people in our neighbourhood will have a cable based Internet access.1 Internet comes through via the coaxial cable, like the traditional cable that you used for your cable TV. This cable is connected to a cable modem, which in our case is the Hitron CDA3-35. The cable modem then makes the Internet accessible via classic networking cables with RJ45 plugs. Think of the cable modem as your main door to the Internet and nothing else. Since this box is typically provided by your cable company, you should probably not trust it, so it is a main door without a lock.

Some cable modems also do Wi-Fi, like the new Rogers Ignite Hubs. For best performance and better security,2 I would recommend configuring the cable modem in bridge mode and not in gateway or router mode. This means that it should not be the box provisioning and managing your network, and it will have its Wi-Fi functionality turned off. This also avoids double NAT-ing, something to be avoided in your home, in my opinion.3

You should invest in your own Wi-Fi access by purchasing something like the TP-Link AX1800 WiFi Router.4 This box provisions your residential network and your local Wi-Fi. You can purchase more advance / expensive Wi-Fi solutions here depending on the size and complexity of your residential layout.

If you have more than one Wi-Fi access point, I would recommend that they all have the same SSID but on different Wi-Fi channels. This will make it convenient and optimal for your Wi-Fi devices. Also keep in mind that some old / cheap IoT devices only like the 2.4GHz band. If you are in that situation, then you should create a specific 2.4GHz network with a different SSID.

If you want to try out VOIP (Voice-Over IP), you may also connect a VOIP Adapter. In our example, we have the Linksys PAP2T box. I am not going to go into details of how to acquire VOIP, or set it up, but this box effectively converts Internet traffic into voice traffic. Traditional landline phones can be linked up to the VOIP adapter using normal phone cables.

Okay, now that we have the different parts of the network defined, let us present a basic diagnostic workflow.

Basic Diagnostic Workflow

I hope the above introduction to the different parts of your home network and a workflow that you can follow will assist you in resolving some common connectivity issues in your home.

Wi-Fi 6 Upgrade with HomeKit Headaches

I recently upgraded all my WiFi access points to the Unifi UAP-U6-LR and UAP-U6-Lite. This will elevate my home to Wi-Fi 6 capable.

This was extremely exciting as my 802.11ax capable devices can now get between 100Mbps to 400Mbps depending on where we are in the house. It seems even the 802.11ac devices got about a 30% speed bump.

As a result of this upgrade, two UAP-AC-M mesh and one UAP-AC-Pro access points were retired from my house. I don’t recommend buying these devices any more since the Wi-Fi 6 devices from Ubiquiti are way more capable with higher performance and increase range than their 802.11ac access points.

However, the honeymoon period did not last long. After about a week, HomeKit devices started to show the dreaded “No Response” labels. Specifically, I had connectivity problems with Leviton Smart Decora Dimmers. In the past, all I had to do was recycle the HomeKit device and it was all good. Another episode of HomeKit and Leviton dimmer switch nightmare was experienced and documented by my previous blog post.

In this particular instance, the Leviton dimmers were able to join the Wi-Fi network and I can validate that with the Unifi Controller software. However, our HomeKit App was not able to connect to the dimmer switches. It took me sometime to figure out that the dimmers were unreachable by other Wi-Fi clients, but was reachable by computers that were physically wired to our network.

I found out which access point the dimmer switches were connected to and ssh into the access point to see if I can ping those devices, and sure enough they were unreachable. Below is a screen capture of the ARP listing from the access point.

Normal ARP listing from the Wi-Fi Access Point

When the dimmers were unreachable, the HW address was set to 00:00:00:00:00:00. After rebooting the culprit access point, I was able to access the offline dimmer switches again from the HomeKit App.

In summary, when HomeKit devices are offline with the dreaded “No Response” labels, here are the following things to try:

  • Ensure that local DNS is working properly and caches are emptied so that the latest data are available;
  • Ensure the device itself has acquired a valid IP address that is from your network;
  • Ensure that the device is reachable from the HomeKit App, typically from your iPhone or iPad;
  • Back trace the physical upstream networking equipment that is connected to your HomeKit device such as switches and access points and see which requires rebooting;

Apple could improve the HomeKit experience by allowing users to perform a full backup of the HomeKit configuration and reset the Home and perform a restore. Unfortunately, the closest thing that I found was from the Home+ App, but they do not restore device connectivity just their configurations.

When HomeKit works, you are literally like god, able to command light and switches with your voice in your home. When it does not work, it is extremely difficult to debug, due to a lack of diagnostics and logging.

After this update, my current networking layout now looks like this:

2021 October Network Layout (Click to Enlarge)

Residential Solar Project Initiated

This spring, I installed solar panels on our green house. This project gave me the experience and knowledge of what I wanted for our house. In August of this year, we finally took the plunge and initiated our solar project for our house.

After much research, I settled with the following three vendors:

They all had a web presence and I initiated contact either by phone or with their online registration. For all three, I provided my postal code, my utility bill or usage, and they were able to prepare a quote for me to review. My initial request was for a grid-tie hybrid solution consisting of: Solar panels, and batteries. Specifically, I wanted to perform a full backup of my house electrical demands in the case of power outages. I wanted to avoid a typical solar only, net-metering, grid-tie solution. I also did not want a partial backup solution where certain high inductive loads such as air conditioners and dryers will not be available.

All three vendors came back with a simple solar net metering solution, the one that I specifically said I did not want. New Dawn Energy Solutions was the only vendor that gave me multiple options, one of which was a partial backup solution, which did not meet my full house backup requirement. With this initial misunderstanding, I thought it would be best that I spent sometime detailing exactly what my requirements are. I proceeded to create a slide deck with this purpose.

Long story short, getting a common understanding of my requirements was still a challenge for the vendors with the exception of New Dawn Energy Solutions. I was able to directly contact the engineer who prepared and designed the solution. This was during the weekend, and we were able to quickly clarify what I wanted and what New Dawn Energy Solutions can provide.

I decided to select New Dawn Energy Solutions and proceeded with a contract with them. While we await for permits, New Dawn Energy Solutions also helped me to start my energy audit for the Canada Greener Home Grant Program. Under this program, we can potentially get up to $5000 CAD back. The first of two audits was already performed by EnerTest. The auditor was super friendly, detailed, informative, and efficient. I would recommend EnerTest if you are going after the same program.

The current solution look something like this, but it is subject to change after an on site engineering assessment.

Our Solar Setup

As of this writing, the first energy audit is now completed. Now we will await for the engineering assessment and the required permits.

I am excited to generate clean energy and will no longer be guilty of enjoying the full capabilities of my air conditioner during the summer heat.

Green Sunroom Project

YouTube viewing has been one of our favourite pass times during the lock down nature of the Covid-19 pandemic. I personally have been watching quite a few channels on how to use LiPO4 cells to build rechargeable battery banks for solar applications, primarily for off grid purposes.

We have a sunroom in our back yard that we used during the summer to grow some vegetables. It has some electrical needs such as water pumps, a temperature sensor, and a fan. Currently there is an electrical socket, fed from the house, that we plug these devices into. We thought it would be a good project to try to get our sunroom off grid. This would be a good learning project.

The first task is to build a 12V LiFePO4 prismatic cells battery bank. I purchased 4 3.2V 100Ah battery cells from AliExpress. The cells came with bus bars so I did not have to purchase those. However, I did have to buy a battery management system (BMS) to balance and manage the charging and discharging of the battery cells. It was very tempting to buy a BMS from AliExpress, but I decided to be cautious and purchased one from a US vendor with the accompanying and preferred quality control. The company Overkill provides a 12V BMS specifically for four LiFePO4 battery cells in series.

It took a very long time for the batteries to arrive from China. I suppose the pandemic could be one of the many reasons for the delay. Once they arrived, I connected in parallel and proceeded to perform a top balance procedure with my voltage limiting desktop power supply. This step is required because each cell will have a different voltage potential from each other. We want all the cells to have the same voltage potential to maximize the capacity that we will get from the aggregated 12V battery bank.

Cells in parallel being topped balanced at 3.65V until zero current

To top balance all the cells, first I hook up the cells in parallel and charge them at a constant voltage of 3.65V. The charge will continue until my desktop power supply shows zero amp going into the battery. This process took a very long time, almost 2 days.

Once the cells are balanced, I reconfigured the cells in series and proceeded to hookup the BMS and the pure sine wave 600W inverter I purchased from Amazon. I had to buy 4 AWG wire, once again from Amazon, because the 10 AWG wire that I purchased earlier was not going to be enough if I want to discharge the battery at 600W which is going to result in more than 50A of current at 12V. I used the remaining 10 AWG wire for solar controller and panel hookups. I also got some XT90 connectors so that I can easily plug/unplug the solar charge controller, solar panels, and potentially plugin charger. I will talk about the solar side some more later on.

All wired up. The yellow XT90 connector is to either a solar charge controller or an external DC charger

So now that we have the guts of our 12V LiFePO4 battery pack, we need to find a suitable home for this thing. My wife had an extra plastic filing box hanging around which is perfect for this.

A filing box is perfect to fit everything
Custom grommets and added a PC fan

I needed to drill some holes to fit a 12V 120mm PC fan for ventilation, and a couple of 2″ grommets so that we can pass plugs and connectors through the box. The fan will be powered by the inverter.

At this point we have ourselves a 1200Wh portable super battery pack that can power up to 600W of electronics, which will be great for road trips. If you plug a 20W iPhone fast charger and charge your phone, it can continuously charge for 60 hours (2.5 days). That is a lot of phones. If your MacBook Air ran out of juice on the road, then this battery pack can power a 45W charger for your MacBook Air for more than a day, and also charge your computer fully. Quite a handy thing to have for emergencies.

Doubles as a 1200Wh portable battery bank

For the solar panels, I purchased two Xinpuguang 100 W flexible solar panels from Aliexpress. They were about $1 / Watt, a pretty good deal. I hook the two panels together in series and got a Victron BlueSolar MPPT 75/10 solar charger to manage the charging of the batteries. The charge controller can accept a maximum of 75V and outputs a maximum of 10A.

The charge controller will automatically adjust the amperage and voltage to the battery bank as required ensuring optimal charging scenario. During a sunny day, it will run the sunroom load from the panels and any remaining current will goto charge the battery. At night, the battery will run the sunroom.

Today, we installed the entire setup. The battery is placed inside the green house to give it some precipitation protection.

The panels are latched to the roof of the green house, one on each side.

The BMS unit has a bluetooth connection and an iOS App. I can use my iPhone when in bluetooth range of the battery to see if the battery is being charged or discharged.

I took the following screen shot of the app today at around 5pm EDT. You can see that there is no current going into the battery and no current going out of the battery. This means the sun is powerful enough to run all the pumps and other electrical appliances in the sunroom. Pretty cool!

It is still too early to tell yet whether there is enough sun power to charge the battery and run the electrical devices in the sunroom in a sustainable manner. My current suspicion is that the two panels are just enough even on a full, bright, sunny day and at peak hours, to power devices and also provide surplus current to charge the batteries.

Here is my overall connectivity diagram:

We will let the system run for about a week to see if this is sustainable during the summer months or not. If not, then I will have to create an automatic transfer switch so that we can intermittently recharge the batteries during the evening with an optional 480W DC charger, which I also got from Aliexpress. This charger can operate between 0-24V and 0-20A. To charge the battery bank, I have set it to a constant voltage of 14.0V and allow the output current to flow unrestricted. This should charge the battery fully in a little over 4 hours from scratch.

Overall, I learned a lot from this project and what a great way to spend the pandemic indoors. This could be a precursor to a DIY Tesla Powerwall Project. We’ll see.

Darci Door Bell

We have a cat named Darci. During the summer time she likes to take strolls through our backyard, checking out other frequent visitors like rabbits, chipmunks, squirrels, birds, and the like. She does this on an extended leash so to avoid her chasing these visitors and get lost into the wild. If you are curious, then visit her on Instagram.

We of course turn on the air conditioner on most days of the summer, so when Darci wants to come back into the house, she sits by the backyard sliding door and await one of us to open the door for her. If we are busy, she waits patiently for quite some time. My wife came up with the door bell idea. Instead of scratching the glass pane of the sliding door, which is mostly silent, we will train her to hit a door bell, which will alert us to let her in.

This is how I was assigned the Darci Door Bell project. This is another excellent opportunity to create a gadget. My first thought is to create a Raspberry Pi with a camera that uses an AI image classifier on the backend. I thought this would be a good opportunity to get my feet wet in AI. However, when dealing with a camera, and a Raspberry Pi, we are now talking about power and the need to be “plugged in”. We wanted a gadget that is wireless and battery operated. A battery based solution will severely restrict the power budget, so back to a WiFi based remote door bell idea.

After more research, I decided to use an ESP8266 MCU with WiFi and a simple step-down buck converter to convert 9V to 3.3V. I had worked with the ESP8266 before when I was attempting to use it to create my garage door opener. That was over six years ago. ESP8266 just came out and has yet to be integrated into the Arduino platform. Today, it is now much easier to work with the ESP8266. Using the Arduino IDE, one can simply program the ESP8266 natively as an MCU without even requiring an Arduino board.

From a previous project, I built a small circuit using an USB FTDI interface that will accept the ESP8266 ESP-01 board. This way I can plug the ESP8266 using USB to my computer and program it with the Arduino IDE. I wrote the following sketch, and programmed the ESP8266 ESP-01 board.

 #include <ESP8266WiFi.h>
 #include <ESP8266HTTPClient.h>

 #define SERVER_IP "192.168.1.111"
 
 #ifndef STASSID
 #define STASSID "myssid"
 #define STAPSK  "adsjfkdajfioeujfngjhf"
 #endif
 
 void setup() {
 
   WiFi.begin(STASSID, STAPSK);
 
   while (WiFi.status() != WL_CONNECTED) {
     delay(250);
   }
 
   WiFiClient client;
   HTTPClient http;

   // configure traged server and url
   http.begin(client, "http://" SERVER_IP "/IOTHandler.php"); //HTTP
   http.addHeader("Content-Type", "application/x-www-form-urlencoded");
 
   // start connection and send HTTP header and body
   http.POST("id=darciButton");
 
   http.end();
 
   ESP.deepSleep(0);
 }
 
 void loop() {
   ESP.deepSleep(0);
 }
 

The above program is pretty simple. When the board wakes up, it connects to my WiFi and then send an HTTP-POST request to my server that will handle the request based on the id, which in this case, it will be darciButton. As soon as the request is sent, the MCU will go into a deep sleep.

Completed Circuit

This way, the door bell will be a physical button that is hooked to the RST pin of the ESP8266 causing the ESP8266 to boot and send this POST request and immediately goes to sleep. The deep sleep is important, because while the device is in this deep sleep mode, the current draw from the 9V battery is negligible (<< 1mA). The only time the battery is used is when the button is pressed and released, and the ESP8266 is sending out the POST request. Using this power conservation approach, it is my hope that the 9V battery will last for the entire year of operation.

I used my 3D printer to print a little box for the whole thing and gave it some packaging padding, making sure the switch is on the top and properly supported. The final result looks something like this.

Packaged in a box

We then created a cardboard top cover that snugly fit the box, so that the top cover can freely move up and down the containing, plastic box. The switch itself has a little spring to it that allows the top cover to return back to its original position after being pressed. The finished product looks like this:

Finished Product

The top cover has a nickel on there so that Darci has a good target to train on.

Remember the server receiving the POST request? Well, I did some simple php programming on the server so that once the POST is received, I send out another HTTP request. This time to the Homebridge server with the homebridge-button-platform plugin installed. Homebridge is something that I already have and use to connect all non-compliant HomeKit accessories so that I can use those accessories via Siri. With this new plugin, I can connect this custom WiFi button to the HomeKit ecosystem within the house.

In effect, whenever this button is pressed, my HomeKit service will register an accessory button being pressed, and I can program a HomeKit scene that gets executed. I programmed a scene to play an audio file on all of my HomePods in the house. The audio file plays an audible door bell twice which I previously added to my Music library.

The final reward as shown by Darci herself. Watch the video below:

Darci Approves!

Of course with the button hooked up to HomeKit, we can now use this wireless button to do whatever HomeKit can do, unlock doors, turn lights on or off, etc. We will explore those possibilities in the future.

Resizing LVM Volume with Cache

I had to increase the size of my media LVM logical volume again. In a previous post, I provided the instructions. I have done this many times. However, this time around, I ran into a snag.

Apparently this is the first time I try to increase the logical volume after I implemented LVM caching, which I wrote about in this post.

The steps in the “Linux LVM Super Simple to Expand” post are the same right up to and including the step involving the resizing of the physical volume. Afterwards, in order to resize the logical volume, we first have to disable the cache temporarily.

sudo lvconvert --splitcache /dev/airvideovg2/airvideo

Once the logical volume is no longer cached, then we can proceed with the resizing.

sudo lvresize -l +100%FREE /dev/airvideovg2/airvideo

Once the resize is completed, we can unmount the volume and perform the required resizing of the filesystem.

sudo systemctl stop smbd.service

sudo systemctl stop mpd.service

sudo systemctl stop apache2.service

sudo umount /mnt/airvideo

sudo e2fsck -y -f /dev/airvideovg2/airvideo

sudo resize2fs -p /dev/airvideovg2/airvideo

Note that e2fsck and resize2fs will take some time, between thirty minutes to an hour each. Once the file system is resized, we can reattach the cache.

sudo lvconvert --type cache --cachepool airvideovg2/lv_cache airvideovg2/airvideo

Usually it is a good idea to reboot the server after this just to make sure it mounts properly.

This is a small snag and LVM is still super simple to expand.

Update on Prius Charging Economics

In my previous post, I talked about how charging the Prius Prime at home versus filling up its gas tank. Well we are in a very special time right now with gasoline prices hovering between $1 / L to $1.05 / L. The electricity rate has also changed to a flat $0.128 / KWh to be applied around the clock until October 31st, 2020.

I figured that I provide an update with these new conditions. With the lowered gasoline prices, the 4.4 L / 100 Km milage rating of the Prius Prime, it would now yield 22.7 km / $ assuming $1 / L as our cost.

Hidden Electrical Costs

When we use the per KWh charge of $0.128 for time of use; $0.0098 for delivery; $0.0039 for regulatory; yielding a total of $0.1417 / KWh, our Prius plugin yields (40 Km / 8.8 KWh / $0.1417) 32.078 km / $ when using the battery alone as an EV.

Clearly 32 km is still better than 23 km. Therefore, it is still better to charge the Toyota Prius Prime at any time of the day now because the electricity cost is the same around the clock.

I left out the monthly delivery and regulatory flat rates because I have to pay that regardless whether I’m charging the Prius or not. Also this calculation does not consider additional savings when charging due to the current Ontario Electricity Rebate that is in effect.

I hope you find this up to date information useful.

HTML5 Video on iOS 13

This past weekend, I was writing a simple HTML5 utility that provides certain videos that I have in my own personal library. The idea is that I can make a limited selection of videos and present it on a web page, so that the user can simply click on the cover art of the video and plays inline on the web page.

I thought it was a pretty simple requirement and I should be able to whip this up in a few minutes. I used the HTML5 <video> tag. Everything worked on my Mac and my iPad. It even worked on my LG OLED TV. However, when it came to the iPhone, mobile Safari would load the movie but it would not play. I was even able to seek through the movie by scrubbing the scroll bar, but when I press the play/pause button, nothing would happen.

After many hours scouring the web, I found out many caveats when serving videos on iOS with the iPhone.

  • Videos behind an authorized location may not work on an iPhone because when Safari passes this information to the player, the player does not inherit the previously authorized identity. To get around this, I had to create a token based technique, where the main page have to pass this token to a PHP page that checks this token and serves the video contents.
  • The PHP used to serve the video also need to handle HTTP Range based requests. This wonderful contribution from GitHub really helped me out!
  • Multichannel audio such as 5.1 audio encoded in AAC will load but not play on my iPhone XS currently running iOS 13. The video will play if I re-encode the audio to either AAC stereo, or 5.1 multichannel in AC3 encoding.
  • Multiple audio streams also did not work. The iOS player was only happy with a single compatible audio stream.
  • If you want to make the video autoplay while inlined within the page, it must first be muted.

Lots of things to consider here. I lost about a day and halve researching and experimenting with this, so here it is all recorded just in case I forget in the future. I also hope that this information will help you out as well.

Plug-in Economics for Prius Prime

According to Toyota, our new 2020 Prius Prime PHEV gets around 4.3L / 100km of city driving. We will use this number since it is not too far off of the combine driving number of 4.4L / 100km. This means at the time of writing this post, the current fuel price at our neighbourhood pump is at $1.15 / L. If you do some fancy math, the Prime will yield us 20.2km per dollar invested at the pump (20.2 km/$).

Ontario Electricity Costs (Fall of 2019)

As depicted by the chart on the right, in Ontario we have three tiers of charging rates. The Prime in the winter can do about 35km with a 9kWh battery. The exact numbers are 40km / 8.8kWh, but this is perfect condition, and we use some battery for heating the vehicle. This will yield us the following:

TierYield
On-Peak18.7km/$
Mid-Peak27.0km/$
Off-Peak38.5km/$

So by comparing the above numbers, it makes perfect sense to charge the vehicle during Off and Mid Peak hours, and not so much during On-Peak hours. However the On-Peak comparison is so close that if the mileage rating was at 4.5L/100km then it is a wash.

With a bit more fancy math, you can actually calculate how much does gas have to cost per Litre before On-Peak charges make sense. This turns out to be around $1.24/L.

Hopefully you find this information helpful.

Let’s Plug-In

On October 30th, 2019, we purchased a Toyota Prius Prime 2020, choosing the Upgrade trim without the technology package. We traded in our 2012 Toyota Sienna 8 passenger Minivan with approx. 90,000km for $11,000. After all the government incentives, fees, taxes, and dealer’s rebates, we ended up forking out less than $27,000 for the vehicle. The only thing we opted for was the rust protection device.

We now have this plug-in hybrid electrical vehicle (PHEV) for almost a week. The vehicle is very comfortable to drive, and much more refined than my 2013 Subaru Impreza. The Prius comes in three drive modes, Eco, Normal and Power. I find the Eco mode to be too slow and has too much accelerator latency. I prefer the Normal mode. The Power mode can be pretty fun especially when you have a fully charged battery.

There are plenty of YouTube videos and written articles already talking about how the car drives, and I agree with their positive take on the Prius Prime. Therefore, I won’t repeat what has already been said. I will focus on what impact the ownership of a Prius Prime has on our residential electrical consumption.

We have yet to invest in a level 2 charger (240V – 16A) for the house yet, so we are just using our regular 120V plug to charge the 8.8kWh battery for the vehicle. So instead of charging the vehicle in 2 hours with the level 2 charger, we find that it takes around 5 hours to fully charge the vehicle. Toyota’s charging specification is pretty dead on and accurate here.

I raided our utility company’s web site and was able to extract the following graphs. Either click on the image or this link to open the graphs.

The consumption graphs above points to a day with no electrical vehicle as a baseline, followed by three days of charging the Prius Prime in the evenings. It looks like charging the Prius only amounts to an average of 1.5 kWh increase from baseline per hour of charge. The graph shows about four hours of heavy charging follow by a lower power charge during the last hour and a half.

At the current off-peak rate of ~$0.10 per kWh, we are looking at about an increase of less than a $1 per day, and this gives you about a realistic 36km of pure EV mode (all electric) of range per charge. So for a month, $30 will give you around 1,000km of range!

We have driven the car for about 5.5 days, and racked up in excess of 300km. We still have 7/8 of a gas tank left, and the only reason why we used the gas is due to a test drive to the Toronto Premium Outlet mall in Milton. Otherwise our daily usage pattern, which consists of largely local errands, would allow us to just keep on using the battery.

Now the game is up. How long do you have to wait for me to update this blog entry when I fuel up our new Prius Prime for the first time? Watch and see, any wagers?