John Shovic's Google Plus Switch: November 2013

Tuesday, November 26, 2013

RasPiConnect Configuration File and Screens Posted


The latest RasPiConnect configuration file and pictures of all five control screens have been posted on the page RasPiConnect Page.  This should answer some of the questions submitted via email.


Monday, November 25, 2013

Current Software and Reliability Issues in Project Curacao


As we get closer to system deployment (March 2014), I am running more system level tests.  The first of these (the week of November 17-24) revealed the following problems that need to be addressed:

- The DHT22 sensor is returning more errors that it should and those errors are getting logged as good data.  Either we aren't using the checksum correctly or the sensor is actually sending bad data in which case we will put a software filter on the output.  See the spikes in the following picture from RasPiConnect:
DHT22 Humidity Bad Data Spikes



Note the windspeed chart.  We are adding a pitot tube windspeed indicator to our environmental subsystem in the next few weeks.


- We are experiencing occasional failures in sending email from ProjectCuracao outside of the systems.   In one case (the initial Reboot and startup email) it is not in a separate thread so it takes the whole Project Curacao main software down when it bombs.  We have good log information so we should be able to track this down.  We will put in Try/Recover blocks, but we'd still like to see what is causing the problem.

- After three days on the Pi, the Project Curacao system is failing because we can't open any more files.  We installed "lsof" on the Pi and we are tracking this down.   This is a lower priority bug at this point because the BatteryWatchdog will shut down the Pi on a daily basis in any case.  Some where, someone is not shutting a file that has been opened and they accumulate.

We swapped out a LiPo Rider Pro board that seemed to have a problem with charging the Watchdog battery properly.  It was discharging and charging in a much different manner than the charge controller for the Pi.  We'll know in a couple of days whether it works properly.




Software Status on Project Curacao (11/25/13)

As of today, the current state of the software in Project Curacao is as follows:

- Arduino Battery Watchdog:  The watchdog is reading and reporting data back to the main software in the Pi via a serial link through level shifters.  The read fails occasionally (and is logged on the Pi) but not often enough to worry about at this point.  The next three things to be implemented:


  1.  Pi power control - The Arduino switching the Pi on and off according to power and time criteria.  Right now the "action" code is commented out and just prints "Pi On" or "Pi Off" to the serial port
  2. Watchdog logging - the Arduino will log major events in EEPROM and then transmit the log, when asked, to the Pi for storage
  3. The Watchdog function - The Arduino will listen for a WD input from the Pi every 5 minutes.  If the Pi misses three sends in a row, the Arduino will send a Reboot command to the Pi and the power cycle the Pi.

- 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.  Not sending Watchdog to the BatteryWatchdog yet.  Nor reading log files from the Arduino Watchdog.  Next three things to be implemented:

  1. Watchdog implementation
  2. Logging Arduino Watchdog Data
  3. Improving sensor error detection




- RasPiConnect:  We have a few more graphs and dials and buttons to implement on the RasPiConnect software, but it's pretty close to final.  We use this all the time now to monitor what is going on in the project remotely.   We are thinking it might be good to put in a process monitor graph and reboot function.  Both are easily done.  Here's the new main screen (1 of 6 at this point).:


Summary Page for Project Curacao on RasPiConnect




Friday, November 15, 2013

Measuring negative currents with the INA219

I read somewhere that the Adafruit C++ library has a bug in the INA219 High Side current measuring device library so the device doesn't correctly return negative values for current.

Obviously, for a solar power system, I need to measure negative currents (current goes both out of and into the battery- when charging). I ran across this problem a couple of months ago and figured it out. I was using the Subfact Python library for the INA219.


There is also a similar bug in the subfact python library as in the Adafruit C++ library for the INA219 (fixed as of November 2013). They aren't calculating twos complement correctly, so negative currents aren't reported correctly.

The ProjectCuracao unit is plugged in at moment to a USB charger, hence the funny looking efficiency numbers. On my RasPiConnect control screen, you can clearly see the -6ma heading into the battery.  Special thanks to "faraday" for finding the same issue and contributing to the fix.





Heres are the fixes for the subfact python library for the INA219.:


def twosToInt( val, len):
      # Convert twos compliment to integer

      if(val & (1 << len - 1)):

         val = val - (1<<len)

      return val




Changes to subfact python library:


        def getShuntVoltage_raw(self):

                result = self.i2c.readList(self.__INA219_REG_SHUNTVOLTAGE,2)
                if (result[0] >> 7 == 1):
                        testint = (result[0]*256 + result[1])
                        othernew = twosToInt( testint, 16)
                        return othernew
                else:
                        return (result[0] << 8) | (result[1])


        def getCurrent_raw(self):

                result = self.i2c.readList(self.__INA219_REG_CURRENT,2)
                 if (result[0] >> 7 == 1):
                        testint = (result[0]*256 + result[1])
                        othernew = twosToInt( testint, 16)
                        return othernew
                else:
                        return (result[0] << 8) | (result[1])

        def getPower_raw(self):

                result = self.i2c.readList(self.__INA219_REG_POWER,2)
                if (result[0] >> 7 == 1):
                        testint = (result[0]*256 + result[1])
                        othernew = twosToInt( testint, 16)
                        return othernew
                else:
                        return (result[0] << 8) | (result[1])

Thursday, November 14, 2013

Project Curacao Added

Today I have posted the first of six articles describing my current "obsession", Project Curacao.  This is a solar powered environmental monitoring box based on a Raspberry Pi and Arduino Mega 2650 controlled by the iPhone/iPad app RasPiConnect.   It will be hung on a amateur radio tower in Curacao in March of 2014.  It is close to be being finished and will go through system testing for January and February of 2014.


The Project Curacao Box as of as of November 3, 2013



















The first prototype and connection to RasPiConnect in February 2013




















I have learned a lot about the current state of inexpensive computers, inexpensive sensors and prototyping techniques.  I've been using embedded systems for close to thirty years, but for an entire decade I was involved with Wastewater Treatment, Computer Security and Medical Software.  Time to get up to date with the current technology.

I'll share all the problems as well as the successes.  Leave a comment if you have learned something good here or want to ask a question.

Welcome

Welcome to Switch, Blog of the stars.  Well, of the geeks anyway.

I will be posting my thoughts about technology, geekness and music here periodically.  I also will be reposting articles I have written and expand upon them.