View on GitHub

GitHub - Timothy S. McKenna

projects page

http://sitebuilt.net
mckenna.tim@gmail.com

GitHub Repositories

Internet Of Things


front-end repository: hooks/iot
server and broker repository: services/iot/v3
microcontroller C++ repository: iot/pio/pio-ardui/espboth
npm package: @mckennatim/react-mqtt
npm package @mckennatim/react-zonetimer

These are apps and utilities for connecting and controlling IOT devices communicating using mqtt. This frontend development environment used for new projects since react 6.8 relied on functional components, hooks as well as a rxjs redux-like store, and navigo for lightweight routing. The mqtt-hooks abstacts away the low level data coming out of one or more iot device to data structures that make sense when thinking about and implementing real world scenarios for controlling some portion of our built environment

Cascada

An implementation of a front end for controlling, scheduling and monitoring a pond with a waterfall and watering stations in the garden.

HVAC.parleyvale.com

An app running at a particular location used to control, schedule and monitor a gas fired hot water boiler connected to 7 heating zones.


Timecards

front-end repository: spa1/timecards
back-end repository: services/timecards

Mobile first design for quick data entry of timecards on phones tablet or laptop. Continuous updating to server every time you punch in or out. Allows multiple levels of access permissions. Includes Jobcost Reporting by job, job category, worker or day as well as monthly, quarterly 941s, year end automated reporting for federal and state taxes, and W2s. Labor costs for all jobs and categories within jobs are updated each week when you run payroll. See up to the minute reports on job cost labor vs estimate/contract labor with all employer witholding, insurance and benefit costs factored in. Data is stored as a downloadable general ledger from MYSQL. Implemented as 7 independent class based react apps closely tied.


prior to 2016

IOT garden home automation React app

ReactJs, ServerSentEvents
repository: cascada-webpack

Cascada-webpack is a React version of a front end for controlling a pond with a waterfall and watering stations in the garden. The back end is a raspberry Pi with a few relays, running python and flask to create a restful API. The project uses Server Sent Events (SSE) to allow any connected device to display the state of the system and its timers. The SSEs modify the state of the root component Yard which then get propogated down to any child component that needs to exhibit that change. Each watering station is represented by a Spot React component and there is a Pond component. Each runs on a separate thread in the pi and both use a custom generic button component Butt whose props modify its size, image, animation, content and look. From a tooling perspective this is a minimalist approach to a React application that uses ES6 via bablify and webpack. I had trouble with the pi's memory card. Multiple writes made it unstable. It may have been that I should have disabled logging.

IOT garden home automation raspberry Pi server

Python, Gevent, Flask, ServerSentEvents
repository: cascada2pi

An Internet of Things (IOT) project using relays and electronics controlled by a raspberry Pi. Project is used for outdoor water control. It turns on and off and sets timers for outdoor watering and controls a two ponds and the waterfall between them injecting new water as needed. Project uses python running forever through supervisrctl. gevent and flask provide the web framework for a Restful API that uses ServerSentEvents(SSE) to notify internet connected devices as to the state of the system. Each garden device is controlled on its own thread

Token Authentication Server

A Node, Express, Passport and MongoDb CORS server
repository: token-auth-server

Token authorization via APIkey. User registers with name and email and gets an apikey sent to their email address. Entering that apikey with your username returns a token which would is stored stored in the browser's localStorage. Protected areas on the server require an token to be sent with each request. Allows Cross-Origin-Resource-Sharing (CORS). MongoDb stores records for each user containing (at least) name, email and apikey.

hackathons

Bogged Down Buses

for
HubHacks2 - Visualizing a Thriving, Healthy, and Innovative Boston

A graphical analytic tool for finding how fast the buses are moving over different sections of their route. This application was written as an entry in the HubHacks2 hackathon in March of 2015.

This project uses the Hubhacks2 data provided by the MBTA and combines it with schedule and shape data and the google map API v3.0 .

Technologies: GeoJSON, Postgresql, PostGis, NodeJS Nginx , Javascript, AngularJS, MongoDB, mapsAP!3

Building the data model was donewith the Potgresql relational database acting on files published periodically by the MBTA in directory of csv files called MBTA_GTFS. Once the static transformations, queries and joins were accomplished, what was left was GeoJSON objects representing the the collection of segments between all stops and their properties (such as distance between stops). They were assembled into a feature collection for each route, those route JSON objects were then stored in a MongoDb.

The application is then driven by the timePointCrossing data. This collection of prior real-time data, gives us the time each bus on each route arrives and departs at 10 points along its route at every time of the day for the days in February and March that were included in the data. That dataset is queried (Postgres) every time you press MapIt. Before the map is displayed the data on those ten stops per route is turned ito durations between stops that is averaged over all the buses running in a half hour window from the user selected time. The properties of the GeoJSON object for the route are then modified and then it is passed into the map along with styles that depend on the speed property of each stop to stop leg. The duration between stops is based on realtime data whenever it is available and scheduled data when it is not. (That's why those MBTA apps are sometimes not actually realtime)

gists, fiddles and plunks

Syncing lists from multiple users using set algebra

In an app in which multiple people create and edit the same list, How to sync them together?

An app needs to be able to function to a certain extent even when not connected to the internet. How do you synchronize with other users who may have changed the list while you were making offline changes?

Checking online status in AngularJS app

Often apps can do useful work while offline. While online and connected to the server additional functionality is enabled. It is helpful to know if a device is connected to the internet and if its server is available.

You might as well check online status every time your app makes an http request. If you wanted to periodically update your online status you could make a simple http request and intercept its response to set the state of a $rootscope variable that could then be watched by any controller.

Intercepting http calls, setting some rootScope variables and watching them from a controller, and, polling the server periodically to update everything, are described.

Promises between service and controller in AngularJS

Calls to $http belong in a service. SinceAJAX calls are asynchronous you have to return a promise that will be deferred until the callback. You can setup the promise in the service by including $q and then act on it when it returns in the controller.

Detecting browser window focus in AngularJS

When using html5 built-in window.onfocus and window.blur you need to inject $window in the controller and after you update the $scope you need to $scope.apply() so angular knows about it.

REST API in NodeJs and Mongo using TDD

Developing a back-end using test-driven development
repository: s2g-api
description: full README

This is the REST api for a rewrite of PHP/MYSQL mobile-first app for shared shopping lists. While I could certainly refactor that existing app into a MVC Agile test driven piece of clean code, I prefer to get some experience the Angular/NodeJS/Express/MongoDb stack. More importantly, I need to somehow shock my system into the paradigm of building an application by the iterative process of decribing a feature, writing a test for it that fails, writing code to implement a passing test, re-factor and loop.So far it is working and I see a future for this approach for all my code.

The basic architecture is to create a REST API that contains a good part of the business logic or MODEL of the system. The api communicates in JSON to a front end encapsulating the CONTROLLER and VIEW.

Currently running on a VPS using Nginx as reverse proxy for subdomains of parleyvale.com running Node servers. Can run as HTTPS but haven't yet plopped down the $9/year for SSL certificate.

Angular JS client & server for shoppping list app

Developing a front-end using javascript framework
repository: s2g-ng
appsite: http://stuff2get.sitebuilt.net
description: full README

The deployed app is a straight port of an old Jquery/PHP/MYSQL to Angular/Node/Mongo. As such it does not take advantage of the cooler features of the new technologies. But it runs and is in use by a dozen people.

The repository is a version that is heavily directive/module/component based using socket.io to push data from server to client. That is proceeding as I immerse myself in the upcoming changes in ES6 and Angular 2.0 and it will be architected to take the upcoming transition into account. My github is littered with fiddles and bits of code not yet ready for deployment.

Authentication is by apikey. Server then creates a token that is sent with every request. This app is for multiple users sharing access to shopping lists from multiple, sometimes shared, devices. Angular and Node will need to deal with cross domain issues.

While the database is in MongoDb on the server, this app will explore the possibilities of using local storage as the data source for the views and controllers. Every change however will get sent to the server, but the Angular app need not wait for the update, communication with the serrver will seem to be happening in the background. Changes written into local storage will be timestamped and some kind of polling mechanism will keep the client and server data stores in synch.

Electronics

Electronic Projects - The Internet of Things
repository: Electronics
description wiki page

Online heating system control project - prototype system currently running hydronic sytem with 7 zones

The most advanced and easy to use user interface these days is probably the one contained in your smartphone or tablet. Apps are easy to use, interactive and readily update-able. The interface on your programmable thermostat probably would not be high on that list. And if you have more than one heating zone then the difficulty is multiplied.

Replace those thermostats with temperature sensors and control the whole house from one interface. Slip a microcontroller device between the thermostat connections and the heating/cooling system. Connect it to the home network and you are ready to go. From 1 zone to 8 zones, it will monitor and control them all.

Start collecting data on your energy use. Which zone calls for heat the most? Which takes longest to heat up? How much would it cost to be a little warmer? How much is setting back the thermostat saving me in my house? Optimize your hydronic system by running the boiler at a lower temperature on a warmer day.

Overriding any zones program is easy and can be done remotely from any connected device, phone tablet or browser.

An Avr microcontroller takes in temperature readings from multiple locations. At the control room the AVR hub polls temperature and for each zone knows the set temperature, the default temperature and whether or not a zone is ON. If it does not hear from the (linux) scheduler then it falls back to act as a multi-zone thermostat set at the default temperatures.

The restAPI contains the model of system, the temperature/relay data from the AVR client and the model of those sensors and relays relation to the rooms, devices and locations in the house as well as the scheduling model. It also contains the controller for the microcontrller; whenever a schedule change point comes up, it notifies the AVR and instruct it to change the set point.

The app runs PHP on the server and JavaScript on the client (mobile or computer). The server resonds to client requests through AJAX. Views are generated on the client, the controllers are partly on the server and partly in javascript. The process of creating of modifying a schedule occurs entirely on the client and is only interacts with the server and API once complete.

System redesign in process


repository: microcontroller code
repository: rest api
repository: app code
description wiki page

Cascada-water control project

little app to communicate between browser/app and microcontroller to run a small waterfall
repository: cascada
description wiki page

We have two little ponds in the yard fed by the rainwater from the roof. They are at the base of a big outcropping of roxbury pudding stone. Water is pumped from the lower pond to the upper pond and from the upper pond up the side of the ledge.

There is an app, "cascada" that starts the pumps and energizes the circuits to turn on the waterfall and control the level of the lower pond.

If it hasn't rained in a while, over time water evaporates and leaks out. The level of the pond is controlled using a $10 lawn sprinkler relay to inject water into the pond when the falls below a certain level. Water gets added while the pumps are on until it reaches the max level then it goes off. If you turn on the pumps again it doesn't continue filling but waits to inject water til the water falls to the low water sensor.

The water level control is independent of the pond timer, is located in its own circuit box on the porch and is activated whenever the waterfall is on.

The other circuit is connected to the house ethernet and contains a server, relays and timers to turn the system on and off. Its microcontroller is connected to an [[Enc28j60]] chip that implements a server capable of delivering GET string variables to the microcontroller.

The app is written in HTML5/javascript, resides on http://cascada.sitebuilt.net and uses $.get to send a string to a php script on the that server which transfers it by curl to the external Enc28j60 server located in the house. It does this via a http://www.noip.com/ since the home network's IP can change. It tells the controller which circuit it wants on and for how long.

LevelThe Field

Visualize a better Income Tax System
repository: LevelTheField
appsite: http://levelthefield.sitebuilt.net
description wiki page

Using published IRS data and other sources, this HTML5 app is designed for mobile devices and creates a model of the income tax system in the US.

It explains the system and allows user to manipulate all the variables of brackets and rates on earned and unearned income to design a better system that raises the same amount of money. A javascript, jquery-mobile, HTML5, flotJS (visualization) app.

Stuff2Get

Share a list on any device
repository: Stuff2Get
description wiki page

You can have shared shopping lists on any mobile device. Update list on one device and the updates show up on another. Stuff2Get is a javscript, jquery-mobile HTML5 app. Server is php/mysql.

OBsoup

Project organizer.
repository: OBSoup
appsite: http://soupteam.sitebuilt.net
description wiki page

The soupteam.com site is one way to organize a project that is going to take place at a certain date/time. You can create project and then send out the word to recruit a team to pull it off. Most pages are created from PHP. Uses MYSQL javascript jquery and jeditable to allow in-browser editing of database.

Miscellaneous Scripts

Assess

A collection of scripts written to support computer use in the classroom for my Humanities classes from 2005-2011 at Parkway Academy of Technology and Health (PATH), a BostonPublic Schools High School. Each student at PATH had a laptop. <br/>

The main computer platform for my courses was Mediawiki. Each student had an account on the wiki and used their account pages as scratchpad, a workbook, as a place for in-class writing, for quizzes and exams and for all the stages of essays and research papers.

mediawik scripts

Some scripts allow me to interact with medaiwiki through its API, doing things like injecting pages into students' acount pages. Check the WikiBot and mw directories. Other scripts helped me to create general course content that would show up on the course wiki's. Most were in PHP and allowed for interaction with the MYSQL databases.

There were course wikis for most of the courses I taught, with an new version every year. Other supporting technology included forums and blogs. Course Wiki's have been archived and some are still hosted in read-only format. Some links to course wikis:

currently offline
http://pathboston.sitebuilt.net/hum4
- a senior level Humanities course focusing on the literature and history of the world from 1500-present
http://pathboston.sitebuilt.net/hum3
- a junior level Humanities class focusing on the literature and history of the United States from post-Reconstruction - present day
http://pathboston.sitebuilt.net/hum2
-a sophomore Humanities class focusing on the literature and history of the United States from Antebellum America through Reconstruction
http://pathboston.sitebuilt.net/poets
- a freshman level course in poetry, mythology and self expression with links to student blogs at http://pathpoets.blogspot.com/
data

There was a database with of article links for material used in each course. These were indexed by course, by unit and standards. Additionally were two other databases, one for questions on the course materials with references into the text and with various multiple choice and short answer responses that connected to those questions. The other database was of vocabulary words from the source materials including the context in which it appeared, other contexts from within and outside the course (some student created), definitions, and parts of speech. Finally there was the database of the quizzes and all student responses to every question which allowed for item analysis.

general work flow

In general, whenever a new article or excerpt was going to be used in a class, I would first process get it in the database and all indexed up.

vocab processing scripts

Then I'd run scripts to extract vocabulary words and terminology. Visual Thesaurus vocabgrabber (if you are a paying customer) allows you to send it a text file, book chapter, whatever and then it will identify vocabulary words based upon lots of criteria. It produces a list of words along with the sentence they showed up in.

Vocabgrab Takes the list produced from visual thesaurus stores it and scrapes the web for definitions and then adds them to the database.

Vocabgrid allows the teacher to quickly review those automatically collected definitions to make sure they are the appropriate definitions. It allowed for in-cell editing of webpage tables. This I wrote in AJAX , using an pretty early version. Alas it only works in an old version of a Firefox Browser from back then. (Now I do all my AJAX through Jquery).

vodb2 contains a few utility programs to get words, definitions and contexts for an article out of the database and into an HTML quiz, a smartboard quiz, or a quizlet or wordlist or a glossary.

question processing scripts

All questions on the readings were collected stored and indexed. Some were in moodle format, and some were in mediawiki format.

wiki2db and q2db are examples of a parsers that extracts questions from mediawiki format and sends them to a database.

qdb2 and combine are scripts to create quizzes from the database according to assorted criteria. The quizzes are then produced in various media including smartboard, smartphone, printed or browser. They are randomized on a question by question and within multiple choice responses so that each quiz looks different. Scores are reported immediately and sent to a database that allows for item analysis.