Monday, August 5, 2019

Putting An Old Cell Phone to Good Use

Several months ago I cracked the screen on my 3 1/2 year old Droid Turbo cell phone, and recently, the battery which used to power the phone for two days on a charge, got down to about one day's use per charge.  The cracked screen stopped buttons from working on some applications.

Ouch!

It was time to replace it, and I wanted to get away from Verizon's crapware, slow updates, and expensive service, so I opted for a Google Pixel 3 with Google Fi service.  Like the Turbo, I expect to be using this phone for at least the next 3 years.

The Droid Turbo's camera wasn't bad except for some pincushion distortion in its images (see video, below), and is very high resolution (24 MP stills, and 1080p video), so I didn't want to throw it in the trash.  I already designed and 3D printed adapters to mount it on a couple microscopes and a telescope so it would still be useful for those functions.

Droid Turbo with microscope adapter from Mark Rehorst on Vimeo.

Droid Turbo mounted on old surgical microscope.




Lot's of magnification!


This is how I inspect 3D print quality.  It's amazing what you can see with a little magnification!  Those are 0.2mm layers of a 3D printed vase.

The same type of adapter works on a telescope.

Shot with Droid Turbo mounted on a Meade ETX 90 telescope.


The telescope and microscope adapters are located here:
https://www.youmagine.com/designs/droid-turbo-phone-to-telescope-adapter
https://www.youmagine.com/designs/microscope-adapter-for-droid-turbo-phone

At the makerspace we have a couple RPi based cameras set up to monitor 3D printers.  They're pretty good but relatively expensive and pretty low resolution compared to my old phone camera.  I thought it would be nice to be able to monitor UMMD with a high resolution camera, so I decided to make it work.  I needed a hardware solution to mount it on the printer where it could see what was going on, and a software app that would let it take pictures every minute or so and post them to a web page.

Hardware:


As usual, I started by creating a simple model of the phone, then took the phone to the printer and measured the angle that gave the best view of the print bed (about 35 degrees from horizontal).  Next I played with several designs of 3D printed mounts and kept simplifying and ultimately decided that this was not a job for a 3D printed part.

I have some 65 mm suction cups that stick very nicely to the front doors on my printer, so I decided to use them.  They are designed to mount on thin, flat, sheet, so I decided to use some of the 1.65 mm aluminum sheet I have in my materials collection.

I thought about making printed brackets to hold the phone (I have a printer, so all problems are solved by printing, no?) to the sheet aluminum but realized that the easiest thing to do was just bend the aluminum to the appropriate angle and put Velcro tape on the bracket and phone.  Here's what I ended up with:

It couldn't be much simpler than this.  The suction cups will stick to the smooth polycarbonate front doors on UMMD and velcro tape will hold the phone on the bracket.

And here's what it looks like in real life.  I made the whole thing, mostly using hand tools, in about 30 minutes. I stuck it to the printer's door and left it there for a week and it didn't fall off, so I think it's going to work well.

Here it is, with a perfect view of the bed plate.  When it's actually being used to monitor prints I'll plug the charger into the phone's USB port.
Here is a drawing with the dimensions of the aluminum bracket.  I folded it about 40 mm from the top edge in the photo above.  The angle of the fold was chosen to provide an entire-bed view with the phone's camera and the way my printer is set up.  You may need to do something else for your phone and printer.

Now that I had the hardware ready to go, it was time to add the software.

Software:


I don't want to watch my printer print via my computer or phone any more than I want to stand next to it and watch it print, so I don't need a video feed.  I just want to take a high resolution photo every few  minutes and upload it to a web site (or Google Drive, etc.) where I can take a look at it to check print progress.

I searched the Google Play store and found a whole bunch of apps that let you use a phone as a baby monitor or security camera.  I loaded and tested a few of them.  They were all videocentric, and all required a subscription to get rid of the tons of ads that display all over the apps.  Yuck!  I was so disgusted that I won't bother to list their names here.

I was ready to start studying App Inventor so I could write my own app for this, but then, just by chance, I posted a question at slashdot and someone pointed me at an app called Open Camera.  It's a FOSS app that allows you to control the camera in an Android phone.  You can set it up to snap a photo at specified intervals and most importantly, store the photo wherever you specify, with a name you specify, in a location that will automatically back it up to Google Photos or Google Drive.  Woohoo!

When you want to check the print progress, you open Google Photos from wherever you are and take a look.

Open Camera is on the Google Play store, it's free, and there are no ads!  Instructions and more info are available here.

I went into settings, selected "use storage access framework", then selected save location "camera" to put images in the normal camera save location so they'll get backed up via Google Photos.

Then I set "repeat" to "unlimited", and repeat mode interval to 5 minutes, and finally turned "timer beep" off.

I selected one of the high res modes for the camera.  Now when I power up and start the Open Camera app, I see the print bed, start the print and then touch the shutter button on the camera.  That takes a photo immediately and starts the interval timer that conveniently counts down on the camera screen.

Turn on "back up and sync" in the Google Photos app so that the images from the phone get uploaded to Google Photos.  You can select specific folders to back up, so even if you save the images in a "nonstandard" folder on the phone, you can still get them backed up.  Each image is uniquely named based on the time and date, so you can string them together to make time lapse videos if you want, otherwise just delete them after you've seen what you want to see.

There may be a way to fix the save-file name so that it just overwrites and you don't end up with a series of images...

Update!  


Already!  Someone at the makerspace (thanks Dan!) pointed me at this:  For those of you with slightly more advanced kung-fu, there's a free app called Rsync Wrapper that can be used to schedule repetitive jobs like uploading a photo (or any other file) to the web server of your choice, so you don't have to rely on Google Drive or Google Backup and Sync to do it.  Just like Open Camera, no ads, no subscriptions... just goodness!  Woohoo!

I've said it before and I'll say it again:  find and join your local makerspace!

Update again!


Folks at the Duet forums recommend the IP Webcam app which gives video or high resolution still images, and can be viewed on local network or can be linked with Ivideon for cloud broadcast to access video from anywhere.  There's a pro version for only $4 that eliminates ads.

Here's one of a recent sequence of images captured by Open Camera and saved to my Google Photos account.  I had some problems when I started trying to use Open Camera- it would take several pictures then stop.  I went into settings and turned off the display maximum brightness option and that seems to have fixed the problem.  When the display was on full brightness I think the phone may have been overheating and shutting down to protect itself.

Making Movies


You can turn an image sequence into a video file with some free programs- in the past I have used ImageJ and VirtualDub.  Just point them at the first file in the sequence and they can easily create a timelapse movie from the still image sequence.  There's more info on software for this sort of conversion here.

Be careful about making movies from long sequences of high resolution images!  You may end up with a gigantic video file.  This can be prevented by batch converting the high resolution images to lower resolution images before you make the movie.  Irfanview is a great photo viewer/editor that can do the batch conversion for you.

The original resolution of the photo above was 3264 x 2448 pixels.  I downloaded the sequence of images to my computer, batch cropped and reduced the resolution to 600 vertical pixels.  Then imported the sequence into ImageJ and used it to spit out an .avi file.

In IrfanView's file menu, select Batch convert, point it at the first file in the sequence, check the "advanced options" box and open the advanced options and specify the new resolution.  You can also change the file names if you want.





No comments:

Post a Comment

Leave comments or a questions here and I'll try to post a response as soon as I can.