Advertisements

Archive for category Software

Xiaomi Dafang Hacks: Motion Detection

Given a camera running Xiaomi Dafang Hacks software, you can set up motion-triggered image capture and save the images either locally or on an FTP server. The latter makes sense, as it automatically plunks the images where they’re more generally available.

Define the FTP server parameters in config/motion.conf:

# Configure FTP snapshots and videos
ftp_snapshot=true
ftp_video=false
ftp_video_duration=10
ftp_host="192.168.1.10"
ftp_port=21
ftp_username="ftp-user-id"
ftp_password="secret-password"
ftp_stills_dir="Cam4"
ftp_videos_dir="Cam4"

The FTP server should have the Cam4 directory in place and shared for read-write access before attempting to plunk files therein. Ahem.

The camera’s Services menu leads to the motion configuration page:

Xiaomi Dafang - Motion Settings page
Xiaomi Dafang – Motion Settings page

Limiting the detection region to the lower-left corner cuts out all the waving-in-the-breeze foliage in the yard, while covering the driveway. High sensitivity detects squirrel-sized objects in the foreground, although your mileage will certainly differ.

The camera seems rate-limited at 5 s/image, which may come from FTP transfer overhead; I don’t know if the code includes a built-in delay or if it just works like that. The NAS drive requires upwards of 7 s to spin up if it hasn’t been used for a while, but afterwards the transfers don’t take that long.

Mounting the NAS drive’s CIFS shared directory from my desktop PC works as before:

sudo mount -v -o rw,credentials=/root/.nas-id,vers=1.0,uid=ed -t cifs //192.168.1.10/Cam4 /mnt/part

Then view / edit / delete images as needed:

Xiaomi Dafang - IR motion capture - 15-04-2019_20.02.06
Xiaomi Dafang – IR motion capture – 15-04-2019_20.02.06

The camera has built-in IR LEDs, but they’re nowhere near powerful enough to illuminate the entire yard.

Motion detection works better in daylight:

Xiaomi Dafang - Daylight motion capture - 16-04-2019_09.53.51
Xiaomi Dafang – Daylight motion capture – 16-04-2019_09.53.51

Unlike the original Wyze firmware, the Xiaomi Dafang Hacks firmware & software keep all the images & metadata within my network and under my control.

Advertisements

5 Comments

Xiaomi Dafang Hacks: Timelapse Images

With the Wyze and Xiamoi Dafang cameras running the Xiaomi-Dafang Hacks firmware and software, I tried the timelapse functions on the yard camera.

The config/timelapse.conf file:

# Interval between snaps, in seconds
TIMELAPSE_INTERVAL=10
# Duration of the script should run, in minutes, set to 0 for unlimited
TIMELAPSE_DURATION=60
# Save dir config
SAVE_DIR_PER_DAY=1
# Enable compression
COMPRESSION_QUALITY=100

The images, named along the lines of 13-04-2019_191810_001.jpg, appear in the DCIM/timelapse directory, tucked into daily directories with names like 2019-04-13, a mismatch obviously in need of tweaking. There’s also a time_lapse directory which seems like cruft from an earlier revision; you can configure the target directory in scripts/timelapse.sh.

Start the script manually or from a crontab entry, wait until it’s done, then transfer the images to somewhere more convenient with a Bash one-liner:

find /system/sdcard/DCIM/timelapse/ -name \*jpg -exec curl -s -n -T {} ftp://192.168.1.10/Timelapse/ \; 

The -s silences all curl output; omit it until you’re sure the lashup works as you expect. I always forget the backslash before the semicolon terminating the -exec command.

The -n pulls the userID and password from the ~/.netrc file you previously set up for manual ftp sessions:

machine 192.168.1.10
login ftp-user-id
password secret-password

The IP address corresponds to my ancient NAS drive; your mileage may vary.

From my desktop box, mount the NAS drive:

sudo mount -t cifs -o "credentials=/root/.nas-id,vers=1.0,uid=ed" "//nasty/Timelapse" /mnt/part

The drive’s credentials aren’t particularly secret, but tucking them into /root/.nas-id means you could automount the drive with no hassle. The NAS drive requires the oldest possible CIFS version, of course.

Then view the pix:

Xiaomi Dafang - 15-04-2019_13.26.18
Xiaomi Dafang – 15-04-2019_13.26.18

You could set up the camera as an NFS share, but having all the cameras deposit their pix in a common location seems more convenient, particularly after I get around to automating the image transfer. Regrettably, the NAS drive doesn’t support subdirectories.

2 Comments

Multiprocess Book-on-CD Ripping

The most recent iteration of ripping a book-on-CD to bits suitable for a small MP3 player begins by defining the metadata:

author="Whoever Wrote It"
title="Whatever It May Be About"

Set up a suitable directory for the MP3 files, with a subdirectory for the WAV files direct from the CD:

mkdir "$author - $title"
cd "$author - $title"
mkdir waves

Then unleash cdparanoia on each disk, but with its error checking dialed back to a minimum because most errors don’t produce much audible damage:

d=01 ; cdparanoia -v -Y --never-skip=1 -B "1-" waves/D$d.wav ; eject cdrom

In some cases, however, a nasty gouge (the previous owners being careless, alas) can jam cdparanoia midway through a track, so I fetch all the remaining tracks:

d=10 ; cdparanoia -v -Y --never-skip=1 -B "6-" waves/D$d.wav

Sometimes re-cleaning the disc and re-reading the offending track produces a better outcome:

d=10 ; cdparanoia -v -Y --never-skip=1 -B "5-5" waves/D$d.wav

With all the WAV files collected, I now know how to unleash multiple lame conversions for all the tracks on each disc:

for d in {01..12} ; do for t in {01..19} ; do if [[ -f waves/track$t.D$d.wav ]] ; then lame --silent --preset tape --tt "D${d}:T${t}" --ta "$author" --tl "$title" --tn $t --tg "Audio Book" --add-id3v2 waves/track${t}.D${d}.wav D${d}-T${t}.mp3  & fi ; done ; wait ; done

The disc and track ranges correspond to notes written on paper while ripping the CDs, there being no automagic way to collect the information.

That may be easier to read with the control structures spread out:

for d in {01..12}
 do for t in {01..19}
  do if [[ -f waves/track$t.D$d.wav ]]
   then
    lame --silent --preset tape --tt "D${d}:T${t}" --ta "$author" --tl "$title" --tn $t --tg "Audio Book" --add-id3v2 waves/track${t}.D${d}.wav D${d}-T${t}.mp3  &
   fi
  done
 wait
done

Affixing an ampersand (&) to the lame command drops it into the background, where it runs as CPU time becomes available. The wait after the first loop stalls until all of the lame instances for each CD finish.

The kernel scheduler manages to keep the GUI responsive while a four-core CPU makes short work of the entire CD.

When it’s all done, transfer the MP3 files to the player:

cd ..
sudo mount -o uid=ed /dev/sde1 /mnt/part
rsync -vrtu --progress --exclude="waves" "$author - $title"  /mnt/part/Music
sync
sudo umount /mnt/part

Fetching commands from history eliminates the need to remember all that, but now it’s written down where I can find it for the next desktop box.

Life is good!

Leave a comment

Wyze V2 Cameras: Xiaomi-Dafang Hacks, Round 2

Another attempt at replacing the Wyze camera firmware went much more smoothly, producing a pair of small cameras with better network manners:

Wyze Camera hacks - Cam 1 overhead workbench
Wyze Camera hacks – Cam 1 overhead workbench

That’s a VLC screen capture from the RTSP stream; obviously, I must up my clutter control game.

I formatted a 32 GB MicroSD card with a 512 MB partition, which may not be strictly necessary, copied the MicroSD CFW bootloader (as demo.bin, sheesh), and it installed without drama.

I resized the partition to 32 GB, installed the firmware (per the FAQ) into the root directory, tweaked the configuration files to match my situation, popped it in the camera, plugged the power cable, and It Just Worked™.

Herewith, a checklist of config directory files requiring tweakage:

  • wpa_supplicant – WiFi SSID and password
  • timezone.conf – America/New_York for us
  • osd.conf – can be tweaked through the Web interface
  • staticip.conf – 192.168.1.11x, as you like
  • resolve.confpihole or router IP, as needed
  • defaultgw.conf – router IP
  • rtspserver.conf – different ports for additional cameras

It would be possible to have the pihole’s DHCP server assign a fixed IP address to each camera, based on its MAC address, but this way the camera knows who it is right from the start and what it’s supposed to be doing.

The router isn’t bright enough to route different port numbers on its Internet side to different LAN IP addresses with the same port address, so each camera must stream from a different port number. I don’t plan many world-available video streams, but a friend does enjoy watching the birds during feeder season.

With the RTSP stream up & running, I flashed the U-Boot bootloader (again, minus drama) and tweaked its uEnv.txt configuration file:

  • Change the memory layout to allow 1920×1080 video
  • ethaddr – set to match hardware MAC address
  • gateway – router IP
  • ipaddr – match the staticip.conf value
  • serverip – router IP (unclear what this does)

The cameras now produce no objectionable network activity, dramatically down from the Wyze firmware’s desperate attempts to contact various servers, every five minutes, around the clock. I have no way of tracking connections made with direct dotted-quad IP addresses, rather than through the pihole, but … this is a distinct improvement.

11 Comments

Seam Ripper Cover

The cover for Mary’s favorite seam ripper cracked long ago, has been repaired several times, and now needs a replacement:

Seam Ripper cover - overview
Seam Ripper cover – overview

The first pass (at the top) matched the interior and exterior shapes, but was entirely too rigid. Unlike the Clover seam ripper, the handle has too much taper for a thick-walled piece of plastic.

The flexy thinwall cover on the ripper comes from a model of the interior shape:

Seam Ripper Cover - handle model
Seam Ripper Cover – handle model

It’s not conspicuously tapered, but OpenSCAD’s perspective view makes the taper hard to see. The wedge on top helps the slicer bridge the opening; it’s not perfect, just close enough to work.

A similar model of the outer surface is one thread width wider on all sides, so subtracting the handle model from the interior produces a single-thread shell with a wedge-shaped interior invisible in this Slic3r preview:

Seam Ripper Cover - exterior - Slic3r preview
Seam Ripper Cover – exterior – Slic3r preview

The brim around the bottom improves platform griptivity. The rounded top (because pretty) precludes building it upside-down, but if you could tolerate a square-ish top, that’s the way to go.

Both models consist of hulls around eight strategically placed spheres, with the wedge on the top of the handle due to the intersection of the hull and a suitable cube. This view shows the situation without the hull:

Seam Ripper Cover - handle model - cube intersection
Seam Ripper Cover – handle model – cube intersection

The spheres overlap, with the top set barely distinguishable, to produce the proper taper. I measured the handle and cover’s wall thicknesses, then guesstimated the cover’s interior dimensions from its outer size.

The handle’s spheres have a radius matching its curvature. The cover’s spheres have a radius exactly one thread width larger, so the difference produces the one-thread-wide shell.

Came out pretty nicely, if I do say so myself: the cover seats fully with an easy push-on fit and stays firmly in place. Best of all, should it get lost (despite the retina-burn orange PETG plastic), I can make another with nearly zero effort.

The Basement Laboratory remains winter-cool, so I taped a paper shield over the platform as insulation from the fan cooling the PETG:

Seam Ripper Cover - platform insulation
Seam Ripper Cover – platform insulation

The shield goes on after the nozzle finishes the first layer. The masking tape adhesive turned into loathesome goo and required acetone to get it off the platform; fortunately, the borosilicate glass didn’t mind.

The OpenSCAD source code as a GitHub Gist:

, , , ,

6 Comments

Desk Lamp Conversion: Photo Light Cold Shoe

Having recently acquired a pair of photo lights and desirous of eliminating some desktop clutter, I decided this ancient incandescent (!) magnifying desk lamp had outlived its usefulness:

Desk Lamp - original magnifiying head
Desk Lamp – original magnifiying head

The styrene plastic shell isn’t quite so yellowed in real life, but it’s close.

Stripping off the frippery reveals the tilt stem on the arm:

Desk Lamp - OEM mount arm
Desk Lamp – OEM mount arm

The photo lights have a tilt-pan mount intended for a camera’s cold (or hot) shoe, so I conjured an adapter from the vasty digital deep:

Photo Light Bracket for Desk Lamp Arm - solid model
Photo Light Bracket for Desk Lamp Arm – solid model

Printing with a brim improved platform griptivity:

Photo Light Bracket for Desk Lamp Arm - Slic3r preview
Photo Light Bracket for Desk Lamp Arm – Slic3r preview

Fortunately, the photo lights aren’t very heavy and shouldn’t apply too much stress to the layers across the joint between the stem and the cold shoe. Enlarging the stem perpendicular to the shoe probably didn’t make much difference, but it was easy enough.

Of course, you (well, I) always forget a detail in the first solid model, so I had to mill recesses around the screw hole to clear the centering bosses in the metal arm plates:

Photo Lamp - bracket recess milling
Photo Lamp – bracket recess milling

Which let it fit perfectly into the arm:

Desk Lamp - photo lamp mount installed
Desk Lamp – photo lamp mount installed

The grody threads on the upper surface around the end of the slot came from poor bridging across a hexagon, so the new version has a simple and tity flat end. The slot is mostly invisible with the tilt-pan adapter in place, anyway.

There being no need for a quick-disconnect fitting, a 1/4-20 button head screw locks the adapter in place:

Photo Lamp - screw detail
Photo Lamp – screw detail

I stripped the line cord from inside the arm struts and zip-tied the photo lamp’s wall wart cable to the outside:

Photo Lamp - installed
Photo Lamp – installed

And then It Just Works™:

Photo Lamp - test image
Photo Lamp – test image

The lens and its retaining clips now live in the Big Box o’ Optical parts, where it may come in handy some day.

The OpenSCAD source code as a GitHub Gist:

The original dimension doodles, made before I removed the stem and discovered the recesses around the screw hole:

Photo Light - Desk Lamp Arm Dimensions
Photo Light – Desk Lamp Arm Dimensions

,

1 Comment

Poster Boilerplate: Whoopsie

Spotted this in a lobby (clicky for more dots):

Hannaford Reusable Bags - Poster Boilerplate
Hannaford Reusable Bags – Poster Boilerplate

I know no more than you do about the situation, but I’d lay long, long odds Hannaford created the poster with a more recent version of Microsoft Word (or whatever) than the recipient organization has available, making the file essentially read-only.

Not casting shade on ’em; sometimes, you do what you gotta do.

FWIW, I’d expect LibreOffice and any Microsoft Word version other than the exact one used to create the poster to mangle the formatting differently. Been there, done that.

2 Comments