Sunday, December 15, 2019

65: Measuring Kilowatt Hours *

I recently bought a plug-in hybrid Kia Niro. I was surprised to find out that while I could schedule when the car would charge and could modify that schedule from a phone app, nothing told me exactly how many kWh of power I was using. I kind of expected that the electric miles would be much cheaper than gas miles but I wanted to know exactly. The battery is supposedly 9.7 kWh. When fully charged, the dashboard display shows me that I have 24 electric miles. That's about right on the highway but around town and on 2-lane roads I get more like 30. Anyway, not finding what I wanted and having a spare Photon, I built the following (with necessary engineering help):

Outside                              Inside   

Sensor – power wire through the hole

The sensor is called a "current indicator." The serious programming is in the Photon. A proto program allowed us to plot the relationship of raw analog sensor values to Watts -- turned out to be a nice straight line. I tested my laptop 45w power charger, a 75w bulb, a 800w toaster and a 1200w clothing iron. The real program takes 40 current samples (1 ms apart) each minute. The maximum value is added to a sum for the hour. The sums for the latest 24 hours are copied to a Particle "variable". That variable is read by a Raspberry Pi -- which produces a summary like this (via a simple PHP program):

    Hr 16: 0.16
    Hr 17: 1.39
    Hr 18: 1.4
    Hr 19: 1.39
    Hr 20: 1.39
    Hr 21: 1.39
    Hr 22: 1.39
    Hr 23: 0.68

    Sat 12/14  kWh: 9.26, cost: $0.83


Michigan Consumers Energy kWh rates for electric vehicles
Oct thru May -- Off peak: .090, On: .103
Jun thru Sep -- Off peak: .085, On: .123

Peak hours: 11:00 up to 19:00

The record above runs from 4pm till midnight for December 14. So I'm paying nearly 3.5 cents per electric mile. At my local $2.60-ish gas per gallon and the Kia's 45 mpg in hybrid mode (under 6 cents per mile) I'm not saving a lot. Gas should be way more expensive. Of course, I only stand out in the cold to pump gas once every 900 miles. 

 I will be accumulating data and will update this page.

* 12/20: Turned out that the Photon interfered with my wireless garage door buttons. Moved it 15 feet away and to different circuit -- now works ok. But why? Very different wireless frequency.

Friday, June 21, 2019

64: Adding a WIFI Antenna to a Photon

I've been having trouble with Photons remaining connected to the cloud. This in a place where an iPhone is ok (1/2 bars). So I started recording signal strength with this line of code:

  int wf = WiFi.RSSI();

Note that if you don't assign the value to an int first it will be treated as unsigned in an sprintf function "%d". Bug!

Anyway, the signal values returned run like this: (good to poor strength range: 1 to –127)
  • -10 -- strong/right next to the modem,
  • up to -60 -- reliable signal,
  • up to -75 -- so-so,
  • over that -- unreliable.

According to Particle Docs, these STARTUP calls control antenna choices:

  //STARTUP(WiFi.selectAntenna(ANT_INTERNAL)); // selects the CHIP antenna, default?
 //STARTUP(WiFi.selectAntenna(ANT_EXTERNAL)); // selects the u.FL antenna
 //STARTUP(WiFi.selectAntenna(ANT_AUTO)); // only works with antenna attached?

Note those statements are all commented out because they seem ineffective. But the good news is that adding a simple/cheap antenna does work* -- to the tune of improving signal strength by 10 to 15.

Another Particle complaint: the Docs generally fail to specify default return values.

_________
* The tiny snap-on connector can be frustrating.