The 100 best digital picture frames on amazon
The 100 best digital picture frames on amazon
The 100 best digital picture frames on amazon
The 100 best digital picture frames on amazon

Using Sync­thing to syn­chro­nize files between your Rasp­berry Pi and Mac/PC/Linux com­put­ers

-

Some time ago, I wrote about using Resilio Sync to eas­i­ly syn­chro­nize images between your dig­i­tal pic­ture frame and your desktop/laptop. While Resilio Sync is free for basic home use, it requires a license for an advanced per­son­al ver­sion and busi­ness use.

There is one alter­na­tive that had escaped me up to now, which is Sync­thing, open-source, mul­ti-plat­­form soft­ware that has been around since 2014 and has con­sis­tent­ly been improved over time. It used to be a bit com­pli­cat­ed to install but no more!

Sync­thing is free and uses strong encryp­tion to ensure that any eaves­drop­per won't ever gain access to your data. Just like Resilio and unlike Drop­box, it doesn't store data any­where else oth­er than on your com­put­ers. There is no cen­tral cloud serv­er that might be com­pro­mised or that requires a sub­scrip­tion mod­el.

In this arti­cle, I will explain the steps to install Sync­thing on your Rasp­berry Pi and Mac.

I will then show you how to sync the images fold­er so that you can add pho­tos of your laptop/desktop and they will auto­mat­i­cal­ly show up on your dig­i­tal pic­ture frame.

About Sync­thing

Sync­thing is a file syn­chro­niza­tion pro­gram. As the authors say on their home­page "it syn­chro­nizes files between two or more com­put­ers in real-time, safe­ly pro­tect­ed from pry­ing eyes. Your data is your data alone and you deserve to choose where it is stored, whether it is shared with some third par­ty, and how it's trans­mit­ted over the inter­net."

The Sync­thing Foun­da­tion is a small reg­is­tered Swedish non-prof­it foun­da­tion that pro­vides sup­port for the infra­struc­ture required to run Sync­thing (like the syncthing.net web­site, dis­cov­ery servers and build servers). The soft­ware was orig­i­nal­ly writ­ten in 2014 by Jakob Borg, Audrius Butke­vi­cius, and Simon Frei and has since been active­ly main­tained on Github by some twen­ty core con­trib­u­tors.

It works on macOS, Microsoft Win­dows, Lin­ux, FreeB­SD, Solaris, and OpenB­SD and doesn't need IP address­es or advanced con­fig­u­ra­tion. It works across a local net­work or the Inter­net. Every machine is iden­ti­fied by an ID which you use to share a fold­er between your local or remote com­put­ers, with friends or col­leagues.

It uses for­ward secre­cy to pre­vent any eaves­drop­per from ever gain­ing access to your data, and a strong cryp­to­graph­ic cer­tifi­cate iden­ti­fies every node (=com­put­er). Only nodes that you have explic­it­ly allowed have access to your data.

On top of this, it is well main­tained and free of charge for per­son­al and busi­ness use. What's not to like?

The under­ly­ing log­ic

So how does it work? Sync­thing syn­chro­nizes fold­ers on remote devices. You know this from Drop­box, but the major dif­fer­ence is that Sync­thing does not keep any copies of your files on any servers. The files are only syn­chro­nized between the com­put­ers that you choose to con­nect to your fold­er shar­ing net­work.

As a first step, you need to install Sync­thing on every com­put­er in your net­work where you want a copy of your fold­er. So in the case of a dig­i­tal pic­ture frame, you would install it on your Rasp­berry Pi and your every­day com­put­er. You can also install it on every com­put­er in the fam­i­ly so that every­body can add images to the dig­i­tal pic­ture frame from the com­fort of their laptop/desktop.

Sec­ond­ly, you con­nect the remote devices with their Device ID.

Third­ly, you then des­ig­nate the folder(s) that you want to share on all con­nect­ed nodes (com­put­ers).

In our exam­ple, we will share the /Pictures/ourphotos fold­er which is the fold­er used by our Rasp­berry Pi image view­er to dis­play your won­der­ful images on the pic­ture frame.

Installing Sync­thing on macOS

Jump to the Down­load Page of Sync­thing, click on "sync­thing-macos" ver­sion under "Inte­gra­tions" and down­load the "Syncthing-xxx.dmg" file. Dou­ble-click file and move the app to the Appli­ca­tions fold­er - as you would with any oth­er soft­ware.

Launch the app. You will see an icon in the menu bar; there is noth­ing shown in the dock. The func­tion­al­i­ty of the app is lim­it­ed to the basic func­tion­al­i­ty, most of the set­tings are in the brows­er GUI.

At the top, you can start, pause and stop the sync process. "Open" will launch a brows­er win­dow for fur­ther set­tings. "Fold­ers" will show you which fold­ers are being synched. The rest is self-explana­­to­ry.

Select "Open" and a brows­er win­dow will come up. If you can see this, then the instal­la­tion on your Mac will have been suc­cess­ful.

On a fresh instal­la­tion, you may see a sam­ple fold­er under "Fold­ers" and no device under "Remote Devices".

You don't need to make any changes at this time. We will first set up Sync­thing on your Rasp­berry Pi.

Installing Sync­thing on Microsoft Win­dows

Jump to the Down­load Page of Sync­thing, click on Sync­Tray­zor ver­sion under "Inte­gra­tions" and fol­low the instruc­tions. As I don't have a Win­dows machine, I haven't tried this part, but I would be aston­ished if it worked much dif­fer­ent­ly than the macOS ver­sion. If it does, please let me know.

You don't need to make any changes at this time. We will first set up Sync­thing on your Rasp­berry Pi.

Installing Sync­thing on the Rasp­berry Pi

This is a bit more com­pli­cat­ed than on macOS or Win­dows but, fear not, I'll walk you through. Open a Ter­mi­nal win­dow from your laptop/desktop and con­nect to your Rasp­berry Pi with

ssh pi@ip-address-of-your-raspberrypi

Then enter these com­mands one by one

  1. curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
  2. echo "deb https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list
  3. sudo apt update
  4. sudo apt install syncthing
  5. syncthing

Sync­thing will now take a moment to set up the pro­gram, and add some files and cer­tifi­cates. It will look like this:

[monitor] 16:34:19 INFO: Default folder created and/or linked to new config
[monitor] 16:34:19 INFO: Starting syncthing
[start] 16:34:19 INFO: syncthing v1.3.3 "Fermium Flea" (go1.13.4 linux-arm) deb@build.syncthing.net 2019-12-08 12:31:26 UTC
[start] 16:34:19 INFO: Generating ECDSA key and certificate for syncthing...
[start] 16:34:19 INFO: Default folder created and/or linked to new config
[start] 16:34:19 INFO: Default config saved. Edit /home/pi/.config/syncthing/config.xml to taste (with Syncthing stopped) or use the GUI
[Z24PT] 16:34:19 INFO: My ID: Z24PTKZ-WVACAUA-VB5ETNF-P4JCZCP-AWN4JBT-XC3LQZC-WAOZ5EF-K3HY4QB
[Z24PT] 16:34:20 INFO: Single thread SHA256 performance is 18 MB/s using crypto/sha256 (18 MB/s using minio/sha256-simd).
[Z24PT] 16:34:21 INFO: Hashing performance is 17.00 MB/s
[Z24PT] 16:34:21 INFO: Overall send rate is unlimited, receive rate is unlimited
[Z24PT] 16:34:21 INFO: No stored folder metadata for "default": recalculating
[Z24PT] 16:34:21 INFO: Using discovery server https://discovery.syncthing.net/v2/?noannounce&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
[Z24PT] 16:34:21 INFO: Using discovery server https://discovery-v4.syncthing.net/v2/?nolookup&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
[Z24PT] 16:34:21 INFO: Using discovery server https://discovery-v6.syncthing.net/v2/?nolookup&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
[Z24PT] 16:34:21 INFO: QUIC listener ([::]:22000) starting
[Z24PT] 16:34:21 INFO: TCP listener ([::]:22000) starting
[Z24PT] 16:34:21 INFO: Relay listener (dynamic+https://relays.syncthing.net/endpoint) starting
[Z24PT] 16:34:21 INFO: Ready to synchronize "Default Folder" (default) (sendreceive)
[Z24PT] 16:34:21 INFO: Completed initial scan of sendreceive folder "Default Folder" (default)
[Z24PT] 16:34:21 INFO: Loading HTTPS certificate: open /home/pi/.config/syncthing/https-cert.pem: no such file or directory
[Z24PT] 16:34:21 INFO: Creating new HTTPS certificate
[Z24PT] 16:34:21 INFO: GUI and API listening on 127.0.0.1:8384
[Z24PT] 16:34:21 INFO: Access the GUI via the following URL: http://127.0.0.1:8384/
[Z24PT] 16:34:21 INFO: My name is "raspberrypi"
[Z24PT] 16:34:32 INFO: Detected 3 NAT services
[Z24PT] 16:34:40 INFO: quic://0.0.0.0:22000 detected NAT type: Port restricted NAT
[Z24PT] 16:34:40 INFO: quic://0.0.0.0:22000 resolved external address quic://93.234.249.183:63352 (via stun.syncthing.net:3478)
[Z24PT] 16:34:52 INFO: Joined relay relay://77.70.78.148:22067

When you see this last line, you can ter­mi­nate the pro­gramm with CTRL-C as it doesn't stop auto­mat­i­cal­ly.

Next, open the Sync­thing con­fig file with

sudo nano ~/.config/syncthing/config.xml

As a dig­i­tal pic­ture frame is typ­i­cal­ly con­trolled through a Ter­mi­nal win­dow from anoth­er com­put­er, we need to change the IP address from local­host to allow an exter­nal brows­er con­nec­tion. Look for the para­graph

<gui enabled="true" tls="false">
    <address>127.0.0.1:8384</address>
    <apikey>xu2Y-Ian-jVkADUWCPZxgVfBd0mQ7TDX</apikey>
</gui>

and change the "127.0.0.1" to "0.0.0.0" like this:

<gui enabled="true" tls="false">
    <address>0.0.0.0:8384</address>
    <apikey>xu2Y-Ian-jVkADUWCPZxgVfBd0mQ7TDX</apikey>
</gui>

Let's install sync­thing as a ser­vice so it is launched auto­mat­i­cal­ly at boot:

sudo wget https://raw.githubusercontent.com/syncthing/syncthing/master/etc/linux-systemd/system/syncthing%40.service \

At the arrow prompt enter:

-O /etc/systemd/user/syncthing@.service

And final­ly:

sudo systemctl enable syncthing@pi.service

Reboot your Rasp­berry Pi and wait three min­utes for sync­thing to run through the start-up sequence.

sudo reboot now

Now con­nect from your brows­er with

http://ip-of-your-raspberry-pi:8384

You will prob­a­bly see a note like this:
To get rid of this mes­sage, go into "Actions" - "Set­tings" and add a user and a pass­word.

Acti­vat­ing "Use HTTPS for GUI" would prob­a­bly make sense, but it cre­ates issues in the brows­er that you have to fig­ure out on every com­put­er. Should you have checked that box and can't get access any­more, just man­u­al­ly change back the sync­thing con­fig file to tls="false". It has to do some­thing with Sync­things cer­tifi­cates being self-signed, so it is expect­ed for them not to be trust­ed. It prob­a­bly doesn't mat­ter much to just use HTTP for our pur­pose.

Shar­ing a fold­er across devices and plat­forms

Now, that we installed Sync­thing on all devices, it's time to share a fold­er. Cre­ate a fold­er "our­pho­tos" in the Pic­tures direc­to­ry of the Rasp­berry Pi.

First, in the brows­er GUI of Sync­thing on your Rasp­berry Pi, you have to add "Remote Devices" that you want to con­nect to and on their side, this needs to be con­firmed.

If you are in a local net­work, oth­er com­put­ers will be sug­gest­ed to you, if you are con­nect­ing over the Inter­net, you will need the Device ID which you will find in the "Actions > Show ID" dia­log on the oth­er device.

Sec­ond, click on "Add fold­er". Spec­i­fy the Fold­er Path and give your fold­er a label. Do not change the Fold­er ID, it is cre­at­ed by Sync­thing.

In "Shar­ing", select your addi­tion­al devices to share this fold­er on.

Now, go back to the brows­er GUI of your oth­er com­put­er (in my case a local Mac­Book). You will see a mes­sage like this:

When you accept, this win­dow comes up:

Spec­i­fy the Fold­er Path on this com­put­er. If it doesn't exist yet, it will be cre­at­ed auto­mat­i­cal­ly. The name of this fold­er can be dif­fer­ent than the fold­er on your Rasp­berry Pi. The only thing that is impor­tant is the Fold­er ID.

That's it. Your fold­er is now shared between your Rasp­berry Pi and your local com­put­er. You can add as many oth­er com­put­ers as you want and share as many fold­ers as you like among them.

To test the fold­er shar­ing, add a few images to either your Rasp­berry Pi or your local com­put­er. Give it a few sec­onds and the files will be syn­chro­nized on both ends. Delete a file on one oth­er com­put­er, and it will be delet­ed on the oth­er one.

Con­clu­sion

There are sev­er­al Sync­thing options that you can explore in the brows­er GUI, like e.g., Ver­sion­ing where you can spec­i­fy what should hap­pen with files that have been delet­ed or replaced.

The most com­mon use case for a dig­i­tal pic­ture frame is to share the images fold­er on the frame with your fam­i­ly so that every­body can add images to it from where ever they hap­pen to be. In this case, it is prob­a­bly a good idea to add sub­di­rec­to­ries for each fam­i­ly mem­ber to the main "our­pho­tos" fold­er to make pho­to house­keep­ing eas­i­er.

Enjoy, and as always, I'd be glad to hear how this works for you!