Raspberry Pi Automated Time Lapse (Updated Sept. 18, 2017)

Update: If you want a Time Lapse Raspberry Pi image you can burn to an SD card? Click here to download the zipped image. Just extract and burn to a 16GB SD card, pop it into a Pi with a camera module and you'll be on your way.
Update #2: Following Phillip Martin's blog post, I set up the Pi's WiFi adapter as an access point so I can connect my iPad and Macbook directly to it without needing to rely on another WiFi network. Now I can remote into it with VNC Viewer in any location I'm recording. See this post for details.

We’re working on some cool video pieces to showcase the awesomeness happening on our campus. As part of that effort, we built an automated time lapse video recorder using a Raspberry Pi 3, case, camera and an Anker PowerCore battery pack. Set this puppy down, point it in the right direction and let it sit for an hour (or 12). Then, stop the script and combine your hundreds (or thousands) of photos into a cool time lapse video.

Here’s a quick example of what’s possible.

Some pictures, with an explanation to follow.

 Front of Raspberry Pi time lapse camera 

Physical build, challenges and prototyping

During the early iterations, the camera module was external to the case and basically taped it to the outside making it vulnerable to damage. Cutting a small hole in the front cover to allow the camera lens to see through and taping the camera module down to hold it in place resolved the issue. There were some small plastic tabs on the inside that needed to be removed in order to get the camera to sit flush. Depending on your case, you’ll likely need to make similar modifications. Be careful to avoid damaging the ribbon cable as it can be kinked, pinched or come loose.

One early frustration was the need to tote around a keyboard, mouse, monitor and power adapter to each filming location. To get around this, a little script runs on startup so that the Raspberry Pi will just start taking pictures as soon as it boots up. Adding the Anker battery pack (perfectly sized to work with the Pi’s case), attached with 3M Command Strip hook and loop fasteners resolved the power issue. Now, it can be set up anywhere. Just attach the power cable and let it run. As soon as it boots, the camera starts taking pictures – one each second, until the power is disconnected or the device is shut down. While we haven’t timed it exactly, the 10000 mAh battery looks like it might be able to run the Pi for  24 hours or longer.

Another challenge was not being able to see how the pictures looked to frame the shot without a monitor. So a VNC server was installed on the Pi. Now an iPad can be used to remote into the Pi to see the pics as they are being taken. Looking at the first few pictures allows adjustments to be made to get the best shot.

How it works [updated 09/03/2017]

This line is added to /home/pi/.config/lxsession/LXDE-pi/autostart file:

@/home/pi/lapsescript

This runs a one-line script named lapsescript stored in the home directory. To create the lapsescript file:

  1. Open the Terminal app on the Pi
  2. Type “cd ~” and hit enter to be sure you’re in the home folder
  3. Type “sudo nano lapsescript” and press enter to create the lapsescript file in the nano text editor
  4. Type lxterminal -e sudo /usr/bin/python2 /home/pi/lapse.py in the nano editor
  5. Press “ctrl-x” to exit nano
  6. Press “y” to save the file
  7. Press enter to confirm saving the file
  8. Now that you’re back in the Terminal window, type “sudo chmod a+x lapsescript” and press enter. This makes the script executable.

So, when the Pi boots up, the line at the top of this section runs lapsescript. If you read the lapsescript line from left to right, lxterminal is executed (opened), the Python interpreter starts, and runs the lapse.py Python script. This script creates a new folder with the current date and time in the home directory and stores pictures (taken one per second – customizable in the script), storing each with a sequential filename of image0000.jpg, image0001.jpg, image0002.jpg, etc. Each time the script runs, a new folder is created so that different shots don’t need to be separated by hand – each has its own folder. Note that this all happens automagically when the Pi boots. No need to type anything. Just set it down where you want to shoot, plug in the external battery and let it sit for as long as you’d like. The Python script will continue to run until you shut it down (Ctrl-c, disconnect the power or otherwise shut down the Pi) or your sd card gets filled.

These pics can then be converted to a movie on the Pi with avconv or transfer them to your favorite video editor. Navigate to the pictures folder in Terminal and use the following command to create a 24 frames/sec mp4 video named timelapse.mp4 scaled to 1280×720:

avconv -r 24 -i image%04d.jpg -r 24 -vcodec libx264 -vf scale=1280:720 timelapse.mp4

How to put it together:

These instructions assume you want to set up your Raspbian installation from scratch. If you just want to download an image that’s all ready to go, just download the image linked at the top of this post, write it to your SD card, pop it in your Pi, point your camera somewhere interesting and turn on the power.

  1. First, connect and enable a camera module. Once connected, open the Pi’s configuration (Preferences > Raspberry Pi Configuration) and select the Interfaces tab. Ensure that the camera is enabled. Also enable VNC and ssh if you want to access your Pi remotely.
  2. Python script creates a directory in the Pi home directory using the current date and time to keep each time lapse sequence separated. The linked .txt file would need to be renamed timelapse.py and in order to work with this automated setup and saved to the home (/home/pi/) directory. To change the length of time between pictures, change the number in the sleep(1) line. The number in parenthesis is the number of seconds to pause between pictures. You can also change the resolution to suit your particular camera module.
  3. To run the script at startup, add the line
    @/home/pi/lapsescript
    to /home/pi/.config/lxsession/LXDE-pi/autostart file. To do this, open a terminal window and type:
    sudo nano /home/pi/.config/lxsession/LXDE-pi/autostart
    This opens an editor with the autostart file. At the bottom of the file, add the line “@/home/pi/lapsescript/” at the bottom. Press control-x, then ‘y’ then enter to save the file.

Future upgrades

A dynamic DNS service would help make the VNC server accessible regardless of the current network or ip address (future upgrade). Ideally, it would have some buttons in order to shut down the Pi properly rather than just disconnecting the power and to change the time between shots. The newer 8MP camera module and a touchscreen are being shipped with hopes that the higher resolution will look awesomer on our new 4k displays. The touchscreen may just help with setup and preclude the need for a VNC/iPad monitor setup. Alternatively, I’d like to add some buttons that could pause or stop the script, change the image resolution and/or the length of time between pictures. I’ll update the post as those get implemented.

Links used in researching this project.

Some links to resources.

  1. Setting up VNC server on the Raspberry Pi
  2. Running Python script on startup. This was particularly helpful. In earlier setups, the script would run, but there was no way of shutting it off. This method opens a Terminal window so that Ctrl-c will interrupt the script.
  3. Python code inspiration came from the second page of this post.
  4. Other Raspberry Pi time lapse posts:
    1. Trevor Appleton
    2. Jeff Geerling – Headless Pi Zero

PowerSchool Custom Reports Notes

This is just a notepad for me to record tips for PowerSchool Custom Reports.

  1. Enter a custom field from any table
    • ^([table number]custom field name)
  2. Get fields from StudentCoreFields into a report
    • ~([Students.StudentCoreFields]PSCORE_LEGAL_FIRST_NAME)
  3. Customizing the “generalDemographics” page to use new legal names
    • <input type=”text” name=”[Students.StudentCoreFields]PSCORE_LEGAL_FIRST_NAME” value=”” size=”25″ maxlength=”50″ id=”firstName”

Remove Jamf framework

To remove JAMF’s Self Service App and all jamf components, enter the following in a Terminal window:

sudo /usr/local/bin/jamf removeFramework

Keep in mind that this will also remove things like any WiFi passwords that were installed using Jamf policies.

IF THE TERMINAL APP IS NOT ACCESSIBLE:

An old version of our MDM setup disabled student access to the Terminal app. Getting it back takes some doing:

  1. Create a new Admin user account.
  2. Log into the new Admin account.
  3. In Applications > Utilities, copy the Terminal app and paste a copy on the Desktop.
  4. Rename the Desktop Terminal app to T2.
  5. Run the T2 app.
  6. paste “sudo /usr/local/bin/jamf removeFramework” in the T2 app and press return.
    (This should remove the JamfFramework, MDM settings and Self Service app.)
  7. If successful, log out and log back into the student’s account and delete the just-created admin account.

Use INDEX with MATCH instead of VLOOKUP in Spreadsheets

VLOOKUP returns janky values if the value you’re looking up doesn’t exist in the lookup column. Combine INDEX and MATCH for more reliable results.

For the long explanation, head over to Ablebits. If you’re Paul and just looking for a reminder of the format, here it is:
=INDEX (column to return a value from, MATCH (lookup valuecolumn to lookup against, 0))

NWEA MAP Import and Export from PowerSchool

This post was shamelessly stolen from PSUG-Asia and is posted here only in case the referenced post disappears. [note to Paul: search your Google Drive for “NWEA MAP Rosters Directions” for a helpful spreadsheet]

This content is from Douglas Sirkka, Educational Technology Coordinator and PowerSchool Administrator from St. Mary’s International School.

You can download the PowerSchool Export Template File Here: MAPExportMap

Or Copy the code below and make your own:

TITLE CONTENTS

School Name ^(decode;^([schools]name);<<your school names here>>
Instructor Last Name [teachers]last_name
Instructor Middle Initial
Bus_Stop
Student First Name [students]first_name
Student Gender [students]gender
Previous Instructor ID
Bus_Stop
Period (Delete)
Expression Instructor ID [teachers]teachernumber
Instructor First Name [teachers]first_name
User Name [teachers]Email_addr
Email Address [teachers]Email_addr
Class Name [courses]course_name
Student ID [students]student_number
Student Date Of Birth [students]DOB
Student Grade [students]grade_level
Student Ethnic
Group Name
Bus_Stop
Student Last Name [students]last_name
Previous Student ID
Bus_Stop
Student Middle Initial
Bus_Stop
*Where it says ‘Bus_Stop’ that’s where I needed a blank in the file. With the TSV file above you can sort by SEQ field.

MAP Testing CRF Import In PowerSchool

  1. select the students who you need to create/update on NWEA.
    1. This will usually be the entire ES, the entire MS, or grades 9 and 10.
  2. In Group Functions, select Export Using a Template Type of Export: Student Schedules
  3. Export template: MapsCourseInforExport
    1. Select Only schedules for the selected… and Submit.
  4. Save the resulting export file and then open.
  5. Filter and select courses you want to associate with student profiles.
  6. Delete Period/Expression column at the end of the file. (this is for sorting/filtering purposes)
  7. Save as CSV (required)
  8. Login to NWEA Select Import Profiles
  9. Select Start New Import Select Combined
  10. Select the appropriate term.
  11. Add the Roster File.
  12. Click Next Check the data (Check student DOB this sometimes gets changed to a number) Reconcile Errors (Beyond scope of theses instructions but pretty straight forward)
  13. I think there is an error in the Export Template the needs a capital S in Not Specified… RP (Grade_Level 0) needs to be reconciled with K.
  14. Post the valid records.

Hope this makes your job a little easier.

Shady – for super granular control of your Macbook screen brightness

On a recent trans-Pacific flight, I was doing some work on my Macbook. All was fine with the in-flight WiFi working pretty well. But when they turned off the lights after dinner, my screen was painfully bright-even on it’s lowest setting.

You can use shift-option-F1/F2 to gain some fine-tuning control over your screen’s brightness, but if you need more, there’s Shady – a tiny li’l utility that basically writes a variably transparent grey layer over your screen. That’s all. It’s great. Get it.

Shady - screen shader

Next Year’s Course Lists for Students and Course Rosters for Teachers from PowerSchool

I use a MacBook to do most of my work. This should work on a PC too, though navigating in Terminal might be a little different. Feel free to leave a message below to let me know if you run into problems and I'll see if I can help.

This spring, our principals want to give students their course lists for next school year with courses listed in alphabetical order. This is so that students can confirm their course enrollments without knowing what period or teacher they are assigned to. This is to help preclude students requesting changes to be with a particular teacher or friend.

I wrote a Python script to do this. <– Note: Change .txt to .py before running

We also wanted to provide teachers with class rosters so that they could look for any potential issues including gender balance.

Another Python script handles this. <– Note: Change .txt to .py before running

To get the data, use DDE to select records from the ScheduleCC table for the next school year. In my case, I set TermID >= 2700 since TermIDs for next year (2017-2018) are 2700, 2701 and 2702

Then I export the data using the fields below. The first 5 come from the ScheduleCC table. Other tables are: 2 Courses, 1 Students, 183 CustomText, 5 Teachers and 3 Sections. Note that for your PowerSchool setup, the Student_Email record may be located elsewhere.

Exported fields:
[1]Student_Number
[2]Course_Name
[1]first_name
[1]middle_name
[1]last_name
[1]Sched_NextYearGrade
TermID
[183]Student_EMail
Course_Number
SectionID
Expression
[5]First_Name
[5]Last_Name
[5]Email_Addr
[1]Gender
[1]Father_Email
[1]Mother_Email

Sorting of the data file is essential!


For student course lists, sort the data in this order: Sched_NextYearGrade, StudentID, Course_Name. If you just want to print course lists for just MS or HS,  remove the excess lines or refine your export from DDE. Save the file with the name sched_data.csv in the same folder as this script. Save this file as a csv file named sched_data.csv in the same folder as the shed_alpha.py script.

For teacher rosters, sort the data in this order: [5]Last_Name, [5]First_Name, TermID, Expression, SectionID, [1]Last_Name, [1]First_Name. Save the file as a csv file with the name roster_data.csv in the same folder as the class_rosters.py script.

To run the script, open Terminal and navigate to the folder containing the script and data file. For instance, if you saved them in a file called rosters in your Documents folder,

cd ~/Documents/rosters

and then run the script:

python class_rosters.py

The python scripts create an .rtf file for each student or teacher. Note that if you open the rtf file in preview, it may not show or print the page breaks that are in the documents. If you open them in MS Word, you should see them properly.

The scripts also create a handy Terminal command to bulk convert the rtf files to pdf format. This command requires LibreOffice available here. After running the the python script to create the rtf files, assuming all went well, you’ll see a folder with the current date and time in its name. Open the folder and find the file named convert_to_pdf.txt. Open this file, copy its contents, paste it into Terminal and hit Enter. In several seconds you’ll have your rtf files converted to pdfs. If you get an error message, Terminal probably isn’t in the correct folder. cd to the folder holding the rtf files and try again.

Oh, another little bonus is a file that gets created called 1mail_merge_info.csv. This has the three columns needed to use Amit Agarwal’s Mail Merge with Attachments to send them out to students and staff.

 

 

Creating individual corporate email signatures for staff

Our staff email signatures are a varied mix of good and bad. When I need to respond to someone who has just emailed me, I’d like to be able to look at the signature to see his or her position/title, room/office number and phone extension. For external email recipients, additional contact information should be included including a link to our website and to our Twitter feed. Personal badges and other clutter should be avoided for a clean, professional looking email. I want it to look like this:

Email Signature
Sample of desired email signature

Google Apps Manager or GAM (https://github.com/jay0lee/GAM/wiki) allows a Google Admin to set signatures for accounts in the domain. So, I use a Python script to create an html signature for each staff person as well as a batch file that tells GAM which signature file to upload to each account.

It all starts with a spreadsheet. The one I use is the Form Responses sheet from a Google Form I use to collect the necessary data from staff. I do this so that individuals are able to decide on how their names show and to ensure that we have accurate information about room numbers and phone extensions. This also allows the individual to decide whether or not to include a personal cell phone number in the signature.

The column headers in the spreadsheet are:
Timestamp, email, Name, Position, Room, Extension, Mobile, Include_Mobile

The script then processes the data in the spreadsheet to create a signature file for each row and staff member as well as a batch file that I run in terminal with the command:

python gam.py batch batchfile.txt

This creates the individualized email signature seen above. KIS social media links like official KIS Twitter feeds, Facebook and Instagram links will be added in the fall of 2017.

 

SQLDeveloper and Java 1.7.0_80.jdk

SQLDeveloper needs to run under a Java version greater than 7 and less than 8. Installing the most up-to-date JDK gets you at least version 1.8.0_131 (as of 26 April, 2017). You can find older versions of Java from their Download Archives where I was able to find version 1.7.0_80.

Alas, even after installing this version, SQLDeveloper “sees” the newer version that I also have installed on my Macbook Pro and not the required JDK.  Luckily one Paulo Pedroso on the stackOverflow posted a solution which was to edit the file
/Applications/SQLDeveloper.app/Contents/MacOS/sqldeveloper.sh
(I used nano) to the line that reads
export JAVA_HOME-‘/use/libexec/java_home -v 1.7’
and simply change the 1.7 to 1.7.0_80.

Yup, that’s it.

Enable PowerTeacher Pro for individual sections

Using DDA with the Sections table, filter the course and sections you want to change – making sure you select the current year so that you do not convert previous years’ gradebooks. In DDA, Click “Modify Records”. In the drop-down menu, choose “Gradebook Type”=2 to change all the selected sections to the new PowerTeacher Pro Gradebook.

For future reference, to enable PTP for all courses, from PowerSource:
Enable PowerTeacher Pro: PowerTeacher Pro is enabled at a section level by setting the gradebook type. You can set this individually by section or en-masse using DDA or Quick Import. You can also set the default gradebook type of newly created sections to PowerTeacher Pro in PowerSchool from the District > PowerTeacher Pro Settings > Default Gradebook Type page . Setting a section to PowerTeacher Pro will cause it to become read-only in PowerTeacher Gradebook.