In the previous post, I talked about two problems that I had discovered in my system.  I addressed first one,  a serious bug in the data collection, last time.  In this post Ill address the slow performance of the website.  A common way to solve a performance problem is with a cache.  Instead of running the web page charts in real time, I will create them automatically every couple of minutes, then serve up a cached version.   In some ways this kind of sucks.  If I had known that I was going to go this way then there would have been 0 need of Tomcat and the Java Server Pages.  Oh well.

I start this process by copying the CreekHistory java object into the “getCreek” part of my project.  I then modify the main batch Java program, called “CreekServer” to understand the CreekHistory object.

Screen Shot 2016-05-08 at 11.19.48 AM

Then I add a new function “createHtml” to the CreekHistory object.  This function creates the webpage with the current information on it.  Basically

  1. A table of the last three hours [line 221-235]
  2. Link to the current chart [line 237]
  3. Link to the floods charts [line 237/238]

Screen Shot 2016-05-08 at 11.26.31 AM

I then add the “Current” command to the “runi2c” batch program.

Screen Shot 2016-05-08 at 11.39.43 AM

This program is run every 2 minutes by the crontab on the Raspberry Pi.  I picked 2 minutes because that is a good bit longer than each job takes to run in total.   Notice that I check to see if the jobs are already running and quit the “runi2c” job if the chart creation process is already going on.

At this point I have (at least) several things which are ugly

  1. I don’t have a good back up system
  2. I duplicate the “CreekHistory” object in the JSP as well as the “getCreek”
  3. I duplicate the “readProperties” method into a bunch of different objects
  4. I have 5Vs (I think) on the I2C pins of the Raspberry Pi, which I don’t understand why this isn’t a problem
  5. I need to get the PSoC4 Bootloader Host going on the Raspberry Pi

Index Description
The Creek: IOT for the Elkhorn Creek Introduction
The Creek: Solution Architecture 1.0 Overall architecture
The Creek: Creek Board 1.1 Eagle layout of the board
The Creek: Creek Board 1.0 – RCCA A discussion of the errors in the 1.0 board
The Creek: CYPI, a Raspberry Pi to Arduino Bridge PSoC4 <--> Raspberry Pi Bridge Board
The Creek: PSoC4 Creator Schematic and Firmware Firmware to interface with the temperature and pressure sensors
The Creek: Testing the Firmware Using tools to verify that the PSoC 4 Firmware is working correctly
The Creek: Testing the Bootloader Make sure that you can load new firmware into the PSoC
The Creek: Software Architecture All of the Raspberry Pi software connections
The Creek: Install MySql Instruction to configure MySql
The Creek: Install Tomcat Instruction to configure Tomcat JSP Server
The Creek: Data Collection Java (Part 1) The Java program that reads the I2C and saves it in the database
The Creek: Data Collection Java (Part 2) The Java program that reads the I2C and saves it in the database
The Creek: Create the Chart with JFreeChart Using open source Java charting software to create plots of the Creek Depth
The Creek: Flood Event Data Processor A batch program to create analyze the database and create a table of flood events
The Creek: Flood Event Web Page A batch program to create the flood event web page
The Creek: Creek Server 1.1 Updates to all of the back off server programs to integrate charts
The Creek: JSP Web Page for The JSP program to make the table and display the website
The Creek: Raspberry Pi Clock Stretching Sorting out a bug in the system having to do with the Broadcomm Raspberry Pi Master not functioning well with clock stretching
The Creek: Creek Server 1.2 Caching the web pages to make them faster


Recommended Posts


  1. You are a crazy mofo

Add a Comment

Your email address will not be published. Required fields are marked *