BeaverWorks

Sunday, 22 January 2017

I have recently started trying out my Sense Hat module for the Raspberry Pi; it has a number of sensors built in to play with and support for reading and writing data through a Python library. There are a number of libraries out there, but I chose this one as it allowed me to recycle some of my old code.

I mostly just recycled the database creation and writing code for SQLite, and I am storing the data as a blob (JSON string) so that I can continue revising my data objects without having to mess around with my database at all.

I'm planning on calling this and processing the data through a service I'm working on as well.

Tuesday, 22 November 2016

Description

My grandmother made her own Irish cream for the holidays and I've been trying to perfect my own recipe now for years. My recipe started from a combination of several others, as is my usual MO and I've been experimenting with some different flavours. One year I tried it with both dark chocolate (melted) instead of the espresso powder, then I tried it with white chocolate... I liked them all.

Note: It goes extremely well with buttery Christmas cookies, but I can't recommend it due to health concerns.

Ingredients

Directions

Dissolve espresso in 75 mL. of hot water, then add the sweetened condensed milk and almond extract and mix thoroughly, this will help thin the condensed milk, and then mix in the heavy cream. Gradually stir in the Irish whiskey and it's done (well you'll want to bottle it).

Try to keep the Irish cream in the refrigerator for one week before drinking for the best flavour.

Stores at room temperature for approximately 2 weeks, and in the refrigerator for two months; or so I'm told. The Irish cream has never lasted long enough for me to verify this statement.

Wednesday, 6 July 2016

A couple of simple steps to make Linux (sshd) secure shell more secure, as a follow up to my previous post about setting up ssh access with a secure key:

a) Change the default port

In order to change the default port we need to edit our ssh configuration file and change the default port from 22 to something else:

sudo nano /etc/ssh/sshd_config

Port 22

b) Disable the password

The password is still a vulnerability, so it's best to either change it to something very secure (long and highly randomized) or to disable it completely and limit access to the ssh key itself. To do this we edit the following line in the sshd_config:

Tuesday, 19 April 2016

I created a very simple line plot for displaying my data using the JavaScript library Chart.js, it has less bells and whistles than a library like D3.js but it has proven to be very easy to use. Even so, I ended up taking a course to introduce myself to JavaScript; with CodeSchool and their JavaScript Road Trip. I liked the course format with video tutorials and code quizzes; I always learn better through doing (and breaking things) and their browser hosted code editor was well done.

I did have one notable issue with previous charts being cached and showing through when I would mouse over certain data points. Luckily this was a fairly well known issue and there was a simple solution, using the destroy() method.

As you can see this is still a work in progress. Next thing I want to work on is a listview to select multiple data streams from the given table, connecting to (ftp) online data sources and updating my database automatically (differential updates) so I can collect data from different sources online. This may take me a while to complete (what with coding full time at work) but that's the plan.

You can see the completed code below:

And here is a screenshot of the completed single line plot, if the controls are empty it defaults to all data:

Simple time-based plot

Next on the agenda is to collect data from local and online resources (ftp); and then make the source user configurable as well as allowing them to select the stream.

Sunday, 30 August 2015

Physical Setup

I'm going to use a Raspberry Pi along with an ADC (Analogue to Digital Converter) I purchased to collect temperature data. I've connected directly to the RPi GPIO port using a T-Cobbler Breakout Kit.

Materials List:

ADC - Microchip Technology MCP3008-I/P

Temperature Sensor - Texas Instruments LM35DZ/LFT1

BreadBoard - Bud Industries BB-32621

24AWG Hookup Wire

RaspBerry Pi Mod B

T-Cobbler Breakout Kit

Whoops, accidentally ordered the unassembled T-Cobbler kit so I had to break out the old soldering iron.

Ye olde soldering iron

Test Setup

I mounted the MCP3008 on the breadboard and wired up a rough test set-up using a potentiometer as the analogue voltage input for the ADC. For the wiring I referred to an online tutorial that didn't involve using the Serial Peripheral Interface at first, but eventually found this recipe and decided to learn more about the SPI with Analogue sensors on the Raspberry Pi using an MCP3008

And here is the finished product wired entirely in purple. Pin 1 (the white stripe) on the ribbon cable corresponds to the P1 on the RPi mainboard. Now to run some smoke tests.

I started with Matt's code from the blog mentioned above and then added a few minor changes to meet my requirements. I used the Pi WebIDE to write and debug my code; it works very well in tandem with my existing BitBucket account by adding a simple OAuth consumer to my settings.

Here is a sample of the code I tested my setup with:
I had originally planned on creating a connector class, to read from the generated (JSON) text file; and this was a useful first step, but I have since decided to send the data directly to a database on the DAQ. I think this will give me a little more flexibility as I further develop the system.

Update

After some testing with the previous setup and fiddling with the code a bit I decided to make a few changes and finish up my circuit. So, as I mentioned before, I added a database to record my sensor data, setup a temperature sensor using the TMP35/LM35, cleaned up my wiring a bit and made some additions to my code.

The main additions to the code for writing to a SQLite table are fairly simple. I made my SQL script in two parts just to make it a little easier to look at; the first string gives the table and variable/column names, followed by the values to insert.

Here is the entire code (hosted in Gist):
I also needed to change the conversion factors from the original sample code as they had been written for the TMP36 and the TMP35 has a different response range, though it is the same linear factor.

Using a vRef of 3.3V this gives me a range from 0V to 1.25V

volts = (data * vRef) / float(1023)

Which translates to a temperature range from 0°C to 125 °C

temp = ((data * vRef)/float(1023))*100

The TMP35 is rated most accurate between 10°C and 125°C

As my final step, I added a Cron job to run my code once every hour on the hour; this should give me enough data to work with in creating my API and give me some ideas for the way I want to query and present the data.

Anyway, until I add more sensors (or maybe an IR camera) that's it for the data acquisition side of my project. What I'm working on now is finishing up the skeleton of the Web API and starting to fill it out with a few features... and eventually documenting it for another post.