<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://beardedmaker.com/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Beard</id>
		<title>TheBeard Science Project Wiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://beardedmaker.com/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Beard"/>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=Special:Contributions/Beard"/>
		<updated>2026-04-16T09:52:15Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.4</generator>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=Chrome/Chromium_Browser&amp;diff=3688</id>
		<title>Chrome/Chromium Browser</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=Chrome/Chromium_Browser&amp;diff=3688"/>
				<updated>2021-04-07T04:15:26Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Disable Hardware Media Key Handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Hidden Settings ==&lt;br /&gt;
&lt;br /&gt;
Type &amp;lt;b&amp;gt;&amp;lt;code&amp;gt;chrome://about&amp;lt;/code&amp;gt;&amp;lt;/b&amp;gt; into you address bar at the top to get a list of all internal pages in Chrome or Chromium browsers. These pages give you a lot of additional configurations, developer options, and information. Many of the hidden configurations can break things, so be careful!&lt;br /&gt;
&lt;br /&gt;
The major one is &amp;lt;b&amp;gt;&amp;lt;code&amp;gt;chrome://flags&amp;lt;/code&amp;gt;&amp;lt;/b&amp;gt; which has a lot of advanced configuration tweaks.&lt;br /&gt;
&lt;br /&gt;
For similar hidden configurations in other browsers, read this article: http://www.howtogeek.com/139736/how-to-change-hidden-advanced-settings-in-any-browser/&lt;br /&gt;
&lt;br /&gt;
== Disable Hardware Media Key Handling ==&lt;br /&gt;
&lt;br /&gt;
With this feature, media that is playing in Chrome will make media controls available to the Operating System, and in Windows 10 this means there will be a media control box that display on the desktop and even on the lock screen.&lt;br /&gt;
&lt;br /&gt;
To disable it, go to this link, set it to disabled, and reload Chrome:&lt;br /&gt;
[[chrome://flags/#hardware-media-key-handling]]&lt;br /&gt;
&lt;br /&gt;
Unfortunately, this also disables the nice feature of being able to use any media controls you have on your keyboard.&lt;br /&gt;
&lt;br /&gt;
== Disable &amp;quot;Use passwords saved in your Google Account&amp;quot; ==&lt;br /&gt;
&lt;br /&gt;
Load chrome://flags in the browser’s address bar.&lt;br /&gt;
# Search for “account data storage”.&lt;br /&gt;
# Set the flag “Enable the account data storage for passwords” to Disabled.&lt;br /&gt;
# Set the flag “Enable IPH for the account data storage for passwords” to Disabled.&lt;br /&gt;
# Restart Google Chrome.&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=Automatic_Email_and_Text_Notifications&amp;diff=3687</id>
		<title>Automatic Email and Text Notifications</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=Automatic_Email_and_Text_Notifications&amp;diff=3687"/>
				<updated>2021-02-26T14:15:30Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Email and Text Messaging with SSMTP */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These tutorials describe my method of automatic messaging via email and text (SMS) from my Linux servers.&lt;br /&gt;
&lt;br /&gt;
== Required Packages ==&lt;br /&gt;
&lt;br /&gt;
These packages are necessary for the all the following sections of this tutorial. In Debain, install them with &amp;lt;code&amp;gt;apt-get&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
apt-get install ssmtp procmail fetchmail&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Directory Structure ==&lt;br /&gt;
&lt;br /&gt;
Just for reference, here are the locations of the relevant files:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
/&lt;br /&gt;
├── etc&lt;br /&gt;
│   └── ssmtp&lt;br /&gt;
│       └── ssmtp.conf&lt;br /&gt;
└── scripts&lt;br /&gt;
    ├── config&lt;br /&gt;
    │   ├── accounts.conf&lt;br /&gt;
    │   ├── ddns-fetchmailrc&lt;br /&gt;
    │   └── ddns-mailprocess.sh&lt;br /&gt;
    ├── ddns.sh&lt;br /&gt;
    ├── email.sh&lt;br /&gt;
    ├── external-ip.sh&lt;br /&gt;
    ├── notifications.sh&lt;br /&gt;
    └── sms.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l /scripts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
drwxr-xr-x 4 root config   4096 Jun 20 08:52 config&lt;br /&gt;
-rwxr-xr-- 1 root root      260 Jun 20 08:40 ddns.sh&lt;br /&gt;
-rwxr-xr-- 1 root mailers   564 Apr 23 12:18 email.sh&lt;br /&gt;
-rwxr-xr-- 1 root root      529 Apr 27 07:56 external-ip.sh&lt;br /&gt;
-rwxr-xr-- 1 root root     3834 May 15 08:32 notifications.sh&lt;br /&gt;
-rwxr-xr-- 1 root texters   545 Apr 23 12:24 sms.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l /scripts/config&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
-rwxr-x--- 1 root mailers  147 May  1 13:01 accounts.conf&lt;br /&gt;
-rwx------ 1 root root     246 May 21 09:49 ddns-fetchmailrc&lt;br /&gt;
-rwxr-x--- 1 root config   604 Jun 20 08:52 ddns-mailprocess.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create Security Groups ==&lt;br /&gt;
&lt;br /&gt;
I use group membership to control read access to certain files. You don't have to do this, but it was useful for me.&lt;br /&gt;
&lt;br /&gt;
Create the groups:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
groupadd texters #allowed to sent text messages&lt;br /&gt;
groupadd mailers #allowed to send email messages&lt;br /&gt;
groupadd config  #allowed to read other config files&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can add a user to all three groups like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
usermod -aG texters,mailers,config username&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Email and Text Messaging with SSMTP ==&lt;br /&gt;
&lt;br /&gt;
First set up the &amp;lt;code&amp;gt;/etc/ssmtp/ssmtp.conf&amp;lt;/code&amp;gt;. I use a dedicated Gmail account (named &amp;lt;b&amp;gt;serveraccount@gmail.com&amp;lt;/b&amp;gt; in the example below) for all of my server messaging. When I receive an email from my server, it will look like it's coming from that Gmail.&lt;br /&gt;
&lt;br /&gt;
Make a backup copy of the original config:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.orig&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here are the contents of my modified &amp;lt;code&amp;gt;/etc/ssmtp/ssmtp.conf&amp;lt;/code&amp;gt;. Replace the relevant values.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Config file for sSMTP sendmail&lt;br /&gt;
#&lt;br /&gt;
# The person who gets all mail for userids &amp;lt; 1000&lt;br /&gt;
# Make this empty to disable rewriting.&lt;br /&gt;
root=serveraccount&lt;br /&gt;
&lt;br /&gt;
# The place where the mail goes. The actual machine name is required no&lt;br /&gt;
# MX records are consulted. Commonly mailhosts are named mail.domain.com&lt;br /&gt;
#mailhub=mail&lt;br /&gt;
&lt;br /&gt;
# Where will the mail seem to come from?&lt;br /&gt;
rewriteDomain=gmail.com&lt;br /&gt;
&lt;br /&gt;
# The full hostname&lt;br /&gt;
# This can be left as 'localhost'&lt;br /&gt;
hostname=localhost&lt;br /&gt;
&lt;br /&gt;
# Are users allowed to set their own From: address?&lt;br /&gt;
# YES - Allow the user to specify their own From: address&lt;br /&gt;
# NO - Use the system generated From: address&lt;br /&gt;
FromLineOverride=YES&lt;br /&gt;
&lt;br /&gt;
mailhub=smtp.gmail.com:587&lt;br /&gt;
UseStartTLS=YES&lt;br /&gt;
UseTLS=YES&lt;br /&gt;
AuthMethod=LOGIN&lt;br /&gt;
AuthUser=serveraccount@gmail.com&lt;br /&gt;
AuthPass=InsertPasswordHere&lt;br /&gt;
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt&lt;br /&gt;
FromLineOverride=YES&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the file contains a password, make sure the file is not readable to normal users.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mail /etc/ssmtp/ssmtp.conf&lt;br /&gt;
chmod 640 /etc/ssmtp/ssmtp.conf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And because you don't have to remember this password, it would be a good idea to make it very long and complex (16+ characters; uppercase, lowercase, numbers, and special characters; no dictionary words).&lt;br /&gt;
&lt;br /&gt;
You now need to log onto the &amp;lt;b&amp;gt;serveraccount&amp;lt;/b&amp;gt; Gmail account and enable &amp;quot;less secure apps&amp;quot; at https://myaccount.google.com/lesssecureapps?pli=1 &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Gmail-less-secure-app.png|frameless|600px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Here is more info about less secure apps: https://support.google.com/cloudidentity/answer/6260879?hl=en&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should now be able use the &amp;lt;code&amp;gt;ssmtp&amp;lt;/code&amp;gt; command line tool from your server. Most of the time, you will need to include a subject line. It's important that it follows the format below (capital 'S' on Subject, colon, space, YourSubject, two newlines):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo -e &amp;quot;Subject: Hi\n\nHello, world!&amp;quot; | ssmtp myaccount@yahoo.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a Secure Accounts File ==&lt;br /&gt;
&lt;br /&gt;
For some of the automatic messaging, you need to store text and email accounts in a file. To figure out the destination address to send text (SMS) messages to your cell, look on your cell provider's website for the proper account/domain name. It will probably be something like &amp;quot;&amp;lt;your-phone-number&amp;gt;@&amp;lt;provider-domain&amp;gt;&amp;quot;. [https://kb.sandisk.com/app/answers/detail/a_id/17056/~/list-of-mobile-carrier-gateway-addresses List of provider addresses]&lt;br /&gt;
&lt;br /&gt;
Contents of my &amp;lt;code&amp;gt;/scripts/config/accounts.conf&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# Secure account information&lt;br /&gt;
# Permissions must be 750 root:mailers&lt;br /&gt;
&lt;br /&gt;
smsto=&amp;quot;17775551234@myprovider.net&amp;quot;&lt;br /&gt;
mailto=&amp;quot;myaccount@yahoo.com&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the permissions on the file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mailers /scripts/config/accounts.conf&lt;br /&gt;
chmod 750 /scripts/config/accounts.conf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Email Script ==&lt;br /&gt;
&lt;br /&gt;
This script can be used to send an email message.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/email.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# Send email message:&lt;br /&gt;
#  Usage: $0 &amp;quot;&amp;lt;Subject&amp;gt;&amp;quot; &amp;quot;&amp;lt;Message&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
default_subject=&amp;quot;Alert from Server (`date`)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
subject=&amp;quot;&amp;quot;&lt;br /&gt;
message=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
case $# in&lt;br /&gt;
  2)&lt;br /&gt;
    subject=&amp;quot;$1&amp;quot;&lt;br /&gt;
    message=&amp;quot;$2&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  1)&lt;br /&gt;
    subject=&amp;quot;$default_subject&amp;quot;&lt;br /&gt;
    message=&amp;quot;$1&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  *)&lt;br /&gt;
    echo &amp;quot;Send Email Message:&amp;quot;&lt;br /&gt;
    echo &amp;quot;  Usage: `basename $0` \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    echo &amp;quot;         `basename $0` \&amp;quot;Subject\&amp;quot; \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
  ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
dir=&amp;quot;$(cd $(dirname ${BASH_SOURCE[0]})&amp;amp;&amp;amp;pwd)&amp;quot;&lt;br /&gt;
. $dir/config/accounts.conf&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;Subject: $subject\n\n$message&amp;quot; | /usr/sbin/ssmtp $mailto&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mailers /scripts/email.sh&lt;br /&gt;
chmod 754 /scripts/email.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create an alias so you can quickly run this from the command line:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo &amp;quot;alias email='/scripts/email.sh'&amp;quot; &amp;gt;&amp;gt;~/.bashrc&lt;br /&gt;
source ~/.bashrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Send message with default subject&lt;br /&gt;
email &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Send message with a subject&lt;br /&gt;
email &amp;quot;Test Subject&amp;quot; &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Text Script ==&lt;br /&gt;
&lt;br /&gt;
This script can be used to send a text (SMS) message.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/sms.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# Send SMS message:&lt;br /&gt;
#  Usage: $0 &amp;quot;&amp;lt;Subject&amp;gt;&amp;quot; &amp;quot;&amp;lt;Message&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
default_subject=&amp;quot;Alert&amp;quot;&lt;br /&gt;
&lt;br /&gt;
subject=&amp;quot;&amp;quot;&lt;br /&gt;
message=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
case $# in&lt;br /&gt;
  2)&lt;br /&gt;
    subject=&amp;quot;$1&amp;quot;&lt;br /&gt;
    message=&amp;quot;$2&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  1)&lt;br /&gt;
    subject=&amp;quot;$default_subject&amp;quot;&lt;br /&gt;
    message=&amp;quot;$1&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  *)&lt;br /&gt;
    echo &amp;quot;Send SMS Message:&amp;quot;&lt;br /&gt;
    echo &amp;quot;  Usage: `basename $0` \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    echo &amp;quot;         `basename $0` \&amp;quot;Subject\&amp;quot; \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
  ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
dir=&amp;quot;$(cd $(dirname ${BASH_SOURCE[0]})&amp;amp;&amp;amp;pwd)&amp;quot;&lt;br /&gt;
. $dir/config/accounts.conf&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;To: $smsto\nSubject: $subject\n\n$message&amp;quot; | /usr/sbin/ssmtp $smsto&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:texters /scripts/sms.sh&lt;br /&gt;
chmod 754 /scripts/sms.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create an alias so you can quickly run this from the command line:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo &amp;quot;alias sms='/scripts/sms.sh'&amp;quot; &amp;gt;&amp;gt;~/.bashrc&lt;br /&gt;
source ~/.bashrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Send message with default subject&lt;br /&gt;
sms &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Send message with a subject&lt;br /&gt;
sms &amp;quot;Test Subject&amp;quot; &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scheduled Notifications Script ==&lt;br /&gt;
&lt;br /&gt;
One of my life improvement tasks was to organize chores into scheduled chore days and rely on text/email notification to remind me to do them.&lt;br /&gt;
&lt;br /&gt;
This dramatically reduced the amount of time I spend working on chores, and the amount of effort I spend thinking about what needs to be done. I could barely get projects done because every day I was loading my task list with chores. Now I don't think about chores until I'm notified. When I think of new chores, new items for my inventory, or other things I need to be reminded of, I update my checklists. When I feel I can improve scheduling or consolidate chores, I update my notifications script.&lt;br /&gt;
&lt;br /&gt;
This utilizes the &amp;lt;b&amp;gt;Email Script&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;Text Script&amp;lt;/b&amp;gt; from the previous sections.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/notifications.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# Send regular notifications.&lt;br /&gt;
# Currently set to run daily at NOON.&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
# Get current datetime values&lt;br /&gt;
dt=(`date +%Y\ %m\ %d\ %H\ %M\ %S\ %a\ %s\ %I\ %p\ %Z`)&lt;br /&gt;
y=$((10#${dt[0]})) #year&lt;br /&gt;
M=$((10#${dt[1]})) #month&lt;br /&gt;
d=$((10#${dt[2]})) #day&lt;br /&gt;
h=$((10#${dt[3]})) #hour(24)&lt;br /&gt;
m=$((10#${dt[4]})) #minute&lt;br /&gt;
s=$((10#${dt[5]})) #second&lt;br /&gt;
w=${dt[6]}         #day of week (eg. Sun)&lt;br /&gt;
e=$((10#${dt[7]})) #epoch&lt;br /&gt;
t=$((10#${dt[8]})) #hour(12)&lt;br /&gt;
p=${dt[9]}         #meridian (AM/PM)&lt;br /&gt;
z=${dt[10]}        #timezone (eg. PDT)&lt;br /&gt;
&lt;br /&gt;
# Schedule command when date ($1) matched regex ($2) with extra grep parameters ($3)&lt;br /&gt;
# Use parameter -P at $3 for perl regex: in case you need to use (str1|str2).&lt;br /&gt;
# Example: schedule $M$d &amp;quot;(115|21)&amp;quot; -P &amp;amp;&amp;amp; sms &amp;quot;Subject&amp;quot; &amp;quot;Message&amp;quot;&lt;br /&gt;
# Don't use -P when you want a range of numbers including 2 or more digit numbers (ie. [1-15]).&lt;br /&gt;
schedule(){ echo &amp;quot;$1&amp;quot; | grep -wq $3 &amp;quot;$2&amp;quot;;}&lt;br /&gt;
sms(){ /scripts/sms.sh &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
eml(){ /scripts/email.sh &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
notify(){ sms &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;eml &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# ==== Temporary Notifications ====&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# Dentist appointment&lt;br /&gt;
#schedule $M$d &amp;quot;58&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Dentist&amp;quot; &amp;quot;Appointment 4:00pm 10/31/2017&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# ====== Chore Notifications ======&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# LAUNDRY DAY&lt;br /&gt;
# Day before&lt;br /&gt;
schedule $w$d &amp;quot;Mon[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;LAUNDRY DAY&amp;quot; &amp;quot;WORK: Check gas. HOME: Do laundry, put laundry away.&amp;quot;&lt;br /&gt;
schedule $w$d &amp;quot;Mon(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;LAUNDRY DAY&amp;quot; &amp;quot;WORK: Check gas. HOME: Do laundry, put laundry away.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# WEEKLY CLEANING DAY&lt;br /&gt;
schedule $w &amp;quot;Tue&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;WEEKLY CLEANING DAY&amp;quot; &amp;quot;WORK: Fill gas, shopping. HOME: Clean, litter, sweep/vac, fridge, trash, check meds.&amp;quot;&lt;br /&gt;
# Day after&lt;br /&gt;
schedule $w &amp;quot;Wed&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;WEEKLY REMINDER&amp;quot; &amp;quot;Order meds if necessary.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# MONTHLY CLEANING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Tue[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;MONTHLY CLEANING DAY&amp;quot; &amp;quot;WORK: Car stuff. HOME: Dishes, kitchen, bathroom, dust, inventory.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# BUSINESS DAY&lt;br /&gt;
schedule $d &amp;quot;[1-4]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;BUSINESS DAY&amp;quot; &amp;quot;Rent due before 5th (\$720). Fedloan, budgeting, donations, next-buy.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# TECH DAY&lt;br /&gt;
schedule $w$d &amp;quot;Mon[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;TECH DAY&amp;quot; &amp;quot;WORK: Updates, phone, healthcheck, security scan, organize files. HOME: Organize Workstation/Laptop, USB drives.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# SHOPPING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Wed[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;SHOPPING DAY&amp;quot; &amp;quot;Shopping, carwash. Maybe do during lunch.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# GROOMING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Sun[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;GROOMING DAY&amp;quot; &amp;quot;Shave/trim, clip nails.&amp;quot;&lt;br /&gt;
schedule $w$d &amp;quot;Sun(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;GROOMING DAY&amp;quot; &amp;quot;Shave/trim, clip nails.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ELIMINATION DAY&lt;br /&gt;
schedule $w$d &amp;quot;Sun(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;ELIMINATION DAY&amp;quot; &amp;quot;Do at least one item on TO_ELIMINATE list.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# INVENTORY DAY&lt;br /&gt;
# Disabled. Inventory is now included in monthly cleaning day.&lt;br /&gt;
# schedule $w$d &amp;quot;Tue[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;INVENTORY DAY&amp;quot; &amp;quot;Do home, car, and office inventory.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# = Other Permanent Notifications =&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# Air filter replacement notifications&lt;br /&gt;
schedule $M$d &amp;quot;71&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Air Filter&amp;quot; &amp;quot;Holmes HAP726: Replace HEPA filters (model:HAPF600,qty:2)&amp;quot;&lt;br /&gt;
schedule $M$d &amp;quot;[1|7]1&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Air Filter&amp;quot; &amp;quot;Holmes HAP726: Replace Carbon filters (model:HAPF600,qty:2)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now set the permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:root /scripts/external-ip.sh&lt;br /&gt;
chmod 754 /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reporting External IP Address ==&lt;br /&gt;
&lt;br /&gt;
My home server does not have a static IP address, so I use dynamic DNS. With my free DDNS service, I have to renew the domain name every 30 days. So if I forget to renew it, it will expire and I won't be able to access my server unless I know the IP address. As a contingency, I created a script that sends my external IP address to an email account every 6 hours. Then at least I would be able find out what my last IP was and use that to access my server.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/external-ip.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
log=&amp;quot;/var/log/external-ip.log&amp;quot;&lt;br /&gt;
ipsrc=&amp;quot;http://checkip.dyndns.org&amp;quot;&lt;br /&gt;
date=&amp;quot;`date`&amp;quot;&lt;br /&gt;
addr=&amp;quot;myaccount@yahoo.com&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ip=`curl -s --connect-timeout 3 $ipsrc 2&amp;gt;/dev/null|grep -Po &amp;quot;Current IP Address: .*?\&amp;lt;&amp;quot;|tr '&amp;lt;' '\0'`&lt;br /&gt;
echo &amp;quot;IP: $ip&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if [ -z &amp;quot;$ip&amp;quot; ];then&lt;br /&gt;
	echo &amp;quot;$date ERROR: Could not get external IP from $ipsrc&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
else&lt;br /&gt;
	echo -e &amp;quot;Subject:[`hostname`] $date $ip&amp;quot; | /usr/sbin/ssmtp $addr&lt;br /&gt;
	if [ &amp;quot;$?&amp;quot; = &amp;quot;0&amp;quot; ];then&lt;br /&gt;
		echo &amp;quot;$date SUCCESS: $ip sent to $addr&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
	else&lt;br /&gt;
		echo &amp;quot;$date ERROR: Could not send to $addr&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
	fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now set the permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:root /scripts/external-ip.sh&lt;br /&gt;
chmod 754 /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script appends to a log file &amp;lt;code&amp;gt;/var/log/external-ip.log&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
touch /var/log/external-ip.log&lt;br /&gt;
chown root:root /var/log/external-ip.log&lt;br /&gt;
chmod 644 /var/log/external-ip.log&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Automatic Email Download ==&lt;br /&gt;
&lt;br /&gt;
As mentioned in a previous section, I use free dynamic DNS which requires that I renew it manually every 30 days. I need to remind myself to do this. My provider sends an email notification a few days before it expires, but I hate email and I don't want it in my face all the time, certainly not in my phone.&lt;br /&gt;
&lt;br /&gt;
The best solution I found was to retrieve the email automatically and send me a text message with only the subject line in the message. I eventually created a second method of notification: it generates a file in a place that I regularly go, the folder that contains all of my to-do lists.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/ddns.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# This script is run by a cron job.&lt;br /&gt;
&lt;br /&gt;
/usr/bin/fetchmail -N -d0 -f &amp;quot;/scripts/config/ddns-fetchmailrc&amp;quot; -m &amp;quot;/scripts/config/ddns-mailprocess.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
alertfile=&amp;quot;/shares/Private/000__DDNS-ALERT__.txt&amp;quot;&lt;br /&gt;
if [ -e $alertfile ];then&lt;br /&gt;
	chown root:root $alertfile&lt;br /&gt;
	chmod 777 $alertfile&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/config/ddns-mailprocess.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# This script is run by /scripts/ddns.sh&lt;br /&gt;
&lt;br /&gt;
mailto=&amp;quot;17775551234@myprovider.net&amp;quot;&lt;br /&gt;
date=&amp;quot;`date`&amp;quot;&lt;br /&gt;
log=&amp;quot;/var/log/ddns.log&amp;quot;&lt;br /&gt;
alertfile=&amp;quot;/shares/Private/000__DDNS-ALERT__.txt&amp;quot;&lt;br /&gt;
sms=&amp;quot;/scripts/sms.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cat /dev/stdin | grep -i &amp;quot;^Subject:&amp;quot; | sed 's/Subject\://g' | $sms &amp;quot;DDNS&amp;quot; &amp;quot;`cat /dev/stdin` ( $date )&amp;quot; &amp;amp;&amp;amp;\&lt;br /&gt;
echo &amp;quot;$date - DDNS notification sent to $mailto&amp;quot; | tee -a $log | sed &amp;quot;s/$mailto/cell\ phone/g&amp;quot; &amp;gt;$alertfile &amp;amp;&amp;amp;\&lt;br /&gt;
chmod 777 $alertfile&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/config/ddns-fetchmailrc&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# This rc file is run by /scripts/ddns.sh&lt;br /&gt;
# This file MUST have root:root and chmod 700&lt;br /&gt;
&lt;br /&gt;
set postmaster &amp;quot;username&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
poll &amp;quot;imap.mail.yahoo.com&amp;quot; protocol IMAP username &amp;quot;myaccount@yahoo.com&amp;quot; password &amp;quot;InsertPasswordHere&amp;quot; is &amp;quot;username&amp;quot; here keep folder &amp;quot;DDNS-Mailbox&amp;quot; ssl&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
UPDATE February 2021: Yahoo now requires you to create a &amp;lt;b&amp;gt;secure app password&amp;lt;/b&amp;gt;. See [[#yahoo-app-pass|this section]].&lt;br /&gt;
&lt;br /&gt;
You'll notice that it creates a file &amp;lt;code&amp;gt;/shares/Private/000__DDNS-ALERT__.txt&amp;lt;/code&amp;gt;. The &amp;quot;000&amp;quot; is just to put it at the top of the directory listing. Also notice that I make it read-write for everyone so I can delete it from my webapp.&lt;br /&gt;
&lt;br /&gt;
Set up permissions on all three files, and create the log file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
touch /var/log/ddns.log&lt;br /&gt;
chown root:root /var/log/ddns.log&lt;br /&gt;
chmod 640 /var/log/ddns.log&lt;br /&gt;
&lt;br /&gt;
chown root:root /scripts/ddns.sh&lt;br /&gt;
chmod 754 /scripts/ddns.sh&lt;br /&gt;
&lt;br /&gt;
chown root:config /scripts/config/ddns-mailprocess.sh&lt;br /&gt;
chmod 750 /scripts/config/ddns-mailprocess.sh&lt;br /&gt;
&lt;br /&gt;
chown root:root /scripts/config/ddns-fetchmailrc&lt;br /&gt;
chmod 700 /scripts/config/ddns-fetchmailrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you run &amp;lt;code&amp;gt;ddns.sh&amp;lt;/code&amp;gt; as root it gives you a warning about running as root. This is okay.&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
fetchmail: WARNING: Running as root is discouraged.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If permissions on &amp;lt;code&amp;gt;ddns-fetchmailrc&amp;lt;/code&amp;gt; are not correct, you will get this failure message:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
File /scripts/config/ddns-fetchmailrc must have no more than -rwx------ (0700) permissions.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set Up Cron ==&lt;br /&gt;
&lt;br /&gt;
Just for reference, here are the entries I made in my &amp;lt;code&amp;gt;/etc/crontab&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Crontabs to be run without 'run-parts'&lt;br /&gt;
#&lt;br /&gt;
# RUN AT NOON&lt;br /&gt;
0                  12           * * *   root    /scripts/ddns.sh&lt;br /&gt;
0                  12           * * *   root    /scripts/notifications.sh&lt;br /&gt;
# RUN EVERY 6 HOURS&lt;br /&gt;
1                  0,6,12,18    * * *   root    /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;yahoo-app-pass&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt;Yahoo App Password ==&lt;br /&gt;
&lt;br /&gt;
As of February 2021, Yahoo changed that way third party apps can access it. Instead of using your normal password, you need to generate an &amp;lt;b&amp;gt;app password&amp;lt;/b&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Login to Yahoo, click you user icon, and click &amp;lt;b&amp;gt;Account Info&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click &amp;lt;b&amp;gt;Account Security&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click &amp;lt;b&amp;gt;Manage app passwords&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click the &amp;lt;b&amp;gt;Select your app&amp;lt;/b&amp;gt; drop-down and select &amp;lt;b&amp;gt;Other app&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Type a name for the app then click &amp;lt;b&amp;gt;Generate&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Now you can copy the password and use it in your app. Once you navigate away from this page, you will not be able to retrieve the password again. You will have to generate another password.&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=Automatic_Email_and_Text_Notifications&amp;diff=3686</id>
		<title>Automatic Email and Text Notifications</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=Automatic_Email_and_Text_Notifications&amp;diff=3686"/>
				<updated>2021-02-26T14:14:55Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Email and Text Messaging with SSMTP */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These tutorials describe my method of automatic messaging via email and text (SMS) from my Linux servers.&lt;br /&gt;
&lt;br /&gt;
== Required Packages ==&lt;br /&gt;
&lt;br /&gt;
These packages are necessary for the all the following sections of this tutorial. In Debain, install them with &amp;lt;code&amp;gt;apt-get&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
apt-get install ssmtp procmail fetchmail&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Directory Structure ==&lt;br /&gt;
&lt;br /&gt;
Just for reference, here are the locations of the relevant files:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
/&lt;br /&gt;
├── etc&lt;br /&gt;
│   └── ssmtp&lt;br /&gt;
│       └── ssmtp.conf&lt;br /&gt;
└── scripts&lt;br /&gt;
    ├── config&lt;br /&gt;
    │   ├── accounts.conf&lt;br /&gt;
    │   ├── ddns-fetchmailrc&lt;br /&gt;
    │   └── ddns-mailprocess.sh&lt;br /&gt;
    ├── ddns.sh&lt;br /&gt;
    ├── email.sh&lt;br /&gt;
    ├── external-ip.sh&lt;br /&gt;
    ├── notifications.sh&lt;br /&gt;
    └── sms.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l /scripts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
drwxr-xr-x 4 root config   4096 Jun 20 08:52 config&lt;br /&gt;
-rwxr-xr-- 1 root root      260 Jun 20 08:40 ddns.sh&lt;br /&gt;
-rwxr-xr-- 1 root mailers   564 Apr 23 12:18 email.sh&lt;br /&gt;
-rwxr-xr-- 1 root root      529 Apr 27 07:56 external-ip.sh&lt;br /&gt;
-rwxr-xr-- 1 root root     3834 May 15 08:32 notifications.sh&lt;br /&gt;
-rwxr-xr-- 1 root texters   545 Apr 23 12:24 sms.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l /scripts/config&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
-rwxr-x--- 1 root mailers  147 May  1 13:01 accounts.conf&lt;br /&gt;
-rwx------ 1 root root     246 May 21 09:49 ddns-fetchmailrc&lt;br /&gt;
-rwxr-x--- 1 root config   604 Jun 20 08:52 ddns-mailprocess.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create Security Groups ==&lt;br /&gt;
&lt;br /&gt;
I use group membership to control read access to certain files. You don't have to do this, but it was useful for me.&lt;br /&gt;
&lt;br /&gt;
Create the groups:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
groupadd texters #allowed to sent text messages&lt;br /&gt;
groupadd mailers #allowed to send email messages&lt;br /&gt;
groupadd config  #allowed to read other config files&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can add a user to all three groups like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
usermod -aG texters,mailers,config username&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Email and Text Messaging with SSMTP ==&lt;br /&gt;
&lt;br /&gt;
First set up the &amp;lt;code&amp;gt;/etc/ssmtp/ssmtp.conf&amp;lt;/code&amp;gt;. I use a dedicated Gmail account (named &amp;lt;b&amp;gt;serveraccount@gmail.com&amp;lt;/b&amp;gt; in the example below) for all of my server messaging. When I receive an email from my server, it will look like it's coming from that Gmail.&lt;br /&gt;
&lt;br /&gt;
Make a backup copy of the original config:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.orig&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here are the contents of my modified &amp;lt;code&amp;gt;/etc/ssmtp/ssmtp.conf&amp;lt;/code&amp;gt;. Replace the relevant values.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Config file for sSMTP sendmail&lt;br /&gt;
#&lt;br /&gt;
# The person who gets all mail for userids &amp;lt; 1000&lt;br /&gt;
# Make this empty to disable rewriting.&lt;br /&gt;
root=serveraccount&lt;br /&gt;
&lt;br /&gt;
# The place where the mail goes. The actual machine name is required no&lt;br /&gt;
# MX records are consulted. Commonly mailhosts are named mail.domain.com&lt;br /&gt;
#mailhub=mail&lt;br /&gt;
&lt;br /&gt;
# Where will the mail seem to come from?&lt;br /&gt;
rewriteDomain=gmail.com&lt;br /&gt;
&lt;br /&gt;
# The full hostname&lt;br /&gt;
# This can be left as 'localhost'&lt;br /&gt;
hostname=localhost&lt;br /&gt;
&lt;br /&gt;
# Are users allowed to set their own From: address?&lt;br /&gt;
# YES - Allow the user to specify their own From: address&lt;br /&gt;
# NO - Use the system generated From: address&lt;br /&gt;
FromLineOverride=YES&lt;br /&gt;
&lt;br /&gt;
mailhub=smtp.gmail.com:587&lt;br /&gt;
UseStartTLS=YES&lt;br /&gt;
UseTLS=YES&lt;br /&gt;
AuthMethod=LOGIN&lt;br /&gt;
AuthUser=serveraccount@gmail.com&lt;br /&gt;
AuthPass=InsertPasswordHere&lt;br /&gt;
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt&lt;br /&gt;
FromLineOverride=YES&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the file contains a password, make sure the file is not readable to normal users.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mail /etc/ssmtp/ssmtp.conf&lt;br /&gt;
chmod 640 /etc/ssmtp/ssmtp.conf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And because you don't have to remember this password, it would be a good idea to make it very long and complex (16+ characters; uppercase, lowercase, numbers, and special characters; no dictionary words).&lt;br /&gt;
&lt;br /&gt;
You now need to log onto the &amp;lt;b&amp;gt;serveraccount&amp;lt;/b&amp;gt; Gmail account and enable &amp;quot;less secure apps&amp;quot; at https://myaccount.google.com/lesssecureapps?pli=1 &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Gmail-less-secure-app.png|frameless|600px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Here is more info about less secure apps: https://support.google.com/cloudidentity/answer/6260879?hl=en&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using Yahoo, see [[#yahoo-app-pass|this section]].&lt;br /&gt;
&lt;br /&gt;
You should now be able use the &amp;lt;code&amp;gt;ssmtp&amp;lt;/code&amp;gt; command line tool from your server. Most of the time, you will need to include a subject line. It's important that it follows the format below (capital 'S' on Subject, colon, space, YourSubject, two newlines):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo -e &amp;quot;Subject: Hi\n\nHello, world!&amp;quot; | ssmtp myaccount@yahoo.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a Secure Accounts File ==&lt;br /&gt;
&lt;br /&gt;
For some of the automatic messaging, you need to store text and email accounts in a file. To figure out the destination address to send text (SMS) messages to your cell, look on your cell provider's website for the proper account/domain name. It will probably be something like &amp;quot;&amp;lt;your-phone-number&amp;gt;@&amp;lt;provider-domain&amp;gt;&amp;quot;. [https://kb.sandisk.com/app/answers/detail/a_id/17056/~/list-of-mobile-carrier-gateway-addresses List of provider addresses]&lt;br /&gt;
&lt;br /&gt;
Contents of my &amp;lt;code&amp;gt;/scripts/config/accounts.conf&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# Secure account information&lt;br /&gt;
# Permissions must be 750 root:mailers&lt;br /&gt;
&lt;br /&gt;
smsto=&amp;quot;17775551234@myprovider.net&amp;quot;&lt;br /&gt;
mailto=&amp;quot;myaccount@yahoo.com&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the permissions on the file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mailers /scripts/config/accounts.conf&lt;br /&gt;
chmod 750 /scripts/config/accounts.conf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Email Script ==&lt;br /&gt;
&lt;br /&gt;
This script can be used to send an email message.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/email.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# Send email message:&lt;br /&gt;
#  Usage: $0 &amp;quot;&amp;lt;Subject&amp;gt;&amp;quot; &amp;quot;&amp;lt;Message&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
default_subject=&amp;quot;Alert from Server (`date`)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
subject=&amp;quot;&amp;quot;&lt;br /&gt;
message=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
case $# in&lt;br /&gt;
  2)&lt;br /&gt;
    subject=&amp;quot;$1&amp;quot;&lt;br /&gt;
    message=&amp;quot;$2&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  1)&lt;br /&gt;
    subject=&amp;quot;$default_subject&amp;quot;&lt;br /&gt;
    message=&amp;quot;$1&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  *)&lt;br /&gt;
    echo &amp;quot;Send Email Message:&amp;quot;&lt;br /&gt;
    echo &amp;quot;  Usage: `basename $0` \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    echo &amp;quot;         `basename $0` \&amp;quot;Subject\&amp;quot; \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
  ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
dir=&amp;quot;$(cd $(dirname ${BASH_SOURCE[0]})&amp;amp;&amp;amp;pwd)&amp;quot;&lt;br /&gt;
. $dir/config/accounts.conf&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;Subject: $subject\n\n$message&amp;quot; | /usr/sbin/ssmtp $mailto&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mailers /scripts/email.sh&lt;br /&gt;
chmod 754 /scripts/email.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create an alias so you can quickly run this from the command line:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo &amp;quot;alias email='/scripts/email.sh'&amp;quot; &amp;gt;&amp;gt;~/.bashrc&lt;br /&gt;
source ~/.bashrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Send message with default subject&lt;br /&gt;
email &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Send message with a subject&lt;br /&gt;
email &amp;quot;Test Subject&amp;quot; &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Text Script ==&lt;br /&gt;
&lt;br /&gt;
This script can be used to send a text (SMS) message.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/sms.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# Send SMS message:&lt;br /&gt;
#  Usage: $0 &amp;quot;&amp;lt;Subject&amp;gt;&amp;quot; &amp;quot;&amp;lt;Message&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
default_subject=&amp;quot;Alert&amp;quot;&lt;br /&gt;
&lt;br /&gt;
subject=&amp;quot;&amp;quot;&lt;br /&gt;
message=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
case $# in&lt;br /&gt;
  2)&lt;br /&gt;
    subject=&amp;quot;$1&amp;quot;&lt;br /&gt;
    message=&amp;quot;$2&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  1)&lt;br /&gt;
    subject=&amp;quot;$default_subject&amp;quot;&lt;br /&gt;
    message=&amp;quot;$1&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  *)&lt;br /&gt;
    echo &amp;quot;Send SMS Message:&amp;quot;&lt;br /&gt;
    echo &amp;quot;  Usage: `basename $0` \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    echo &amp;quot;         `basename $0` \&amp;quot;Subject\&amp;quot; \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
  ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
dir=&amp;quot;$(cd $(dirname ${BASH_SOURCE[0]})&amp;amp;&amp;amp;pwd)&amp;quot;&lt;br /&gt;
. $dir/config/accounts.conf&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;To: $smsto\nSubject: $subject\n\n$message&amp;quot; | /usr/sbin/ssmtp $smsto&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:texters /scripts/sms.sh&lt;br /&gt;
chmod 754 /scripts/sms.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create an alias so you can quickly run this from the command line:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo &amp;quot;alias sms='/scripts/sms.sh'&amp;quot; &amp;gt;&amp;gt;~/.bashrc&lt;br /&gt;
source ~/.bashrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Send message with default subject&lt;br /&gt;
sms &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Send message with a subject&lt;br /&gt;
sms &amp;quot;Test Subject&amp;quot; &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scheduled Notifications Script ==&lt;br /&gt;
&lt;br /&gt;
One of my life improvement tasks was to organize chores into scheduled chore days and rely on text/email notification to remind me to do them.&lt;br /&gt;
&lt;br /&gt;
This dramatically reduced the amount of time I spend working on chores, and the amount of effort I spend thinking about what needs to be done. I could barely get projects done because every day I was loading my task list with chores. Now I don't think about chores until I'm notified. When I think of new chores, new items for my inventory, or other things I need to be reminded of, I update my checklists. When I feel I can improve scheduling or consolidate chores, I update my notifications script.&lt;br /&gt;
&lt;br /&gt;
This utilizes the &amp;lt;b&amp;gt;Email Script&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;Text Script&amp;lt;/b&amp;gt; from the previous sections.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/notifications.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# Send regular notifications.&lt;br /&gt;
# Currently set to run daily at NOON.&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
# Get current datetime values&lt;br /&gt;
dt=(`date +%Y\ %m\ %d\ %H\ %M\ %S\ %a\ %s\ %I\ %p\ %Z`)&lt;br /&gt;
y=$((10#${dt[0]})) #year&lt;br /&gt;
M=$((10#${dt[1]})) #month&lt;br /&gt;
d=$((10#${dt[2]})) #day&lt;br /&gt;
h=$((10#${dt[3]})) #hour(24)&lt;br /&gt;
m=$((10#${dt[4]})) #minute&lt;br /&gt;
s=$((10#${dt[5]})) #second&lt;br /&gt;
w=${dt[6]}         #day of week (eg. Sun)&lt;br /&gt;
e=$((10#${dt[7]})) #epoch&lt;br /&gt;
t=$((10#${dt[8]})) #hour(12)&lt;br /&gt;
p=${dt[9]}         #meridian (AM/PM)&lt;br /&gt;
z=${dt[10]}        #timezone (eg. PDT)&lt;br /&gt;
&lt;br /&gt;
# Schedule command when date ($1) matched regex ($2) with extra grep parameters ($3)&lt;br /&gt;
# Use parameter -P at $3 for perl regex: in case you need to use (str1|str2).&lt;br /&gt;
# Example: schedule $M$d &amp;quot;(115|21)&amp;quot; -P &amp;amp;&amp;amp; sms &amp;quot;Subject&amp;quot; &amp;quot;Message&amp;quot;&lt;br /&gt;
# Don't use -P when you want a range of numbers including 2 or more digit numbers (ie. [1-15]).&lt;br /&gt;
schedule(){ echo &amp;quot;$1&amp;quot; | grep -wq $3 &amp;quot;$2&amp;quot;;}&lt;br /&gt;
sms(){ /scripts/sms.sh &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
eml(){ /scripts/email.sh &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
notify(){ sms &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;eml &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# ==== Temporary Notifications ====&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# Dentist appointment&lt;br /&gt;
#schedule $M$d &amp;quot;58&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Dentist&amp;quot; &amp;quot;Appointment 4:00pm 10/31/2017&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# ====== Chore Notifications ======&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# LAUNDRY DAY&lt;br /&gt;
# Day before&lt;br /&gt;
schedule $w$d &amp;quot;Mon[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;LAUNDRY DAY&amp;quot; &amp;quot;WORK: Check gas. HOME: Do laundry, put laundry away.&amp;quot;&lt;br /&gt;
schedule $w$d &amp;quot;Mon(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;LAUNDRY DAY&amp;quot; &amp;quot;WORK: Check gas. HOME: Do laundry, put laundry away.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# WEEKLY CLEANING DAY&lt;br /&gt;
schedule $w &amp;quot;Tue&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;WEEKLY CLEANING DAY&amp;quot; &amp;quot;WORK: Fill gas, shopping. HOME: Clean, litter, sweep/vac, fridge, trash, check meds.&amp;quot;&lt;br /&gt;
# Day after&lt;br /&gt;
schedule $w &amp;quot;Wed&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;WEEKLY REMINDER&amp;quot; &amp;quot;Order meds if necessary.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# MONTHLY CLEANING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Tue[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;MONTHLY CLEANING DAY&amp;quot; &amp;quot;WORK: Car stuff. HOME: Dishes, kitchen, bathroom, dust, inventory.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# BUSINESS DAY&lt;br /&gt;
schedule $d &amp;quot;[1-4]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;BUSINESS DAY&amp;quot; &amp;quot;Rent due before 5th (\$720). Fedloan, budgeting, donations, next-buy.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# TECH DAY&lt;br /&gt;
schedule $w$d &amp;quot;Mon[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;TECH DAY&amp;quot; &amp;quot;WORK: Updates, phone, healthcheck, security scan, organize files. HOME: Organize Workstation/Laptop, USB drives.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# SHOPPING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Wed[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;SHOPPING DAY&amp;quot; &amp;quot;Shopping, carwash. Maybe do during lunch.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# GROOMING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Sun[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;GROOMING DAY&amp;quot; &amp;quot;Shave/trim, clip nails.&amp;quot;&lt;br /&gt;
schedule $w$d &amp;quot;Sun(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;GROOMING DAY&amp;quot; &amp;quot;Shave/trim, clip nails.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ELIMINATION DAY&lt;br /&gt;
schedule $w$d &amp;quot;Sun(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;ELIMINATION DAY&amp;quot; &amp;quot;Do at least one item on TO_ELIMINATE list.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# INVENTORY DAY&lt;br /&gt;
# Disabled. Inventory is now included in monthly cleaning day.&lt;br /&gt;
# schedule $w$d &amp;quot;Tue[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;INVENTORY DAY&amp;quot; &amp;quot;Do home, car, and office inventory.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# = Other Permanent Notifications =&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# Air filter replacement notifications&lt;br /&gt;
schedule $M$d &amp;quot;71&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Air Filter&amp;quot; &amp;quot;Holmes HAP726: Replace HEPA filters (model:HAPF600,qty:2)&amp;quot;&lt;br /&gt;
schedule $M$d &amp;quot;[1|7]1&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Air Filter&amp;quot; &amp;quot;Holmes HAP726: Replace Carbon filters (model:HAPF600,qty:2)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now set the permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:root /scripts/external-ip.sh&lt;br /&gt;
chmod 754 /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reporting External IP Address ==&lt;br /&gt;
&lt;br /&gt;
My home server does not have a static IP address, so I use dynamic DNS. With my free DDNS service, I have to renew the domain name every 30 days. So if I forget to renew it, it will expire and I won't be able to access my server unless I know the IP address. As a contingency, I created a script that sends my external IP address to an email account every 6 hours. Then at least I would be able find out what my last IP was and use that to access my server.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/external-ip.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
log=&amp;quot;/var/log/external-ip.log&amp;quot;&lt;br /&gt;
ipsrc=&amp;quot;http://checkip.dyndns.org&amp;quot;&lt;br /&gt;
date=&amp;quot;`date`&amp;quot;&lt;br /&gt;
addr=&amp;quot;myaccount@yahoo.com&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ip=`curl -s --connect-timeout 3 $ipsrc 2&amp;gt;/dev/null|grep -Po &amp;quot;Current IP Address: .*?\&amp;lt;&amp;quot;|tr '&amp;lt;' '\0'`&lt;br /&gt;
echo &amp;quot;IP: $ip&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if [ -z &amp;quot;$ip&amp;quot; ];then&lt;br /&gt;
	echo &amp;quot;$date ERROR: Could not get external IP from $ipsrc&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
else&lt;br /&gt;
	echo -e &amp;quot;Subject:[`hostname`] $date $ip&amp;quot; | /usr/sbin/ssmtp $addr&lt;br /&gt;
	if [ &amp;quot;$?&amp;quot; = &amp;quot;0&amp;quot; ];then&lt;br /&gt;
		echo &amp;quot;$date SUCCESS: $ip sent to $addr&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
	else&lt;br /&gt;
		echo &amp;quot;$date ERROR: Could not send to $addr&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
	fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now set the permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:root /scripts/external-ip.sh&lt;br /&gt;
chmod 754 /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script appends to a log file &amp;lt;code&amp;gt;/var/log/external-ip.log&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
touch /var/log/external-ip.log&lt;br /&gt;
chown root:root /var/log/external-ip.log&lt;br /&gt;
chmod 644 /var/log/external-ip.log&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Automatic Email Download ==&lt;br /&gt;
&lt;br /&gt;
As mentioned in a previous section, I use free dynamic DNS which requires that I renew it manually every 30 days. I need to remind myself to do this. My provider sends an email notification a few days before it expires, but I hate email and I don't want it in my face all the time, certainly not in my phone.&lt;br /&gt;
&lt;br /&gt;
The best solution I found was to retrieve the email automatically and send me a text message with only the subject line in the message. I eventually created a second method of notification: it generates a file in a place that I regularly go, the folder that contains all of my to-do lists.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/ddns.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# This script is run by a cron job.&lt;br /&gt;
&lt;br /&gt;
/usr/bin/fetchmail -N -d0 -f &amp;quot;/scripts/config/ddns-fetchmailrc&amp;quot; -m &amp;quot;/scripts/config/ddns-mailprocess.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
alertfile=&amp;quot;/shares/Private/000__DDNS-ALERT__.txt&amp;quot;&lt;br /&gt;
if [ -e $alertfile ];then&lt;br /&gt;
	chown root:root $alertfile&lt;br /&gt;
	chmod 777 $alertfile&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/config/ddns-mailprocess.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# This script is run by /scripts/ddns.sh&lt;br /&gt;
&lt;br /&gt;
mailto=&amp;quot;17775551234@myprovider.net&amp;quot;&lt;br /&gt;
date=&amp;quot;`date`&amp;quot;&lt;br /&gt;
log=&amp;quot;/var/log/ddns.log&amp;quot;&lt;br /&gt;
alertfile=&amp;quot;/shares/Private/000__DDNS-ALERT__.txt&amp;quot;&lt;br /&gt;
sms=&amp;quot;/scripts/sms.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cat /dev/stdin | grep -i &amp;quot;^Subject:&amp;quot; | sed 's/Subject\://g' | $sms &amp;quot;DDNS&amp;quot; &amp;quot;`cat /dev/stdin` ( $date )&amp;quot; &amp;amp;&amp;amp;\&lt;br /&gt;
echo &amp;quot;$date - DDNS notification sent to $mailto&amp;quot; | tee -a $log | sed &amp;quot;s/$mailto/cell\ phone/g&amp;quot; &amp;gt;$alertfile &amp;amp;&amp;amp;\&lt;br /&gt;
chmod 777 $alertfile&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/config/ddns-fetchmailrc&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# This rc file is run by /scripts/ddns.sh&lt;br /&gt;
# This file MUST have root:root and chmod 700&lt;br /&gt;
&lt;br /&gt;
set postmaster &amp;quot;username&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
poll &amp;quot;imap.mail.yahoo.com&amp;quot; protocol IMAP username &amp;quot;myaccount@yahoo.com&amp;quot; password &amp;quot;InsertPasswordHere&amp;quot; is &amp;quot;username&amp;quot; here keep folder &amp;quot;DDNS-Mailbox&amp;quot; ssl&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
UPDATE February 2021: Yahoo now requires you to create a &amp;lt;b&amp;gt;secure app password&amp;lt;/b&amp;gt;. See [[#yahoo-app-pass|this section]].&lt;br /&gt;
&lt;br /&gt;
You'll notice that it creates a file &amp;lt;code&amp;gt;/shares/Private/000__DDNS-ALERT__.txt&amp;lt;/code&amp;gt;. The &amp;quot;000&amp;quot; is just to put it at the top of the directory listing. Also notice that I make it read-write for everyone so I can delete it from my webapp.&lt;br /&gt;
&lt;br /&gt;
Set up permissions on all three files, and create the log file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
touch /var/log/ddns.log&lt;br /&gt;
chown root:root /var/log/ddns.log&lt;br /&gt;
chmod 640 /var/log/ddns.log&lt;br /&gt;
&lt;br /&gt;
chown root:root /scripts/ddns.sh&lt;br /&gt;
chmod 754 /scripts/ddns.sh&lt;br /&gt;
&lt;br /&gt;
chown root:config /scripts/config/ddns-mailprocess.sh&lt;br /&gt;
chmod 750 /scripts/config/ddns-mailprocess.sh&lt;br /&gt;
&lt;br /&gt;
chown root:root /scripts/config/ddns-fetchmailrc&lt;br /&gt;
chmod 700 /scripts/config/ddns-fetchmailrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you run &amp;lt;code&amp;gt;ddns.sh&amp;lt;/code&amp;gt; as root it gives you a warning about running as root. This is okay.&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
fetchmail: WARNING: Running as root is discouraged.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If permissions on &amp;lt;code&amp;gt;ddns-fetchmailrc&amp;lt;/code&amp;gt; are not correct, you will get this failure message:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
File /scripts/config/ddns-fetchmailrc must have no more than -rwx------ (0700) permissions.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set Up Cron ==&lt;br /&gt;
&lt;br /&gt;
Just for reference, here are the entries I made in my &amp;lt;code&amp;gt;/etc/crontab&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Crontabs to be run without 'run-parts'&lt;br /&gt;
#&lt;br /&gt;
# RUN AT NOON&lt;br /&gt;
0                  12           * * *   root    /scripts/ddns.sh&lt;br /&gt;
0                  12           * * *   root    /scripts/notifications.sh&lt;br /&gt;
# RUN EVERY 6 HOURS&lt;br /&gt;
1                  0,6,12,18    * * *   root    /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;yahoo-app-pass&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt;Yahoo App Password ==&lt;br /&gt;
&lt;br /&gt;
As of February 2021, Yahoo changed that way third party apps can access it. Instead of using your normal password, you need to generate an &amp;lt;b&amp;gt;app password&amp;lt;/b&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Login to Yahoo, click you user icon, and click &amp;lt;b&amp;gt;Account Info&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click &amp;lt;b&amp;gt;Account Security&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click &amp;lt;b&amp;gt;Manage app passwords&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click the &amp;lt;b&amp;gt;Select your app&amp;lt;/b&amp;gt; drop-down and select &amp;lt;b&amp;gt;Other app&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Type a name for the app then click &amp;lt;b&amp;gt;Generate&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Now you can copy the password and use it in your app. Once you navigate away from this page, you will not be able to retrieve the password again. You will have to generate another password.&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=Automatic_Email_and_Text_Notifications&amp;diff=3685</id>
		<title>Automatic Email and Text Notifications</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=Automatic_Email_and_Text_Notifications&amp;diff=3685"/>
				<updated>2021-02-26T14:14:07Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Automatic Email Download */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These tutorials describe my method of automatic messaging via email and text (SMS) from my Linux servers.&lt;br /&gt;
&lt;br /&gt;
== Required Packages ==&lt;br /&gt;
&lt;br /&gt;
These packages are necessary for the all the following sections of this tutorial. In Debain, install them with &amp;lt;code&amp;gt;apt-get&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
apt-get install ssmtp procmail fetchmail&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Directory Structure ==&lt;br /&gt;
&lt;br /&gt;
Just for reference, here are the locations of the relevant files:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
/&lt;br /&gt;
├── etc&lt;br /&gt;
│   └── ssmtp&lt;br /&gt;
│       └── ssmtp.conf&lt;br /&gt;
└── scripts&lt;br /&gt;
    ├── config&lt;br /&gt;
    │   ├── accounts.conf&lt;br /&gt;
    │   ├── ddns-fetchmailrc&lt;br /&gt;
    │   └── ddns-mailprocess.sh&lt;br /&gt;
    ├── ddns.sh&lt;br /&gt;
    ├── email.sh&lt;br /&gt;
    ├── external-ip.sh&lt;br /&gt;
    ├── notifications.sh&lt;br /&gt;
    └── sms.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l /scripts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
drwxr-xr-x 4 root config   4096 Jun 20 08:52 config&lt;br /&gt;
-rwxr-xr-- 1 root root      260 Jun 20 08:40 ddns.sh&lt;br /&gt;
-rwxr-xr-- 1 root mailers   564 Apr 23 12:18 email.sh&lt;br /&gt;
-rwxr-xr-- 1 root root      529 Apr 27 07:56 external-ip.sh&lt;br /&gt;
-rwxr-xr-- 1 root root     3834 May 15 08:32 notifications.sh&lt;br /&gt;
-rwxr-xr-- 1 root texters   545 Apr 23 12:24 sms.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l /scripts/config&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
-rwxr-x--- 1 root mailers  147 May  1 13:01 accounts.conf&lt;br /&gt;
-rwx------ 1 root root     246 May 21 09:49 ddns-fetchmailrc&lt;br /&gt;
-rwxr-x--- 1 root config   604 Jun 20 08:52 ddns-mailprocess.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create Security Groups ==&lt;br /&gt;
&lt;br /&gt;
I use group membership to control read access to certain files. You don't have to do this, but it was useful for me.&lt;br /&gt;
&lt;br /&gt;
Create the groups:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
groupadd texters #allowed to sent text messages&lt;br /&gt;
groupadd mailers #allowed to send email messages&lt;br /&gt;
groupadd config  #allowed to read other config files&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can add a user to all three groups like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
usermod -aG texters,mailers,config username&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Email and Text Messaging with SSMTP ==&lt;br /&gt;
&lt;br /&gt;
First set up the &amp;lt;code&amp;gt;/etc/ssmtp/ssmtp.conf&amp;lt;/code&amp;gt;. I use a dedicated Gmail account (named &amp;lt;b&amp;gt;serveraccount@gmail.com&amp;lt;/b&amp;gt; in the example below) for all of my server messaging. When I receive an email from my server, it will look like it's coming from that Gmail.&lt;br /&gt;
&lt;br /&gt;
Make a backup copy of the original config:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.orig&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here are the contents of my modified &amp;lt;code&amp;gt;/etc/ssmtp/ssmtp.conf&amp;lt;/code&amp;gt;. Replace the relevant values.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Config file for sSMTP sendmail&lt;br /&gt;
#&lt;br /&gt;
# The person who gets all mail for userids &amp;lt; 1000&lt;br /&gt;
# Make this empty to disable rewriting.&lt;br /&gt;
root=serveraccount&lt;br /&gt;
&lt;br /&gt;
# The place where the mail goes. The actual machine name is required no&lt;br /&gt;
# MX records are consulted. Commonly mailhosts are named mail.domain.com&lt;br /&gt;
#mailhub=mail&lt;br /&gt;
&lt;br /&gt;
# Where will the mail seem to come from?&lt;br /&gt;
rewriteDomain=gmail.com&lt;br /&gt;
&lt;br /&gt;
# The full hostname&lt;br /&gt;
# This can be left as 'localhost'&lt;br /&gt;
hostname=localhost&lt;br /&gt;
&lt;br /&gt;
# Are users allowed to set their own From: address?&lt;br /&gt;
# YES - Allow the user to specify their own From: address&lt;br /&gt;
# NO - Use the system generated From: address&lt;br /&gt;
FromLineOverride=YES&lt;br /&gt;
&lt;br /&gt;
mailhub=smtp.gmail.com:587&lt;br /&gt;
UseStartTLS=YES&lt;br /&gt;
UseTLS=YES&lt;br /&gt;
AuthMethod=LOGIN&lt;br /&gt;
AuthUser=serveraccount@gmail.com&lt;br /&gt;
AuthPass=InsertPasswordHere&lt;br /&gt;
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt&lt;br /&gt;
FromLineOverride=YES&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the file contains a password, make sure the file is not readable to normal users.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mail /etc/ssmtp/ssmtp.conf&lt;br /&gt;
chmod 640 /etc/ssmtp/ssmtp.conf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And because you don't have to remember this password, it would be a good idea to make it very long and complex (16+ characters; uppercase, lowercase, numbers, and special characters; no dictionary words).&lt;br /&gt;
&lt;br /&gt;
You now need to log onto the &amp;lt;b&amp;gt;serveraccount&amp;lt;/b&amp;gt; Gmail account and enable &amp;quot;less secure apps&amp;quot; at https://myaccount.google.com/lesssecureapps?pli=1 &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Gmail-less-secure-app.png|frameless|600px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Here is more info about less secure apps: https://support.google.com/cloudidentity/answer/6260879?hl=en&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should now be able use the &amp;lt;code&amp;gt;ssmtp&amp;lt;/code&amp;gt; command line tool from your server. Most of the time, you will need to include a subject line. It's important that it follows the format below (capital 'S' on Subject, colon, space, YourSubject, two newlines):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo -e &amp;quot;Subject: Hi\n\nHello, world!&amp;quot; | ssmtp myaccount@yahoo.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a Secure Accounts File ==&lt;br /&gt;
&lt;br /&gt;
For some of the automatic messaging, you need to store text and email accounts in a file. To figure out the destination address to send text (SMS) messages to your cell, look on your cell provider's website for the proper account/domain name. It will probably be something like &amp;quot;&amp;lt;your-phone-number&amp;gt;@&amp;lt;provider-domain&amp;gt;&amp;quot;. [https://kb.sandisk.com/app/answers/detail/a_id/17056/~/list-of-mobile-carrier-gateway-addresses List of provider addresses]&lt;br /&gt;
&lt;br /&gt;
Contents of my &amp;lt;code&amp;gt;/scripts/config/accounts.conf&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# Secure account information&lt;br /&gt;
# Permissions must be 750 root:mailers&lt;br /&gt;
&lt;br /&gt;
smsto=&amp;quot;17775551234@myprovider.net&amp;quot;&lt;br /&gt;
mailto=&amp;quot;myaccount@yahoo.com&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the permissions on the file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mailers /scripts/config/accounts.conf&lt;br /&gt;
chmod 750 /scripts/config/accounts.conf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Email Script ==&lt;br /&gt;
&lt;br /&gt;
This script can be used to send an email message.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/email.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# Send email message:&lt;br /&gt;
#  Usage: $0 &amp;quot;&amp;lt;Subject&amp;gt;&amp;quot; &amp;quot;&amp;lt;Message&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
default_subject=&amp;quot;Alert from Server (`date`)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
subject=&amp;quot;&amp;quot;&lt;br /&gt;
message=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
case $# in&lt;br /&gt;
  2)&lt;br /&gt;
    subject=&amp;quot;$1&amp;quot;&lt;br /&gt;
    message=&amp;quot;$2&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  1)&lt;br /&gt;
    subject=&amp;quot;$default_subject&amp;quot;&lt;br /&gt;
    message=&amp;quot;$1&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  *)&lt;br /&gt;
    echo &amp;quot;Send Email Message:&amp;quot;&lt;br /&gt;
    echo &amp;quot;  Usage: `basename $0` \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    echo &amp;quot;         `basename $0` \&amp;quot;Subject\&amp;quot; \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
  ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
dir=&amp;quot;$(cd $(dirname ${BASH_SOURCE[0]})&amp;amp;&amp;amp;pwd)&amp;quot;&lt;br /&gt;
. $dir/config/accounts.conf&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;Subject: $subject\n\n$message&amp;quot; | /usr/sbin/ssmtp $mailto&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mailers /scripts/email.sh&lt;br /&gt;
chmod 754 /scripts/email.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create an alias so you can quickly run this from the command line:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo &amp;quot;alias email='/scripts/email.sh'&amp;quot; &amp;gt;&amp;gt;~/.bashrc&lt;br /&gt;
source ~/.bashrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Send message with default subject&lt;br /&gt;
email &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Send message with a subject&lt;br /&gt;
email &amp;quot;Test Subject&amp;quot; &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Text Script ==&lt;br /&gt;
&lt;br /&gt;
This script can be used to send a text (SMS) message.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/sms.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# Send SMS message:&lt;br /&gt;
#  Usage: $0 &amp;quot;&amp;lt;Subject&amp;gt;&amp;quot; &amp;quot;&amp;lt;Message&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
default_subject=&amp;quot;Alert&amp;quot;&lt;br /&gt;
&lt;br /&gt;
subject=&amp;quot;&amp;quot;&lt;br /&gt;
message=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
case $# in&lt;br /&gt;
  2)&lt;br /&gt;
    subject=&amp;quot;$1&amp;quot;&lt;br /&gt;
    message=&amp;quot;$2&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  1)&lt;br /&gt;
    subject=&amp;quot;$default_subject&amp;quot;&lt;br /&gt;
    message=&amp;quot;$1&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  *)&lt;br /&gt;
    echo &amp;quot;Send SMS Message:&amp;quot;&lt;br /&gt;
    echo &amp;quot;  Usage: `basename $0` \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    echo &amp;quot;         `basename $0` \&amp;quot;Subject\&amp;quot; \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
  ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
dir=&amp;quot;$(cd $(dirname ${BASH_SOURCE[0]})&amp;amp;&amp;amp;pwd)&amp;quot;&lt;br /&gt;
. $dir/config/accounts.conf&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;To: $smsto\nSubject: $subject\n\n$message&amp;quot; | /usr/sbin/ssmtp $smsto&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:texters /scripts/sms.sh&lt;br /&gt;
chmod 754 /scripts/sms.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create an alias so you can quickly run this from the command line:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo &amp;quot;alias sms='/scripts/sms.sh'&amp;quot; &amp;gt;&amp;gt;~/.bashrc&lt;br /&gt;
source ~/.bashrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Send message with default subject&lt;br /&gt;
sms &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Send message with a subject&lt;br /&gt;
sms &amp;quot;Test Subject&amp;quot; &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scheduled Notifications Script ==&lt;br /&gt;
&lt;br /&gt;
One of my life improvement tasks was to organize chores into scheduled chore days and rely on text/email notification to remind me to do them.&lt;br /&gt;
&lt;br /&gt;
This dramatically reduced the amount of time I spend working on chores, and the amount of effort I spend thinking about what needs to be done. I could barely get projects done because every day I was loading my task list with chores. Now I don't think about chores until I'm notified. When I think of new chores, new items for my inventory, or other things I need to be reminded of, I update my checklists. When I feel I can improve scheduling or consolidate chores, I update my notifications script.&lt;br /&gt;
&lt;br /&gt;
This utilizes the &amp;lt;b&amp;gt;Email Script&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;Text Script&amp;lt;/b&amp;gt; from the previous sections.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/notifications.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# Send regular notifications.&lt;br /&gt;
# Currently set to run daily at NOON.&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
# Get current datetime values&lt;br /&gt;
dt=(`date +%Y\ %m\ %d\ %H\ %M\ %S\ %a\ %s\ %I\ %p\ %Z`)&lt;br /&gt;
y=$((10#${dt[0]})) #year&lt;br /&gt;
M=$((10#${dt[1]})) #month&lt;br /&gt;
d=$((10#${dt[2]})) #day&lt;br /&gt;
h=$((10#${dt[3]})) #hour(24)&lt;br /&gt;
m=$((10#${dt[4]})) #minute&lt;br /&gt;
s=$((10#${dt[5]})) #second&lt;br /&gt;
w=${dt[6]}         #day of week (eg. Sun)&lt;br /&gt;
e=$((10#${dt[7]})) #epoch&lt;br /&gt;
t=$((10#${dt[8]})) #hour(12)&lt;br /&gt;
p=${dt[9]}         #meridian (AM/PM)&lt;br /&gt;
z=${dt[10]}        #timezone (eg. PDT)&lt;br /&gt;
&lt;br /&gt;
# Schedule command when date ($1) matched regex ($2) with extra grep parameters ($3)&lt;br /&gt;
# Use parameter -P at $3 for perl regex: in case you need to use (str1|str2).&lt;br /&gt;
# Example: schedule $M$d &amp;quot;(115|21)&amp;quot; -P &amp;amp;&amp;amp; sms &amp;quot;Subject&amp;quot; &amp;quot;Message&amp;quot;&lt;br /&gt;
# Don't use -P when you want a range of numbers including 2 or more digit numbers (ie. [1-15]).&lt;br /&gt;
schedule(){ echo &amp;quot;$1&amp;quot; | grep -wq $3 &amp;quot;$2&amp;quot;;}&lt;br /&gt;
sms(){ /scripts/sms.sh &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
eml(){ /scripts/email.sh &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
notify(){ sms &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;eml &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# ==== Temporary Notifications ====&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# Dentist appointment&lt;br /&gt;
#schedule $M$d &amp;quot;58&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Dentist&amp;quot; &amp;quot;Appointment 4:00pm 10/31/2017&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# ====== Chore Notifications ======&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# LAUNDRY DAY&lt;br /&gt;
# Day before&lt;br /&gt;
schedule $w$d &amp;quot;Mon[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;LAUNDRY DAY&amp;quot; &amp;quot;WORK: Check gas. HOME: Do laundry, put laundry away.&amp;quot;&lt;br /&gt;
schedule $w$d &amp;quot;Mon(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;LAUNDRY DAY&amp;quot; &amp;quot;WORK: Check gas. HOME: Do laundry, put laundry away.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# WEEKLY CLEANING DAY&lt;br /&gt;
schedule $w &amp;quot;Tue&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;WEEKLY CLEANING DAY&amp;quot; &amp;quot;WORK: Fill gas, shopping. HOME: Clean, litter, sweep/vac, fridge, trash, check meds.&amp;quot;&lt;br /&gt;
# Day after&lt;br /&gt;
schedule $w &amp;quot;Wed&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;WEEKLY REMINDER&amp;quot; &amp;quot;Order meds if necessary.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# MONTHLY CLEANING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Tue[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;MONTHLY CLEANING DAY&amp;quot; &amp;quot;WORK: Car stuff. HOME: Dishes, kitchen, bathroom, dust, inventory.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# BUSINESS DAY&lt;br /&gt;
schedule $d &amp;quot;[1-4]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;BUSINESS DAY&amp;quot; &amp;quot;Rent due before 5th (\$720). Fedloan, budgeting, donations, next-buy.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# TECH DAY&lt;br /&gt;
schedule $w$d &amp;quot;Mon[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;TECH DAY&amp;quot; &amp;quot;WORK: Updates, phone, healthcheck, security scan, organize files. HOME: Organize Workstation/Laptop, USB drives.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# SHOPPING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Wed[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;SHOPPING DAY&amp;quot; &amp;quot;Shopping, carwash. Maybe do during lunch.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# GROOMING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Sun[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;GROOMING DAY&amp;quot; &amp;quot;Shave/trim, clip nails.&amp;quot;&lt;br /&gt;
schedule $w$d &amp;quot;Sun(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;GROOMING DAY&amp;quot; &amp;quot;Shave/trim, clip nails.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ELIMINATION DAY&lt;br /&gt;
schedule $w$d &amp;quot;Sun(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;ELIMINATION DAY&amp;quot; &amp;quot;Do at least one item on TO_ELIMINATE list.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# INVENTORY DAY&lt;br /&gt;
# Disabled. Inventory is now included in monthly cleaning day.&lt;br /&gt;
# schedule $w$d &amp;quot;Tue[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;INVENTORY DAY&amp;quot; &amp;quot;Do home, car, and office inventory.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# = Other Permanent Notifications =&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# Air filter replacement notifications&lt;br /&gt;
schedule $M$d &amp;quot;71&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Air Filter&amp;quot; &amp;quot;Holmes HAP726: Replace HEPA filters (model:HAPF600,qty:2)&amp;quot;&lt;br /&gt;
schedule $M$d &amp;quot;[1|7]1&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Air Filter&amp;quot; &amp;quot;Holmes HAP726: Replace Carbon filters (model:HAPF600,qty:2)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now set the permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:root /scripts/external-ip.sh&lt;br /&gt;
chmod 754 /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reporting External IP Address ==&lt;br /&gt;
&lt;br /&gt;
My home server does not have a static IP address, so I use dynamic DNS. With my free DDNS service, I have to renew the domain name every 30 days. So if I forget to renew it, it will expire and I won't be able to access my server unless I know the IP address. As a contingency, I created a script that sends my external IP address to an email account every 6 hours. Then at least I would be able find out what my last IP was and use that to access my server.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/external-ip.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
log=&amp;quot;/var/log/external-ip.log&amp;quot;&lt;br /&gt;
ipsrc=&amp;quot;http://checkip.dyndns.org&amp;quot;&lt;br /&gt;
date=&amp;quot;`date`&amp;quot;&lt;br /&gt;
addr=&amp;quot;myaccount@yahoo.com&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ip=`curl -s --connect-timeout 3 $ipsrc 2&amp;gt;/dev/null|grep -Po &amp;quot;Current IP Address: .*?\&amp;lt;&amp;quot;|tr '&amp;lt;' '\0'`&lt;br /&gt;
echo &amp;quot;IP: $ip&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if [ -z &amp;quot;$ip&amp;quot; ];then&lt;br /&gt;
	echo &amp;quot;$date ERROR: Could not get external IP from $ipsrc&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
else&lt;br /&gt;
	echo -e &amp;quot;Subject:[`hostname`] $date $ip&amp;quot; | /usr/sbin/ssmtp $addr&lt;br /&gt;
	if [ &amp;quot;$?&amp;quot; = &amp;quot;0&amp;quot; ];then&lt;br /&gt;
		echo &amp;quot;$date SUCCESS: $ip sent to $addr&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
	else&lt;br /&gt;
		echo &amp;quot;$date ERROR: Could not send to $addr&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
	fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now set the permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:root /scripts/external-ip.sh&lt;br /&gt;
chmod 754 /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script appends to a log file &amp;lt;code&amp;gt;/var/log/external-ip.log&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
touch /var/log/external-ip.log&lt;br /&gt;
chown root:root /var/log/external-ip.log&lt;br /&gt;
chmod 644 /var/log/external-ip.log&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Automatic Email Download ==&lt;br /&gt;
&lt;br /&gt;
As mentioned in a previous section, I use free dynamic DNS which requires that I renew it manually every 30 days. I need to remind myself to do this. My provider sends an email notification a few days before it expires, but I hate email and I don't want it in my face all the time, certainly not in my phone.&lt;br /&gt;
&lt;br /&gt;
The best solution I found was to retrieve the email automatically and send me a text message with only the subject line in the message. I eventually created a second method of notification: it generates a file in a place that I regularly go, the folder that contains all of my to-do lists.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/ddns.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# This script is run by a cron job.&lt;br /&gt;
&lt;br /&gt;
/usr/bin/fetchmail -N -d0 -f &amp;quot;/scripts/config/ddns-fetchmailrc&amp;quot; -m &amp;quot;/scripts/config/ddns-mailprocess.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
alertfile=&amp;quot;/shares/Private/000__DDNS-ALERT__.txt&amp;quot;&lt;br /&gt;
if [ -e $alertfile ];then&lt;br /&gt;
	chown root:root $alertfile&lt;br /&gt;
	chmod 777 $alertfile&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/config/ddns-mailprocess.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# This script is run by /scripts/ddns.sh&lt;br /&gt;
&lt;br /&gt;
mailto=&amp;quot;17775551234@myprovider.net&amp;quot;&lt;br /&gt;
date=&amp;quot;`date`&amp;quot;&lt;br /&gt;
log=&amp;quot;/var/log/ddns.log&amp;quot;&lt;br /&gt;
alertfile=&amp;quot;/shares/Private/000__DDNS-ALERT__.txt&amp;quot;&lt;br /&gt;
sms=&amp;quot;/scripts/sms.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cat /dev/stdin | grep -i &amp;quot;^Subject:&amp;quot; | sed 's/Subject\://g' | $sms &amp;quot;DDNS&amp;quot; &amp;quot;`cat /dev/stdin` ( $date )&amp;quot; &amp;amp;&amp;amp;\&lt;br /&gt;
echo &amp;quot;$date - DDNS notification sent to $mailto&amp;quot; | tee -a $log | sed &amp;quot;s/$mailto/cell\ phone/g&amp;quot; &amp;gt;$alertfile &amp;amp;&amp;amp;\&lt;br /&gt;
chmod 777 $alertfile&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/config/ddns-fetchmailrc&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# This rc file is run by /scripts/ddns.sh&lt;br /&gt;
# This file MUST have root:root and chmod 700&lt;br /&gt;
&lt;br /&gt;
set postmaster &amp;quot;username&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
poll &amp;quot;imap.mail.yahoo.com&amp;quot; protocol IMAP username &amp;quot;myaccount@yahoo.com&amp;quot; password &amp;quot;InsertPasswordHere&amp;quot; is &amp;quot;username&amp;quot; here keep folder &amp;quot;DDNS-Mailbox&amp;quot; ssl&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
UPDATE February 2021: Yahoo now requires you to create a &amp;lt;b&amp;gt;secure app password&amp;lt;/b&amp;gt;. See [[#yahoo-app-pass|this section]].&lt;br /&gt;
&lt;br /&gt;
You'll notice that it creates a file &amp;lt;code&amp;gt;/shares/Private/000__DDNS-ALERT__.txt&amp;lt;/code&amp;gt;. The &amp;quot;000&amp;quot; is just to put it at the top of the directory listing. Also notice that I make it read-write for everyone so I can delete it from my webapp.&lt;br /&gt;
&lt;br /&gt;
Set up permissions on all three files, and create the log file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
touch /var/log/ddns.log&lt;br /&gt;
chown root:root /var/log/ddns.log&lt;br /&gt;
chmod 640 /var/log/ddns.log&lt;br /&gt;
&lt;br /&gt;
chown root:root /scripts/ddns.sh&lt;br /&gt;
chmod 754 /scripts/ddns.sh&lt;br /&gt;
&lt;br /&gt;
chown root:config /scripts/config/ddns-mailprocess.sh&lt;br /&gt;
chmod 750 /scripts/config/ddns-mailprocess.sh&lt;br /&gt;
&lt;br /&gt;
chown root:root /scripts/config/ddns-fetchmailrc&lt;br /&gt;
chmod 700 /scripts/config/ddns-fetchmailrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you run &amp;lt;code&amp;gt;ddns.sh&amp;lt;/code&amp;gt; as root it gives you a warning about running as root. This is okay.&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
fetchmail: WARNING: Running as root is discouraged.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If permissions on &amp;lt;code&amp;gt;ddns-fetchmailrc&amp;lt;/code&amp;gt; are not correct, you will get this failure message:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
File /scripts/config/ddns-fetchmailrc must have no more than -rwx------ (0700) permissions.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set Up Cron ==&lt;br /&gt;
&lt;br /&gt;
Just for reference, here are the entries I made in my &amp;lt;code&amp;gt;/etc/crontab&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Crontabs to be run without 'run-parts'&lt;br /&gt;
#&lt;br /&gt;
# RUN AT NOON&lt;br /&gt;
0                  12           * * *   root    /scripts/ddns.sh&lt;br /&gt;
0                  12           * * *   root    /scripts/notifications.sh&lt;br /&gt;
# RUN EVERY 6 HOURS&lt;br /&gt;
1                  0,6,12,18    * * *   root    /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;yahoo-app-pass&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt;Yahoo App Password ==&lt;br /&gt;
&lt;br /&gt;
As of February 2021, Yahoo changed that way third party apps can access it. Instead of using your normal password, you need to generate an &amp;lt;b&amp;gt;app password&amp;lt;/b&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Login to Yahoo, click you user icon, and click &amp;lt;b&amp;gt;Account Info&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click &amp;lt;b&amp;gt;Account Security&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click &amp;lt;b&amp;gt;Manage app passwords&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click the &amp;lt;b&amp;gt;Select your app&amp;lt;/b&amp;gt; drop-down and select &amp;lt;b&amp;gt;Other app&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Type a name for the app then click &amp;lt;b&amp;gt;Generate&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Now you can copy the password and use it in your app. Once you navigate away from this page, you will not be able to retrieve the password again. You will have to generate another password.&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=Automatic_Email_and_Text_Notifications&amp;diff=3684</id>
		<title>Automatic Email and Text Notifications</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=Automatic_Email_and_Text_Notifications&amp;diff=3684"/>
				<updated>2021-02-26T14:12:44Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Yahoo App Password */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These tutorials describe my method of automatic messaging via email and text (SMS) from my Linux servers.&lt;br /&gt;
&lt;br /&gt;
== Required Packages ==&lt;br /&gt;
&lt;br /&gt;
These packages are necessary for the all the following sections of this tutorial. In Debain, install them with &amp;lt;code&amp;gt;apt-get&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
apt-get install ssmtp procmail fetchmail&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Directory Structure ==&lt;br /&gt;
&lt;br /&gt;
Just for reference, here are the locations of the relevant files:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
/&lt;br /&gt;
├── etc&lt;br /&gt;
│   └── ssmtp&lt;br /&gt;
│       └── ssmtp.conf&lt;br /&gt;
└── scripts&lt;br /&gt;
    ├── config&lt;br /&gt;
    │   ├── accounts.conf&lt;br /&gt;
    │   ├── ddns-fetchmailrc&lt;br /&gt;
    │   └── ddns-mailprocess.sh&lt;br /&gt;
    ├── ddns.sh&lt;br /&gt;
    ├── email.sh&lt;br /&gt;
    ├── external-ip.sh&lt;br /&gt;
    ├── notifications.sh&lt;br /&gt;
    └── sms.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l /scripts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
drwxr-xr-x 4 root config   4096 Jun 20 08:52 config&lt;br /&gt;
-rwxr-xr-- 1 root root      260 Jun 20 08:40 ddns.sh&lt;br /&gt;
-rwxr-xr-- 1 root mailers   564 Apr 23 12:18 email.sh&lt;br /&gt;
-rwxr-xr-- 1 root root      529 Apr 27 07:56 external-ip.sh&lt;br /&gt;
-rwxr-xr-- 1 root root     3834 May 15 08:32 notifications.sh&lt;br /&gt;
-rwxr-xr-- 1 root texters   545 Apr 23 12:24 sms.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l /scripts/config&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
-rwxr-x--- 1 root mailers  147 May  1 13:01 accounts.conf&lt;br /&gt;
-rwx------ 1 root root     246 May 21 09:49 ddns-fetchmailrc&lt;br /&gt;
-rwxr-x--- 1 root config   604 Jun 20 08:52 ddns-mailprocess.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create Security Groups ==&lt;br /&gt;
&lt;br /&gt;
I use group membership to control read access to certain files. You don't have to do this, but it was useful for me.&lt;br /&gt;
&lt;br /&gt;
Create the groups:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
groupadd texters #allowed to sent text messages&lt;br /&gt;
groupadd mailers #allowed to send email messages&lt;br /&gt;
groupadd config  #allowed to read other config files&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can add a user to all three groups like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
usermod -aG texters,mailers,config username&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Email and Text Messaging with SSMTP ==&lt;br /&gt;
&lt;br /&gt;
First set up the &amp;lt;code&amp;gt;/etc/ssmtp/ssmtp.conf&amp;lt;/code&amp;gt;. I use a dedicated Gmail account (named &amp;lt;b&amp;gt;serveraccount@gmail.com&amp;lt;/b&amp;gt; in the example below) for all of my server messaging. When I receive an email from my server, it will look like it's coming from that Gmail.&lt;br /&gt;
&lt;br /&gt;
Make a backup copy of the original config:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.orig&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here are the contents of my modified &amp;lt;code&amp;gt;/etc/ssmtp/ssmtp.conf&amp;lt;/code&amp;gt;. Replace the relevant values.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Config file for sSMTP sendmail&lt;br /&gt;
#&lt;br /&gt;
# The person who gets all mail for userids &amp;lt; 1000&lt;br /&gt;
# Make this empty to disable rewriting.&lt;br /&gt;
root=serveraccount&lt;br /&gt;
&lt;br /&gt;
# The place where the mail goes. The actual machine name is required no&lt;br /&gt;
# MX records are consulted. Commonly mailhosts are named mail.domain.com&lt;br /&gt;
#mailhub=mail&lt;br /&gt;
&lt;br /&gt;
# Where will the mail seem to come from?&lt;br /&gt;
rewriteDomain=gmail.com&lt;br /&gt;
&lt;br /&gt;
# The full hostname&lt;br /&gt;
# This can be left as 'localhost'&lt;br /&gt;
hostname=localhost&lt;br /&gt;
&lt;br /&gt;
# Are users allowed to set their own From: address?&lt;br /&gt;
# YES - Allow the user to specify their own From: address&lt;br /&gt;
# NO - Use the system generated From: address&lt;br /&gt;
FromLineOverride=YES&lt;br /&gt;
&lt;br /&gt;
mailhub=smtp.gmail.com:587&lt;br /&gt;
UseStartTLS=YES&lt;br /&gt;
UseTLS=YES&lt;br /&gt;
AuthMethod=LOGIN&lt;br /&gt;
AuthUser=serveraccount@gmail.com&lt;br /&gt;
AuthPass=InsertPasswordHere&lt;br /&gt;
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt&lt;br /&gt;
FromLineOverride=YES&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the file contains a password, make sure the file is not readable to normal users.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mail /etc/ssmtp/ssmtp.conf&lt;br /&gt;
chmod 640 /etc/ssmtp/ssmtp.conf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And because you don't have to remember this password, it would be a good idea to make it very long and complex (16+ characters; uppercase, lowercase, numbers, and special characters; no dictionary words).&lt;br /&gt;
&lt;br /&gt;
You now need to log onto the &amp;lt;b&amp;gt;serveraccount&amp;lt;/b&amp;gt; Gmail account and enable &amp;quot;less secure apps&amp;quot; at https://myaccount.google.com/lesssecureapps?pli=1 &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Gmail-less-secure-app.png|frameless|600px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Here is more info about less secure apps: https://support.google.com/cloudidentity/answer/6260879?hl=en&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should now be able use the &amp;lt;code&amp;gt;ssmtp&amp;lt;/code&amp;gt; command line tool from your server. Most of the time, you will need to include a subject line. It's important that it follows the format below (capital 'S' on Subject, colon, space, YourSubject, two newlines):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo -e &amp;quot;Subject: Hi\n\nHello, world!&amp;quot; | ssmtp myaccount@yahoo.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a Secure Accounts File ==&lt;br /&gt;
&lt;br /&gt;
For some of the automatic messaging, you need to store text and email accounts in a file. To figure out the destination address to send text (SMS) messages to your cell, look on your cell provider's website for the proper account/domain name. It will probably be something like &amp;quot;&amp;lt;your-phone-number&amp;gt;@&amp;lt;provider-domain&amp;gt;&amp;quot;. [https://kb.sandisk.com/app/answers/detail/a_id/17056/~/list-of-mobile-carrier-gateway-addresses List of provider addresses]&lt;br /&gt;
&lt;br /&gt;
Contents of my &amp;lt;code&amp;gt;/scripts/config/accounts.conf&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# Secure account information&lt;br /&gt;
# Permissions must be 750 root:mailers&lt;br /&gt;
&lt;br /&gt;
smsto=&amp;quot;17775551234@myprovider.net&amp;quot;&lt;br /&gt;
mailto=&amp;quot;myaccount@yahoo.com&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the permissions on the file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mailers /scripts/config/accounts.conf&lt;br /&gt;
chmod 750 /scripts/config/accounts.conf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Email Script ==&lt;br /&gt;
&lt;br /&gt;
This script can be used to send an email message.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/email.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# Send email message:&lt;br /&gt;
#  Usage: $0 &amp;quot;&amp;lt;Subject&amp;gt;&amp;quot; &amp;quot;&amp;lt;Message&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
default_subject=&amp;quot;Alert from Server (`date`)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
subject=&amp;quot;&amp;quot;&lt;br /&gt;
message=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
case $# in&lt;br /&gt;
  2)&lt;br /&gt;
    subject=&amp;quot;$1&amp;quot;&lt;br /&gt;
    message=&amp;quot;$2&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  1)&lt;br /&gt;
    subject=&amp;quot;$default_subject&amp;quot;&lt;br /&gt;
    message=&amp;quot;$1&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  *)&lt;br /&gt;
    echo &amp;quot;Send Email Message:&amp;quot;&lt;br /&gt;
    echo &amp;quot;  Usage: `basename $0` \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    echo &amp;quot;         `basename $0` \&amp;quot;Subject\&amp;quot; \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
  ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
dir=&amp;quot;$(cd $(dirname ${BASH_SOURCE[0]})&amp;amp;&amp;amp;pwd)&amp;quot;&lt;br /&gt;
. $dir/config/accounts.conf&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;Subject: $subject\n\n$message&amp;quot; | /usr/sbin/ssmtp $mailto&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mailers /scripts/email.sh&lt;br /&gt;
chmod 754 /scripts/email.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create an alias so you can quickly run this from the command line:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo &amp;quot;alias email='/scripts/email.sh'&amp;quot; &amp;gt;&amp;gt;~/.bashrc&lt;br /&gt;
source ~/.bashrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Send message with default subject&lt;br /&gt;
email &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Send message with a subject&lt;br /&gt;
email &amp;quot;Test Subject&amp;quot; &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Text Script ==&lt;br /&gt;
&lt;br /&gt;
This script can be used to send a text (SMS) message.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/sms.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# Send SMS message:&lt;br /&gt;
#  Usage: $0 &amp;quot;&amp;lt;Subject&amp;gt;&amp;quot; &amp;quot;&amp;lt;Message&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
default_subject=&amp;quot;Alert&amp;quot;&lt;br /&gt;
&lt;br /&gt;
subject=&amp;quot;&amp;quot;&lt;br /&gt;
message=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
case $# in&lt;br /&gt;
  2)&lt;br /&gt;
    subject=&amp;quot;$1&amp;quot;&lt;br /&gt;
    message=&amp;quot;$2&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  1)&lt;br /&gt;
    subject=&amp;quot;$default_subject&amp;quot;&lt;br /&gt;
    message=&amp;quot;$1&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  *)&lt;br /&gt;
    echo &amp;quot;Send SMS Message:&amp;quot;&lt;br /&gt;
    echo &amp;quot;  Usage: `basename $0` \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    echo &amp;quot;         `basename $0` \&amp;quot;Subject\&amp;quot; \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
  ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
dir=&amp;quot;$(cd $(dirname ${BASH_SOURCE[0]})&amp;amp;&amp;amp;pwd)&amp;quot;&lt;br /&gt;
. $dir/config/accounts.conf&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;To: $smsto\nSubject: $subject\n\n$message&amp;quot; | /usr/sbin/ssmtp $smsto&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:texters /scripts/sms.sh&lt;br /&gt;
chmod 754 /scripts/sms.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create an alias so you can quickly run this from the command line:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo &amp;quot;alias sms='/scripts/sms.sh'&amp;quot; &amp;gt;&amp;gt;~/.bashrc&lt;br /&gt;
source ~/.bashrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Send message with default subject&lt;br /&gt;
sms &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Send message with a subject&lt;br /&gt;
sms &amp;quot;Test Subject&amp;quot; &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scheduled Notifications Script ==&lt;br /&gt;
&lt;br /&gt;
One of my life improvement tasks was to organize chores into scheduled chore days and rely on text/email notification to remind me to do them.&lt;br /&gt;
&lt;br /&gt;
This dramatically reduced the amount of time I spend working on chores, and the amount of effort I spend thinking about what needs to be done. I could barely get projects done because every day I was loading my task list with chores. Now I don't think about chores until I'm notified. When I think of new chores, new items for my inventory, or other things I need to be reminded of, I update my checklists. When I feel I can improve scheduling or consolidate chores, I update my notifications script.&lt;br /&gt;
&lt;br /&gt;
This utilizes the &amp;lt;b&amp;gt;Email Script&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;Text Script&amp;lt;/b&amp;gt; from the previous sections.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/notifications.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# Send regular notifications.&lt;br /&gt;
# Currently set to run daily at NOON.&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
# Get current datetime values&lt;br /&gt;
dt=(`date +%Y\ %m\ %d\ %H\ %M\ %S\ %a\ %s\ %I\ %p\ %Z`)&lt;br /&gt;
y=$((10#${dt[0]})) #year&lt;br /&gt;
M=$((10#${dt[1]})) #month&lt;br /&gt;
d=$((10#${dt[2]})) #day&lt;br /&gt;
h=$((10#${dt[3]})) #hour(24)&lt;br /&gt;
m=$((10#${dt[4]})) #minute&lt;br /&gt;
s=$((10#${dt[5]})) #second&lt;br /&gt;
w=${dt[6]}         #day of week (eg. Sun)&lt;br /&gt;
e=$((10#${dt[7]})) #epoch&lt;br /&gt;
t=$((10#${dt[8]})) #hour(12)&lt;br /&gt;
p=${dt[9]}         #meridian (AM/PM)&lt;br /&gt;
z=${dt[10]}        #timezone (eg. PDT)&lt;br /&gt;
&lt;br /&gt;
# Schedule command when date ($1) matched regex ($2) with extra grep parameters ($3)&lt;br /&gt;
# Use parameter -P at $3 for perl regex: in case you need to use (str1|str2).&lt;br /&gt;
# Example: schedule $M$d &amp;quot;(115|21)&amp;quot; -P &amp;amp;&amp;amp; sms &amp;quot;Subject&amp;quot; &amp;quot;Message&amp;quot;&lt;br /&gt;
# Don't use -P when you want a range of numbers including 2 or more digit numbers (ie. [1-15]).&lt;br /&gt;
schedule(){ echo &amp;quot;$1&amp;quot; | grep -wq $3 &amp;quot;$2&amp;quot;;}&lt;br /&gt;
sms(){ /scripts/sms.sh &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
eml(){ /scripts/email.sh &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
notify(){ sms &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;eml &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# ==== Temporary Notifications ====&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# Dentist appointment&lt;br /&gt;
#schedule $M$d &amp;quot;58&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Dentist&amp;quot; &amp;quot;Appointment 4:00pm 10/31/2017&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# ====== Chore Notifications ======&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# LAUNDRY DAY&lt;br /&gt;
# Day before&lt;br /&gt;
schedule $w$d &amp;quot;Mon[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;LAUNDRY DAY&amp;quot; &amp;quot;WORK: Check gas. HOME: Do laundry, put laundry away.&amp;quot;&lt;br /&gt;
schedule $w$d &amp;quot;Mon(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;LAUNDRY DAY&amp;quot; &amp;quot;WORK: Check gas. HOME: Do laundry, put laundry away.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# WEEKLY CLEANING DAY&lt;br /&gt;
schedule $w &amp;quot;Tue&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;WEEKLY CLEANING DAY&amp;quot; &amp;quot;WORK: Fill gas, shopping. HOME: Clean, litter, sweep/vac, fridge, trash, check meds.&amp;quot;&lt;br /&gt;
# Day after&lt;br /&gt;
schedule $w &amp;quot;Wed&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;WEEKLY REMINDER&amp;quot; &amp;quot;Order meds if necessary.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# MONTHLY CLEANING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Tue[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;MONTHLY CLEANING DAY&amp;quot; &amp;quot;WORK: Car stuff. HOME: Dishes, kitchen, bathroom, dust, inventory.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# BUSINESS DAY&lt;br /&gt;
schedule $d &amp;quot;[1-4]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;BUSINESS DAY&amp;quot; &amp;quot;Rent due before 5th (\$720). Fedloan, budgeting, donations, next-buy.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# TECH DAY&lt;br /&gt;
schedule $w$d &amp;quot;Mon[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;TECH DAY&amp;quot; &amp;quot;WORK: Updates, phone, healthcheck, security scan, organize files. HOME: Organize Workstation/Laptop, USB drives.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# SHOPPING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Wed[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;SHOPPING DAY&amp;quot; &amp;quot;Shopping, carwash. Maybe do during lunch.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# GROOMING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Sun[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;GROOMING DAY&amp;quot; &amp;quot;Shave/trim, clip nails.&amp;quot;&lt;br /&gt;
schedule $w$d &amp;quot;Sun(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;GROOMING DAY&amp;quot; &amp;quot;Shave/trim, clip nails.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ELIMINATION DAY&lt;br /&gt;
schedule $w$d &amp;quot;Sun(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;ELIMINATION DAY&amp;quot; &amp;quot;Do at least one item on TO_ELIMINATE list.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# INVENTORY DAY&lt;br /&gt;
# Disabled. Inventory is now included in monthly cleaning day.&lt;br /&gt;
# schedule $w$d &amp;quot;Tue[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;INVENTORY DAY&amp;quot; &amp;quot;Do home, car, and office inventory.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# = Other Permanent Notifications =&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# Air filter replacement notifications&lt;br /&gt;
schedule $M$d &amp;quot;71&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Air Filter&amp;quot; &amp;quot;Holmes HAP726: Replace HEPA filters (model:HAPF600,qty:2)&amp;quot;&lt;br /&gt;
schedule $M$d &amp;quot;[1|7]1&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Air Filter&amp;quot; &amp;quot;Holmes HAP726: Replace Carbon filters (model:HAPF600,qty:2)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now set the permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:root /scripts/external-ip.sh&lt;br /&gt;
chmod 754 /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reporting External IP Address ==&lt;br /&gt;
&lt;br /&gt;
My home server does not have a static IP address, so I use dynamic DNS. With my free DDNS service, I have to renew the domain name every 30 days. So if I forget to renew it, it will expire and I won't be able to access my server unless I know the IP address. As a contingency, I created a script that sends my external IP address to an email account every 6 hours. Then at least I would be able find out what my last IP was and use that to access my server.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/external-ip.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
log=&amp;quot;/var/log/external-ip.log&amp;quot;&lt;br /&gt;
ipsrc=&amp;quot;http://checkip.dyndns.org&amp;quot;&lt;br /&gt;
date=&amp;quot;`date`&amp;quot;&lt;br /&gt;
addr=&amp;quot;myaccount@yahoo.com&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ip=`curl -s --connect-timeout 3 $ipsrc 2&amp;gt;/dev/null|grep -Po &amp;quot;Current IP Address: .*?\&amp;lt;&amp;quot;|tr '&amp;lt;' '\0'`&lt;br /&gt;
echo &amp;quot;IP: $ip&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if [ -z &amp;quot;$ip&amp;quot; ];then&lt;br /&gt;
	echo &amp;quot;$date ERROR: Could not get external IP from $ipsrc&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
else&lt;br /&gt;
	echo -e &amp;quot;Subject:[`hostname`] $date $ip&amp;quot; | /usr/sbin/ssmtp $addr&lt;br /&gt;
	if [ &amp;quot;$?&amp;quot; = &amp;quot;0&amp;quot; ];then&lt;br /&gt;
		echo &amp;quot;$date SUCCESS: $ip sent to $addr&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
	else&lt;br /&gt;
		echo &amp;quot;$date ERROR: Could not send to $addr&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
	fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now set the permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:root /scripts/external-ip.sh&lt;br /&gt;
chmod 754 /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script appends to a log file &amp;lt;code&amp;gt;/var/log/external-ip.log&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
touch /var/log/external-ip.log&lt;br /&gt;
chown root:root /var/log/external-ip.log&lt;br /&gt;
chmod 644 /var/log/external-ip.log&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Automatic Email Download ==&lt;br /&gt;
&lt;br /&gt;
As mentioned in a previous section, I use free dynamic DNS which requires that I renew it manually every 30 days. I need to remind myself to do this. My provider sends an email notification a few days before it expires, but I hate email and I don't want it in my face all the time, certainly not in my phone.&lt;br /&gt;
&lt;br /&gt;
The best solution I found was to retrieve the email automatically and send me a text message with only the subject line in the message. I eventually created a second method of notification: it generates a file in a place that I regularly go, the folder that contains all of my to-do lists.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/ddns.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# This script is run by a cron job.&lt;br /&gt;
&lt;br /&gt;
/usr/bin/fetchmail -N -d0 -f &amp;quot;/scripts/config/ddns-fetchmailrc&amp;quot; -m &amp;quot;/scripts/config/ddns-mailprocess.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
alertfile=&amp;quot;/shares/Private/000__DDNS-ALERT__.txt&amp;quot;&lt;br /&gt;
if [ -e $alertfile ];then&lt;br /&gt;
	chown root:root $alertfile&lt;br /&gt;
	chmod 777 $alertfile&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/config/ddns-mailprocess.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# This script is run by /scripts/ddns.sh&lt;br /&gt;
&lt;br /&gt;
mailto=&amp;quot;17775551234@myprovider.net&amp;quot;&lt;br /&gt;
date=&amp;quot;`date`&amp;quot;&lt;br /&gt;
log=&amp;quot;/var/log/ddns.log&amp;quot;&lt;br /&gt;
alertfile=&amp;quot;/shares/Private/000__DDNS-ALERT__.txt&amp;quot;&lt;br /&gt;
sms=&amp;quot;/scripts/sms.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cat /dev/stdin | grep -i &amp;quot;^Subject:&amp;quot; | sed 's/Subject\://g' | $sms &amp;quot;DDNS&amp;quot; &amp;quot;`cat /dev/stdin` ( $date )&amp;quot; &amp;amp;&amp;amp;\&lt;br /&gt;
echo &amp;quot;$date - DDNS notification sent to $mailto&amp;quot; | tee -a $log | sed &amp;quot;s/$mailto/cell\ phone/g&amp;quot; &amp;gt;$alertfile &amp;amp;&amp;amp;\&lt;br /&gt;
chmod 777 $alertfile&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/config/ddns-fetchmailrc&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# This rc file is run by /scripts/ddns.sh&lt;br /&gt;
# This file MUST have root:root and chmod 700&lt;br /&gt;
&lt;br /&gt;
set postmaster &amp;quot;username&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
poll &amp;quot;imap.mail.yahoo.com&amp;quot; protocol IMAP username &amp;quot;myaccount@yahoo.com&amp;quot; password &amp;quot;InsertPasswordHere&amp;quot; is &amp;quot;username&amp;quot; here keep folder &amp;quot;DDNS-Mailbox&amp;quot; ssl&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You'll notice that it creates a file &amp;lt;code&amp;gt;/shares/Private/000__DDNS-ALERT__.txt&amp;lt;/code&amp;gt;. The &amp;quot;000&amp;quot; is just to put it at the top of the directory listing. Also notice that I make it read-write for everyone so I can delete it from my webapp.&lt;br /&gt;
&lt;br /&gt;
Set up permissions on all three files, and create the log file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
touch /var/log/ddns.log&lt;br /&gt;
chown root:root /var/log/ddns.log&lt;br /&gt;
chmod 640 /var/log/ddns.log&lt;br /&gt;
&lt;br /&gt;
chown root:root /scripts/ddns.sh&lt;br /&gt;
chmod 754 /scripts/ddns.sh&lt;br /&gt;
&lt;br /&gt;
chown root:config /scripts/config/ddns-mailprocess.sh&lt;br /&gt;
chmod 750 /scripts/config/ddns-mailprocess.sh&lt;br /&gt;
&lt;br /&gt;
chown root:root /scripts/config/ddns-fetchmailrc&lt;br /&gt;
chmod 700 /scripts/config/ddns-fetchmailrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
UPDATE February 2021: Yahoo now requires you to create a &amp;lt;b&amp;gt;secure app password&amp;lt;/b&amp;gt;. See [[#yahoo-app-pass|this section]].&lt;br /&gt;
&lt;br /&gt;
When you run &amp;lt;code&amp;gt;ddns.sh&amp;lt;/code&amp;gt; as root it gives you a warning about running as root. This is okay.&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
fetchmail: WARNING: Running as root is discouraged.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If permissions on &amp;lt;code&amp;gt;ddns-fetchmailrc&amp;lt;/code&amp;gt; are not correct, you will get this failure message:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
File /scripts/config/ddns-fetchmailrc must have no more than -rwx------ (0700) permissions.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set Up Cron ==&lt;br /&gt;
&lt;br /&gt;
Just for reference, here are the entries I made in my &amp;lt;code&amp;gt;/etc/crontab&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Crontabs to be run without 'run-parts'&lt;br /&gt;
#&lt;br /&gt;
# RUN AT NOON&lt;br /&gt;
0                  12           * * *   root    /scripts/ddns.sh&lt;br /&gt;
0                  12           * * *   root    /scripts/notifications.sh&lt;br /&gt;
# RUN EVERY 6 HOURS&lt;br /&gt;
1                  0,6,12,18    * * *   root    /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;yahoo-app-pass&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt;Yahoo App Password ==&lt;br /&gt;
&lt;br /&gt;
As of February 2021, Yahoo changed that way third party apps can access it. Instead of using your normal password, you need to generate an &amp;lt;b&amp;gt;app password&amp;lt;/b&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Login to Yahoo, click you user icon, and click &amp;lt;b&amp;gt;Account Info&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click &amp;lt;b&amp;gt;Account Security&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click &amp;lt;b&amp;gt;Manage app passwords&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click the &amp;lt;b&amp;gt;Select your app&amp;lt;/b&amp;gt; drop-down and select &amp;lt;b&amp;gt;Other app&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Type a name for the app then click &amp;lt;b&amp;gt;Generate&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Now you can copy the password and use it in your app. Once you navigate away from this page, you will not be able to retrieve the password again. You will have to generate another password.&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=Automatic_Email_and_Text_Notifications&amp;diff=3683</id>
		<title>Automatic Email and Text Notifications</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=Automatic_Email_and_Text_Notifications&amp;diff=3683"/>
				<updated>2021-02-26T14:12:09Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Yahoo App Password */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These tutorials describe my method of automatic messaging via email and text (SMS) from my Linux servers.&lt;br /&gt;
&lt;br /&gt;
== Required Packages ==&lt;br /&gt;
&lt;br /&gt;
These packages are necessary for the all the following sections of this tutorial. In Debain, install them with &amp;lt;code&amp;gt;apt-get&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
apt-get install ssmtp procmail fetchmail&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Directory Structure ==&lt;br /&gt;
&lt;br /&gt;
Just for reference, here are the locations of the relevant files:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
/&lt;br /&gt;
├── etc&lt;br /&gt;
│   └── ssmtp&lt;br /&gt;
│       └── ssmtp.conf&lt;br /&gt;
└── scripts&lt;br /&gt;
    ├── config&lt;br /&gt;
    │   ├── accounts.conf&lt;br /&gt;
    │   ├── ddns-fetchmailrc&lt;br /&gt;
    │   └── ddns-mailprocess.sh&lt;br /&gt;
    ├── ddns.sh&lt;br /&gt;
    ├── email.sh&lt;br /&gt;
    ├── external-ip.sh&lt;br /&gt;
    ├── notifications.sh&lt;br /&gt;
    └── sms.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l /scripts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
drwxr-xr-x 4 root config   4096 Jun 20 08:52 config&lt;br /&gt;
-rwxr-xr-- 1 root root      260 Jun 20 08:40 ddns.sh&lt;br /&gt;
-rwxr-xr-- 1 root mailers   564 Apr 23 12:18 email.sh&lt;br /&gt;
-rwxr-xr-- 1 root root      529 Apr 27 07:56 external-ip.sh&lt;br /&gt;
-rwxr-xr-- 1 root root     3834 May 15 08:32 notifications.sh&lt;br /&gt;
-rwxr-xr-- 1 root texters   545 Apr 23 12:24 sms.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l /scripts/config&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
-rwxr-x--- 1 root mailers  147 May  1 13:01 accounts.conf&lt;br /&gt;
-rwx------ 1 root root     246 May 21 09:49 ddns-fetchmailrc&lt;br /&gt;
-rwxr-x--- 1 root config   604 Jun 20 08:52 ddns-mailprocess.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create Security Groups ==&lt;br /&gt;
&lt;br /&gt;
I use group membership to control read access to certain files. You don't have to do this, but it was useful for me.&lt;br /&gt;
&lt;br /&gt;
Create the groups:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
groupadd texters #allowed to sent text messages&lt;br /&gt;
groupadd mailers #allowed to send email messages&lt;br /&gt;
groupadd config  #allowed to read other config files&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can add a user to all three groups like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
usermod -aG texters,mailers,config username&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Email and Text Messaging with SSMTP ==&lt;br /&gt;
&lt;br /&gt;
First set up the &amp;lt;code&amp;gt;/etc/ssmtp/ssmtp.conf&amp;lt;/code&amp;gt;. I use a dedicated Gmail account (named &amp;lt;b&amp;gt;serveraccount@gmail.com&amp;lt;/b&amp;gt; in the example below) for all of my server messaging. When I receive an email from my server, it will look like it's coming from that Gmail.&lt;br /&gt;
&lt;br /&gt;
Make a backup copy of the original config:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.orig&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here are the contents of my modified &amp;lt;code&amp;gt;/etc/ssmtp/ssmtp.conf&amp;lt;/code&amp;gt;. Replace the relevant values.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Config file for sSMTP sendmail&lt;br /&gt;
#&lt;br /&gt;
# The person who gets all mail for userids &amp;lt; 1000&lt;br /&gt;
# Make this empty to disable rewriting.&lt;br /&gt;
root=serveraccount&lt;br /&gt;
&lt;br /&gt;
# The place where the mail goes. The actual machine name is required no&lt;br /&gt;
# MX records are consulted. Commonly mailhosts are named mail.domain.com&lt;br /&gt;
#mailhub=mail&lt;br /&gt;
&lt;br /&gt;
# Where will the mail seem to come from?&lt;br /&gt;
rewriteDomain=gmail.com&lt;br /&gt;
&lt;br /&gt;
# The full hostname&lt;br /&gt;
# This can be left as 'localhost'&lt;br /&gt;
hostname=localhost&lt;br /&gt;
&lt;br /&gt;
# Are users allowed to set their own From: address?&lt;br /&gt;
# YES - Allow the user to specify their own From: address&lt;br /&gt;
# NO - Use the system generated From: address&lt;br /&gt;
FromLineOverride=YES&lt;br /&gt;
&lt;br /&gt;
mailhub=smtp.gmail.com:587&lt;br /&gt;
UseStartTLS=YES&lt;br /&gt;
UseTLS=YES&lt;br /&gt;
AuthMethod=LOGIN&lt;br /&gt;
AuthUser=serveraccount@gmail.com&lt;br /&gt;
AuthPass=InsertPasswordHere&lt;br /&gt;
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt&lt;br /&gt;
FromLineOverride=YES&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the file contains a password, make sure the file is not readable to normal users.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mail /etc/ssmtp/ssmtp.conf&lt;br /&gt;
chmod 640 /etc/ssmtp/ssmtp.conf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And because you don't have to remember this password, it would be a good idea to make it very long and complex (16+ characters; uppercase, lowercase, numbers, and special characters; no dictionary words).&lt;br /&gt;
&lt;br /&gt;
You now need to log onto the &amp;lt;b&amp;gt;serveraccount&amp;lt;/b&amp;gt; Gmail account and enable &amp;quot;less secure apps&amp;quot; at https://myaccount.google.com/lesssecureapps?pli=1 &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Gmail-less-secure-app.png|frameless|600px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Here is more info about less secure apps: https://support.google.com/cloudidentity/answer/6260879?hl=en&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should now be able use the &amp;lt;code&amp;gt;ssmtp&amp;lt;/code&amp;gt; command line tool from your server. Most of the time, you will need to include a subject line. It's important that it follows the format below (capital 'S' on Subject, colon, space, YourSubject, two newlines):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo -e &amp;quot;Subject: Hi\n\nHello, world!&amp;quot; | ssmtp myaccount@yahoo.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a Secure Accounts File ==&lt;br /&gt;
&lt;br /&gt;
For some of the automatic messaging, you need to store text and email accounts in a file. To figure out the destination address to send text (SMS) messages to your cell, look on your cell provider's website for the proper account/domain name. It will probably be something like &amp;quot;&amp;lt;your-phone-number&amp;gt;@&amp;lt;provider-domain&amp;gt;&amp;quot;. [https://kb.sandisk.com/app/answers/detail/a_id/17056/~/list-of-mobile-carrier-gateway-addresses List of provider addresses]&lt;br /&gt;
&lt;br /&gt;
Contents of my &amp;lt;code&amp;gt;/scripts/config/accounts.conf&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# Secure account information&lt;br /&gt;
# Permissions must be 750 root:mailers&lt;br /&gt;
&lt;br /&gt;
smsto=&amp;quot;17775551234@myprovider.net&amp;quot;&lt;br /&gt;
mailto=&amp;quot;myaccount@yahoo.com&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the permissions on the file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mailers /scripts/config/accounts.conf&lt;br /&gt;
chmod 750 /scripts/config/accounts.conf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Email Script ==&lt;br /&gt;
&lt;br /&gt;
This script can be used to send an email message.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/email.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# Send email message:&lt;br /&gt;
#  Usage: $0 &amp;quot;&amp;lt;Subject&amp;gt;&amp;quot; &amp;quot;&amp;lt;Message&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
default_subject=&amp;quot;Alert from Server (`date`)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
subject=&amp;quot;&amp;quot;&lt;br /&gt;
message=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
case $# in&lt;br /&gt;
  2)&lt;br /&gt;
    subject=&amp;quot;$1&amp;quot;&lt;br /&gt;
    message=&amp;quot;$2&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  1)&lt;br /&gt;
    subject=&amp;quot;$default_subject&amp;quot;&lt;br /&gt;
    message=&amp;quot;$1&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  *)&lt;br /&gt;
    echo &amp;quot;Send Email Message:&amp;quot;&lt;br /&gt;
    echo &amp;quot;  Usage: `basename $0` \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    echo &amp;quot;         `basename $0` \&amp;quot;Subject\&amp;quot; \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
  ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
dir=&amp;quot;$(cd $(dirname ${BASH_SOURCE[0]})&amp;amp;&amp;amp;pwd)&amp;quot;&lt;br /&gt;
. $dir/config/accounts.conf&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;Subject: $subject\n\n$message&amp;quot; | /usr/sbin/ssmtp $mailto&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mailers /scripts/email.sh&lt;br /&gt;
chmod 754 /scripts/email.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create an alias so you can quickly run this from the command line:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo &amp;quot;alias email='/scripts/email.sh'&amp;quot; &amp;gt;&amp;gt;~/.bashrc&lt;br /&gt;
source ~/.bashrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Send message with default subject&lt;br /&gt;
email &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Send message with a subject&lt;br /&gt;
email &amp;quot;Test Subject&amp;quot; &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Text Script ==&lt;br /&gt;
&lt;br /&gt;
This script can be used to send a text (SMS) message.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/sms.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# Send SMS message:&lt;br /&gt;
#  Usage: $0 &amp;quot;&amp;lt;Subject&amp;gt;&amp;quot; &amp;quot;&amp;lt;Message&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
default_subject=&amp;quot;Alert&amp;quot;&lt;br /&gt;
&lt;br /&gt;
subject=&amp;quot;&amp;quot;&lt;br /&gt;
message=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
case $# in&lt;br /&gt;
  2)&lt;br /&gt;
    subject=&amp;quot;$1&amp;quot;&lt;br /&gt;
    message=&amp;quot;$2&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  1)&lt;br /&gt;
    subject=&amp;quot;$default_subject&amp;quot;&lt;br /&gt;
    message=&amp;quot;$1&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  *)&lt;br /&gt;
    echo &amp;quot;Send SMS Message:&amp;quot;&lt;br /&gt;
    echo &amp;quot;  Usage: `basename $0` \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    echo &amp;quot;         `basename $0` \&amp;quot;Subject\&amp;quot; \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
  ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
dir=&amp;quot;$(cd $(dirname ${BASH_SOURCE[0]})&amp;amp;&amp;amp;pwd)&amp;quot;&lt;br /&gt;
. $dir/config/accounts.conf&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;To: $smsto\nSubject: $subject\n\n$message&amp;quot; | /usr/sbin/ssmtp $smsto&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:texters /scripts/sms.sh&lt;br /&gt;
chmod 754 /scripts/sms.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create an alias so you can quickly run this from the command line:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo &amp;quot;alias sms='/scripts/sms.sh'&amp;quot; &amp;gt;&amp;gt;~/.bashrc&lt;br /&gt;
source ~/.bashrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Send message with default subject&lt;br /&gt;
sms &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Send message with a subject&lt;br /&gt;
sms &amp;quot;Test Subject&amp;quot; &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scheduled Notifications Script ==&lt;br /&gt;
&lt;br /&gt;
One of my life improvement tasks was to organize chores into scheduled chore days and rely on text/email notification to remind me to do them.&lt;br /&gt;
&lt;br /&gt;
This dramatically reduced the amount of time I spend working on chores, and the amount of effort I spend thinking about what needs to be done. I could barely get projects done because every day I was loading my task list with chores. Now I don't think about chores until I'm notified. When I think of new chores, new items for my inventory, or other things I need to be reminded of, I update my checklists. When I feel I can improve scheduling or consolidate chores, I update my notifications script.&lt;br /&gt;
&lt;br /&gt;
This utilizes the &amp;lt;b&amp;gt;Email Script&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;Text Script&amp;lt;/b&amp;gt; from the previous sections.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/notifications.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# Send regular notifications.&lt;br /&gt;
# Currently set to run daily at NOON.&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
# Get current datetime values&lt;br /&gt;
dt=(`date +%Y\ %m\ %d\ %H\ %M\ %S\ %a\ %s\ %I\ %p\ %Z`)&lt;br /&gt;
y=$((10#${dt[0]})) #year&lt;br /&gt;
M=$((10#${dt[1]})) #month&lt;br /&gt;
d=$((10#${dt[2]})) #day&lt;br /&gt;
h=$((10#${dt[3]})) #hour(24)&lt;br /&gt;
m=$((10#${dt[4]})) #minute&lt;br /&gt;
s=$((10#${dt[5]})) #second&lt;br /&gt;
w=${dt[6]}         #day of week (eg. Sun)&lt;br /&gt;
e=$((10#${dt[7]})) #epoch&lt;br /&gt;
t=$((10#${dt[8]})) #hour(12)&lt;br /&gt;
p=${dt[9]}         #meridian (AM/PM)&lt;br /&gt;
z=${dt[10]}        #timezone (eg. PDT)&lt;br /&gt;
&lt;br /&gt;
# Schedule command when date ($1) matched regex ($2) with extra grep parameters ($3)&lt;br /&gt;
# Use parameter -P at $3 for perl regex: in case you need to use (str1|str2).&lt;br /&gt;
# Example: schedule $M$d &amp;quot;(115|21)&amp;quot; -P &amp;amp;&amp;amp; sms &amp;quot;Subject&amp;quot; &amp;quot;Message&amp;quot;&lt;br /&gt;
# Don't use -P when you want a range of numbers including 2 or more digit numbers (ie. [1-15]).&lt;br /&gt;
schedule(){ echo &amp;quot;$1&amp;quot; | grep -wq $3 &amp;quot;$2&amp;quot;;}&lt;br /&gt;
sms(){ /scripts/sms.sh &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
eml(){ /scripts/email.sh &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
notify(){ sms &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;eml &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# ==== Temporary Notifications ====&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# Dentist appointment&lt;br /&gt;
#schedule $M$d &amp;quot;58&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Dentist&amp;quot; &amp;quot;Appointment 4:00pm 10/31/2017&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# ====== Chore Notifications ======&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# LAUNDRY DAY&lt;br /&gt;
# Day before&lt;br /&gt;
schedule $w$d &amp;quot;Mon[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;LAUNDRY DAY&amp;quot; &amp;quot;WORK: Check gas. HOME: Do laundry, put laundry away.&amp;quot;&lt;br /&gt;
schedule $w$d &amp;quot;Mon(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;LAUNDRY DAY&amp;quot; &amp;quot;WORK: Check gas. HOME: Do laundry, put laundry away.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# WEEKLY CLEANING DAY&lt;br /&gt;
schedule $w &amp;quot;Tue&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;WEEKLY CLEANING DAY&amp;quot; &amp;quot;WORK: Fill gas, shopping. HOME: Clean, litter, sweep/vac, fridge, trash, check meds.&amp;quot;&lt;br /&gt;
# Day after&lt;br /&gt;
schedule $w &amp;quot;Wed&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;WEEKLY REMINDER&amp;quot; &amp;quot;Order meds if necessary.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# MONTHLY CLEANING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Tue[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;MONTHLY CLEANING DAY&amp;quot; &amp;quot;WORK: Car stuff. HOME: Dishes, kitchen, bathroom, dust, inventory.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# BUSINESS DAY&lt;br /&gt;
schedule $d &amp;quot;[1-4]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;BUSINESS DAY&amp;quot; &amp;quot;Rent due before 5th (\$720). Fedloan, budgeting, donations, next-buy.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# TECH DAY&lt;br /&gt;
schedule $w$d &amp;quot;Mon[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;TECH DAY&amp;quot; &amp;quot;WORK: Updates, phone, healthcheck, security scan, organize files. HOME: Organize Workstation/Laptop, USB drives.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# SHOPPING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Wed[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;SHOPPING DAY&amp;quot; &amp;quot;Shopping, carwash. Maybe do during lunch.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# GROOMING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Sun[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;GROOMING DAY&amp;quot; &amp;quot;Shave/trim, clip nails.&amp;quot;&lt;br /&gt;
schedule $w$d &amp;quot;Sun(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;GROOMING DAY&amp;quot; &amp;quot;Shave/trim, clip nails.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ELIMINATION DAY&lt;br /&gt;
schedule $w$d &amp;quot;Sun(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;ELIMINATION DAY&amp;quot; &amp;quot;Do at least one item on TO_ELIMINATE list.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# INVENTORY DAY&lt;br /&gt;
# Disabled. Inventory is now included in monthly cleaning day.&lt;br /&gt;
# schedule $w$d &amp;quot;Tue[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;INVENTORY DAY&amp;quot; &amp;quot;Do home, car, and office inventory.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# = Other Permanent Notifications =&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# Air filter replacement notifications&lt;br /&gt;
schedule $M$d &amp;quot;71&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Air Filter&amp;quot; &amp;quot;Holmes HAP726: Replace HEPA filters (model:HAPF600,qty:2)&amp;quot;&lt;br /&gt;
schedule $M$d &amp;quot;[1|7]1&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Air Filter&amp;quot; &amp;quot;Holmes HAP726: Replace Carbon filters (model:HAPF600,qty:2)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now set the permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:root /scripts/external-ip.sh&lt;br /&gt;
chmod 754 /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reporting External IP Address ==&lt;br /&gt;
&lt;br /&gt;
My home server does not have a static IP address, so I use dynamic DNS. With my free DDNS service, I have to renew the domain name every 30 days. So if I forget to renew it, it will expire and I won't be able to access my server unless I know the IP address. As a contingency, I created a script that sends my external IP address to an email account every 6 hours. Then at least I would be able find out what my last IP was and use that to access my server.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/external-ip.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
log=&amp;quot;/var/log/external-ip.log&amp;quot;&lt;br /&gt;
ipsrc=&amp;quot;http://checkip.dyndns.org&amp;quot;&lt;br /&gt;
date=&amp;quot;`date`&amp;quot;&lt;br /&gt;
addr=&amp;quot;myaccount@yahoo.com&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ip=`curl -s --connect-timeout 3 $ipsrc 2&amp;gt;/dev/null|grep -Po &amp;quot;Current IP Address: .*?\&amp;lt;&amp;quot;|tr '&amp;lt;' '\0'`&lt;br /&gt;
echo &amp;quot;IP: $ip&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if [ -z &amp;quot;$ip&amp;quot; ];then&lt;br /&gt;
	echo &amp;quot;$date ERROR: Could not get external IP from $ipsrc&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
else&lt;br /&gt;
	echo -e &amp;quot;Subject:[`hostname`] $date $ip&amp;quot; | /usr/sbin/ssmtp $addr&lt;br /&gt;
	if [ &amp;quot;$?&amp;quot; = &amp;quot;0&amp;quot; ];then&lt;br /&gt;
		echo &amp;quot;$date SUCCESS: $ip sent to $addr&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
	else&lt;br /&gt;
		echo &amp;quot;$date ERROR: Could not send to $addr&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
	fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now set the permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:root /scripts/external-ip.sh&lt;br /&gt;
chmod 754 /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script appends to a log file &amp;lt;code&amp;gt;/var/log/external-ip.log&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
touch /var/log/external-ip.log&lt;br /&gt;
chown root:root /var/log/external-ip.log&lt;br /&gt;
chmod 644 /var/log/external-ip.log&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Automatic Email Download ==&lt;br /&gt;
&lt;br /&gt;
As mentioned in a previous section, I use free dynamic DNS which requires that I renew it manually every 30 days. I need to remind myself to do this. My provider sends an email notification a few days before it expires, but I hate email and I don't want it in my face all the time, certainly not in my phone.&lt;br /&gt;
&lt;br /&gt;
The best solution I found was to retrieve the email automatically and send me a text message with only the subject line in the message. I eventually created a second method of notification: it generates a file in a place that I regularly go, the folder that contains all of my to-do lists.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/ddns.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# This script is run by a cron job.&lt;br /&gt;
&lt;br /&gt;
/usr/bin/fetchmail -N -d0 -f &amp;quot;/scripts/config/ddns-fetchmailrc&amp;quot; -m &amp;quot;/scripts/config/ddns-mailprocess.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
alertfile=&amp;quot;/shares/Private/000__DDNS-ALERT__.txt&amp;quot;&lt;br /&gt;
if [ -e $alertfile ];then&lt;br /&gt;
	chown root:root $alertfile&lt;br /&gt;
	chmod 777 $alertfile&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/config/ddns-mailprocess.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# This script is run by /scripts/ddns.sh&lt;br /&gt;
&lt;br /&gt;
mailto=&amp;quot;17775551234@myprovider.net&amp;quot;&lt;br /&gt;
date=&amp;quot;`date`&amp;quot;&lt;br /&gt;
log=&amp;quot;/var/log/ddns.log&amp;quot;&lt;br /&gt;
alertfile=&amp;quot;/shares/Private/000__DDNS-ALERT__.txt&amp;quot;&lt;br /&gt;
sms=&amp;quot;/scripts/sms.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cat /dev/stdin | grep -i &amp;quot;^Subject:&amp;quot; | sed 's/Subject\://g' | $sms &amp;quot;DDNS&amp;quot; &amp;quot;`cat /dev/stdin` ( $date )&amp;quot; &amp;amp;&amp;amp;\&lt;br /&gt;
echo &amp;quot;$date - DDNS notification sent to $mailto&amp;quot; | tee -a $log | sed &amp;quot;s/$mailto/cell\ phone/g&amp;quot; &amp;gt;$alertfile &amp;amp;&amp;amp;\&lt;br /&gt;
chmod 777 $alertfile&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/config/ddns-fetchmailrc&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# This rc file is run by /scripts/ddns.sh&lt;br /&gt;
# This file MUST have root:root and chmod 700&lt;br /&gt;
&lt;br /&gt;
set postmaster &amp;quot;username&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
poll &amp;quot;imap.mail.yahoo.com&amp;quot; protocol IMAP username &amp;quot;myaccount@yahoo.com&amp;quot; password &amp;quot;InsertPasswordHere&amp;quot; is &amp;quot;username&amp;quot; here keep folder &amp;quot;DDNS-Mailbox&amp;quot; ssl&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You'll notice that it creates a file &amp;lt;code&amp;gt;/shares/Private/000__DDNS-ALERT__.txt&amp;lt;/code&amp;gt;. The &amp;quot;000&amp;quot; is just to put it at the top of the directory listing. Also notice that I make it read-write for everyone so I can delete it from my webapp.&lt;br /&gt;
&lt;br /&gt;
Set up permissions on all three files, and create the log file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
touch /var/log/ddns.log&lt;br /&gt;
chown root:root /var/log/ddns.log&lt;br /&gt;
chmod 640 /var/log/ddns.log&lt;br /&gt;
&lt;br /&gt;
chown root:root /scripts/ddns.sh&lt;br /&gt;
chmod 754 /scripts/ddns.sh&lt;br /&gt;
&lt;br /&gt;
chown root:config /scripts/config/ddns-mailprocess.sh&lt;br /&gt;
chmod 750 /scripts/config/ddns-mailprocess.sh&lt;br /&gt;
&lt;br /&gt;
chown root:root /scripts/config/ddns-fetchmailrc&lt;br /&gt;
chmod 700 /scripts/config/ddns-fetchmailrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
UPDATE February 2021: Yahoo now requires you to create a &amp;lt;b&amp;gt;secure app password&amp;lt;/b&amp;gt;. See [[#yahoo-app-pass|this section]].&lt;br /&gt;
&lt;br /&gt;
When you run &amp;lt;code&amp;gt;ddns.sh&amp;lt;/code&amp;gt; as root it gives you a warning about running as root. This is okay.&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
fetchmail: WARNING: Running as root is discouraged.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If permissions on &amp;lt;code&amp;gt;ddns-fetchmailrc&amp;lt;/code&amp;gt; are not correct, you will get this failure message:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
File /scripts/config/ddns-fetchmailrc must have no more than -rwx------ (0700) permissions.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set Up Cron ==&lt;br /&gt;
&lt;br /&gt;
Just for reference, here are the entries I made in my &amp;lt;code&amp;gt;/etc/crontab&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Crontabs to be run without 'run-parts'&lt;br /&gt;
#&lt;br /&gt;
# RUN AT NOON&lt;br /&gt;
0                  12           * * *   root    /scripts/ddns.sh&lt;br /&gt;
0                  12           * * *   root    /scripts/notifications.sh&lt;br /&gt;
# RUN EVERY 6 HOURS&lt;br /&gt;
1                  0,6,12,18    * * *   root    /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;a name=&amp;quot;yahoo-app-pass&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;Yahoo App Password ==&lt;br /&gt;
&lt;br /&gt;
As of February 2021, Yahoo changed that way third party apps can access it. Instead of using your normal password, you need to generate an &amp;lt;b&amp;gt;app password&amp;lt;/b&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Login to Yahoo, click you user icon, and click &amp;lt;b&amp;gt;Account Info&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click &amp;lt;b&amp;gt;Account Security&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click &amp;lt;b&amp;gt;Manage app passwords&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click the &amp;lt;b&amp;gt;Select your app&amp;lt;/b&amp;gt; drop-down and select &amp;lt;b&amp;gt;Other app&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Type a name for the app then click &amp;lt;b&amp;gt;Generate&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Now you can copy the password and use it in your app. Once you navigate away from this page, you will not be able to retrieve the password again. You will have to generate another password.&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=Automatic_Email_and_Text_Notifications&amp;diff=3682</id>
		<title>Automatic Email and Text Notifications</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=Automatic_Email_and_Text_Notifications&amp;diff=3682"/>
				<updated>2021-02-26T14:11:26Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Set Up Cron */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These tutorials describe my method of automatic messaging via email and text (SMS) from my Linux servers.&lt;br /&gt;
&lt;br /&gt;
== Required Packages ==&lt;br /&gt;
&lt;br /&gt;
These packages are necessary for the all the following sections of this tutorial. In Debain, install them with &amp;lt;code&amp;gt;apt-get&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
apt-get install ssmtp procmail fetchmail&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Directory Structure ==&lt;br /&gt;
&lt;br /&gt;
Just for reference, here are the locations of the relevant files:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
/&lt;br /&gt;
├── etc&lt;br /&gt;
│   └── ssmtp&lt;br /&gt;
│       └── ssmtp.conf&lt;br /&gt;
└── scripts&lt;br /&gt;
    ├── config&lt;br /&gt;
    │   ├── accounts.conf&lt;br /&gt;
    │   ├── ddns-fetchmailrc&lt;br /&gt;
    │   └── ddns-mailprocess.sh&lt;br /&gt;
    ├── ddns.sh&lt;br /&gt;
    ├── email.sh&lt;br /&gt;
    ├── external-ip.sh&lt;br /&gt;
    ├── notifications.sh&lt;br /&gt;
    └── sms.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l /scripts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
drwxr-xr-x 4 root config   4096 Jun 20 08:52 config&lt;br /&gt;
-rwxr-xr-- 1 root root      260 Jun 20 08:40 ddns.sh&lt;br /&gt;
-rwxr-xr-- 1 root mailers   564 Apr 23 12:18 email.sh&lt;br /&gt;
-rwxr-xr-- 1 root root      529 Apr 27 07:56 external-ip.sh&lt;br /&gt;
-rwxr-xr-- 1 root root     3834 May 15 08:32 notifications.sh&lt;br /&gt;
-rwxr-xr-- 1 root texters   545 Apr 23 12:24 sms.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l /scripts/config&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
-rwxr-x--- 1 root mailers  147 May  1 13:01 accounts.conf&lt;br /&gt;
-rwx------ 1 root root     246 May 21 09:49 ddns-fetchmailrc&lt;br /&gt;
-rwxr-x--- 1 root config   604 Jun 20 08:52 ddns-mailprocess.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create Security Groups ==&lt;br /&gt;
&lt;br /&gt;
I use group membership to control read access to certain files. You don't have to do this, but it was useful for me.&lt;br /&gt;
&lt;br /&gt;
Create the groups:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
groupadd texters #allowed to sent text messages&lt;br /&gt;
groupadd mailers #allowed to send email messages&lt;br /&gt;
groupadd config  #allowed to read other config files&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can add a user to all three groups like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
usermod -aG texters,mailers,config username&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Email and Text Messaging with SSMTP ==&lt;br /&gt;
&lt;br /&gt;
First set up the &amp;lt;code&amp;gt;/etc/ssmtp/ssmtp.conf&amp;lt;/code&amp;gt;. I use a dedicated Gmail account (named &amp;lt;b&amp;gt;serveraccount@gmail.com&amp;lt;/b&amp;gt; in the example below) for all of my server messaging. When I receive an email from my server, it will look like it's coming from that Gmail.&lt;br /&gt;
&lt;br /&gt;
Make a backup copy of the original config:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.orig&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here are the contents of my modified &amp;lt;code&amp;gt;/etc/ssmtp/ssmtp.conf&amp;lt;/code&amp;gt;. Replace the relevant values.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Config file for sSMTP sendmail&lt;br /&gt;
#&lt;br /&gt;
# The person who gets all mail for userids &amp;lt; 1000&lt;br /&gt;
# Make this empty to disable rewriting.&lt;br /&gt;
root=serveraccount&lt;br /&gt;
&lt;br /&gt;
# The place where the mail goes. The actual machine name is required no&lt;br /&gt;
# MX records are consulted. Commonly mailhosts are named mail.domain.com&lt;br /&gt;
#mailhub=mail&lt;br /&gt;
&lt;br /&gt;
# Where will the mail seem to come from?&lt;br /&gt;
rewriteDomain=gmail.com&lt;br /&gt;
&lt;br /&gt;
# The full hostname&lt;br /&gt;
# This can be left as 'localhost'&lt;br /&gt;
hostname=localhost&lt;br /&gt;
&lt;br /&gt;
# Are users allowed to set their own From: address?&lt;br /&gt;
# YES - Allow the user to specify their own From: address&lt;br /&gt;
# NO - Use the system generated From: address&lt;br /&gt;
FromLineOverride=YES&lt;br /&gt;
&lt;br /&gt;
mailhub=smtp.gmail.com:587&lt;br /&gt;
UseStartTLS=YES&lt;br /&gt;
UseTLS=YES&lt;br /&gt;
AuthMethod=LOGIN&lt;br /&gt;
AuthUser=serveraccount@gmail.com&lt;br /&gt;
AuthPass=InsertPasswordHere&lt;br /&gt;
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt&lt;br /&gt;
FromLineOverride=YES&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the file contains a password, make sure the file is not readable to normal users.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mail /etc/ssmtp/ssmtp.conf&lt;br /&gt;
chmod 640 /etc/ssmtp/ssmtp.conf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And because you don't have to remember this password, it would be a good idea to make it very long and complex (16+ characters; uppercase, lowercase, numbers, and special characters; no dictionary words).&lt;br /&gt;
&lt;br /&gt;
You now need to log onto the &amp;lt;b&amp;gt;serveraccount&amp;lt;/b&amp;gt; Gmail account and enable &amp;quot;less secure apps&amp;quot; at https://myaccount.google.com/lesssecureapps?pli=1 &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Gmail-less-secure-app.png|frameless|600px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Here is more info about less secure apps: https://support.google.com/cloudidentity/answer/6260879?hl=en&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should now be able use the &amp;lt;code&amp;gt;ssmtp&amp;lt;/code&amp;gt; command line tool from your server. Most of the time, you will need to include a subject line. It's important that it follows the format below (capital 'S' on Subject, colon, space, YourSubject, two newlines):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo -e &amp;quot;Subject: Hi\n\nHello, world!&amp;quot; | ssmtp myaccount@yahoo.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a Secure Accounts File ==&lt;br /&gt;
&lt;br /&gt;
For some of the automatic messaging, you need to store text and email accounts in a file. To figure out the destination address to send text (SMS) messages to your cell, look on your cell provider's website for the proper account/domain name. It will probably be something like &amp;quot;&amp;lt;your-phone-number&amp;gt;@&amp;lt;provider-domain&amp;gt;&amp;quot;. [https://kb.sandisk.com/app/answers/detail/a_id/17056/~/list-of-mobile-carrier-gateway-addresses List of provider addresses]&lt;br /&gt;
&lt;br /&gt;
Contents of my &amp;lt;code&amp;gt;/scripts/config/accounts.conf&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# Secure account information&lt;br /&gt;
# Permissions must be 750 root:mailers&lt;br /&gt;
&lt;br /&gt;
smsto=&amp;quot;17775551234@myprovider.net&amp;quot;&lt;br /&gt;
mailto=&amp;quot;myaccount@yahoo.com&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the permissions on the file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mailers /scripts/config/accounts.conf&lt;br /&gt;
chmod 750 /scripts/config/accounts.conf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Email Script ==&lt;br /&gt;
&lt;br /&gt;
This script can be used to send an email message.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/email.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# Send email message:&lt;br /&gt;
#  Usage: $0 &amp;quot;&amp;lt;Subject&amp;gt;&amp;quot; &amp;quot;&amp;lt;Message&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
default_subject=&amp;quot;Alert from Server (`date`)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
subject=&amp;quot;&amp;quot;&lt;br /&gt;
message=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
case $# in&lt;br /&gt;
  2)&lt;br /&gt;
    subject=&amp;quot;$1&amp;quot;&lt;br /&gt;
    message=&amp;quot;$2&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  1)&lt;br /&gt;
    subject=&amp;quot;$default_subject&amp;quot;&lt;br /&gt;
    message=&amp;quot;$1&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  *)&lt;br /&gt;
    echo &amp;quot;Send Email Message:&amp;quot;&lt;br /&gt;
    echo &amp;quot;  Usage: `basename $0` \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    echo &amp;quot;         `basename $0` \&amp;quot;Subject\&amp;quot; \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
  ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
dir=&amp;quot;$(cd $(dirname ${BASH_SOURCE[0]})&amp;amp;&amp;amp;pwd)&amp;quot;&lt;br /&gt;
. $dir/config/accounts.conf&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;Subject: $subject\n\n$message&amp;quot; | /usr/sbin/ssmtp $mailto&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mailers /scripts/email.sh&lt;br /&gt;
chmod 754 /scripts/email.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create an alias so you can quickly run this from the command line:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo &amp;quot;alias email='/scripts/email.sh'&amp;quot; &amp;gt;&amp;gt;~/.bashrc&lt;br /&gt;
source ~/.bashrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Send message with default subject&lt;br /&gt;
email &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Send message with a subject&lt;br /&gt;
email &amp;quot;Test Subject&amp;quot; &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Text Script ==&lt;br /&gt;
&lt;br /&gt;
This script can be used to send a text (SMS) message.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/sms.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# Send SMS message:&lt;br /&gt;
#  Usage: $0 &amp;quot;&amp;lt;Subject&amp;gt;&amp;quot; &amp;quot;&amp;lt;Message&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
default_subject=&amp;quot;Alert&amp;quot;&lt;br /&gt;
&lt;br /&gt;
subject=&amp;quot;&amp;quot;&lt;br /&gt;
message=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
case $# in&lt;br /&gt;
  2)&lt;br /&gt;
    subject=&amp;quot;$1&amp;quot;&lt;br /&gt;
    message=&amp;quot;$2&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  1)&lt;br /&gt;
    subject=&amp;quot;$default_subject&amp;quot;&lt;br /&gt;
    message=&amp;quot;$1&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  *)&lt;br /&gt;
    echo &amp;quot;Send SMS Message:&amp;quot;&lt;br /&gt;
    echo &amp;quot;  Usage: `basename $0` \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    echo &amp;quot;         `basename $0` \&amp;quot;Subject\&amp;quot; \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
  ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
dir=&amp;quot;$(cd $(dirname ${BASH_SOURCE[0]})&amp;amp;&amp;amp;pwd)&amp;quot;&lt;br /&gt;
. $dir/config/accounts.conf&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;To: $smsto\nSubject: $subject\n\n$message&amp;quot; | /usr/sbin/ssmtp $smsto&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:texters /scripts/sms.sh&lt;br /&gt;
chmod 754 /scripts/sms.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create an alias so you can quickly run this from the command line:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo &amp;quot;alias sms='/scripts/sms.sh'&amp;quot; &amp;gt;&amp;gt;~/.bashrc&lt;br /&gt;
source ~/.bashrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Send message with default subject&lt;br /&gt;
sms &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Send message with a subject&lt;br /&gt;
sms &amp;quot;Test Subject&amp;quot; &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scheduled Notifications Script ==&lt;br /&gt;
&lt;br /&gt;
One of my life improvement tasks was to organize chores into scheduled chore days and rely on text/email notification to remind me to do them.&lt;br /&gt;
&lt;br /&gt;
This dramatically reduced the amount of time I spend working on chores, and the amount of effort I spend thinking about what needs to be done. I could barely get projects done because every day I was loading my task list with chores. Now I don't think about chores until I'm notified. When I think of new chores, new items for my inventory, or other things I need to be reminded of, I update my checklists. When I feel I can improve scheduling or consolidate chores, I update my notifications script.&lt;br /&gt;
&lt;br /&gt;
This utilizes the &amp;lt;b&amp;gt;Email Script&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;Text Script&amp;lt;/b&amp;gt; from the previous sections.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/notifications.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# Send regular notifications.&lt;br /&gt;
# Currently set to run daily at NOON.&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
# Get current datetime values&lt;br /&gt;
dt=(`date +%Y\ %m\ %d\ %H\ %M\ %S\ %a\ %s\ %I\ %p\ %Z`)&lt;br /&gt;
y=$((10#${dt[0]})) #year&lt;br /&gt;
M=$((10#${dt[1]})) #month&lt;br /&gt;
d=$((10#${dt[2]})) #day&lt;br /&gt;
h=$((10#${dt[3]})) #hour(24)&lt;br /&gt;
m=$((10#${dt[4]})) #minute&lt;br /&gt;
s=$((10#${dt[5]})) #second&lt;br /&gt;
w=${dt[6]}         #day of week (eg. Sun)&lt;br /&gt;
e=$((10#${dt[7]})) #epoch&lt;br /&gt;
t=$((10#${dt[8]})) #hour(12)&lt;br /&gt;
p=${dt[9]}         #meridian (AM/PM)&lt;br /&gt;
z=${dt[10]}        #timezone (eg. PDT)&lt;br /&gt;
&lt;br /&gt;
# Schedule command when date ($1) matched regex ($2) with extra grep parameters ($3)&lt;br /&gt;
# Use parameter -P at $3 for perl regex: in case you need to use (str1|str2).&lt;br /&gt;
# Example: schedule $M$d &amp;quot;(115|21)&amp;quot; -P &amp;amp;&amp;amp; sms &amp;quot;Subject&amp;quot; &amp;quot;Message&amp;quot;&lt;br /&gt;
# Don't use -P when you want a range of numbers including 2 or more digit numbers (ie. [1-15]).&lt;br /&gt;
schedule(){ echo &amp;quot;$1&amp;quot; | grep -wq $3 &amp;quot;$2&amp;quot;;}&lt;br /&gt;
sms(){ /scripts/sms.sh &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
eml(){ /scripts/email.sh &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
notify(){ sms &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;eml &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# ==== Temporary Notifications ====&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# Dentist appointment&lt;br /&gt;
#schedule $M$d &amp;quot;58&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Dentist&amp;quot; &amp;quot;Appointment 4:00pm 10/31/2017&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# ====== Chore Notifications ======&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# LAUNDRY DAY&lt;br /&gt;
# Day before&lt;br /&gt;
schedule $w$d &amp;quot;Mon[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;LAUNDRY DAY&amp;quot; &amp;quot;WORK: Check gas. HOME: Do laundry, put laundry away.&amp;quot;&lt;br /&gt;
schedule $w$d &amp;quot;Mon(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;LAUNDRY DAY&amp;quot; &amp;quot;WORK: Check gas. HOME: Do laundry, put laundry away.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# WEEKLY CLEANING DAY&lt;br /&gt;
schedule $w &amp;quot;Tue&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;WEEKLY CLEANING DAY&amp;quot; &amp;quot;WORK: Fill gas, shopping. HOME: Clean, litter, sweep/vac, fridge, trash, check meds.&amp;quot;&lt;br /&gt;
# Day after&lt;br /&gt;
schedule $w &amp;quot;Wed&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;WEEKLY REMINDER&amp;quot; &amp;quot;Order meds if necessary.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# MONTHLY CLEANING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Tue[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;MONTHLY CLEANING DAY&amp;quot; &amp;quot;WORK: Car stuff. HOME: Dishes, kitchen, bathroom, dust, inventory.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# BUSINESS DAY&lt;br /&gt;
schedule $d &amp;quot;[1-4]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;BUSINESS DAY&amp;quot; &amp;quot;Rent due before 5th (\$720). Fedloan, budgeting, donations, next-buy.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# TECH DAY&lt;br /&gt;
schedule $w$d &amp;quot;Mon[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;TECH DAY&amp;quot; &amp;quot;WORK: Updates, phone, healthcheck, security scan, organize files. HOME: Organize Workstation/Laptop, USB drives.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# SHOPPING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Wed[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;SHOPPING DAY&amp;quot; &amp;quot;Shopping, carwash. Maybe do during lunch.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# GROOMING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Sun[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;GROOMING DAY&amp;quot; &amp;quot;Shave/trim, clip nails.&amp;quot;&lt;br /&gt;
schedule $w$d &amp;quot;Sun(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;GROOMING DAY&amp;quot; &amp;quot;Shave/trim, clip nails.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ELIMINATION DAY&lt;br /&gt;
schedule $w$d &amp;quot;Sun(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;ELIMINATION DAY&amp;quot; &amp;quot;Do at least one item on TO_ELIMINATE list.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# INVENTORY DAY&lt;br /&gt;
# Disabled. Inventory is now included in monthly cleaning day.&lt;br /&gt;
# schedule $w$d &amp;quot;Tue[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;INVENTORY DAY&amp;quot; &amp;quot;Do home, car, and office inventory.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# = Other Permanent Notifications =&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# Air filter replacement notifications&lt;br /&gt;
schedule $M$d &amp;quot;71&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Air Filter&amp;quot; &amp;quot;Holmes HAP726: Replace HEPA filters (model:HAPF600,qty:2)&amp;quot;&lt;br /&gt;
schedule $M$d &amp;quot;[1|7]1&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Air Filter&amp;quot; &amp;quot;Holmes HAP726: Replace Carbon filters (model:HAPF600,qty:2)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now set the permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:root /scripts/external-ip.sh&lt;br /&gt;
chmod 754 /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reporting External IP Address ==&lt;br /&gt;
&lt;br /&gt;
My home server does not have a static IP address, so I use dynamic DNS. With my free DDNS service, I have to renew the domain name every 30 days. So if I forget to renew it, it will expire and I won't be able to access my server unless I know the IP address. As a contingency, I created a script that sends my external IP address to an email account every 6 hours. Then at least I would be able find out what my last IP was and use that to access my server.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/external-ip.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
log=&amp;quot;/var/log/external-ip.log&amp;quot;&lt;br /&gt;
ipsrc=&amp;quot;http://checkip.dyndns.org&amp;quot;&lt;br /&gt;
date=&amp;quot;`date`&amp;quot;&lt;br /&gt;
addr=&amp;quot;myaccount@yahoo.com&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ip=`curl -s --connect-timeout 3 $ipsrc 2&amp;gt;/dev/null|grep -Po &amp;quot;Current IP Address: .*?\&amp;lt;&amp;quot;|tr '&amp;lt;' '\0'`&lt;br /&gt;
echo &amp;quot;IP: $ip&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if [ -z &amp;quot;$ip&amp;quot; ];then&lt;br /&gt;
	echo &amp;quot;$date ERROR: Could not get external IP from $ipsrc&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
else&lt;br /&gt;
	echo -e &amp;quot;Subject:[`hostname`] $date $ip&amp;quot; | /usr/sbin/ssmtp $addr&lt;br /&gt;
	if [ &amp;quot;$?&amp;quot; = &amp;quot;0&amp;quot; ];then&lt;br /&gt;
		echo &amp;quot;$date SUCCESS: $ip sent to $addr&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
	else&lt;br /&gt;
		echo &amp;quot;$date ERROR: Could not send to $addr&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
	fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now set the permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:root /scripts/external-ip.sh&lt;br /&gt;
chmod 754 /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script appends to a log file &amp;lt;code&amp;gt;/var/log/external-ip.log&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
touch /var/log/external-ip.log&lt;br /&gt;
chown root:root /var/log/external-ip.log&lt;br /&gt;
chmod 644 /var/log/external-ip.log&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Automatic Email Download ==&lt;br /&gt;
&lt;br /&gt;
As mentioned in a previous section, I use free dynamic DNS which requires that I renew it manually every 30 days. I need to remind myself to do this. My provider sends an email notification a few days before it expires, but I hate email and I don't want it in my face all the time, certainly not in my phone.&lt;br /&gt;
&lt;br /&gt;
The best solution I found was to retrieve the email automatically and send me a text message with only the subject line in the message. I eventually created a second method of notification: it generates a file in a place that I regularly go, the folder that contains all of my to-do lists.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/ddns.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# This script is run by a cron job.&lt;br /&gt;
&lt;br /&gt;
/usr/bin/fetchmail -N -d0 -f &amp;quot;/scripts/config/ddns-fetchmailrc&amp;quot; -m &amp;quot;/scripts/config/ddns-mailprocess.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
alertfile=&amp;quot;/shares/Private/000__DDNS-ALERT__.txt&amp;quot;&lt;br /&gt;
if [ -e $alertfile ];then&lt;br /&gt;
	chown root:root $alertfile&lt;br /&gt;
	chmod 777 $alertfile&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/config/ddns-mailprocess.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# This script is run by /scripts/ddns.sh&lt;br /&gt;
&lt;br /&gt;
mailto=&amp;quot;17775551234@myprovider.net&amp;quot;&lt;br /&gt;
date=&amp;quot;`date`&amp;quot;&lt;br /&gt;
log=&amp;quot;/var/log/ddns.log&amp;quot;&lt;br /&gt;
alertfile=&amp;quot;/shares/Private/000__DDNS-ALERT__.txt&amp;quot;&lt;br /&gt;
sms=&amp;quot;/scripts/sms.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cat /dev/stdin | grep -i &amp;quot;^Subject:&amp;quot; | sed 's/Subject\://g' | $sms &amp;quot;DDNS&amp;quot; &amp;quot;`cat /dev/stdin` ( $date )&amp;quot; &amp;amp;&amp;amp;\&lt;br /&gt;
echo &amp;quot;$date - DDNS notification sent to $mailto&amp;quot; | tee -a $log | sed &amp;quot;s/$mailto/cell\ phone/g&amp;quot; &amp;gt;$alertfile &amp;amp;&amp;amp;\&lt;br /&gt;
chmod 777 $alertfile&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/config/ddns-fetchmailrc&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# This rc file is run by /scripts/ddns.sh&lt;br /&gt;
# This file MUST have root:root and chmod 700&lt;br /&gt;
&lt;br /&gt;
set postmaster &amp;quot;username&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
poll &amp;quot;imap.mail.yahoo.com&amp;quot; protocol IMAP username &amp;quot;myaccount@yahoo.com&amp;quot; password &amp;quot;InsertPasswordHere&amp;quot; is &amp;quot;username&amp;quot; here keep folder &amp;quot;DDNS-Mailbox&amp;quot; ssl&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You'll notice that it creates a file &amp;lt;code&amp;gt;/shares/Private/000__DDNS-ALERT__.txt&amp;lt;/code&amp;gt;. The &amp;quot;000&amp;quot; is just to put it at the top of the directory listing. Also notice that I make it read-write for everyone so I can delete it from my webapp.&lt;br /&gt;
&lt;br /&gt;
Set up permissions on all three files, and create the log file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
touch /var/log/ddns.log&lt;br /&gt;
chown root:root /var/log/ddns.log&lt;br /&gt;
chmod 640 /var/log/ddns.log&lt;br /&gt;
&lt;br /&gt;
chown root:root /scripts/ddns.sh&lt;br /&gt;
chmod 754 /scripts/ddns.sh&lt;br /&gt;
&lt;br /&gt;
chown root:config /scripts/config/ddns-mailprocess.sh&lt;br /&gt;
chmod 750 /scripts/config/ddns-mailprocess.sh&lt;br /&gt;
&lt;br /&gt;
chown root:root /scripts/config/ddns-fetchmailrc&lt;br /&gt;
chmod 700 /scripts/config/ddns-fetchmailrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
UPDATE February 2021: Yahoo now requires you to create a &amp;lt;b&amp;gt;secure app password&amp;lt;/b&amp;gt;. See [[#yahoo-app-pass|this section]].&lt;br /&gt;
&lt;br /&gt;
When you run &amp;lt;code&amp;gt;ddns.sh&amp;lt;/code&amp;gt; as root it gives you a warning about running as root. This is okay.&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
fetchmail: WARNING: Running as root is discouraged.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If permissions on &amp;lt;code&amp;gt;ddns-fetchmailrc&amp;lt;/code&amp;gt; are not correct, you will get this failure message:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
File /scripts/config/ddns-fetchmailrc must have no more than -rwx------ (0700) permissions.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set Up Cron ==&lt;br /&gt;
&lt;br /&gt;
Just for reference, here are the entries I made in my &amp;lt;code&amp;gt;/etc/crontab&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Crontabs to be run without 'run-parts'&lt;br /&gt;
#&lt;br /&gt;
# RUN AT NOON&lt;br /&gt;
0                  12           * * *   root    /scripts/ddns.sh&lt;br /&gt;
0                  12           * * *   root    /scripts/notifications.sh&lt;br /&gt;
# RUN EVERY 6 HOURS&lt;br /&gt;
1                  0,6,12,18    * * *   root    /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Yahoo App Password ==&lt;br /&gt;
&lt;br /&gt;
As of February 2021, Yahoo changed that way third party apps can access it. Instead of using your normal password, you need to generate an &amp;lt;b&amp;gt;app password&amp;lt;/b&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Login to Yahoo, click you user icon, and click &amp;lt;b&amp;gt;Account Info&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click &amp;lt;b&amp;gt;Account Security&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click &amp;lt;b&amp;gt;Manage app passwords&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click the &amp;lt;b&amp;gt;Select your app&amp;lt;/b&amp;gt; drop-down and select &amp;lt;b&amp;gt;Other app&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Type a name for the app then click &amp;lt;b&amp;gt;Generate&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Now you can copy the password and use it in your app. Once you navigate away from this page, you will not be able to retrieve the password again. You will have to generate another password.&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=Automatic_Email_and_Text_Notifications&amp;diff=3681</id>
		<title>Automatic Email and Text Notifications</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=Automatic_Email_and_Text_Notifications&amp;diff=3681"/>
				<updated>2021-02-26T14:10:21Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Set Up Cron */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These tutorials describe my method of automatic messaging via email and text (SMS) from my Linux servers.&lt;br /&gt;
&lt;br /&gt;
== Required Packages ==&lt;br /&gt;
&lt;br /&gt;
These packages are necessary for the all the following sections of this tutorial. In Debain, install them with &amp;lt;code&amp;gt;apt-get&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
apt-get install ssmtp procmail fetchmail&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Directory Structure ==&lt;br /&gt;
&lt;br /&gt;
Just for reference, here are the locations of the relevant files:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
/&lt;br /&gt;
├── etc&lt;br /&gt;
│   └── ssmtp&lt;br /&gt;
│       └── ssmtp.conf&lt;br /&gt;
└── scripts&lt;br /&gt;
    ├── config&lt;br /&gt;
    │   ├── accounts.conf&lt;br /&gt;
    │   ├── ddns-fetchmailrc&lt;br /&gt;
    │   └── ddns-mailprocess.sh&lt;br /&gt;
    ├── ddns.sh&lt;br /&gt;
    ├── email.sh&lt;br /&gt;
    ├── external-ip.sh&lt;br /&gt;
    ├── notifications.sh&lt;br /&gt;
    └── sms.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l /scripts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
drwxr-xr-x 4 root config   4096 Jun 20 08:52 config&lt;br /&gt;
-rwxr-xr-- 1 root root      260 Jun 20 08:40 ddns.sh&lt;br /&gt;
-rwxr-xr-- 1 root mailers   564 Apr 23 12:18 email.sh&lt;br /&gt;
-rwxr-xr-- 1 root root      529 Apr 27 07:56 external-ip.sh&lt;br /&gt;
-rwxr-xr-- 1 root root     3834 May 15 08:32 notifications.sh&lt;br /&gt;
-rwxr-xr-- 1 root texters   545 Apr 23 12:24 sms.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l /scripts/config&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
-rwxr-x--- 1 root mailers  147 May  1 13:01 accounts.conf&lt;br /&gt;
-rwx------ 1 root root     246 May 21 09:49 ddns-fetchmailrc&lt;br /&gt;
-rwxr-x--- 1 root config   604 Jun 20 08:52 ddns-mailprocess.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create Security Groups ==&lt;br /&gt;
&lt;br /&gt;
I use group membership to control read access to certain files. You don't have to do this, but it was useful for me.&lt;br /&gt;
&lt;br /&gt;
Create the groups:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
groupadd texters #allowed to sent text messages&lt;br /&gt;
groupadd mailers #allowed to send email messages&lt;br /&gt;
groupadd config  #allowed to read other config files&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can add a user to all three groups like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
usermod -aG texters,mailers,config username&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Email and Text Messaging with SSMTP ==&lt;br /&gt;
&lt;br /&gt;
First set up the &amp;lt;code&amp;gt;/etc/ssmtp/ssmtp.conf&amp;lt;/code&amp;gt;. I use a dedicated Gmail account (named &amp;lt;b&amp;gt;serveraccount@gmail.com&amp;lt;/b&amp;gt; in the example below) for all of my server messaging. When I receive an email from my server, it will look like it's coming from that Gmail.&lt;br /&gt;
&lt;br /&gt;
Make a backup copy of the original config:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.orig&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here are the contents of my modified &amp;lt;code&amp;gt;/etc/ssmtp/ssmtp.conf&amp;lt;/code&amp;gt;. Replace the relevant values.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Config file for sSMTP sendmail&lt;br /&gt;
#&lt;br /&gt;
# The person who gets all mail for userids &amp;lt; 1000&lt;br /&gt;
# Make this empty to disable rewriting.&lt;br /&gt;
root=serveraccount&lt;br /&gt;
&lt;br /&gt;
# The place where the mail goes. The actual machine name is required no&lt;br /&gt;
# MX records are consulted. Commonly mailhosts are named mail.domain.com&lt;br /&gt;
#mailhub=mail&lt;br /&gt;
&lt;br /&gt;
# Where will the mail seem to come from?&lt;br /&gt;
rewriteDomain=gmail.com&lt;br /&gt;
&lt;br /&gt;
# The full hostname&lt;br /&gt;
# This can be left as 'localhost'&lt;br /&gt;
hostname=localhost&lt;br /&gt;
&lt;br /&gt;
# Are users allowed to set their own From: address?&lt;br /&gt;
# YES - Allow the user to specify their own From: address&lt;br /&gt;
# NO - Use the system generated From: address&lt;br /&gt;
FromLineOverride=YES&lt;br /&gt;
&lt;br /&gt;
mailhub=smtp.gmail.com:587&lt;br /&gt;
UseStartTLS=YES&lt;br /&gt;
UseTLS=YES&lt;br /&gt;
AuthMethod=LOGIN&lt;br /&gt;
AuthUser=serveraccount@gmail.com&lt;br /&gt;
AuthPass=InsertPasswordHere&lt;br /&gt;
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt&lt;br /&gt;
FromLineOverride=YES&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the file contains a password, make sure the file is not readable to normal users.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mail /etc/ssmtp/ssmtp.conf&lt;br /&gt;
chmod 640 /etc/ssmtp/ssmtp.conf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And because you don't have to remember this password, it would be a good idea to make it very long and complex (16+ characters; uppercase, lowercase, numbers, and special characters; no dictionary words).&lt;br /&gt;
&lt;br /&gt;
You now need to log onto the &amp;lt;b&amp;gt;serveraccount&amp;lt;/b&amp;gt; Gmail account and enable &amp;quot;less secure apps&amp;quot; at https://myaccount.google.com/lesssecureapps?pli=1 &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Gmail-less-secure-app.png|frameless|600px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Here is more info about less secure apps: https://support.google.com/cloudidentity/answer/6260879?hl=en&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should now be able use the &amp;lt;code&amp;gt;ssmtp&amp;lt;/code&amp;gt; command line tool from your server. Most of the time, you will need to include a subject line. It's important that it follows the format below (capital 'S' on Subject, colon, space, YourSubject, two newlines):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo -e &amp;quot;Subject: Hi\n\nHello, world!&amp;quot; | ssmtp myaccount@yahoo.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a Secure Accounts File ==&lt;br /&gt;
&lt;br /&gt;
For some of the automatic messaging, you need to store text and email accounts in a file. To figure out the destination address to send text (SMS) messages to your cell, look on your cell provider's website for the proper account/domain name. It will probably be something like &amp;quot;&amp;lt;your-phone-number&amp;gt;@&amp;lt;provider-domain&amp;gt;&amp;quot;. [https://kb.sandisk.com/app/answers/detail/a_id/17056/~/list-of-mobile-carrier-gateway-addresses List of provider addresses]&lt;br /&gt;
&lt;br /&gt;
Contents of my &amp;lt;code&amp;gt;/scripts/config/accounts.conf&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# Secure account information&lt;br /&gt;
# Permissions must be 750 root:mailers&lt;br /&gt;
&lt;br /&gt;
smsto=&amp;quot;17775551234@myprovider.net&amp;quot;&lt;br /&gt;
mailto=&amp;quot;myaccount@yahoo.com&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the permissions on the file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mailers /scripts/config/accounts.conf&lt;br /&gt;
chmod 750 /scripts/config/accounts.conf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Email Script ==&lt;br /&gt;
&lt;br /&gt;
This script can be used to send an email message.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/email.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# Send email message:&lt;br /&gt;
#  Usage: $0 &amp;quot;&amp;lt;Subject&amp;gt;&amp;quot; &amp;quot;&amp;lt;Message&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
default_subject=&amp;quot;Alert from Server (`date`)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
subject=&amp;quot;&amp;quot;&lt;br /&gt;
message=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
case $# in&lt;br /&gt;
  2)&lt;br /&gt;
    subject=&amp;quot;$1&amp;quot;&lt;br /&gt;
    message=&amp;quot;$2&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  1)&lt;br /&gt;
    subject=&amp;quot;$default_subject&amp;quot;&lt;br /&gt;
    message=&amp;quot;$1&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  *)&lt;br /&gt;
    echo &amp;quot;Send Email Message:&amp;quot;&lt;br /&gt;
    echo &amp;quot;  Usage: `basename $0` \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    echo &amp;quot;         `basename $0` \&amp;quot;Subject\&amp;quot; \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
  ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
dir=&amp;quot;$(cd $(dirname ${BASH_SOURCE[0]})&amp;amp;&amp;amp;pwd)&amp;quot;&lt;br /&gt;
. $dir/config/accounts.conf&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;Subject: $subject\n\n$message&amp;quot; | /usr/sbin/ssmtp $mailto&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mailers /scripts/email.sh&lt;br /&gt;
chmod 754 /scripts/email.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create an alias so you can quickly run this from the command line:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo &amp;quot;alias email='/scripts/email.sh'&amp;quot; &amp;gt;&amp;gt;~/.bashrc&lt;br /&gt;
source ~/.bashrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Send message with default subject&lt;br /&gt;
email &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Send message with a subject&lt;br /&gt;
email &amp;quot;Test Subject&amp;quot; &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Text Script ==&lt;br /&gt;
&lt;br /&gt;
This script can be used to send a text (SMS) message.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/sms.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# Send SMS message:&lt;br /&gt;
#  Usage: $0 &amp;quot;&amp;lt;Subject&amp;gt;&amp;quot; &amp;quot;&amp;lt;Message&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
default_subject=&amp;quot;Alert&amp;quot;&lt;br /&gt;
&lt;br /&gt;
subject=&amp;quot;&amp;quot;&lt;br /&gt;
message=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
case $# in&lt;br /&gt;
  2)&lt;br /&gt;
    subject=&amp;quot;$1&amp;quot;&lt;br /&gt;
    message=&amp;quot;$2&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  1)&lt;br /&gt;
    subject=&amp;quot;$default_subject&amp;quot;&lt;br /&gt;
    message=&amp;quot;$1&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  *)&lt;br /&gt;
    echo &amp;quot;Send SMS Message:&amp;quot;&lt;br /&gt;
    echo &amp;quot;  Usage: `basename $0` \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    echo &amp;quot;         `basename $0` \&amp;quot;Subject\&amp;quot; \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
  ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
dir=&amp;quot;$(cd $(dirname ${BASH_SOURCE[0]})&amp;amp;&amp;amp;pwd)&amp;quot;&lt;br /&gt;
. $dir/config/accounts.conf&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;To: $smsto\nSubject: $subject\n\n$message&amp;quot; | /usr/sbin/ssmtp $smsto&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:texters /scripts/sms.sh&lt;br /&gt;
chmod 754 /scripts/sms.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create an alias so you can quickly run this from the command line:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo &amp;quot;alias sms='/scripts/sms.sh'&amp;quot; &amp;gt;&amp;gt;~/.bashrc&lt;br /&gt;
source ~/.bashrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Send message with default subject&lt;br /&gt;
sms &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Send message with a subject&lt;br /&gt;
sms &amp;quot;Test Subject&amp;quot; &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scheduled Notifications Script ==&lt;br /&gt;
&lt;br /&gt;
One of my life improvement tasks was to organize chores into scheduled chore days and rely on text/email notification to remind me to do them.&lt;br /&gt;
&lt;br /&gt;
This dramatically reduced the amount of time I spend working on chores, and the amount of effort I spend thinking about what needs to be done. I could barely get projects done because every day I was loading my task list with chores. Now I don't think about chores until I'm notified. When I think of new chores, new items for my inventory, or other things I need to be reminded of, I update my checklists. When I feel I can improve scheduling or consolidate chores, I update my notifications script.&lt;br /&gt;
&lt;br /&gt;
This utilizes the &amp;lt;b&amp;gt;Email Script&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;Text Script&amp;lt;/b&amp;gt; from the previous sections.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/notifications.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# Send regular notifications.&lt;br /&gt;
# Currently set to run daily at NOON.&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
# Get current datetime values&lt;br /&gt;
dt=(`date +%Y\ %m\ %d\ %H\ %M\ %S\ %a\ %s\ %I\ %p\ %Z`)&lt;br /&gt;
y=$((10#${dt[0]})) #year&lt;br /&gt;
M=$((10#${dt[1]})) #month&lt;br /&gt;
d=$((10#${dt[2]})) #day&lt;br /&gt;
h=$((10#${dt[3]})) #hour(24)&lt;br /&gt;
m=$((10#${dt[4]})) #minute&lt;br /&gt;
s=$((10#${dt[5]})) #second&lt;br /&gt;
w=${dt[6]}         #day of week (eg. Sun)&lt;br /&gt;
e=$((10#${dt[7]})) #epoch&lt;br /&gt;
t=$((10#${dt[8]})) #hour(12)&lt;br /&gt;
p=${dt[9]}         #meridian (AM/PM)&lt;br /&gt;
z=${dt[10]}        #timezone (eg. PDT)&lt;br /&gt;
&lt;br /&gt;
# Schedule command when date ($1) matched regex ($2) with extra grep parameters ($3)&lt;br /&gt;
# Use parameter -P at $3 for perl regex: in case you need to use (str1|str2).&lt;br /&gt;
# Example: schedule $M$d &amp;quot;(115|21)&amp;quot; -P &amp;amp;&amp;amp; sms &amp;quot;Subject&amp;quot; &amp;quot;Message&amp;quot;&lt;br /&gt;
# Don't use -P when you want a range of numbers including 2 or more digit numbers (ie. [1-15]).&lt;br /&gt;
schedule(){ echo &amp;quot;$1&amp;quot; | grep -wq $3 &amp;quot;$2&amp;quot;;}&lt;br /&gt;
sms(){ /scripts/sms.sh &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
eml(){ /scripts/email.sh &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
notify(){ sms &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;eml &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# ==== Temporary Notifications ====&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# Dentist appointment&lt;br /&gt;
#schedule $M$d &amp;quot;58&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Dentist&amp;quot; &amp;quot;Appointment 4:00pm 10/31/2017&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# ====== Chore Notifications ======&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# LAUNDRY DAY&lt;br /&gt;
# Day before&lt;br /&gt;
schedule $w$d &amp;quot;Mon[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;LAUNDRY DAY&amp;quot; &amp;quot;WORK: Check gas. HOME: Do laundry, put laundry away.&amp;quot;&lt;br /&gt;
schedule $w$d &amp;quot;Mon(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;LAUNDRY DAY&amp;quot; &amp;quot;WORK: Check gas. HOME: Do laundry, put laundry away.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# WEEKLY CLEANING DAY&lt;br /&gt;
schedule $w &amp;quot;Tue&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;WEEKLY CLEANING DAY&amp;quot; &amp;quot;WORK: Fill gas, shopping. HOME: Clean, litter, sweep/vac, fridge, trash, check meds.&amp;quot;&lt;br /&gt;
# Day after&lt;br /&gt;
schedule $w &amp;quot;Wed&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;WEEKLY REMINDER&amp;quot; &amp;quot;Order meds if necessary.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# MONTHLY CLEANING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Tue[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;MONTHLY CLEANING DAY&amp;quot; &amp;quot;WORK: Car stuff. HOME: Dishes, kitchen, bathroom, dust, inventory.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# BUSINESS DAY&lt;br /&gt;
schedule $d &amp;quot;[1-4]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;BUSINESS DAY&amp;quot; &amp;quot;Rent due before 5th (\$720). Fedloan, budgeting, donations, next-buy.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# TECH DAY&lt;br /&gt;
schedule $w$d &amp;quot;Mon[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;TECH DAY&amp;quot; &amp;quot;WORK: Updates, phone, healthcheck, security scan, organize files. HOME: Organize Workstation/Laptop, USB drives.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# SHOPPING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Wed[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;SHOPPING DAY&amp;quot; &amp;quot;Shopping, carwash. Maybe do during lunch.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# GROOMING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Sun[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;GROOMING DAY&amp;quot; &amp;quot;Shave/trim, clip nails.&amp;quot;&lt;br /&gt;
schedule $w$d &amp;quot;Sun(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;GROOMING DAY&amp;quot; &amp;quot;Shave/trim, clip nails.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ELIMINATION DAY&lt;br /&gt;
schedule $w$d &amp;quot;Sun(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;ELIMINATION DAY&amp;quot; &amp;quot;Do at least one item on TO_ELIMINATE list.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# INVENTORY DAY&lt;br /&gt;
# Disabled. Inventory is now included in monthly cleaning day.&lt;br /&gt;
# schedule $w$d &amp;quot;Tue[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;INVENTORY DAY&amp;quot; &amp;quot;Do home, car, and office inventory.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# = Other Permanent Notifications =&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# Air filter replacement notifications&lt;br /&gt;
schedule $M$d &amp;quot;71&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Air Filter&amp;quot; &amp;quot;Holmes HAP726: Replace HEPA filters (model:HAPF600,qty:2)&amp;quot;&lt;br /&gt;
schedule $M$d &amp;quot;[1|7]1&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Air Filter&amp;quot; &amp;quot;Holmes HAP726: Replace Carbon filters (model:HAPF600,qty:2)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now set the permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:root /scripts/external-ip.sh&lt;br /&gt;
chmod 754 /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reporting External IP Address ==&lt;br /&gt;
&lt;br /&gt;
My home server does not have a static IP address, so I use dynamic DNS. With my free DDNS service, I have to renew the domain name every 30 days. So if I forget to renew it, it will expire and I won't be able to access my server unless I know the IP address. As a contingency, I created a script that sends my external IP address to an email account every 6 hours. Then at least I would be able find out what my last IP was and use that to access my server.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/external-ip.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
log=&amp;quot;/var/log/external-ip.log&amp;quot;&lt;br /&gt;
ipsrc=&amp;quot;http://checkip.dyndns.org&amp;quot;&lt;br /&gt;
date=&amp;quot;`date`&amp;quot;&lt;br /&gt;
addr=&amp;quot;myaccount@yahoo.com&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ip=`curl -s --connect-timeout 3 $ipsrc 2&amp;gt;/dev/null|grep -Po &amp;quot;Current IP Address: .*?\&amp;lt;&amp;quot;|tr '&amp;lt;' '\0'`&lt;br /&gt;
echo &amp;quot;IP: $ip&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if [ -z &amp;quot;$ip&amp;quot; ];then&lt;br /&gt;
	echo &amp;quot;$date ERROR: Could not get external IP from $ipsrc&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
else&lt;br /&gt;
	echo -e &amp;quot;Subject:[`hostname`] $date $ip&amp;quot; | /usr/sbin/ssmtp $addr&lt;br /&gt;
	if [ &amp;quot;$?&amp;quot; = &amp;quot;0&amp;quot; ];then&lt;br /&gt;
		echo &amp;quot;$date SUCCESS: $ip sent to $addr&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
	else&lt;br /&gt;
		echo &amp;quot;$date ERROR: Could not send to $addr&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
	fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now set the permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:root /scripts/external-ip.sh&lt;br /&gt;
chmod 754 /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script appends to a log file &amp;lt;code&amp;gt;/var/log/external-ip.log&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
touch /var/log/external-ip.log&lt;br /&gt;
chown root:root /var/log/external-ip.log&lt;br /&gt;
chmod 644 /var/log/external-ip.log&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Automatic Email Download ==&lt;br /&gt;
&lt;br /&gt;
As mentioned in a previous section, I use free dynamic DNS which requires that I renew it manually every 30 days. I need to remind myself to do this. My provider sends an email notification a few days before it expires, but I hate email and I don't want it in my face all the time, certainly not in my phone.&lt;br /&gt;
&lt;br /&gt;
The best solution I found was to retrieve the email automatically and send me a text message with only the subject line in the message. I eventually created a second method of notification: it generates a file in a place that I regularly go, the folder that contains all of my to-do lists.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/ddns.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# This script is run by a cron job.&lt;br /&gt;
&lt;br /&gt;
/usr/bin/fetchmail -N -d0 -f &amp;quot;/scripts/config/ddns-fetchmailrc&amp;quot; -m &amp;quot;/scripts/config/ddns-mailprocess.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
alertfile=&amp;quot;/shares/Private/000__DDNS-ALERT__.txt&amp;quot;&lt;br /&gt;
if [ -e $alertfile ];then&lt;br /&gt;
	chown root:root $alertfile&lt;br /&gt;
	chmod 777 $alertfile&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/config/ddns-mailprocess.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# This script is run by /scripts/ddns.sh&lt;br /&gt;
&lt;br /&gt;
mailto=&amp;quot;17775551234@myprovider.net&amp;quot;&lt;br /&gt;
date=&amp;quot;`date`&amp;quot;&lt;br /&gt;
log=&amp;quot;/var/log/ddns.log&amp;quot;&lt;br /&gt;
alertfile=&amp;quot;/shares/Private/000__DDNS-ALERT__.txt&amp;quot;&lt;br /&gt;
sms=&amp;quot;/scripts/sms.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cat /dev/stdin | grep -i &amp;quot;^Subject:&amp;quot; | sed 's/Subject\://g' | $sms &amp;quot;DDNS&amp;quot; &amp;quot;`cat /dev/stdin` ( $date )&amp;quot; &amp;amp;&amp;amp;\&lt;br /&gt;
echo &amp;quot;$date - DDNS notification sent to $mailto&amp;quot; | tee -a $log | sed &amp;quot;s/$mailto/cell\ phone/g&amp;quot; &amp;gt;$alertfile &amp;amp;&amp;amp;\&lt;br /&gt;
chmod 777 $alertfile&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/config/ddns-fetchmailrc&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# This rc file is run by /scripts/ddns.sh&lt;br /&gt;
# This file MUST have root:root and chmod 700&lt;br /&gt;
&lt;br /&gt;
set postmaster &amp;quot;username&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
poll &amp;quot;imap.mail.yahoo.com&amp;quot; protocol IMAP username &amp;quot;myaccount@yahoo.com&amp;quot; password &amp;quot;InsertPasswordHere&amp;quot; is &amp;quot;username&amp;quot; here keep folder &amp;quot;DDNS-Mailbox&amp;quot; ssl&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You'll notice that it creates a file &amp;lt;code&amp;gt;/shares/Private/000__DDNS-ALERT__.txt&amp;lt;/code&amp;gt;. The &amp;quot;000&amp;quot; is just to put it at the top of the directory listing. Also notice that I make it read-write for everyone so I can delete it from my webapp.&lt;br /&gt;
&lt;br /&gt;
Set up permissions on all three files, and create the log file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
touch /var/log/ddns.log&lt;br /&gt;
chown root:root /var/log/ddns.log&lt;br /&gt;
chmod 640 /var/log/ddns.log&lt;br /&gt;
&lt;br /&gt;
chown root:root /scripts/ddns.sh&lt;br /&gt;
chmod 754 /scripts/ddns.sh&lt;br /&gt;
&lt;br /&gt;
chown root:config /scripts/config/ddns-mailprocess.sh&lt;br /&gt;
chmod 750 /scripts/config/ddns-mailprocess.sh&lt;br /&gt;
&lt;br /&gt;
chown root:root /scripts/config/ddns-fetchmailrc&lt;br /&gt;
chmod 700 /scripts/config/ddns-fetchmailrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
UPDATE February 2021: Yahoo now requires you to create a &amp;lt;b&amp;gt;secure app password&amp;lt;/b&amp;gt;. See [[#yahoo-app-pass|this section]].&lt;br /&gt;
&lt;br /&gt;
When you run &amp;lt;code&amp;gt;ddns.sh&amp;lt;/code&amp;gt; as root it gives you a warning about running as root. This is okay.&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
fetchmail: WARNING: Running as root is discouraged.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If permissions on &amp;lt;code&amp;gt;ddns-fetchmailrc&amp;lt;/code&amp;gt; are not correct, you will get this failure message:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
File /scripts/config/ddns-fetchmailrc must have no more than -rwx------ (0700) permissions.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set Up Cron ==&lt;br /&gt;
&lt;br /&gt;
Just for reference, here are the entries I made in my &amp;lt;code&amp;gt;/etc/crontab&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Crontabs to be run without 'run-parts'&lt;br /&gt;
#&lt;br /&gt;
# RUN AT NOON&lt;br /&gt;
0                  12           * * *   root    /scripts/ddns.sh&lt;br /&gt;
0                  12           * * *   root    /scripts/notifications.sh&lt;br /&gt;
# RUN EVERY 6 HOURS&lt;br /&gt;
1                  0,6,12,18    * * *   root    /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Yahoo App Password ==&lt;br /&gt;
&lt;br /&gt;
As of February 2021, Yahoo changed that way third party apps can access it. Instead of using your normal password, you need to generate an &amp;lt;b&amp;gt;app password&amp;lt;/b&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Login to Yahoo, click you user icon, and click &amp;lt;b&amp;gt;Account Info&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click &amp;lt;b&amp;gt;Account Security&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click &amp;lt;b&amp;gt;Manage app passwords&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Click the &amp;lt;b&amp;gt;Select your app&amp;lt;/b&amp;gt; drop-down and select &amp;lt;b&amp;gt;Other app&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Type a name for the app then click &amp;lt;b&amp;gt;Generate&amp;lt;/b&amp;gt;.&lt;br /&gt;
# Now you can copy the password and use it in your app. Once you navigate away from this page, you will not be able to retrieve the password again. You will have to generate another password.&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=Automatic_Email_and_Text_Notifications&amp;diff=3680</id>
		<title>Automatic Email and Text Notifications</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=Automatic_Email_and_Text_Notifications&amp;diff=3680"/>
				<updated>2021-02-26T13:57:16Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Automatic Email Download */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These tutorials describe my method of automatic messaging via email and text (SMS) from my Linux servers.&lt;br /&gt;
&lt;br /&gt;
== Required Packages ==&lt;br /&gt;
&lt;br /&gt;
These packages are necessary for the all the following sections of this tutorial. In Debain, install them with &amp;lt;code&amp;gt;apt-get&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
apt-get install ssmtp procmail fetchmail&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Directory Structure ==&lt;br /&gt;
&lt;br /&gt;
Just for reference, here are the locations of the relevant files:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
/&lt;br /&gt;
├── etc&lt;br /&gt;
│   └── ssmtp&lt;br /&gt;
│       └── ssmtp.conf&lt;br /&gt;
└── scripts&lt;br /&gt;
    ├── config&lt;br /&gt;
    │   ├── accounts.conf&lt;br /&gt;
    │   ├── ddns-fetchmailrc&lt;br /&gt;
    │   └── ddns-mailprocess.sh&lt;br /&gt;
    ├── ddns.sh&lt;br /&gt;
    ├── email.sh&lt;br /&gt;
    ├── external-ip.sh&lt;br /&gt;
    ├── notifications.sh&lt;br /&gt;
    └── sms.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l /scripts&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
drwxr-xr-x 4 root config   4096 Jun 20 08:52 config&lt;br /&gt;
-rwxr-xr-- 1 root root      260 Jun 20 08:40 ddns.sh&lt;br /&gt;
-rwxr-xr-- 1 root mailers   564 Apr 23 12:18 email.sh&lt;br /&gt;
-rwxr-xr-- 1 root root      529 Apr 27 07:56 external-ip.sh&lt;br /&gt;
-rwxr-xr-- 1 root root     3834 May 15 08:32 notifications.sh&lt;br /&gt;
-rwxr-xr-- 1 root texters   545 Apr 23 12:24 sms.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l /scripts/config&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
-rwxr-x--- 1 root mailers  147 May  1 13:01 accounts.conf&lt;br /&gt;
-rwx------ 1 root root     246 May 21 09:49 ddns-fetchmailrc&lt;br /&gt;
-rwxr-x--- 1 root config   604 Jun 20 08:52 ddns-mailprocess.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create Security Groups ==&lt;br /&gt;
&lt;br /&gt;
I use group membership to control read access to certain files. You don't have to do this, but it was useful for me.&lt;br /&gt;
&lt;br /&gt;
Create the groups:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
groupadd texters #allowed to sent text messages&lt;br /&gt;
groupadd mailers #allowed to send email messages&lt;br /&gt;
groupadd config  #allowed to read other config files&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can add a user to all three groups like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
usermod -aG texters,mailers,config username&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Email and Text Messaging with SSMTP ==&lt;br /&gt;
&lt;br /&gt;
First set up the &amp;lt;code&amp;gt;/etc/ssmtp/ssmtp.conf&amp;lt;/code&amp;gt;. I use a dedicated Gmail account (named &amp;lt;b&amp;gt;serveraccount@gmail.com&amp;lt;/b&amp;gt; in the example below) for all of my server messaging. When I receive an email from my server, it will look like it's coming from that Gmail.&lt;br /&gt;
&lt;br /&gt;
Make a backup copy of the original config:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.orig&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here are the contents of my modified &amp;lt;code&amp;gt;/etc/ssmtp/ssmtp.conf&amp;lt;/code&amp;gt;. Replace the relevant values.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Config file for sSMTP sendmail&lt;br /&gt;
#&lt;br /&gt;
# The person who gets all mail for userids &amp;lt; 1000&lt;br /&gt;
# Make this empty to disable rewriting.&lt;br /&gt;
root=serveraccount&lt;br /&gt;
&lt;br /&gt;
# The place where the mail goes. The actual machine name is required no&lt;br /&gt;
# MX records are consulted. Commonly mailhosts are named mail.domain.com&lt;br /&gt;
#mailhub=mail&lt;br /&gt;
&lt;br /&gt;
# Where will the mail seem to come from?&lt;br /&gt;
rewriteDomain=gmail.com&lt;br /&gt;
&lt;br /&gt;
# The full hostname&lt;br /&gt;
# This can be left as 'localhost'&lt;br /&gt;
hostname=localhost&lt;br /&gt;
&lt;br /&gt;
# Are users allowed to set their own From: address?&lt;br /&gt;
# YES - Allow the user to specify their own From: address&lt;br /&gt;
# NO - Use the system generated From: address&lt;br /&gt;
FromLineOverride=YES&lt;br /&gt;
&lt;br /&gt;
mailhub=smtp.gmail.com:587&lt;br /&gt;
UseStartTLS=YES&lt;br /&gt;
UseTLS=YES&lt;br /&gt;
AuthMethod=LOGIN&lt;br /&gt;
AuthUser=serveraccount@gmail.com&lt;br /&gt;
AuthPass=InsertPasswordHere&lt;br /&gt;
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt&lt;br /&gt;
FromLineOverride=YES&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the file contains a password, make sure the file is not readable to normal users.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mail /etc/ssmtp/ssmtp.conf&lt;br /&gt;
chmod 640 /etc/ssmtp/ssmtp.conf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And because you don't have to remember this password, it would be a good idea to make it very long and complex (16+ characters; uppercase, lowercase, numbers, and special characters; no dictionary words).&lt;br /&gt;
&lt;br /&gt;
You now need to log onto the &amp;lt;b&amp;gt;serveraccount&amp;lt;/b&amp;gt; Gmail account and enable &amp;quot;less secure apps&amp;quot; at https://myaccount.google.com/lesssecureapps?pli=1 &amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Gmail-less-secure-app.png|frameless|600px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Here is more info about less secure apps: https://support.google.com/cloudidentity/answer/6260879?hl=en&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should now be able use the &amp;lt;code&amp;gt;ssmtp&amp;lt;/code&amp;gt; command line tool from your server. Most of the time, you will need to include a subject line. It's important that it follows the format below (capital 'S' on Subject, colon, space, YourSubject, two newlines):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo -e &amp;quot;Subject: Hi\n\nHello, world!&amp;quot; | ssmtp myaccount@yahoo.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a Secure Accounts File ==&lt;br /&gt;
&lt;br /&gt;
For some of the automatic messaging, you need to store text and email accounts in a file. To figure out the destination address to send text (SMS) messages to your cell, look on your cell provider's website for the proper account/domain name. It will probably be something like &amp;quot;&amp;lt;your-phone-number&amp;gt;@&amp;lt;provider-domain&amp;gt;&amp;quot;. [https://kb.sandisk.com/app/answers/detail/a_id/17056/~/list-of-mobile-carrier-gateway-addresses List of provider addresses]&lt;br /&gt;
&lt;br /&gt;
Contents of my &amp;lt;code&amp;gt;/scripts/config/accounts.conf&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# Secure account information&lt;br /&gt;
# Permissions must be 750 root:mailers&lt;br /&gt;
&lt;br /&gt;
smsto=&amp;quot;17775551234@myprovider.net&amp;quot;&lt;br /&gt;
mailto=&amp;quot;myaccount@yahoo.com&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the permissions on the file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mailers /scripts/config/accounts.conf&lt;br /&gt;
chmod 750 /scripts/config/accounts.conf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Email Script ==&lt;br /&gt;
&lt;br /&gt;
This script can be used to send an email message.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/email.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# Send email message:&lt;br /&gt;
#  Usage: $0 &amp;quot;&amp;lt;Subject&amp;gt;&amp;quot; &amp;quot;&amp;lt;Message&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
default_subject=&amp;quot;Alert from Server (`date`)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
subject=&amp;quot;&amp;quot;&lt;br /&gt;
message=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
case $# in&lt;br /&gt;
  2)&lt;br /&gt;
    subject=&amp;quot;$1&amp;quot;&lt;br /&gt;
    message=&amp;quot;$2&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  1)&lt;br /&gt;
    subject=&amp;quot;$default_subject&amp;quot;&lt;br /&gt;
    message=&amp;quot;$1&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  *)&lt;br /&gt;
    echo &amp;quot;Send Email Message:&amp;quot;&lt;br /&gt;
    echo &amp;quot;  Usage: `basename $0` \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    echo &amp;quot;         `basename $0` \&amp;quot;Subject\&amp;quot; \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
  ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
dir=&amp;quot;$(cd $(dirname ${BASH_SOURCE[0]})&amp;amp;&amp;amp;pwd)&amp;quot;&lt;br /&gt;
. $dir/config/accounts.conf&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;Subject: $subject\n\n$message&amp;quot; | /usr/sbin/ssmtp $mailto&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:mailers /scripts/email.sh&lt;br /&gt;
chmod 754 /scripts/email.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create an alias so you can quickly run this from the command line:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo &amp;quot;alias email='/scripts/email.sh'&amp;quot; &amp;gt;&amp;gt;~/.bashrc&lt;br /&gt;
source ~/.bashrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Send message with default subject&lt;br /&gt;
email &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Send message with a subject&lt;br /&gt;
email &amp;quot;Test Subject&amp;quot; &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Text Script ==&lt;br /&gt;
&lt;br /&gt;
This script can be used to send a text (SMS) message.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/sms.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# Send SMS message:&lt;br /&gt;
#  Usage: $0 &amp;quot;&amp;lt;Subject&amp;gt;&amp;quot; &amp;quot;&amp;lt;Message&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
default_subject=&amp;quot;Alert&amp;quot;&lt;br /&gt;
&lt;br /&gt;
subject=&amp;quot;&amp;quot;&lt;br /&gt;
message=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
case $# in&lt;br /&gt;
  2)&lt;br /&gt;
    subject=&amp;quot;$1&amp;quot;&lt;br /&gt;
    message=&amp;quot;$2&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  1)&lt;br /&gt;
    subject=&amp;quot;$default_subject&amp;quot;&lt;br /&gt;
    message=&amp;quot;$1&amp;quot;&lt;br /&gt;
  ;;&lt;br /&gt;
  *)&lt;br /&gt;
    echo &amp;quot;Send SMS Message:&amp;quot;&lt;br /&gt;
    echo &amp;quot;  Usage: `basename $0` \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    echo &amp;quot;         `basename $0` \&amp;quot;Subject\&amp;quot; \&amp;quot;Message\&amp;quot;&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
  ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
dir=&amp;quot;$(cd $(dirname ${BASH_SOURCE[0]})&amp;amp;&amp;amp;pwd)&amp;quot;&lt;br /&gt;
. $dir/config/accounts.conf&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;To: $smsto\nSubject: $subject\n\n$message&amp;quot; | /usr/sbin/ssmtp $smsto&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:texters /scripts/sms.sh&lt;br /&gt;
chmod 754 /scripts/sms.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create an alias so you can quickly run this from the command line:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
echo &amp;quot;alias sms='/scripts/sms.sh'&amp;quot; &amp;gt;&amp;gt;~/.bashrc&lt;br /&gt;
source ~/.bashrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Send message with default subject&lt;br /&gt;
sms &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Send message with a subject&lt;br /&gt;
sms &amp;quot;Test Subject&amp;quot; &amp;quot;This is a test message.&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scheduled Notifications Script ==&lt;br /&gt;
&lt;br /&gt;
One of my life improvement tasks was to organize chores into scheduled chore days and rely on text/email notification to remind me to do them.&lt;br /&gt;
&lt;br /&gt;
This dramatically reduced the amount of time I spend working on chores, and the amount of effort I spend thinking about what needs to be done. I could barely get projects done because every day I was loading my task list with chores. Now I don't think about chores until I'm notified. When I think of new chores, new items for my inventory, or other things I need to be reminded of, I update my checklists. When I feel I can improve scheduling or consolidate chores, I update my notifications script.&lt;br /&gt;
&lt;br /&gt;
This utilizes the &amp;lt;b&amp;gt;Email Script&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;Text Script&amp;lt;/b&amp;gt; from the previous sections.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/notifications.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# Send regular notifications.&lt;br /&gt;
# Currently set to run daily at NOON.&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
# Get current datetime values&lt;br /&gt;
dt=(`date +%Y\ %m\ %d\ %H\ %M\ %S\ %a\ %s\ %I\ %p\ %Z`)&lt;br /&gt;
y=$((10#${dt[0]})) #year&lt;br /&gt;
M=$((10#${dt[1]})) #month&lt;br /&gt;
d=$((10#${dt[2]})) #day&lt;br /&gt;
h=$((10#${dt[3]})) #hour(24)&lt;br /&gt;
m=$((10#${dt[4]})) #minute&lt;br /&gt;
s=$((10#${dt[5]})) #second&lt;br /&gt;
w=${dt[6]}         #day of week (eg. Sun)&lt;br /&gt;
e=$((10#${dt[7]})) #epoch&lt;br /&gt;
t=$((10#${dt[8]})) #hour(12)&lt;br /&gt;
p=${dt[9]}         #meridian (AM/PM)&lt;br /&gt;
z=${dt[10]}        #timezone (eg. PDT)&lt;br /&gt;
&lt;br /&gt;
# Schedule command when date ($1) matched regex ($2) with extra grep parameters ($3)&lt;br /&gt;
# Use parameter -P at $3 for perl regex: in case you need to use (str1|str2).&lt;br /&gt;
# Example: schedule $M$d &amp;quot;(115|21)&amp;quot; -P &amp;amp;&amp;amp; sms &amp;quot;Subject&amp;quot; &amp;quot;Message&amp;quot;&lt;br /&gt;
# Don't use -P when you want a range of numbers including 2 or more digit numbers (ie. [1-15]).&lt;br /&gt;
schedule(){ echo &amp;quot;$1&amp;quot; | grep -wq $3 &amp;quot;$2&amp;quot;;}&lt;br /&gt;
sms(){ /scripts/sms.sh &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
eml(){ /scripts/email.sh &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
notify(){ sms &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;eml &amp;quot;$1&amp;quot; &amp;quot;$2&amp;quot;;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# ==== Temporary Notifications ====&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# Dentist appointment&lt;br /&gt;
#schedule $M$d &amp;quot;58&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Dentist&amp;quot; &amp;quot;Appointment 4:00pm 10/31/2017&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# ====== Chore Notifications ======&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# LAUNDRY DAY&lt;br /&gt;
# Day before&lt;br /&gt;
schedule $w$d &amp;quot;Mon[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;LAUNDRY DAY&amp;quot; &amp;quot;WORK: Check gas. HOME: Do laundry, put laundry away.&amp;quot;&lt;br /&gt;
schedule $w$d &amp;quot;Mon(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;LAUNDRY DAY&amp;quot; &amp;quot;WORK: Check gas. HOME: Do laundry, put laundry away.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# WEEKLY CLEANING DAY&lt;br /&gt;
schedule $w &amp;quot;Tue&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;WEEKLY CLEANING DAY&amp;quot; &amp;quot;WORK: Fill gas, shopping. HOME: Clean, litter, sweep/vac, fridge, trash, check meds.&amp;quot;&lt;br /&gt;
# Day after&lt;br /&gt;
schedule $w &amp;quot;Wed&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;WEEKLY REMINDER&amp;quot; &amp;quot;Order meds if necessary.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# MONTHLY CLEANING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Tue[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;MONTHLY CLEANING DAY&amp;quot; &amp;quot;WORK: Car stuff. HOME: Dishes, kitchen, bathroom, dust, inventory.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# BUSINESS DAY&lt;br /&gt;
schedule $d &amp;quot;[1-4]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;BUSINESS DAY&amp;quot; &amp;quot;Rent due before 5th (\$720). Fedloan, budgeting, donations, next-buy.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# TECH DAY&lt;br /&gt;
schedule $w$d &amp;quot;Mon[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;TECH DAY&amp;quot; &amp;quot;WORK: Updates, phone, healthcheck, security scan, organize files. HOME: Organize Workstation/Laptop, USB drives.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# SHOPPING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Wed[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;SHOPPING DAY&amp;quot; &amp;quot;Shopping, carwash. Maybe do during lunch.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# GROOMING DAY&lt;br /&gt;
schedule $w$d &amp;quot;Sun[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;GROOMING DAY&amp;quot; &amp;quot;Shave/trim, clip nails.&amp;quot;&lt;br /&gt;
schedule $w$d &amp;quot;Sun(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;GROOMING DAY&amp;quot; &amp;quot;Shave/trim, clip nails.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ELIMINATION DAY&lt;br /&gt;
schedule $w$d &amp;quot;Sun(15|16|17|18|19|20|21)&amp;quot; -P &amp;amp;&amp;amp; notify &amp;quot;ELIMINATION DAY&amp;quot; &amp;quot;Do at least one item on TO_ELIMINATE list.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# INVENTORY DAY&lt;br /&gt;
# Disabled. Inventory is now included in monthly cleaning day.&lt;br /&gt;
# schedule $w$d &amp;quot;Tue[1-7]&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;INVENTORY DAY&amp;quot; &amp;quot;Do home, car, and office inventory.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# =================================&lt;br /&gt;
# = Other Permanent Notifications =&lt;br /&gt;
# =================================&lt;br /&gt;
&lt;br /&gt;
# Air filter replacement notifications&lt;br /&gt;
schedule $M$d &amp;quot;71&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Air Filter&amp;quot; &amp;quot;Holmes HAP726: Replace HEPA filters (model:HAPF600,qty:2)&amp;quot;&lt;br /&gt;
schedule $M$d &amp;quot;[1|7]1&amp;quot; &amp;amp;&amp;amp; notify &amp;quot;Air Filter&amp;quot; &amp;quot;Holmes HAP726: Replace Carbon filters (model:HAPF600,qty:2)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now set the permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:root /scripts/external-ip.sh&lt;br /&gt;
chmod 754 /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reporting External IP Address ==&lt;br /&gt;
&lt;br /&gt;
My home server does not have a static IP address, so I use dynamic DNS. With my free DDNS service, I have to renew the domain name every 30 days. So if I forget to renew it, it will expire and I won't be able to access my server unless I know the IP address. As a contingency, I created a script that sends my external IP address to an email account every 6 hours. Then at least I would be able find out what my last IP was and use that to access my server.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/external-ip.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
log=&amp;quot;/var/log/external-ip.log&amp;quot;&lt;br /&gt;
ipsrc=&amp;quot;http://checkip.dyndns.org&amp;quot;&lt;br /&gt;
date=&amp;quot;`date`&amp;quot;&lt;br /&gt;
addr=&amp;quot;myaccount@yahoo.com&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ip=`curl -s --connect-timeout 3 $ipsrc 2&amp;gt;/dev/null|grep -Po &amp;quot;Current IP Address: .*?\&amp;lt;&amp;quot;|tr '&amp;lt;' '\0'`&lt;br /&gt;
echo &amp;quot;IP: $ip&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if [ -z &amp;quot;$ip&amp;quot; ];then&lt;br /&gt;
	echo &amp;quot;$date ERROR: Could not get external IP from $ipsrc&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
else&lt;br /&gt;
	echo -e &amp;quot;Subject:[`hostname`] $date $ip&amp;quot; | /usr/sbin/ssmtp $addr&lt;br /&gt;
	if [ &amp;quot;$?&amp;quot; = &amp;quot;0&amp;quot; ];then&lt;br /&gt;
		echo &amp;quot;$date SUCCESS: $ip sent to $addr&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
	else&lt;br /&gt;
		echo &amp;quot;$date ERROR: Could not send to $addr&amp;quot; &amp;gt;&amp;gt;$log&lt;br /&gt;
	fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now set the permissions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
chown root:root /scripts/external-ip.sh&lt;br /&gt;
chmod 754 /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script appends to a log file &amp;lt;code&amp;gt;/var/log/external-ip.log&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
touch /var/log/external-ip.log&lt;br /&gt;
chown root:root /var/log/external-ip.log&lt;br /&gt;
chmod 644 /var/log/external-ip.log&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Automatic Email Download ==&lt;br /&gt;
&lt;br /&gt;
As mentioned in a previous section, I use free dynamic DNS which requires that I renew it manually every 30 days. I need to remind myself to do this. My provider sends an email notification a few days before it expires, but I hate email and I don't want it in my face all the time, certainly not in my phone.&lt;br /&gt;
&lt;br /&gt;
The best solution I found was to retrieve the email automatically and send me a text message with only the subject line in the message. I eventually created a second method of notification: it generates a file in a place that I regularly go, the folder that contains all of my to-do lists.&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/ddns.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# This script is run by a cron job.&lt;br /&gt;
&lt;br /&gt;
/usr/bin/fetchmail -N -d0 -f &amp;quot;/scripts/config/ddns-fetchmailrc&amp;quot; -m &amp;quot;/scripts/config/ddns-mailprocess.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
alertfile=&amp;quot;/shares/Private/000__DDNS-ALERT__.txt&amp;quot;&lt;br /&gt;
if [ -e $alertfile ];then&lt;br /&gt;
	chown root:root $alertfile&lt;br /&gt;
	chmod 777 $alertfile&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/config/ddns-mailprocess.sh&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# This script is run by /scripts/ddns.sh&lt;br /&gt;
&lt;br /&gt;
mailto=&amp;quot;17775551234@myprovider.net&amp;quot;&lt;br /&gt;
date=&amp;quot;`date`&amp;quot;&lt;br /&gt;
log=&amp;quot;/var/log/ddns.log&amp;quot;&lt;br /&gt;
alertfile=&amp;quot;/shares/Private/000__DDNS-ALERT__.txt&amp;quot;&lt;br /&gt;
sms=&amp;quot;/scripts/sms.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cat /dev/stdin | grep -i &amp;quot;^Subject:&amp;quot; | sed 's/Subject\://g' | $sms &amp;quot;DDNS&amp;quot; &amp;quot;`cat /dev/stdin` ( $date )&amp;quot; &amp;amp;&amp;amp;\&lt;br /&gt;
echo &amp;quot;$date - DDNS notification sent to $mailto&amp;quot; | tee -a $log | sed &amp;quot;s/$mailto/cell\ phone/g&amp;quot; &amp;gt;$alertfile &amp;amp;&amp;amp;\&lt;br /&gt;
chmod 777 $alertfile&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of the file &amp;lt;code&amp;gt;/scripts/config/ddns-fetchmailrc&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# This rc file is run by /scripts/ddns.sh&lt;br /&gt;
# This file MUST have root:root and chmod 700&lt;br /&gt;
&lt;br /&gt;
set postmaster &amp;quot;username&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
poll &amp;quot;imap.mail.yahoo.com&amp;quot; protocol IMAP username &amp;quot;myaccount@yahoo.com&amp;quot; password &amp;quot;InsertPasswordHere&amp;quot; is &amp;quot;username&amp;quot; here keep folder &amp;quot;DDNS-Mailbox&amp;quot; ssl&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You'll notice that it creates a file &amp;lt;code&amp;gt;/shares/Private/000__DDNS-ALERT__.txt&amp;lt;/code&amp;gt;. The &amp;quot;000&amp;quot; is just to put it at the top of the directory listing. Also notice that I make it read-write for everyone so I can delete it from my webapp.&lt;br /&gt;
&lt;br /&gt;
Set up permissions on all three files, and create the log file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
touch /var/log/ddns.log&lt;br /&gt;
chown root:root /var/log/ddns.log&lt;br /&gt;
chmod 640 /var/log/ddns.log&lt;br /&gt;
&lt;br /&gt;
chown root:root /scripts/ddns.sh&lt;br /&gt;
chmod 754 /scripts/ddns.sh&lt;br /&gt;
&lt;br /&gt;
chown root:config /scripts/config/ddns-mailprocess.sh&lt;br /&gt;
chmod 750 /scripts/config/ddns-mailprocess.sh&lt;br /&gt;
&lt;br /&gt;
chown root:root /scripts/config/ddns-fetchmailrc&lt;br /&gt;
chmod 700 /scripts/config/ddns-fetchmailrc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
UPDATE February 2021: Yahoo now requires you to create a &amp;lt;b&amp;gt;secure app password&amp;lt;/b&amp;gt;. See [[#yahoo-app-pass|this section]].&lt;br /&gt;
&lt;br /&gt;
When you run &amp;lt;code&amp;gt;ddns.sh&amp;lt;/code&amp;gt; as root it gives you a warning about running as root. This is okay.&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
fetchmail: WARNING: Running as root is discouraged.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If permissions on &amp;lt;code&amp;gt;ddns-fetchmailrc&amp;lt;/code&amp;gt; are not correct, you will get this failure message:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
File /scripts/config/ddns-fetchmailrc must have no more than -rwx------ (0700) permissions.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Set Up Cron ==&lt;br /&gt;
&lt;br /&gt;
Just for reference, here are the entries I made in my &amp;lt;code&amp;gt;/etc/crontab&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
# Crontabs to be run without 'run-parts'&lt;br /&gt;
#&lt;br /&gt;
# RUN AT NOON&lt;br /&gt;
0                  12           * * *   root    /scripts/ddns.sh&lt;br /&gt;
0                  12           * * *   root    /scripts/notifications.sh&lt;br /&gt;
# RUN EVERY 6 HOURS&lt;br /&gt;
1                  0,6,12,18    * * *   root    /scripts/external-ip.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=Dmesg_Real_Dates/TImestamps&amp;diff=3679</id>
		<title>Dmesg Real Dates/TImestamps</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=Dmesg_Real_Dates/TImestamps&amp;diff=3679"/>
				<updated>2021-01-21T05:48:27Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Dmesg shows timestamps in seconds since the last boot, and newer versions of dmesg take the &amp;quot;-T&amp;quot; parameter like &amp;lt;code&amp;gt;dmesg -T&amp;lt;/code&amp;gt; to display dates in human readable format, but in case your server is running an old version here's a great bash function that provides that functionality. I didn't write this I stole it from someone else. Keep in mind that if the system has been put to sleep, suspended, or hibernated then the timestamps will be inaccurate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
dmesg_with_human_timestamps () {&lt;br /&gt;
    $(type -P dmesg) &amp;quot;$@&amp;quot; | perl -w -e 'use strict;&lt;br /&gt;
        my ($uptime) = do { local @ARGV=&amp;quot;/proc/uptime&amp;quot;;&amp;lt;&amp;gt;}; ($uptime) = ($uptime =~ /^(\d+)\./);&lt;br /&gt;
        foreach my $line (&amp;lt;&amp;gt;) {&lt;br /&gt;
            printf( ($line=~/^\[\s*(\d+)\.\d+\](.+)/) ? ( &amp;quot;[%s]%s\n&amp;quot;, scalar localtime(time - $uptime + $1), $2 ) : $line )&lt;br /&gt;
        }'&lt;br /&gt;
}&lt;br /&gt;
alias dmesg=dmesg_with_human_timestamps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=Dmesg_Real_Dates/TImestamps&amp;diff=3678</id>
		<title>Dmesg Real Dates/TImestamps</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=Dmesg_Real_Dates/TImestamps&amp;diff=3678"/>
				<updated>2021-01-21T05:46:57Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: Created page with &amp;quot;Dmesg shows timestamps in seconds since the last boot, and newer versions of dmesg take the &amp;quot;-T&amp;quot; parameter like &amp;lt;code&amp;gt;dmesg -T&amp;lt;/code&amp;gt; to display dates in human readable format...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Dmesg shows timestamps in seconds since the last boot, and newer versions of dmesg take the &amp;quot;-T&amp;quot; parameter like &amp;lt;code&amp;gt;dmesg -T&amp;lt;/code&amp;gt; to display dates in human readable format, but in case your server is running an old version, here's a great bash function that I stole from someone else. Keep in mind that if the system has been put to sleep, suspended, or hibernated then the timestamps will be inaccurate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
dmesg_with_human_timestamps () {&lt;br /&gt;
    $(type -P dmesg) &amp;quot;$@&amp;quot; | perl -w -e 'use strict;&lt;br /&gt;
        my ($uptime) = do { local @ARGV=&amp;quot;/proc/uptime&amp;quot;;&amp;lt;&amp;gt;}; ($uptime) = ($uptime =~ /^(\d+)\./);&lt;br /&gt;
        foreach my $line (&amp;lt;&amp;gt;) {&lt;br /&gt;
            printf( ($line=~/^\[\s*(\d+)\.\d+\](.+)/) ? ( &amp;quot;[%s]%s\n&amp;quot;, scalar localtime(time - $uptime + $1), $2 ) : $line )&lt;br /&gt;
        }'&lt;br /&gt;
}&lt;br /&gt;
alias dmesg=dmesg_with_human_timestamps&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=Linux&amp;diff=3677</id>
		<title>Linux</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=Linux&amp;diff=3677"/>
				<updated>2021-01-21T05:37:30Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Particular Problems/Solutions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== General Linux Notes ==&lt;br /&gt;
&lt;br /&gt;
* Massive list of [[Linux Commands]].&lt;br /&gt;
* Other notes about software, services, configs, etc. go to [[Notes]] page.&lt;br /&gt;
&lt;br /&gt;
== Scripts ==&lt;br /&gt;
&lt;br /&gt;
* [[Custom Window Snap]]: Gosnap (Good Old Snap) emulates the Aero Snap feature in Windows 7&lt;br /&gt;
&lt;br /&gt;
== Custom Distros ==&lt;br /&gt;
&lt;br /&gt;
* [[Custom Slax Bootable OS]]&lt;br /&gt;
&lt;br /&gt;
== Tips and Tricks ==&lt;br /&gt;
&lt;br /&gt;
* [[The Fastest Checksum]]&lt;br /&gt;
* [[List DHCP Leases]]&lt;br /&gt;
* [[Power Saving]]&lt;br /&gt;
* [[Disable Update Notifier]]&lt;br /&gt;
* [[Mouse/Touchpad Drivers and Settings]]&lt;br /&gt;
* [[Automatic Email and Text Notifications]]&lt;br /&gt;
* [[Raspberry Pi SSH Without Logging In]]&lt;br /&gt;
* [[Bash CSV Handling]]&lt;br /&gt;
* [[Bi-Directional Directory Synchronization]]&lt;br /&gt;
* [[Better Bash Configs]]&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
&lt;br /&gt;
* [[rdiff-backup]]: Incremental backup tool.&lt;br /&gt;
* [[Openssl - Generate Self-signed Certificate for Chrome]]&lt;br /&gt;
* [[Truecrypt Over NFS or SSH]]&lt;br /&gt;
* [[Vim]]&lt;br /&gt;
* [[Raspberry Pi Video Streaming]]&lt;br /&gt;
&lt;br /&gt;
== Particular Problems/Solutions ==&lt;br /&gt;
&lt;br /&gt;
* [[Kernel Panic: VFS :Unable to mount root fs on unknown-block]]&lt;br /&gt;
* [[The Problem with Journaling File systems on an SD Card]]&lt;br /&gt;
* [[Beyond The Max Audio Volume]]&lt;br /&gt;
* [[Unattended-Upgrades Automatically Rebooting The System]]&lt;br /&gt;
* [[Set Font Size on TTY]]&lt;br /&gt;
* [[Weird Characters in Terminal]]&lt;br /&gt;
* [[SSH Won't Work Via Shell Command in PHP]]&lt;br /&gt;
* [[Retrieve Package List from Dead System]]&lt;br /&gt;
* [[Ubuntu 18.04 Ctrl+Scroll Won't Zoom in Chromium]]&lt;br /&gt;
* [[Ubuntu 18.04 Audacity Poor Recording and Popping]]&lt;br /&gt;
* [[Systemd Private Tmp Folders]]&lt;br /&gt;
* [[Dmesg Real Dates/TImestamps]]&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=External_Links&amp;diff=3676</id>
		<title>External Links</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=External_Links&amp;diff=3676"/>
				<updated>2020-12-03T17:15:08Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Programming */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Tools ==&lt;br /&gt;
&lt;br /&gt;
* https://www.virustotal.com/: Multi-scanner anti-virus (no installation required).&lt;br /&gt;
&lt;br /&gt;
== Programming ==&lt;br /&gt;
&lt;br /&gt;
* https://fiddles.io/: Online boilerplates for all languages.&lt;br /&gt;
* http://cpp.sh/: Better online boilerplate for C++.&lt;br /&gt;
* https://regex101.com/: Online boilerplate for regular expressions.&lt;br /&gt;
* https://www.hex-rays.com/products/ida/support/download_freeware.shtml: Binary disassembler.&lt;br /&gt;
* https://www.epochconverter.com/: Unix Epoch Datetime Converter&lt;br /&gt;
&lt;br /&gt;
== Web Development ==&lt;br /&gt;
&lt;br /&gt;
=== CSS and Other Style Stuff ===&lt;br /&gt;
&lt;br /&gt;
* http://paletton.com/: Color palette creator.&lt;br /&gt;
* http://www.colorzilla.com/gradient-editor/: CSS gradient generator&lt;br /&gt;
* http://www.cssmatic.com/: CSS Tools: gradient, border radius, texture, box shadow&lt;br /&gt;
* http://css3generator.com/: CSS multi-generator&lt;br /&gt;
* http://www.cssbuttongenerator.com/: CSS button generator&lt;br /&gt;
* https://www.hscripts.com/tools/drop-down-menu/index.php: JS drop-down menu generator&lt;br /&gt;
* http://purecssmenu.com/: CSS menu generator&lt;br /&gt;
* http://www.sassmeister.com/gist/5bcb7fefa9d05955f66c: Sass Lab&lt;br /&gt;
* https://beautifier.io/: Javescript, CSS, and HTML Unminifier/Beautifier (Code Expander)&lt;br /&gt;
&lt;br /&gt;
=== Fonts ===&lt;br /&gt;
&lt;br /&gt;
* https://fonts.google.com/: Google's fonts&lt;br /&gt;
* https://icomoon.io/: Font maker&lt;br /&gt;
&lt;br /&gt;
=== Basic Tools and Info ===&lt;br /&gt;
&lt;br /&gt;
* http://validator.w3.org/unicorn/: HTML validation tool&lt;br /&gt;
* https://www.xml-sitemaps.com/: XML sitemap generator&lt;br /&gt;
* https://www.browserstack.com/: Browser emulator&lt;br /&gt;
* http://www.ssec.edu/~tomw/java/unicode.html: Unicode List&lt;br /&gt;
* http://www.freeformatter.com/html-entities.html: Complete list of HTML entities&lt;br /&gt;
&lt;br /&gt;
== Volunteer Computing ==&lt;br /&gt;
&lt;br /&gt;
* https://boinc.berkeley.edu/: Berkeley distributed computing network (multiple projects).&lt;br /&gt;
* https://boinc.bakerlab.org/: Rosetta@Home protein folding.&lt;br /&gt;
* https://foldingathome.org/: Folding@Home protein folding.&lt;br /&gt;
* https://einsteinathome.org/: Einstein@Home physics simulation.&lt;br /&gt;
* https://lhcathome.cern.ch/lhcathome/: LHC@Home Large Hadron Collider simulation.&lt;br /&gt;
* https://eternagame.org/: A game that contributes to protein simulation as you play.&lt;br /&gt;
* https://www.zooniverse.org/: A lot of projects that allow people to actively participate in science.&lt;br /&gt;
* https://www.zooniverse.org/projects/zookeeper/galaxy-zoo: Help classify galaxies by examining telescope photos.&lt;br /&gt;
* https://www.zooniverse.org/projects/ianc2/exoplanet-explorers/: Help identify exoplanets.&lt;br /&gt;
&lt;br /&gt;
== News and Information ==&lt;br /&gt;
&lt;br /&gt;
* http://darksky.net/: Really nice weather report&lt;br /&gt;
* http://www.weathertab.com/: Long range weather forecast (1 year)&lt;br /&gt;
* http://www.ustream.tv/nasahdtv: NASA live stream&lt;br /&gt;
* http://everytimezone.com/: Visual chart of timezones&lt;br /&gt;
* http://www.spacerogue.net: Hacker/tech news&lt;br /&gt;
* http://www.freeinfosociety.com: Tons of free information&lt;br /&gt;
&lt;br /&gt;
== Educational ==&lt;br /&gt;
&lt;br /&gt;
* http://interactmath.com/: Free interactive math tutorials&lt;br /&gt;
* http://www.ptable.com/: Interactive periodic table&lt;br /&gt;
* http://ascendmath.com/fcm/html5/: Simple math flash cards&lt;br /&gt;
* https://www.desmos.com/calculator: Graphing calculator&lt;br /&gt;
* https://www.khanacademy.org: Free online academy (math, physics, chemistry, etc.)&lt;br /&gt;
* http://galaxyzoo.org: Volunteer to categorize galaxies&lt;br /&gt;
* http://www.planethunters.org: Volunteer to help identify exoplanets&lt;br /&gt;
* https://op-webtools.web.cern.ch/vistar/vistars.php: Large Hadron Collider monitor (LHC)&lt;br /&gt;
* http://ispy-webgl.web.cern.ch/ispy-webgl/: CMS Data Visualization&lt;br /&gt;
* https://www.aviso.altimetry.fr/en/data.html: Oceanic and Altimetric database&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
&lt;br /&gt;
=== Guacamole VNC Server ===&lt;br /&gt;
&lt;br /&gt;
* http://guac-dev.org/doc/gug/&lt;br /&gt;
* https://gist.github.com/jeffersonmartin/8236574: Version 0.8.3 for Ubuntu Server&lt;br /&gt;
* http://www.linuxintro.org/wiki/Guacamole&lt;br /&gt;
* https://deviantengineer.com/2013/10/guacamole/&lt;br /&gt;
&lt;br /&gt;
=== Ampache Streaming Media Server ===&lt;br /&gt;
&lt;br /&gt;
* https://github.com/ampache/ampache/wiki/Installation&lt;br /&gt;
&lt;br /&gt;
== Files and Software ==&lt;br /&gt;
&lt;br /&gt;
* https://archive.org/: THE INTERNET ARCHIVE&lt;br /&gt;
* https://librivox.org/: Free audio books&lt;br /&gt;
* http://www.freeimages.com: Royalty-free/creative common images&lt;br /&gt;
* http://www.freewebtemplates.com/: Free web templates&lt;br /&gt;
* https://www.softaculous.com/apps/: Nice list of software&lt;br /&gt;
* https://www.draw.io/: Free web-based network diagram/flowchart designer (like Visio).&lt;br /&gt;
* http://www.emachineshop.com/machine-shop/Free-CAD-Design-Software/page100.html: Freee CAD software (also good for making gears).&lt;br /&gt;
* https://easyeda.com: Free circuit diagram software online&lt;br /&gt;
* https://www.circuitlab.com/editor/: Very simple free circuit diagram software online (can't save to file)&lt;br /&gt;
* ftp://ftp.ncbi.nih.gov/genomes/: National Institute of Health genome archives&lt;br /&gt;
* http://redobackup.org/: Bootable backup utility.&lt;br /&gt;
* https://www.sites.google.com/site/unoardusim/services: Arduino Uno simulator.&lt;br /&gt;
&lt;br /&gt;
=== Service Manuals ===&lt;br /&gt;
&lt;br /&gt;
* https://freeservicemanuals.info&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
* https://thepihut.com/: Raspberry Pi stuff&lt;br /&gt;
* https://www.newark.com/?COM=element14_store_Home: Electronics&lt;br /&gt;
* https://www.adafruit.com/: Electronics&lt;br /&gt;
&lt;br /&gt;
== Materials ==&lt;br /&gt;
&lt;br /&gt;
* http://www.tapplastics.com/: Custom plastics&lt;br /&gt;
&lt;br /&gt;
== Art Tools ==&lt;br /&gt;
&lt;br /&gt;
* http://www.text-image.com/convert/ascii.html: Image to ASCII art converter&lt;br /&gt;
* http://www.wordle.net/: word-cloud generator&lt;br /&gt;
* http://www.patorjk.com/software/taag/: text to ASCII art generator&lt;br /&gt;
* http://www.flamingtext.com/: Logo designer&lt;br /&gt;
&lt;br /&gt;
== Audio Tools ==&lt;br /&gt;
&lt;br /&gt;
* http://imtranslator.net/translation/text-to-speech/: text to speech&lt;br /&gt;
&lt;br /&gt;
== Document Tools ==&lt;br /&gt;
&lt;br /&gt;
* http://www.free-ocr.com/: Optical Character Recognition (OCR); finds text in an image&lt;br /&gt;
* http://www.myfonts.com/WhatTheFont/: Font identifier&lt;br /&gt;
&lt;br /&gt;
== Space and Earth ==&lt;br /&gt;
&lt;br /&gt;
* https://www.jasondavies.com/maps/transition/: interactive world map projections.&lt;br /&gt;
* https://worldview.earthdata.nasa.gov/: NASA Worldview.&lt;br /&gt;
* https://sdo.gsfc.nasa.gov/data/: NASA Solar Dynamics Observatory (SDO).&lt;br /&gt;
* https://helioviewer.org/: Interactive up-to-date view of the Sun.&lt;br /&gt;
* http://lmsal.com/isolsearch: Another interactive map of the Sun and solar activity.&lt;br /&gt;
* https://www.jwst.nasa.gov/webcam.html: Goddard Space Center clean-room  webcams.&lt;br /&gt;
* https://science.ksc.nasa.gov/shuttle/countdown/video/: Kennedy Space Center webcams.&lt;br /&gt;
* http://www.isstracker.com/embed: International Space Station Tracker.&lt;br /&gt;
* https://spotthestation.nasa.gov/widget/: Spot The Station widget.&lt;br /&gt;
* http://www.ustream.tv/embed/6540154?html5ui: NASA Public-Education channel.&lt;br /&gt;
* http://www.ustream.tv/embed/10414700?html5ui: NASA TV Media.&lt;br /&gt;
* http://www.ustream.tv/embed/17074538?v=3&amp;amp;wmode=direct;autoplay=1: ISS Livestream 1&lt;br /&gt;
* http://www.ustream.tv/embed/9408562?v=3&amp;amp;wmode=direct;autoplay=1: ISS Livestream 2&lt;br /&gt;
&lt;br /&gt;
== Privacy and Anti-Advertising ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scam Alerts&amp;lt;/b&amp;gt;&lt;br /&gt;
* https://www.consumer.ftc.gov/scam-alerts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Government Sites About Spam, Fraud, etc.&amp;lt;/b&amp;gt;&lt;br /&gt;
* https://attorneygeneral.nd.gov/consumer-resources/identity-theft/preventing-identity-theft&lt;br /&gt;
* https://www.consumer.ftc.gov/articles/0038-spam&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Opt-Out Registries&amp;lt;/b&amp;gt;&lt;br /&gt;
* https://www.donotcall.gov/&lt;br /&gt;
* https://www.optoutprescreen.com&lt;br /&gt;
* https://dmachoice.thedma.org/&lt;br /&gt;
* http://www.directmail.com/mail_preference/&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Privacy/Ad-blocker Tools&amp;lt;/b&amp;gt;&lt;br /&gt;
* https://ublock.org/: Browser plugin&lt;br /&gt;
* https://adblockplus.org/: Browser plugin&lt;br /&gt;
* https://pi-hole.net/: Network level ad-blocker (DNS-based)&lt;br /&gt;
* https://freek.ws/public-pi-hole/: Public hosted PiHole DNS Servers&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;VPN Services:&amp;lt;/b&amp;gt;&lt;br /&gt;
* https://www.expressvpn.com/: This company has the highest merits by my reckoning. Authorities have asked for logs and they were unable to provide it, which demonstrates that they are honest about their no-log policy. Off-shore jurisdiction: British Virgin Islands. Also, they have less usage restrictions than other VPN providers.&lt;br /&gt;
&lt;br /&gt;
== Other Nifty Stuff ==&lt;br /&gt;
&lt;br /&gt;
* https://www.herox.com/: A website where companies put bounties on innovation&lt;br /&gt;
* https://maroslaw.github.io/rainyday.js/demo012_1.html: Rainy window animation (press F11 to full-screen).&lt;br /&gt;
* http://www.beepbox.co/: 8-bit music synthesizer.&lt;br /&gt;
* http://www.eviloverlord.com/lists/overlord.html: A funny list of axioms for being a successful evil overlord.&lt;br /&gt;
* http://www.petittube.com/: Automatically plays random YouTube videos that have zero views, so you are literally the first viewer.&lt;br /&gt;
* http://www.virtualcolossus.co.uk/: Functional simulation of a Colossus Mk II.&lt;br /&gt;
* https://ban.ai/multics/: Virtual Multics Operating System&lt;br /&gt;
* http://asciicker.com/x13/: Incredible 3D ASCII based game (the &amp;quot;x13&amp;quot; is the version, use lower numbers to see older versions)&lt;br /&gt;
* https://ideasai.net/: An business idea generator powered by artificial intelligence (GPT-3)&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=External_Links&amp;diff=3675</id>
		<title>External Links</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=External_Links&amp;diff=3675"/>
				<updated>2020-10-22T02:44:36Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Other Nifty Stuff */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Tools ==&lt;br /&gt;
&lt;br /&gt;
* https://www.virustotal.com/: Multi-scanner anti-virus (no installation required).&lt;br /&gt;
&lt;br /&gt;
== Programming ==&lt;br /&gt;
&lt;br /&gt;
* https://fiddles.io/: Online boiler plates for all languages.&lt;br /&gt;
* http://cpp.sh/ : Better online boiler plate for C++.&lt;br /&gt;
* https://www.hex-rays.com/products/ida/support/download_freeware.shtml: Binary disassembler.&lt;br /&gt;
* https://www.epochconverter.com/: Unix Epoch Datetime Converter&lt;br /&gt;
&lt;br /&gt;
== Web Development ==&lt;br /&gt;
&lt;br /&gt;
=== CSS and Other Style Stuff ===&lt;br /&gt;
&lt;br /&gt;
* http://paletton.com/: Color palette creator.&lt;br /&gt;
* http://www.colorzilla.com/gradient-editor/: CSS gradient generator&lt;br /&gt;
* http://www.cssmatic.com/: CSS Tools: gradient, border radius, texture, box shadow&lt;br /&gt;
* http://css3generator.com/: CSS multi-generator&lt;br /&gt;
* http://www.cssbuttongenerator.com/: CSS button generator&lt;br /&gt;
* https://www.hscripts.com/tools/drop-down-menu/index.php: JS drop-down menu generator&lt;br /&gt;
* http://purecssmenu.com/: CSS menu generator&lt;br /&gt;
* http://www.sassmeister.com/gist/5bcb7fefa9d05955f66c: Sass Lab&lt;br /&gt;
* https://beautifier.io/: Javescript, CSS, and HTML Unminifier/Beautifier (Code Expander)&lt;br /&gt;
&lt;br /&gt;
=== Fonts ===&lt;br /&gt;
&lt;br /&gt;
* https://fonts.google.com/: Google's fonts&lt;br /&gt;
* https://icomoon.io/: Font maker&lt;br /&gt;
&lt;br /&gt;
=== Basic Tools and Info ===&lt;br /&gt;
&lt;br /&gt;
* http://validator.w3.org/unicorn/: HTML validation tool&lt;br /&gt;
* https://www.xml-sitemaps.com/: XML sitemap generator&lt;br /&gt;
* https://www.browserstack.com/: Browser emulator&lt;br /&gt;
* http://www.ssec.edu/~tomw/java/unicode.html: Unicode List&lt;br /&gt;
* http://www.freeformatter.com/html-entities.html: Complete list of HTML entities&lt;br /&gt;
&lt;br /&gt;
== Volunteer Computing ==&lt;br /&gt;
&lt;br /&gt;
* https://boinc.berkeley.edu/: Berkeley distributed computing network (multiple projects).&lt;br /&gt;
* https://boinc.bakerlab.org/: Rosetta@Home protein folding.&lt;br /&gt;
* https://foldingathome.org/: Folding@Home protein folding.&lt;br /&gt;
* https://einsteinathome.org/: Einstein@Home physics simulation.&lt;br /&gt;
* https://lhcathome.cern.ch/lhcathome/: LHC@Home Large Hadron Collider simulation.&lt;br /&gt;
* https://eternagame.org/: A game that contributes to protein simulation as you play.&lt;br /&gt;
* https://www.zooniverse.org/: A lot of projects that allow people to actively participate in science.&lt;br /&gt;
* https://www.zooniverse.org/projects/zookeeper/galaxy-zoo: Help classify galaxies by examining telescope photos.&lt;br /&gt;
* https://www.zooniverse.org/projects/ianc2/exoplanet-explorers/: Help identify exoplanets.&lt;br /&gt;
&lt;br /&gt;
== News and Information ==&lt;br /&gt;
&lt;br /&gt;
* http://darksky.net/: Really nice weather report&lt;br /&gt;
* http://www.weathertab.com/: Long range weather forecast (1 year)&lt;br /&gt;
* http://www.ustream.tv/nasahdtv: NASA live stream&lt;br /&gt;
* http://everytimezone.com/: Visual chart of timezones&lt;br /&gt;
* http://www.spacerogue.net: Hacker/tech news&lt;br /&gt;
* http://www.freeinfosociety.com: Tons of free information&lt;br /&gt;
&lt;br /&gt;
== Educational ==&lt;br /&gt;
&lt;br /&gt;
* http://interactmath.com/: Free interactive math tutorials&lt;br /&gt;
* http://www.ptable.com/: Interactive periodic table&lt;br /&gt;
* http://ascendmath.com/fcm/html5/: Simple math flash cards&lt;br /&gt;
* https://www.desmos.com/calculator: Graphing calculator&lt;br /&gt;
* https://www.khanacademy.org: Free online academy (math, physics, chemistry, etc.)&lt;br /&gt;
* http://galaxyzoo.org: Volunteer to categorize galaxies&lt;br /&gt;
* http://www.planethunters.org: Volunteer to help identify exoplanets&lt;br /&gt;
* https://op-webtools.web.cern.ch/vistar/vistars.php: Large Hadron Collider monitor (LHC)&lt;br /&gt;
* http://ispy-webgl.web.cern.ch/ispy-webgl/: CMS Data Visualization&lt;br /&gt;
* https://www.aviso.altimetry.fr/en/data.html: Oceanic and Altimetric database&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
&lt;br /&gt;
=== Guacamole VNC Server ===&lt;br /&gt;
&lt;br /&gt;
* http://guac-dev.org/doc/gug/&lt;br /&gt;
* https://gist.github.com/jeffersonmartin/8236574: Version 0.8.3 for Ubuntu Server&lt;br /&gt;
* http://www.linuxintro.org/wiki/Guacamole&lt;br /&gt;
* https://deviantengineer.com/2013/10/guacamole/&lt;br /&gt;
&lt;br /&gt;
=== Ampache Streaming Media Server ===&lt;br /&gt;
&lt;br /&gt;
* https://github.com/ampache/ampache/wiki/Installation&lt;br /&gt;
&lt;br /&gt;
== Files and Software ==&lt;br /&gt;
&lt;br /&gt;
* https://archive.org/: THE INTERNET ARCHIVE&lt;br /&gt;
* https://librivox.org/: Free audio books&lt;br /&gt;
* http://www.freeimages.com: Royalty-free/creative common images&lt;br /&gt;
* http://www.freewebtemplates.com/: Free web templates&lt;br /&gt;
* https://www.softaculous.com/apps/: Nice list of software&lt;br /&gt;
* https://www.draw.io/: Free web-based network diagram/flowchart designer (like Visio).&lt;br /&gt;
* http://www.emachineshop.com/machine-shop/Free-CAD-Design-Software/page100.html: Freee CAD software (also good for making gears).&lt;br /&gt;
* https://easyeda.com: Free circuit diagram software online&lt;br /&gt;
* https://www.circuitlab.com/editor/: Very simple free circuit diagram software online (can't save to file)&lt;br /&gt;
* ftp://ftp.ncbi.nih.gov/genomes/: National Institute of Health genome archives&lt;br /&gt;
* http://redobackup.org/: Bootable backup utility.&lt;br /&gt;
* https://www.sites.google.com/site/unoardusim/services: Arduino Uno simulator.&lt;br /&gt;
&lt;br /&gt;
=== Service Manuals ===&lt;br /&gt;
&lt;br /&gt;
* https://freeservicemanuals.info&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
* https://thepihut.com/: Raspberry Pi stuff&lt;br /&gt;
* https://www.newark.com/?COM=element14_store_Home: Electronics&lt;br /&gt;
* https://www.adafruit.com/: Electronics&lt;br /&gt;
&lt;br /&gt;
== Materials ==&lt;br /&gt;
&lt;br /&gt;
* http://www.tapplastics.com/: Custom plastics&lt;br /&gt;
&lt;br /&gt;
== Art Tools ==&lt;br /&gt;
&lt;br /&gt;
* http://www.text-image.com/convert/ascii.html: Image to ASCII art converter&lt;br /&gt;
* http://www.wordle.net/: word-cloud generator&lt;br /&gt;
* http://www.patorjk.com/software/taag/: text to ASCII art generator&lt;br /&gt;
* http://www.flamingtext.com/: Logo designer&lt;br /&gt;
&lt;br /&gt;
== Audio Tools ==&lt;br /&gt;
&lt;br /&gt;
* http://imtranslator.net/translation/text-to-speech/: text to speech&lt;br /&gt;
&lt;br /&gt;
== Document Tools ==&lt;br /&gt;
&lt;br /&gt;
* http://www.free-ocr.com/: Optical Character Recognition (OCR); finds text in an image&lt;br /&gt;
* http://www.myfonts.com/WhatTheFont/: Font identifier&lt;br /&gt;
&lt;br /&gt;
== Space and Earth ==&lt;br /&gt;
&lt;br /&gt;
* https://www.jasondavies.com/maps/transition/: interactive world map projections.&lt;br /&gt;
* https://worldview.earthdata.nasa.gov/: NASA Worldview.&lt;br /&gt;
* https://sdo.gsfc.nasa.gov/data/: NASA Solar Dynamics Observatory (SDO).&lt;br /&gt;
* https://helioviewer.org/: Interactive up-to-date view of the Sun.&lt;br /&gt;
* http://lmsal.com/isolsearch: Another interactive map of the Sun and solar activity.&lt;br /&gt;
* https://www.jwst.nasa.gov/webcam.html: Goddard Space Center clean-room  webcams.&lt;br /&gt;
* https://science.ksc.nasa.gov/shuttle/countdown/video/: Kennedy Space Center webcams.&lt;br /&gt;
* http://www.isstracker.com/embed: International Space Station Tracker.&lt;br /&gt;
* https://spotthestation.nasa.gov/widget/: Spot The Station widget.&lt;br /&gt;
* http://www.ustream.tv/embed/6540154?html5ui: NASA Public-Education channel.&lt;br /&gt;
* http://www.ustream.tv/embed/10414700?html5ui: NASA TV Media.&lt;br /&gt;
* http://www.ustream.tv/embed/17074538?v=3&amp;amp;wmode=direct;autoplay=1: ISS Livestream 1&lt;br /&gt;
* http://www.ustream.tv/embed/9408562?v=3&amp;amp;wmode=direct;autoplay=1: ISS Livestream 2&lt;br /&gt;
&lt;br /&gt;
== Privacy and Anti-Advertising ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scam Alerts&amp;lt;/b&amp;gt;&lt;br /&gt;
* https://www.consumer.ftc.gov/scam-alerts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Government Sites About Spam, Fraud, etc.&amp;lt;/b&amp;gt;&lt;br /&gt;
* https://attorneygeneral.nd.gov/consumer-resources/identity-theft/preventing-identity-theft&lt;br /&gt;
* https://www.consumer.ftc.gov/articles/0038-spam&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Opt-Out Registries&amp;lt;/b&amp;gt;&lt;br /&gt;
* https://www.donotcall.gov/&lt;br /&gt;
* https://www.optoutprescreen.com&lt;br /&gt;
* https://dmachoice.thedma.org/&lt;br /&gt;
* http://www.directmail.com/mail_preference/&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Privacy/Ad-blocker Tools&amp;lt;/b&amp;gt;&lt;br /&gt;
* https://ublock.org/: Browser plugin&lt;br /&gt;
* https://adblockplus.org/: Browser plugin&lt;br /&gt;
* https://pi-hole.net/: Network level ad-blocker (DNS-based)&lt;br /&gt;
* https://freek.ws/public-pi-hole/: Public hosted PiHole DNS Servers&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;VPN Services:&amp;lt;/b&amp;gt;&lt;br /&gt;
* https://www.expressvpn.com/: This company has the highest merits by my reckoning. Authorities have asked for logs and they were unable to provide it, which demonstrates that they are honest about their no-log policy. Off-shore jurisdiction: British Virgin Islands. Also, they have less usage restrictions than other VPN providers.&lt;br /&gt;
&lt;br /&gt;
== Other Nifty Stuff ==&lt;br /&gt;
&lt;br /&gt;
* https://www.herox.com/: A website where companies put bounties on innovation&lt;br /&gt;
* https://maroslaw.github.io/rainyday.js/demo012_1.html: Rainy window animation (press F11 to full-screen).&lt;br /&gt;
* http://www.beepbox.co/: 8-bit music synthesizer.&lt;br /&gt;
* http://www.eviloverlord.com/lists/overlord.html: A funny list of axioms for being a successful evil overlord.&lt;br /&gt;
* http://www.petittube.com/: Automatically plays random YouTube videos that have zero views, so you are literally the first viewer.&lt;br /&gt;
* http://www.virtualcolossus.co.uk/: Functional simulation of a Colossus Mk II.&lt;br /&gt;
* https://ban.ai/multics/: Virtual Multics Operating System&lt;br /&gt;
* http://asciicker.com/x13/: Incredible 3D ASCII based game (the &amp;quot;x13&amp;quot; is the version, use lower numbers to see older versions)&lt;br /&gt;
* https://ideasai.net/: An business idea generator powered by artificial intelligence (GPT-3)&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=External_Links&amp;diff=3674</id>
		<title>External Links</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=External_Links&amp;diff=3674"/>
				<updated>2020-10-22T02:42:40Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Privacy and Anti-Consumerism */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Tools ==&lt;br /&gt;
&lt;br /&gt;
* https://www.virustotal.com/: Multi-scanner anti-virus (no installation required).&lt;br /&gt;
&lt;br /&gt;
== Programming ==&lt;br /&gt;
&lt;br /&gt;
* https://fiddles.io/: Online boiler plates for all languages.&lt;br /&gt;
* http://cpp.sh/ : Better online boiler plate for C++.&lt;br /&gt;
* https://www.hex-rays.com/products/ida/support/download_freeware.shtml: Binary disassembler.&lt;br /&gt;
* https://www.epochconverter.com/: Unix Epoch Datetime Converter&lt;br /&gt;
&lt;br /&gt;
== Web Development ==&lt;br /&gt;
&lt;br /&gt;
=== CSS and Other Style Stuff ===&lt;br /&gt;
&lt;br /&gt;
* http://paletton.com/: Color palette creator.&lt;br /&gt;
* http://www.colorzilla.com/gradient-editor/: CSS gradient generator&lt;br /&gt;
* http://www.cssmatic.com/: CSS Tools: gradient, border radius, texture, box shadow&lt;br /&gt;
* http://css3generator.com/: CSS multi-generator&lt;br /&gt;
* http://www.cssbuttongenerator.com/: CSS button generator&lt;br /&gt;
* https://www.hscripts.com/tools/drop-down-menu/index.php: JS drop-down menu generator&lt;br /&gt;
* http://purecssmenu.com/: CSS menu generator&lt;br /&gt;
* http://www.sassmeister.com/gist/5bcb7fefa9d05955f66c: Sass Lab&lt;br /&gt;
* https://beautifier.io/: Javescript, CSS, and HTML Unminifier/Beautifier (Code Expander)&lt;br /&gt;
&lt;br /&gt;
=== Fonts ===&lt;br /&gt;
&lt;br /&gt;
* https://fonts.google.com/: Google's fonts&lt;br /&gt;
* https://icomoon.io/: Font maker&lt;br /&gt;
&lt;br /&gt;
=== Basic Tools and Info ===&lt;br /&gt;
&lt;br /&gt;
* http://validator.w3.org/unicorn/: HTML validation tool&lt;br /&gt;
* https://www.xml-sitemaps.com/: XML sitemap generator&lt;br /&gt;
* https://www.browserstack.com/: Browser emulator&lt;br /&gt;
* http://www.ssec.edu/~tomw/java/unicode.html: Unicode List&lt;br /&gt;
* http://www.freeformatter.com/html-entities.html: Complete list of HTML entities&lt;br /&gt;
&lt;br /&gt;
== Volunteer Computing ==&lt;br /&gt;
&lt;br /&gt;
* https://boinc.berkeley.edu/: Berkeley distributed computing network (multiple projects).&lt;br /&gt;
* https://boinc.bakerlab.org/: Rosetta@Home protein folding.&lt;br /&gt;
* https://foldingathome.org/: Folding@Home protein folding.&lt;br /&gt;
* https://einsteinathome.org/: Einstein@Home physics simulation.&lt;br /&gt;
* https://lhcathome.cern.ch/lhcathome/: LHC@Home Large Hadron Collider simulation.&lt;br /&gt;
* https://eternagame.org/: A game that contributes to protein simulation as you play.&lt;br /&gt;
* https://www.zooniverse.org/: A lot of projects that allow people to actively participate in science.&lt;br /&gt;
* https://www.zooniverse.org/projects/zookeeper/galaxy-zoo: Help classify galaxies by examining telescope photos.&lt;br /&gt;
* https://www.zooniverse.org/projects/ianc2/exoplanet-explorers/: Help identify exoplanets.&lt;br /&gt;
&lt;br /&gt;
== News and Information ==&lt;br /&gt;
&lt;br /&gt;
* http://darksky.net/: Really nice weather report&lt;br /&gt;
* http://www.weathertab.com/: Long range weather forecast (1 year)&lt;br /&gt;
* http://www.ustream.tv/nasahdtv: NASA live stream&lt;br /&gt;
* http://everytimezone.com/: Visual chart of timezones&lt;br /&gt;
* http://www.spacerogue.net: Hacker/tech news&lt;br /&gt;
* http://www.freeinfosociety.com: Tons of free information&lt;br /&gt;
&lt;br /&gt;
== Educational ==&lt;br /&gt;
&lt;br /&gt;
* http://interactmath.com/: Free interactive math tutorials&lt;br /&gt;
* http://www.ptable.com/: Interactive periodic table&lt;br /&gt;
* http://ascendmath.com/fcm/html5/: Simple math flash cards&lt;br /&gt;
* https://www.desmos.com/calculator: Graphing calculator&lt;br /&gt;
* https://www.khanacademy.org: Free online academy (math, physics, chemistry, etc.)&lt;br /&gt;
* http://galaxyzoo.org: Volunteer to categorize galaxies&lt;br /&gt;
* http://www.planethunters.org: Volunteer to help identify exoplanets&lt;br /&gt;
* https://op-webtools.web.cern.ch/vistar/vistars.php: Large Hadron Collider monitor (LHC)&lt;br /&gt;
* http://ispy-webgl.web.cern.ch/ispy-webgl/: CMS Data Visualization&lt;br /&gt;
* https://www.aviso.altimetry.fr/en/data.html: Oceanic and Altimetric database&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
&lt;br /&gt;
=== Guacamole VNC Server ===&lt;br /&gt;
&lt;br /&gt;
* http://guac-dev.org/doc/gug/&lt;br /&gt;
* https://gist.github.com/jeffersonmartin/8236574: Version 0.8.3 for Ubuntu Server&lt;br /&gt;
* http://www.linuxintro.org/wiki/Guacamole&lt;br /&gt;
* https://deviantengineer.com/2013/10/guacamole/&lt;br /&gt;
&lt;br /&gt;
=== Ampache Streaming Media Server ===&lt;br /&gt;
&lt;br /&gt;
* https://github.com/ampache/ampache/wiki/Installation&lt;br /&gt;
&lt;br /&gt;
== Files and Software ==&lt;br /&gt;
&lt;br /&gt;
* https://archive.org/: THE INTERNET ARCHIVE&lt;br /&gt;
* https://librivox.org/: Free audio books&lt;br /&gt;
* http://www.freeimages.com: Royalty-free/creative common images&lt;br /&gt;
* http://www.freewebtemplates.com/: Free web templates&lt;br /&gt;
* https://www.softaculous.com/apps/: Nice list of software&lt;br /&gt;
* https://www.draw.io/: Free web-based network diagram/flowchart designer (like Visio).&lt;br /&gt;
* http://www.emachineshop.com/machine-shop/Free-CAD-Design-Software/page100.html: Freee CAD software (also good for making gears).&lt;br /&gt;
* https://easyeda.com: Free circuit diagram software online&lt;br /&gt;
* https://www.circuitlab.com/editor/: Very simple free circuit diagram software online (can't save to file)&lt;br /&gt;
* ftp://ftp.ncbi.nih.gov/genomes/: National Institute of Health genome archives&lt;br /&gt;
* http://redobackup.org/: Bootable backup utility.&lt;br /&gt;
* https://www.sites.google.com/site/unoardusim/services: Arduino Uno simulator.&lt;br /&gt;
&lt;br /&gt;
=== Service Manuals ===&lt;br /&gt;
&lt;br /&gt;
* https://freeservicemanuals.info&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
* https://thepihut.com/: Raspberry Pi stuff&lt;br /&gt;
* https://www.newark.com/?COM=element14_store_Home: Electronics&lt;br /&gt;
* https://www.adafruit.com/: Electronics&lt;br /&gt;
&lt;br /&gt;
== Materials ==&lt;br /&gt;
&lt;br /&gt;
* http://www.tapplastics.com/: Custom plastics&lt;br /&gt;
&lt;br /&gt;
== Art Tools ==&lt;br /&gt;
&lt;br /&gt;
* http://www.text-image.com/convert/ascii.html: Image to ASCII art converter&lt;br /&gt;
* http://www.wordle.net/: word-cloud generator&lt;br /&gt;
* http://www.patorjk.com/software/taag/: text to ASCII art generator&lt;br /&gt;
* http://www.flamingtext.com/: Logo designer&lt;br /&gt;
&lt;br /&gt;
== Audio Tools ==&lt;br /&gt;
&lt;br /&gt;
* http://imtranslator.net/translation/text-to-speech/: text to speech&lt;br /&gt;
&lt;br /&gt;
== Document Tools ==&lt;br /&gt;
&lt;br /&gt;
* http://www.free-ocr.com/: Optical Character Recognition (OCR); finds text in an image&lt;br /&gt;
* http://www.myfonts.com/WhatTheFont/: Font identifier&lt;br /&gt;
&lt;br /&gt;
== Space and Earth ==&lt;br /&gt;
&lt;br /&gt;
* https://www.jasondavies.com/maps/transition/: interactive world map projections.&lt;br /&gt;
* https://worldview.earthdata.nasa.gov/: NASA Worldview.&lt;br /&gt;
* https://sdo.gsfc.nasa.gov/data/: NASA Solar Dynamics Observatory (SDO).&lt;br /&gt;
* https://helioviewer.org/: Interactive up-to-date view of the Sun.&lt;br /&gt;
* http://lmsal.com/isolsearch: Another interactive map of the Sun and solar activity.&lt;br /&gt;
* https://www.jwst.nasa.gov/webcam.html: Goddard Space Center clean-room  webcams.&lt;br /&gt;
* https://science.ksc.nasa.gov/shuttle/countdown/video/: Kennedy Space Center webcams.&lt;br /&gt;
* http://www.isstracker.com/embed: International Space Station Tracker.&lt;br /&gt;
* https://spotthestation.nasa.gov/widget/: Spot The Station widget.&lt;br /&gt;
* http://www.ustream.tv/embed/6540154?html5ui: NASA Public-Education channel.&lt;br /&gt;
* http://www.ustream.tv/embed/10414700?html5ui: NASA TV Media.&lt;br /&gt;
* http://www.ustream.tv/embed/17074538?v=3&amp;amp;wmode=direct;autoplay=1: ISS Livestream 1&lt;br /&gt;
* http://www.ustream.tv/embed/9408562?v=3&amp;amp;wmode=direct;autoplay=1: ISS Livestream 2&lt;br /&gt;
&lt;br /&gt;
== Privacy and Anti-Advertising ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scam Alerts&amp;lt;/b&amp;gt;&lt;br /&gt;
* https://www.consumer.ftc.gov/scam-alerts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Government Sites About Spam, Fraud, etc.&amp;lt;/b&amp;gt;&lt;br /&gt;
* https://attorneygeneral.nd.gov/consumer-resources/identity-theft/preventing-identity-theft&lt;br /&gt;
* https://www.consumer.ftc.gov/articles/0038-spam&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Opt-Out Registries&amp;lt;/b&amp;gt;&lt;br /&gt;
* https://www.donotcall.gov/&lt;br /&gt;
* https://www.optoutprescreen.com&lt;br /&gt;
* https://dmachoice.thedma.org/&lt;br /&gt;
* http://www.directmail.com/mail_preference/&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Privacy/Ad-blocker Tools&amp;lt;/b&amp;gt;&lt;br /&gt;
* https://ublock.org/: Browser plugin&lt;br /&gt;
* https://adblockplus.org/: Browser plugin&lt;br /&gt;
* https://pi-hole.net/: Network level ad-blocker (DNS-based)&lt;br /&gt;
* https://freek.ws/public-pi-hole/: Public hosted PiHole DNS Servers&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;VPN Services:&amp;lt;/b&amp;gt;&lt;br /&gt;
* https://www.expressvpn.com/: This company has the highest merits by my reckoning. Authorities have asked for logs and they were unable to provide it, which demonstrates that they are honest about their no-log policy. Off-shore jurisdiction: British Virgin Islands. Also, they have less usage restrictions than other VPN providers.&lt;br /&gt;
&lt;br /&gt;
== Other Nifty Stuff ==&lt;br /&gt;
&lt;br /&gt;
* https://maroslaw.github.io/rainyday.js/demo012_1.html: Rainy window animation (press F11 to full-screen).&lt;br /&gt;
* http://www.beepbox.co/: 8-bit music synthesizer.&lt;br /&gt;
* http://www.eviloverlord.com/lists/overlord.html: A funny list of axioms for being a successful evil overlord.&lt;br /&gt;
* http://www.petittube.com/: Automatically plays random YouTube videos that have zero views, so you are literally the first viewer.&lt;br /&gt;
* http://www.virtualcolossus.co.uk/: Functional simulation of a Colossus Mk II.&lt;br /&gt;
* https://ban.ai/multics/: Virtual Multics Operating System&lt;br /&gt;
* http://asciicker.com/x13/: Incredible 3D ASCII based game (the &amp;quot;x13&amp;quot; is the version, use lower numbers to see older versions)&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=Arduino&amp;diff=3673</id>
		<title>Arduino</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=Arduino&amp;diff=3673"/>
				<updated>2020-09-08T22:31:09Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== Hall Effect Sensor (simple setup) ==&lt;br /&gt;
&lt;br /&gt;
[[File:He_sensor_diagram.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Audio Shield ==&lt;br /&gt;
&lt;br /&gt;
[[Arduino Audio Shield 01]]: using the Adafruit Wave Shield.&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=Arduino&amp;diff=3672</id>
		<title>Arduino</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=Arduino&amp;diff=3672"/>
				<updated>2020-09-08T22:30:47Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Hall Effect Sensor (simple setup) ==&lt;br /&gt;
&lt;br /&gt;
[[File:He_sensor_diagram.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Audio Shield ==&lt;br /&gt;
&lt;br /&gt;
[[Arduino Audio Shield 01]]: using the Adafruit Wave Shield.&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=Projects&amp;diff=3671</id>
		<title>Projects</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=Projects&amp;diff=3671"/>
				<updated>2020-09-08T22:29:20Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Electrical */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Computing, Programming, and Networking ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;&lt;br /&gt;
* [[Custom Router]]&lt;br /&gt;
* [[Climate Control System]]&lt;br /&gt;
* [[Miniand Hackberry A10]]&lt;br /&gt;
* [[Game Boy Zero]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
* [[Camera Security System]] (incomplete)&lt;br /&gt;
* [[Volunteer Computing]] (incomplete)&lt;br /&gt;
* [[Backup NAS Mini]] (incomplete)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Electrical ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;&lt;br /&gt;
* [[Electromagnet 01]]&lt;br /&gt;
* [[Electromagnet 02]]&lt;br /&gt;
* [[Electromagnet Hard Drive Erasure]]&lt;br /&gt;
* [[Magnetic Viewing Film Under Microscope]]&lt;br /&gt;
* [[Spot Welder]]&lt;br /&gt;
* [[High Voltage SMores|High Voltage S'Mores]]&lt;br /&gt;
* [[Gameboy Power Supply]]&lt;br /&gt;
* [[PCB Light-Up Skull]]&lt;br /&gt;
* [[RGB LEDs]]&lt;br /&gt;
* [[Atari Punk Console]]&lt;br /&gt;
* [[Variable Power Supply/Battery Charger]]&lt;br /&gt;
* [[Alpha Radiation Detector]]&lt;br /&gt;
* [[TCL HDTV Repair]]&lt;br /&gt;
* [[Arduino Audio Shield 01]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
* [[Tesla Coil]] (incomplete)&lt;br /&gt;
* [[Geiger Counter Sound Mod]] (incomplete)&lt;br /&gt;
* [[Geiger Counter Sound Mod]] (incomplete)&lt;br /&gt;
* [[DIY Geiger Counter]] (incomplete)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 3D Printing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;&lt;br /&gt;
* [https://www.thingiverse.com/The_BeardBot/designs All My 3D Models on Thingiverse]&lt;br /&gt;
* [[Phone Mount]]&lt;br /&gt;
* [[CTC Upgrade 01]]&lt;br /&gt;
* [[CTC Upgrade 02]]&lt;br /&gt;
* [[Audio Jack Reinforcement]]&lt;br /&gt;
&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Chemistry &amp;amp; Biology ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;&lt;br /&gt;
* [[Tin Crystals from Tin(II) Chloride]]&lt;br /&gt;
* [[Recovering and Casting Indium]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
* [[Germicidal UV Lamp &amp;amp; Bacterial Incubator]] (incomplete)&lt;br /&gt;
* [[Guide to Collecting the Elements]] (incomplete)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous Projects ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;For small, miscellaneous projects and other things, see my [[Old Blog]].&amp;lt;/big&amp;gt;&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=Arduino_Audio_Shield_01&amp;diff=3669</id>
		<title>Arduino Audio Shield 01</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=Arduino_Audio_Shield_01&amp;diff=3669"/>
				<updated>2020-09-08T22:28:43Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: Beard moved page Arduino Wave Shield 01 to Arduino Audio Shield 01&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I bought the Adafruit Wave Shield and thought it would be a funny first project to have an entrance theme play every time I get home from work. I created a compilation of audio clips from the TV show Seinfeld and made them play at random when my front door opens.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;iframe width=&amp;quot;560&amp;quot; height=&amp;quot;315&amp;quot; src=&amp;quot;https://youtube.com/embed/pdIsm2yy6xs&amp;quot; frameborder=&amp;quot;0&amp;quot; allowfullscreen&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
* Adafruit Wave Shield v1.1 ([https://www.adafruit.com/product/94 source])&lt;br /&gt;
* Arduino Uno R3 ([https://store.arduino.cc/usa/arduino-uno-rev3 source])&lt;br /&gt;
* AUX speaker adapter (dollar store)&lt;br /&gt;
* Cheap door alarm (dollar store)&lt;br /&gt;
* SD Card&lt;br /&gt;
* USB power adapter&lt;br /&gt;
* Cat-5 cable&lt;br /&gt;
&lt;br /&gt;
== File Downloads ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;nice&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;Filename&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;Description&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;Size&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;Modified&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;Link&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td name=&amp;quot;file&amp;quot;&amp;gt;&lt;br /&gt;
arduino_wave1.zip&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td name=&amp;quot;desc&amp;quot;&amp;gt;Arduino code including WaveHC library.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td name=&amp;quot;size&amp;quot;&amp;gt;31KB&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td name=&amp;quot;modf&amp;quot;&amp;gt;12/29/2018&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td name=&amp;quot;link&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&amp;lt;a href=&amp;quot;https://beardedmaker.com/wiki/images/files/waveshield01/arduino_wave1.zip&amp;quot;&amp;gt;&lt;br /&gt;
Download&lt;br /&gt;
&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td name=&amp;quot;file&amp;quot;&amp;gt;&lt;br /&gt;
seinfeld_audio.zip&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td name=&amp;quot;desc&amp;quot;&amp;gt;Audio clips used in this project.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td name=&amp;quot;size&amp;quot;&amp;gt;7.9MB&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td name=&amp;quot;modf&amp;quot;&amp;gt;12/29/2018&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td name=&amp;quot;link&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&amp;lt;a href=&amp;quot;https://beardedmaker.com/wiki/images/files/waveshield01/seinfeld_audio.zip&amp;quot;&amp;gt;&lt;br /&gt;
Download&lt;br /&gt;
&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
&lt;br /&gt;
The files need to be in WAV format (16 bit/sample, 22050 Hz sample rate).&lt;br /&gt;
&lt;br /&gt;
The SD car needs to be formatted with a FAT32 file system.&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* Wave Shield Assembly Instructions ([https://learn.adafruit.com/adafruit-wave-shield-audio-shield-for-arduino/solder link])&lt;br /&gt;
&lt;br /&gt;
== Gallery ==&lt;br /&gt;
&lt;br /&gt;
[[File:DSC00580.JPG|frameless|400px]]&lt;br /&gt;
[[File:DSC00581.JPG|frameless|400px]]&lt;br /&gt;
[[File:DSC00582.JPG|frameless|400px]]&lt;br /&gt;
[[File:DSC00583.JPG|frameless|400px]]&lt;br /&gt;
[[File:DSC00584.JPG|frameless|400px]]&lt;br /&gt;
[[File:DSC00585.JPG|frameless|400px]]&lt;br /&gt;
[[File:DSC00586.JPG|frameless|400px]]&lt;br /&gt;
[[File:DSC00587.JPG|frameless|400px]]&lt;br /&gt;
[[File:DSC00588.JPG|frameless|400px]]&lt;br /&gt;
[[File:DSC00589.JPG|frameless|400px]]&lt;br /&gt;
[[File:DSC00590.JPG|frameless|400px]]&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
Here is the Arduino code. Requires the WaveHC library.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;WaveUtil.h&amp;quot;&lt;br /&gt;
#include &amp;quot;WaveHC.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
// Pin that triggers audio&lt;br /&gt;
int inpin = 13;&lt;br /&gt;
&lt;br /&gt;
// Delay before audio plays after trigger&lt;br /&gt;
int playDelay = 1500;&lt;br /&gt;
&lt;br /&gt;
SdReader card;&lt;br /&gt;
FatVolume vol;&lt;br /&gt;
FatReader root;&lt;br /&gt;
WaveHC wave;&lt;br /&gt;
uint8_t dirLevel;&lt;br /&gt;
dir_t dirBuf;&lt;br /&gt;
int btnState = 0;&lt;br /&gt;
int fileCount = 0;&lt;br /&gt;
bool reset = false;&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Serial.begin(9600);&lt;br /&gt;
  Serial.println(&amp;quot;\nStart&amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
  // Set the output pins for the DAC control&lt;br /&gt;
  // This pins are defined in the library&lt;br /&gt;
  pinMode(2, OUTPUT);&lt;br /&gt;
  pinMode(3, OUTPUT);&lt;br /&gt;
  pinMode(4, OUTPUT);&lt;br /&gt;
  pinMode(5, OUTPUT);&lt;br /&gt;
 &lt;br /&gt;
  pinMode(inpin, INPUT);&lt;br /&gt;
  &lt;br /&gt;
  if (!card.init())&lt;br /&gt;
  {&lt;br /&gt;
    Serial.println(&amp;quot;Card init. failed!&amp;quot;);&lt;br /&gt;
    while(1); // Halt&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  // Enable optimize read&lt;br /&gt;
  // Some cards may timeout. Disable if you're having problems&lt;br /&gt;
  card.partialBlockRead(true);&lt;br /&gt;
  &lt;br /&gt;
  // Look for a FAT partition&lt;br /&gt;
  uint8_t part;&lt;br /&gt;
  for (part = 0; part &amp;lt; 5; part++)&lt;br /&gt;
  {&lt;br /&gt;
    if (vol.init(card, part))&lt;br /&gt;
    { &lt;br /&gt;
      break;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  if (part == 5)&lt;br /&gt;
  {&lt;br /&gt;
    Serial.println(&amp;quot;No valid FAT partition!&amp;quot;);&lt;br /&gt;
    while(1); // Halt&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  Serial.print(&amp;quot;Using partition &amp;quot;);&lt;br /&gt;
  Serial.print(part, DEC);&lt;br /&gt;
  Serial.print(&amp;quot;, type is FAT&amp;quot;);&lt;br /&gt;
  Serial.println(vol.fatType(),DEC);&lt;br /&gt;
  &lt;br /&gt;
  // Try to open the root directory&lt;br /&gt;
  if (!root.openRoot(vol))&lt;br /&gt;
  {&lt;br /&gt;
    Serial.println(&amp;quot;Can't open root dir!&amp;quot;);&lt;br /&gt;
    while(1); // Halt&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  // Print the file names&lt;br /&gt;
  Serial.println(&amp;quot;Files found:&amp;quot;);&lt;br /&gt;
  dirLevel = 0;&lt;br /&gt;
  lsR(root);&lt;br /&gt;
&lt;br /&gt;
  // Seed the random number generator by reading an analog pin&lt;br /&gt;
  randomSeed(analogRead(A0));&lt;br /&gt;
&lt;br /&gt;
  // Count the number of files&lt;br /&gt;
  root.rewind();&lt;br /&gt;
  fileCount = countFiles(root);&lt;br /&gt;
  Serial.print(&amp;quot;File count: &amp;quot;);&lt;br /&gt;
  Serial.println(fileCount);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
  btnState = digitalRead(inpin);&lt;br /&gt;
  if (btnState == HIGH)&lt;br /&gt;
  {&lt;br /&gt;
    Serial.println(&amp;quot;Door Closed; wait&amp;quot;);&lt;br /&gt;
    reset = true;&lt;br /&gt;
    delay(200);&lt;br /&gt;
&lt;br /&gt;
    while (reset == true)&lt;br /&gt;
    {&lt;br /&gt;
      btnState = digitalRead(inpin);&lt;br /&gt;
      if (btnState == LOW)&lt;br /&gt;
      {&lt;br /&gt;
         Serial.println(&amp;quot;Door Open; play and wait&amp;quot;);&lt;br /&gt;
         delay(playDelay);&lt;br /&gt;
         root.rewind();&lt;br /&gt;
         playRandom(root, fileCount);&lt;br /&gt;
         Serial.println();&lt;br /&gt;
         reset = false;&lt;br /&gt;
         delay(500);&lt;br /&gt;
         break;&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        continue;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * Play a random file&lt;br /&gt;
 */&lt;br /&gt;
void playRandom(FatReader &amp;amp;dir, int fileCount)&lt;br /&gt;
{&lt;br /&gt;
  FatReader file;&lt;br /&gt;
  &lt;br /&gt;
  int playFile = random(1, fileCount);&lt;br /&gt;
  int fileIter = 1;&lt;br /&gt;
&lt;br /&gt;
  // Read every file in the directory one at a time&lt;br /&gt;
  while (dir.readDir(dirBuf) &amp;gt; 0)&lt;br /&gt;
  {&lt;br /&gt;
    // skip . and .. directories&lt;br /&gt;
    if (dirBuf.name[0] == '.')&lt;br /&gt;
    { &lt;br /&gt;
      continue;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    if (fileIter &amp;lt; playFile)&lt;br /&gt;
    {&lt;br /&gt;
      fileIter++;&lt;br /&gt;
      continue;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    if (!file.open(vol, dirBuf))&lt;br /&gt;
    {&lt;br /&gt;
      Serial.println(&amp;quot;file.open failed&amp;quot;);&lt;br /&gt;
      while(1); // Halt&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Serial.print(&amp;quot;Playing &amp;quot;);&lt;br /&gt;
    printEntryName(dirBuf);&lt;br /&gt;
    if (!wave.create(file))&lt;br /&gt;
    {&lt;br /&gt;
      Serial.print(&amp;quot; Not a valid WAV&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      // playing occurs in interrupts&lt;br /&gt;
      wave.play();&lt;br /&gt;
&lt;br /&gt;
      while (wave.isplaying)&lt;br /&gt;
      {&lt;br /&gt;
        putstring(&amp;quot;.&amp;quot;);&lt;br /&gt;
        delay(100);&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      if (wave.errors)&lt;br /&gt;
      {&lt;br /&gt;
        Serial.println(wave.errors);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    break;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * Count files on the SD card&lt;br /&gt;
 */&lt;br /&gt;
int countFiles(FatReader &amp;amp;dir)&lt;br /&gt;
{&lt;br /&gt;
  int fileCount = 0;&lt;br /&gt;
  FatReader file;&lt;br /&gt;
  while (dir.readDir(dirBuf) &amp;gt; 0)&lt;br /&gt;
  {&lt;br /&gt;
    if (dirBuf.name[0] == '.' || !file.open(vol, dirBuf))&lt;br /&gt;
    {&lt;br /&gt;
      continue;&lt;br /&gt;
    }                                 &lt;br /&gt;
    fileCount++;&lt;br /&gt;
  }&lt;br /&gt;
  return fileCount;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * List files recursively&lt;br /&gt;
 */&lt;br /&gt;
void lsR(FatReader &amp;amp;d)&lt;br /&gt;
{&lt;br /&gt;
  // indicates the level of recursion&lt;br /&gt;
  int8_t r;&lt;br /&gt;
  &lt;br /&gt;
  while ((r = d.readDir(dirBuf)) &amp;gt; 0)&lt;br /&gt;
  {&lt;br /&gt;
    // skip subdirs . and ..&lt;br /&gt;
    if (dirBuf.name[0] == '.')&lt;br /&gt;
    {&lt;br /&gt;
      continue;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    for (uint8_t i = 0; i &amp;lt; dirLevel; i++)&lt;br /&gt;
    {&lt;br /&gt;
      Serial.print(' ');&lt;br /&gt;
    }&lt;br /&gt;
     &lt;br /&gt;
    printEntryName(dirBuf);&lt;br /&gt;
    Serial.println();&lt;br /&gt;
&lt;br /&gt;
    // Recurse on any direcory&lt;br /&gt;
    if (DIR_IS_SUBDIR(dirBuf))&lt;br /&gt;
    {&lt;br /&gt;
      FatReader s;&lt;br /&gt;
      dirLevel += 2;&lt;br /&gt;
      if (s.open(vol, dirBuf))&lt;br /&gt;
      {&lt;br /&gt;
        lsR(s);&lt;br /&gt;
      }&lt;br /&gt;
      dirLevel -=2;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=Arduino_Wave_Shield_01&amp;diff=3670</id>
		<title>Arduino Wave Shield 01</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=Arduino_Wave_Shield_01&amp;diff=3670"/>
				<updated>2020-09-08T22:28:43Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: Beard moved page Arduino Wave Shield 01 to Arduino Audio Shield 01&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Arduino Audio Shield 01]]&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3668</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3668"/>
				<updated>2020-08-31T18:44:16Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Line Input Sensitivity */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
Will be adding notes here soon.&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using your package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following sections, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial to USB adapter, you can run the following command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/usbserial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should see the following output:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
usbserinfo:1.0 driver:2.0&lt;br /&gt;
0: module:ch341 name:&amp;quot;ch341-uart&amp;quot; vendor:1a86 product:7523 num_ports:1 port:0 path:usb-0000:00:1d.0-1.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the second line, the number N on the far left corresponds to &amp;lt;code&amp;gt;/dev/ttyUSBN&amp;lt;/code&amp;gt;. Mine shows &amp;lt;code&amp;gt;0:&amp;lt;/code&amp;gt; so I would use &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;. When you unplug the cable and plug it back in there's a chance that the number will change. I've also seen the number change when starting and stopping apcupsd, but I'm not sure of the cause.&lt;br /&gt;
&lt;br /&gt;
Another way you can do it, because USB serial devices only show up in /dev when they are connected, is to see which files appear when you plug in your device. Leave the cable &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;unplugged&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt; from your computer, then run the command below. It will print a newline and pause. While it's paused plug in the cable then press Enter:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
diff &amp;lt;(ls /dev) &amp;lt;(read;ls /dev)|grep &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; serial&lt;br /&gt;
&amp;gt; ttyUSB0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I found that &amp;lt;code&amp;gt;/dev/serial&amp;lt;/code&amp;gt; did not work, so I used &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank or say COMMLOST. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the software runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Hard Reset =&lt;br /&gt;
&lt;br /&gt;
This is the process to perform a hard reset (a.k.a. &amp;quot;brain dead&amp;quot;, hard reboot, discharge cycle). You may want to try this process when troubleshooting a UPS that is acting strangely. It sometimes solves the issue.&lt;br /&gt;
&lt;br /&gt;
# Turn the UPS off using the power button.&lt;br /&gt;
# Unplug everything from the UPS (including any serial, USB, or network cables).&lt;br /&gt;
# Unplug the UPS from the wall outlet.&lt;br /&gt;
# Disconnect the batteries.&lt;br /&gt;
# Press and hold the power button for at least 5 seconds.&lt;br /&gt;
# Reconnect the batteries.&lt;br /&gt;
# Plug the UPS into the wall outlet.&lt;br /&gt;
# Turn on the UPS.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (for high), &amp;quot;M&amp;quot; (for medium), or &amp;quot;L&amp;quot; (for low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section. If you don't have a 4-battery harness, you may want to check out my [[#3D_Printed_Parts|3D Printed Parts]].&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;3D_Printed_Parts&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3667</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3667"/>
				<updated>2020-08-31T18:43:36Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Line Input Sensitivity */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
Will be adding notes here soon.&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using your package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following sections, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial to USB adapter, you can run the following command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/usbserial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should see the following output:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
usbserinfo:1.0 driver:2.0&lt;br /&gt;
0: module:ch341 name:&amp;quot;ch341-uart&amp;quot; vendor:1a86 product:7523 num_ports:1 port:0 path:usb-0000:00:1d.0-1.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the second line, the number N on the far left corresponds to &amp;lt;code&amp;gt;/dev/ttyUSBN&amp;lt;/code&amp;gt;. Mine shows &amp;lt;code&amp;gt;0:&amp;lt;/code&amp;gt; so I would use &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;. When you unplug the cable and plug it back in there's a chance that the number will change. I've also seen the number change when starting and stopping apcupsd, but I'm not sure of the cause.&lt;br /&gt;
&lt;br /&gt;
Another way you can do it, because USB serial devices only show up in /dev when they are connected, is to see which files appear when you plug in your device. Leave the cable &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;unplugged&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt; from your computer, then run the command below. It will print a newline and pause. While it's paused plug in the cable then press Enter:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
diff &amp;lt;(ls /dev) &amp;lt;(read;ls /dev)|grep &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; serial&lt;br /&gt;
&amp;gt; ttyUSB0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I found that &amp;lt;code&amp;gt;/dev/serial&amp;lt;/code&amp;gt; did not work, so I used &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank or say COMMLOST. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the software runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Hard Reset =&lt;br /&gt;
&lt;br /&gt;
This is the process to perform a hard reset (a.k.a. &amp;quot;brain dead&amp;quot;, hard reboot, discharge cycle). You may want to try this process when troubleshooting a UPS that is acting strangely. It sometimes solves the issue.&lt;br /&gt;
&lt;br /&gt;
# Turn the UPS off using the power button.&lt;br /&gt;
# Unplug everything from the UPS (including any serial, USB, or network cables).&lt;br /&gt;
# Unplug the UPS from the wall outlet.&lt;br /&gt;
# Disconnect the batteries.&lt;br /&gt;
# Press and hold the power button for at least 5 seconds.&lt;br /&gt;
# Reconnect the batteries.&lt;br /&gt;
# Plug the UPS into the wall outlet.&lt;br /&gt;
# Turn on the UPS.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section. If you don't have a 4-battery harness, you may want to check out my [[#3D_Printed_Parts|3D Printed Parts]].&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;3D_Printed_Parts&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3666</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3666"/>
				<updated>2020-08-31T18:42:28Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Hard Reset */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
Will be adding notes here soon.&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using your package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following sections, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial to USB adapter, you can run the following command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/usbserial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should see the following output:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
usbserinfo:1.0 driver:2.0&lt;br /&gt;
0: module:ch341 name:&amp;quot;ch341-uart&amp;quot; vendor:1a86 product:7523 num_ports:1 port:0 path:usb-0000:00:1d.0-1.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the second line, the number N on the far left corresponds to &amp;lt;code&amp;gt;/dev/ttyUSBN&amp;lt;/code&amp;gt;. Mine shows &amp;lt;code&amp;gt;0:&amp;lt;/code&amp;gt; so I would use &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;. When you unplug the cable and plug it back in there's a chance that the number will change. I've also seen the number change when starting and stopping apcupsd, but I'm not sure of the cause.&lt;br /&gt;
&lt;br /&gt;
Another way you can do it, because USB serial devices only show up in /dev when they are connected, is to see which files appear when you plug in your device. Leave the cable &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;unplugged&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt; from your computer, then run the command below. It will print a newline and pause. While it's paused plug in the cable then press Enter:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
diff &amp;lt;(ls /dev) &amp;lt;(read;ls /dev)|grep &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; serial&lt;br /&gt;
&amp;gt; ttyUSB0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I found that &amp;lt;code&amp;gt;/dev/serial&amp;lt;/code&amp;gt; did not work, so I used &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank or say COMMLOST. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the software runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Hard Reset =&lt;br /&gt;
&lt;br /&gt;
This is the process to perform a hard reset (a.k.a. &amp;quot;brain dead&amp;quot;, hard reboot, discharge cycle). You may want to try this process when troubleshooting a UPS that is acting strangely. It sometimes solves the issue.&lt;br /&gt;
&lt;br /&gt;
# Turn the UPS off using the power button.&lt;br /&gt;
# Unplug everything from the UPS (including any serial, USB, or network cables).&lt;br /&gt;
# Unplug the UPS from the wall outlet.&lt;br /&gt;
# Disconnect the batteries.&lt;br /&gt;
# Press and hold the power button for at least 5 seconds.&lt;br /&gt;
# Reconnect the batteries.&lt;br /&gt;
# Plug the UPS into the wall outlet.&lt;br /&gt;
# Turn on the UPS.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section. If you don't have a 4-battery harness, you may want to check out my [[#3D_Printed_Parts|3D Printed Parts]].&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;3D_Printed_Parts&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3665</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3665"/>
				<updated>2020-08-31T18:42:08Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Hard Reset */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
Will be adding notes here soon.&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using your package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following sections, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial to USB adapter, you can run the following command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/usbserial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should see the following output:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
usbserinfo:1.0 driver:2.0&lt;br /&gt;
0: module:ch341 name:&amp;quot;ch341-uart&amp;quot; vendor:1a86 product:7523 num_ports:1 port:0 path:usb-0000:00:1d.0-1.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the second line, the number N on the far left corresponds to &amp;lt;code&amp;gt;/dev/ttyUSBN&amp;lt;/code&amp;gt;. Mine shows &amp;lt;code&amp;gt;0:&amp;lt;/code&amp;gt; so I would use &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;. When you unplug the cable and plug it back in there's a chance that the number will change. I've also seen the number change when starting and stopping apcupsd, but I'm not sure of the cause.&lt;br /&gt;
&lt;br /&gt;
Another way you can do it, because USB serial devices only show up in /dev when they are connected, is to see which files appear when you plug in your device. Leave the cable &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;unplugged&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt; from your computer, then run the command below. It will print a newline and pause. While it's paused plug in the cable then press Enter:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
diff &amp;lt;(ls /dev) &amp;lt;(read;ls /dev)|grep &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; serial&lt;br /&gt;
&amp;gt; ttyUSB0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I found that &amp;lt;code&amp;gt;/dev/serial&amp;lt;/code&amp;gt; did not work, so I used &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank or say COMMLOST. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the software runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Hard Reset =&lt;br /&gt;
&lt;br /&gt;
This is the process to perform a hard reset (a.k.a. &amp;quot;brain dead&amp;quot;, hard reboot, discharge cycle). You may want to try this process when troubleshooting a UPS that is acting strangely. It sometimes solves the issue.&lt;br /&gt;
&lt;br /&gt;
# Turn the UPS off using the power button.&lt;br /&gt;
# Unplug everything from the UPS (including any serial, USB, or network cables).&lt;br /&gt;
# Unplug the UPS from the wall outlet.&lt;br /&gt;
# Disconnect the batteries.&lt;br /&gt;
# Press and hold the power button for at least 5 seconds.&lt;br /&gt;
# Reconnect the batteries.&lt;br /&gt;
# Plug the UPS into mains power.&lt;br /&gt;
# Turn on the UPS.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section. If you don't have a 4-battery harness, you may want to check out my [[#3D_Printed_Parts|3D Printed Parts]].&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;3D_Printed_Parts&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3664</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3664"/>
				<updated>2020-08-31T18:40:49Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /*  Manual Runtime Calibration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
Will be adding notes here soon.&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using your package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following sections, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial to USB adapter, you can run the following command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/usbserial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should see the following output:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
usbserinfo:1.0 driver:2.0&lt;br /&gt;
0: module:ch341 name:&amp;quot;ch341-uart&amp;quot; vendor:1a86 product:7523 num_ports:1 port:0 path:usb-0000:00:1d.0-1.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the second line, the number N on the far left corresponds to &amp;lt;code&amp;gt;/dev/ttyUSBN&amp;lt;/code&amp;gt;. Mine shows &amp;lt;code&amp;gt;0:&amp;lt;/code&amp;gt; so I would use &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;. When you unplug the cable and plug it back in there's a chance that the number will change. I've also seen the number change when starting and stopping apcupsd, but I'm not sure of the cause.&lt;br /&gt;
&lt;br /&gt;
Another way you can do it, because USB serial devices only show up in /dev when they are connected, is to see which files appear when you plug in your device. Leave the cable &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;unplugged&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt; from your computer, then run the command below. It will print a newline and pause. While it's paused plug in the cable then press Enter:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
diff &amp;lt;(ls /dev) &amp;lt;(read;ls /dev)|grep &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; serial&lt;br /&gt;
&amp;gt; ttyUSB0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I found that &amp;lt;code&amp;gt;/dev/serial&amp;lt;/code&amp;gt; did not work, so I used &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank or say COMMLOST. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the software runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Hard Reset =&lt;br /&gt;
&lt;br /&gt;
This is the process to perform a hard reset (a.k.a. &amp;quot;brain dead&amp;quot;, hard reboot, discharge cycle). You may want to try this process when troubleshooting a UPS that is acting strangely. It sometimes solves the issue.&lt;br /&gt;
&lt;br /&gt;
# Turn the UPS off using the power button.&lt;br /&gt;
# Unplug everything from the UPS (including any serial, USB, or network cables).&lt;br /&gt;
# Unplug the UPS from mains power.&lt;br /&gt;
# Disconnect the batteries.&lt;br /&gt;
# Press and hold the power button for at least 5 seconds.&lt;br /&gt;
# Reconnect the batteries.&lt;br /&gt;
# Plug the UPS into mains power.&lt;br /&gt;
# Turn on the UPS.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section. If you don't have a 4-battery harness, you may want to check out my [[#3D_Printed_Parts|3D Printed Parts]].&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;3D_Printed_Parts&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3663</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3663"/>
				<updated>2020-08-31T18:36:42Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Finding Your Serial Port */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
Will be adding notes here soon.&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using your package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following sections, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial to USB adapter, you can run the following command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/usbserial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should see the following output:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
usbserinfo:1.0 driver:2.0&lt;br /&gt;
0: module:ch341 name:&amp;quot;ch341-uart&amp;quot; vendor:1a86 product:7523 num_ports:1 port:0 path:usb-0000:00:1d.0-1.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the second line, the number N on the far left corresponds to &amp;lt;code&amp;gt;/dev/ttyUSBN&amp;lt;/code&amp;gt;. Mine shows &amp;lt;code&amp;gt;0:&amp;lt;/code&amp;gt; so I would use &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;. When you unplug the cable and plug it back in there's a chance that the number will change. I've also seen the number change when starting and stopping apcupsd, but I'm not sure of the cause.&lt;br /&gt;
&lt;br /&gt;
Another way you can do it, because USB serial devices only show up in /dev when they are connected, is to see which files appear when you plug in your device. Leave the cable &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;unplugged&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt; from your computer, then run the command below. It will print a newline and pause. While it's paused plug in the cable then press Enter:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
diff &amp;lt;(ls /dev) &amp;lt;(read;ls /dev)|grep &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; serial&lt;br /&gt;
&amp;gt; ttyUSB0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I found that &amp;lt;code&amp;gt;/dev/serial&amp;lt;/code&amp;gt; did not work, so I used &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank or say COMMLOST. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Hard Reset =&lt;br /&gt;
&lt;br /&gt;
This is the process to perform a hard reset (a.k.a. &amp;quot;brain dead&amp;quot;, hard reboot, discharge cycle). You may want to try this process when troubleshooting a UPS that is acting strangely. It sometimes solves the issue.&lt;br /&gt;
&lt;br /&gt;
# Turn the UPS off using the power button.&lt;br /&gt;
# Unplug everything from the UPS (including any serial, USB, or network cables).&lt;br /&gt;
# Unplug the UPS from mains power.&lt;br /&gt;
# Disconnect the batteries.&lt;br /&gt;
# Press and hold the power button for at least 5 seconds.&lt;br /&gt;
# Reconnect the batteries.&lt;br /&gt;
# Plug the UPS into mains power.&lt;br /&gt;
# Turn on the UPS.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section. If you don't have a 4-battery harness, you may want to check out my [[#3D_Printed_Parts|3D Printed Parts]].&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;3D_Printed_Parts&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3662</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3662"/>
				<updated>2020-08-31T18:35:53Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Finding Your Serial Port */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
Will be adding notes here soon.&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using your package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following sections, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial to USB adapter, you can run the following command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/usbserial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should see the following output:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
usbserinfo:1.0 driver:2.0&lt;br /&gt;
0: module:ch341 name:&amp;quot;ch341-uart&amp;quot; vendor:1a86 product:7523 num_ports:1 port:0 path:usb-0000:00:1d.0-1.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the second line, the number N on the far left corresponds to &amp;lt;code&amp;gt;/dev/ttyUSBN&amp;lt;/code&amp;gt;. Mine shows &amp;lt;code&amp;gt;0:&amp;lt;/code&amp;gt; so I would use &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;. When you unplug the cable and plug it back in there's a chance that the number will change. I've also seen the number change when starting and stopping apcupsd, but I'm not sure of the cause.&lt;br /&gt;
&lt;br /&gt;
Another way you can do it, because USB serial devices only show up in /dev when they are connected, is to see which files appear when you plug in your device. Leave the cable unplugged from your computer, then run the command below. It will print a newline and pause. While it's paused plug in the cable then press Enter:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
diff &amp;lt;(ls /dev) &amp;lt;(read;ls /dev)|grep &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; serial&lt;br /&gt;
&amp;gt; ttyUSB0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I found that &amp;lt;code&amp;gt;/dev/serial&amp;lt;/code&amp;gt; did not work, so I used &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank or say COMMLOST. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Hard Reset =&lt;br /&gt;
&lt;br /&gt;
This is the process to perform a hard reset (a.k.a. &amp;quot;brain dead&amp;quot;, hard reboot, discharge cycle). You may want to try this process when troubleshooting a UPS that is acting strangely. It sometimes solves the issue.&lt;br /&gt;
&lt;br /&gt;
# Turn the UPS off using the power button.&lt;br /&gt;
# Unplug everything from the UPS (including any serial, USB, or network cables).&lt;br /&gt;
# Unplug the UPS from mains power.&lt;br /&gt;
# Disconnect the batteries.&lt;br /&gt;
# Press and hold the power button for at least 5 seconds.&lt;br /&gt;
# Reconnect the batteries.&lt;br /&gt;
# Plug the UPS into mains power.&lt;br /&gt;
# Turn on the UPS.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section. If you don't have a 4-battery harness, you may want to check out my [[#3D_Printed_Parts|3D Printed Parts]].&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;3D_Printed_Parts&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3661</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3661"/>
				<updated>2020-08-31T18:35:12Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Finding Your Serial Port */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
Will be adding notes here soon.&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using your package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following sections, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial to USB adapter, you can run the following command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/usbserial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should see the following output:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
usbserinfo:1.0 driver:2.0&lt;br /&gt;
0: module:ch341 name:&amp;quot;ch341-uart&amp;quot; vendor:1a86 product:7523 num_ports:1 port:0 path:usb-0000:00:1d.0-1.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the second line, the number N on the far left corresponds to &amp;lt;code&amp;gt;/dev/ttyUSBN&amp;lt;/code&amp;gt;. Mine shows &amp;lt;code&amp;gt;0:&amp;lt;/code&amp;gt; so I would use &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;. When you unplug the cable and plug it back in there's a chance that the number will change. I've also seen the number change when starting and stopping apcupsd, but I'm not sure of the cause.&lt;br /&gt;
&lt;br /&gt;
Another way you can do it, because USB serial devices only show up in /dev when they are connected, is to see which files appear when you plug in you device. Leave the cable unplugged from your computer, then run the command below. It will print a newline and pause. While it's paused plug in the cable then press Enter:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
diff &amp;lt;(ls /dev) &amp;lt;(read;ls /dev)|grep &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; serial&lt;br /&gt;
&amp;gt; ttyUSB0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I found that &amp;lt;code&amp;gt;/dev/serial&amp;lt;/code&amp;gt; did not work, so I used &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank or say COMMLOST. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Hard Reset =&lt;br /&gt;
&lt;br /&gt;
This is the process to perform a hard reset (a.k.a. &amp;quot;brain dead&amp;quot;, hard reboot, discharge cycle). You may want to try this process when troubleshooting a UPS that is acting strangely. It sometimes solves the issue.&lt;br /&gt;
&lt;br /&gt;
# Turn the UPS off using the power button.&lt;br /&gt;
# Unplug everything from the UPS (including any serial, USB, or network cables).&lt;br /&gt;
# Unplug the UPS from mains power.&lt;br /&gt;
# Disconnect the batteries.&lt;br /&gt;
# Press and hold the power button for at least 5 seconds.&lt;br /&gt;
# Reconnect the batteries.&lt;br /&gt;
# Plug the UPS into mains power.&lt;br /&gt;
# Turn on the UPS.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section. If you don't have a 4-battery harness, you may want to check out my [[#3D_Printed_Parts|3D Printed Parts]].&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;3D_Printed_Parts&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3660</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3660"/>
				<updated>2020-08-31T18:33:50Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Finding Your Serial Port */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
Will be adding notes here soon.&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using your package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following sections, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial to USB adapter, you can run the following command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/usbserial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should see the following output:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
usbserinfo:1.0 driver:2.0&lt;br /&gt;
0: module:ch341 name:&amp;quot;ch341-uart&amp;quot; vendor:1a86 product:7523 num_ports:1 port:0 path:usb-0000:00:1d.0-1.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the second line, the number N on the far left corresponds to &amp;lt;code&amp;gt;/dev/ttyUSBN&amp;lt;/code&amp;gt;. Mine shows &amp;lt;code&amp;gt;0:&amp;lt;/code&amp;gt; so I would use &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;. When you unplug the cable and plug it back in there's a chance that the number will change.&lt;br /&gt;
&lt;br /&gt;
Another way you can do it, because USB serial devices only show up in /dev when they are connected, is to see which files appear when you plug in you device. Leave the cable unplugged from your computer, then run the command below. It will print a newline and pause. While it's paused plug in the cable then press Enter:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
diff &amp;lt;(ls /dev) &amp;lt;(read;ls /dev)|grep &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; serial&lt;br /&gt;
&amp;gt; ttyUSB0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I found that &amp;lt;code&amp;gt;/dev/serial&amp;lt;/code&amp;gt; did not work, so I used &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank or say COMMLOST. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Hard Reset =&lt;br /&gt;
&lt;br /&gt;
This is the process to perform a hard reset (a.k.a. &amp;quot;brain dead&amp;quot;, hard reboot, discharge cycle). You may want to try this process when troubleshooting a UPS that is acting strangely. It sometimes solves the issue.&lt;br /&gt;
&lt;br /&gt;
# Turn the UPS off using the power button.&lt;br /&gt;
# Unplug everything from the UPS (including any serial, USB, or network cables).&lt;br /&gt;
# Unplug the UPS from mains power.&lt;br /&gt;
# Disconnect the batteries.&lt;br /&gt;
# Press and hold the power button for at least 5 seconds.&lt;br /&gt;
# Reconnect the batteries.&lt;br /&gt;
# Plug the UPS into mains power.&lt;br /&gt;
# Turn on the UPS.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section. If you don't have a 4-battery harness, you may want to check out my [[#3D_Printed_Parts|3D Printed Parts]].&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;3D_Printed_Parts&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3659</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3659"/>
				<updated>2020-08-31T18:31:22Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Monitoring Using Apcupsd (Linux) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
Will be adding notes here soon.&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using your package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following sections, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial to USB adapter, you can run the following command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/usbserial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should look for the &amp;lt;code&amp;gt;port:&amp;lt;/code&amp;gt; in the following output:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
usbserinfo:1.0 driver:2.0&lt;br /&gt;
0: module:ch341 name:&amp;quot;ch341-uart&amp;quot; vendor:1a86 product:7523 num_ports:1 port:0 path:usb-0000:00:1d.0-1.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the second line, the number N at the very beginning of the line corresponds to &amp;lt;code&amp;gt;/dev/ttyUSBN&amp;lt;/code&amp;gt;. Mine shows &amp;lt;code&amp;gt;0:&amp;lt;/code&amp;gt; so I would use &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;. When you unplug the cable and plug it back in there's a chance that the number will change.&lt;br /&gt;
&lt;br /&gt;
Another way you can do it, because USB serial devices only show up in /dev when they are connected, is to see which files appear when you plug in you device. Leave the cable unplugged from your computer, then run the command below. It will print a newline and pause. While it's paused plug in the cable then press Enter:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
diff &amp;lt;(ls /dev) &amp;lt;(read;ls /dev)|grep &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; serial&lt;br /&gt;
&amp;gt; ttyUSB0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I found that &amp;lt;code&amp;gt;/dev/serial&amp;lt;/code&amp;gt; did not work, so I used &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank or say COMMLOST. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Hard Reset =&lt;br /&gt;
&lt;br /&gt;
This is the process to perform a hard reset (a.k.a. &amp;quot;brain dead&amp;quot;, hard reboot, discharge cycle). You may want to try this process when troubleshooting a UPS that is acting strangely. It sometimes solves the issue.&lt;br /&gt;
&lt;br /&gt;
# Turn the UPS off using the power button.&lt;br /&gt;
# Unplug everything from the UPS (including any serial, USB, or network cables).&lt;br /&gt;
# Unplug the UPS from mains power.&lt;br /&gt;
# Disconnect the batteries.&lt;br /&gt;
# Press and hold the power button for at least 5 seconds.&lt;br /&gt;
# Reconnect the batteries.&lt;br /&gt;
# Plug the UPS into mains power.&lt;br /&gt;
# Turn on the UPS.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section. If you don't have a 4-battery harness, you may want to check out my [[#3D_Printed_Parts|3D Printed Parts]].&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;3D_Printed_Parts&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=Working&amp;diff=3658</id>
		<title>Working</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=Working&amp;diff=3658"/>
				<updated>2020-08-31T18:29:44Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
Pages that I am currently working on.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Reminders:&amp;lt;/b&amp;gt;&lt;br /&gt;
* Search for notes in square brackets [] for things that need completion.&lt;br /&gt;
* Search for headers with no text under them.&lt;br /&gt;
* The &amp;lt;code&amp;gt;&amp;amp;lt;source&amp;amp;gt;&amp;lt;/code&amp;gt; tag is a synonym for &amp;lt;code&amp;gt;&amp;amp;lt;syntaxhighlight&amp;amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Add line numbers like this: &amp;lt;code&amp;gt;&amp;amp;lt;source lang=&amp;quot;shell&amp;quot; line&amp;amp;gt;echo &amp;quot;hi&amp;quot;&amp;amp;lt;/source&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Mediawiki|Mediawiki Tutorials]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Licenses:&amp;lt;/b&amp;gt;&lt;br /&gt;
* GNU GPL 2.0 ([https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt external], [https://beardedmaker.com/gpl-2.0.txt local]): &amp;lt;nowiki&amp;gt;https://beardedmaker.com/gpl-2.0.txt&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
* GNU GPL 3.0 ([https://www.gnu.org/licenses/gpl-3.0.txt external], [https://beardedmaker.com/gpl-3.0.txt local]): &amp;lt;nowiki&amp;gt;https://beardedmaker.com/gpl-3.0.txt&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Special Pages:&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;html&amp;gt;&amp;lt;a href=&amp;quot;https://beardedmaker.com/wiki/index.php/MediaWiki:Common.css&amp;quot;&amp;gt;Global CSS Stylesheet&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt;&lt;br /&gt;
* &amp;lt;html&amp;gt;&amp;lt;a href=&amp;quot;https://beardedmaker.com/wiki/index.php/MediaWiki:Sidebar&amp;quot;&amp;gt;Sidebar Navigation List&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt;&lt;br /&gt;
* &amp;lt;html&amp;gt;&amp;lt;a href=&amp;quot;https://beardedmaker.com/wiki/index.php/MediaWiki:Mainpage&amp;quot;&amp;gt;Main Page Definition&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt;&lt;br /&gt;
* &amp;lt;html&amp;gt;&amp;lt;a href=&amp;quot;https://beardedmaker.com/wiki/index.php?title=Special:Version&amp;quot;&amp;gt;Versions for Everything&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt;&lt;br /&gt;
* &amp;lt;html&amp;gt;&amp;lt;a href=&amp;quot;https://beardedmaker.com/wiki/index.php?title=Special:BatchUpload&amp;quot;&amp;gt;Batch Upload&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Completed but needs Revision/Additions ==&lt;br /&gt;
&lt;br /&gt;
* [[3D Printing]]&lt;br /&gt;
* [[Run a Script on Startup or Shutdown]] (add links to [[VirtualBox]] and [[Backup NAS Mini]])&lt;br /&gt;
&lt;br /&gt;
== Projects ==&lt;br /&gt;
&lt;br /&gt;
=== Computing, Programming, and Networking ===&lt;br /&gt;
&lt;br /&gt;
* [[Camera Security System]]&lt;br /&gt;
* [[Volunteer Computing]]&lt;br /&gt;
* [[Backup NAS Mini]]&lt;br /&gt;
&lt;br /&gt;
=== Electrical ===&lt;br /&gt;
&lt;br /&gt;
* [[Tesla Coil]]&lt;br /&gt;
* [[Geiger Counter Sound Mod]]&lt;br /&gt;
* [[DIY Geiger Counter]]&lt;br /&gt;
&lt;br /&gt;
=== 3D Printing ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Chemistry &amp;amp; Biology ===&lt;br /&gt;
&lt;br /&gt;
* [[Germicidal UV Lamp &amp;amp; Bacterial Incubator]]&lt;br /&gt;
* [[Guide to Collecting the Elements]]&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
&lt;br /&gt;
* [[APC Smart-UPS]]&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3657</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3657"/>
				<updated>2020-08-27T16:01:46Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Monitoring Using PowerChute (Windows) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
Will be adding notes here soon.&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using you package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following sections, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial to USB adapter, you can run the following command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/usbserial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should look for the &amp;lt;code&amp;gt;port:&amp;lt;/code&amp;gt; in the following output:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
usbserinfo:1.0 driver:2.0&lt;br /&gt;
0: module:ch341 name:&amp;quot;ch341-uart&amp;quot; vendor:1a86 product:7523 num_ports:1 port:0 path:usb-0000:00:1d.0-1.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the second line, the number N at the very beginning of the line corresponds to &amp;lt;code&amp;gt;/dev/ttyUSBN&amp;lt;/code&amp;gt;. Mine shows &amp;lt;code&amp;gt;0:&amp;lt;/code&amp;gt; so I would use &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;. When you unplug the cable and plug it back in there's a chance that the number will change.&lt;br /&gt;
&lt;br /&gt;
Another way you can do it, because USB serial devices only show up in /dev when they are connected, is to see which files appear when you plug in you device. Leave the cable unplugged from your computer, then run the command below. It will print a newline and pause. While it's paused plug in the cable then press Enter:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
diff &amp;lt;(ls /dev) &amp;lt;(read;ls /dev)|grep &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; serial&lt;br /&gt;
&amp;gt; ttyUSB0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I found that &amp;lt;code&amp;gt;/dev/serial&amp;lt;/code&amp;gt; did not work, so I used &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank or say COMMLOST. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Hard Reset =&lt;br /&gt;
&lt;br /&gt;
This is the process to perform a hard reset (a.k.a. &amp;quot;brain dead&amp;quot;, hard reboot, discharge cycle). You may want to try this process when troubleshooting a UPS that is acting strangely. It sometimes solves the issue.&lt;br /&gt;
&lt;br /&gt;
# Turn the UPS off using the power button.&lt;br /&gt;
# Unplug everything from the UPS (including any serial, USB, or network cables).&lt;br /&gt;
# Unplug the UPS from mains power.&lt;br /&gt;
# Disconnect the batteries.&lt;br /&gt;
# Press and hold the power button for at least 5 seconds.&lt;br /&gt;
# Reconnect the batteries.&lt;br /&gt;
# Plug the UPS into mains power.&lt;br /&gt;
# Turn on the UPS.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section. If you don't have a 4-battery harness, you may want to check out my [[#3D_Printed_Parts|3D Printed Parts]].&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;3D_Printed_Parts&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3656</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3656"/>
				<updated>2020-08-25T05:03:05Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Hard Reset */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using you package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following sections, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial to USB adapter, you can run the following command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/usbserial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should look for the &amp;lt;code&amp;gt;port:&amp;lt;/code&amp;gt; in the following output:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
usbserinfo:1.0 driver:2.0&lt;br /&gt;
0: module:ch341 name:&amp;quot;ch341-uart&amp;quot; vendor:1a86 product:7523 num_ports:1 port:0 path:usb-0000:00:1d.0-1.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the second line, the number N at the very beginning of the line corresponds to &amp;lt;code&amp;gt;/dev/ttyUSBN&amp;lt;/code&amp;gt;. Mine shows &amp;lt;code&amp;gt;0:&amp;lt;/code&amp;gt; so I would use &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;. When you unplug the cable and plug it back in there's a chance that the number will change.&lt;br /&gt;
&lt;br /&gt;
Another way you can do it, because USB serial devices only show up in /dev when they are connected, is to see which files appear when you plug in you device. Leave the cable unplugged from your computer, then run the command below. It will print a newline and pause. While it's paused plug in the cable then press Enter:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
diff &amp;lt;(ls /dev) &amp;lt;(read;ls /dev)|grep &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; serial&lt;br /&gt;
&amp;gt; ttyUSB0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I found that &amp;lt;code&amp;gt;/dev/serial&amp;lt;/code&amp;gt; did not work, so I used &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank or say COMMLOST. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Hard Reset =&lt;br /&gt;
&lt;br /&gt;
This is the process to perform a hard reset (a.k.a. &amp;quot;brain dead&amp;quot;, hard reboot, discharge cycle). You may want to try this process when troubleshooting a UPS that is acting strangely. It sometimes solves the issue.&lt;br /&gt;
&lt;br /&gt;
# Turn the UPS off using the power button.&lt;br /&gt;
# Unplug everything from the UPS (including any serial, USB, or network cables).&lt;br /&gt;
# Unplug the UPS from mains power.&lt;br /&gt;
# Disconnect the batteries.&lt;br /&gt;
# Press and hold the power button for at least 5 seconds.&lt;br /&gt;
# Reconnect the batteries.&lt;br /&gt;
# Plug the UPS into mains power.&lt;br /&gt;
# Turn on the UPS.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section. If you don't have a 4-battery harness, you may want to check out my [[#3D_Printed_Parts|3D Printed Parts]].&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;3D_Printed_Parts&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3655</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3655"/>
				<updated>2020-08-25T05:00:43Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /*  Manual Runtime Calibration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using you package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following sections, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial to USB adapter, you can run the following command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/usbserial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should look for the &amp;lt;code&amp;gt;port:&amp;lt;/code&amp;gt; in the following output:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
usbserinfo:1.0 driver:2.0&lt;br /&gt;
0: module:ch341 name:&amp;quot;ch341-uart&amp;quot; vendor:1a86 product:7523 num_ports:1 port:0 path:usb-0000:00:1d.0-1.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the second line, the number N at the very beginning of the line corresponds to &amp;lt;code&amp;gt;/dev/ttyUSBN&amp;lt;/code&amp;gt;. Mine shows &amp;lt;code&amp;gt;0:&amp;lt;/code&amp;gt; so I would use &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;. When you unplug the cable and plug it back in there's a chance that the number will change.&lt;br /&gt;
&lt;br /&gt;
Another way you can do it, because USB serial devices only show up in /dev when they are connected, is to see which files appear when you plug in you device. Leave the cable unplugged from your computer, then run the command below. It will print a newline and pause. While it's paused plug in the cable then press Enter:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
diff &amp;lt;(ls /dev) &amp;lt;(read;ls /dev)|grep &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; serial&lt;br /&gt;
&amp;gt; ttyUSB0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I found that &amp;lt;code&amp;gt;/dev/serial&amp;lt;/code&amp;gt; did not work, so I used &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank or say COMMLOST. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Hard Reset =&lt;br /&gt;
&lt;br /&gt;
This is the process to perform a hard reset (a.k.a. &amp;quot;brain dead&amp;quot;, hard reboot, discharge cycle):&lt;br /&gt;
&lt;br /&gt;
# Turn the UPS off using the power button.&lt;br /&gt;
# Unplug everything from the UPS (including any serial, USB, or network cables).&lt;br /&gt;
# Unplug the UPS from mains power.&lt;br /&gt;
# Disconnect the batteries.&lt;br /&gt;
# Press and hold the power button for at least 5 seconds.&lt;br /&gt;
# Reconnect the batteries.&lt;br /&gt;
# Plug the UPS into mains power.&lt;br /&gt;
# Turn on the UPS.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section. If you don't have a 4-battery harness, you may want to check out my [[#3D_Printed_Parts|3D Printed Parts]].&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;3D_Printed_Parts&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3654</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3654"/>
				<updated>2020-08-25T03:56:44Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Finding Your Serial Port */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using you package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following sections, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial to USB adapter, you can run the following command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/usbserial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should look for the &amp;lt;code&amp;gt;port:&amp;lt;/code&amp;gt; in the following output:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
usbserinfo:1.0 driver:2.0&lt;br /&gt;
0: module:ch341 name:&amp;quot;ch341-uart&amp;quot; vendor:1a86 product:7523 num_ports:1 port:0 path:usb-0000:00:1d.0-1.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the second line, the number N at the very beginning of the line corresponds to &amp;lt;code&amp;gt;/dev/ttyUSBN&amp;lt;/code&amp;gt;. Mine shows &amp;lt;code&amp;gt;0:&amp;lt;/code&amp;gt; so I would use &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;. When you unplug the cable and plug it back in there's a chance that the number will change.&lt;br /&gt;
&lt;br /&gt;
Another way you can do it, because USB serial devices only show up in /dev when they are connected, is to see which files appear when you plug in you device. Leave the cable unplugged from your computer, then run the command below. It will print a newline and pause. While it's paused plug in the cable then press Enter:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
diff &amp;lt;(ls /dev) &amp;lt;(read;ls /dev)|grep &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; serial&lt;br /&gt;
&amp;gt; ttyUSB0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I found that &amp;lt;code&amp;gt;/dev/serial&amp;lt;/code&amp;gt; did not work, so I used &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank or say COMMLOST. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section. If you don't have a 4-battery harness, you may want to check out my [[#3D_Printed_Parts|3D Printed Parts]].&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;3D_Printed_Parts&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3653</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3653"/>
				<updated>2020-08-25T03:54:59Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Finding Your Serial Port */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using you package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following sections, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial to USB adapter, you can run the following command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/usbserial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should look for the &amp;lt;code&amp;gt;port:&amp;lt;/code&amp;gt; in the following output:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
usbserinfo:1.0 driver:2.0&lt;br /&gt;
0: module:ch341 name:&amp;quot;ch341-uart&amp;quot; vendor:1a86 product:7523 num_ports:1 port:0 path:usb-0000:00:1d.0-1.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the second line, the number N at the very beginning of the line corresponds to &amp;lt;code&amp;gt;/dev/ttyUSBN&amp;lt;/code&amp;gt;. Mine shows &amp;lt;code&amp;gt;0:&amp;lt;/code&amp;gt; so I would use &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Another way you can do it, because USB serial devices only show up in /dev when they are connected, is to see which files appear when you plug in you device. Leave the cable unplugged from your computer, then run the command below. It will print a newline and pause. While it's paused plug in the cable then press Enter:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
diff &amp;lt;(ls /dev) &amp;lt;(read;ls /dev)|grep &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; serial&lt;br /&gt;
&amp;gt; ttyUSB0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I found that &amp;lt;code&amp;gt;/dev/serial&amp;lt;/code&amp;gt; did not work, so I used &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank or say COMMLOST. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section. If you don't have a 4-battery harness, you may want to check out my [[#3D_Printed_Parts|3D Printed Parts]].&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;3D_Printed_Parts&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3652</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3652"/>
				<updated>2020-08-25T03:39:09Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Converting a 2-Battery UPS to a 4-Battery UPS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using you package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following sections, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial to USB adapter, you can run the following command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/usbserial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should look for the &amp;lt;code&amp;gt;port:&amp;lt;/code&amp;gt; in the following output:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
usbserinfo:1.0 driver:2.0&lt;br /&gt;
1: module:ch341 name:&amp;quot;ch341-uart&amp;quot; vendor:1a86 product:7523 num_ports:1 port:0 path:usb-0000:00:1d.0-1.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mine shows &amp;lt;code&amp;gt;port:0&amp;lt;/code&amp;gt; which corresponds to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Another way you can do it, because USB serial devices only show up in /dev when they are connected, is to see which files appear when you plug in you device. Leave the cable unplugged from your computer, then run the command below. It will print a newline and pause. While it's paused plug in the cable then press Enter:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
diff &amp;lt;(ls /dev) &amp;lt;(read;ls /dev)|grep &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; serial&lt;br /&gt;
&amp;gt; ttyUSB0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I found that &amp;lt;code&amp;gt;/dev/serial&amp;lt;/code&amp;gt; did not work, so I used &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank or say COMMLOST. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section. If you don't have a 4-battery harness, you may want to check out my [[#3D_Printed_Parts|3D Printed Parts]].&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;3D_Printed_Parts&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3651</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3651"/>
				<updated>2020-08-25T03:37:20Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* 3D Printed Parts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using you package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following sections, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial to USB adapter, you can run the following command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/usbserial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should look for the &amp;lt;code&amp;gt;port:&amp;lt;/code&amp;gt; in the following output:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
usbserinfo:1.0 driver:2.0&lt;br /&gt;
1: module:ch341 name:&amp;quot;ch341-uart&amp;quot; vendor:1a86 product:7523 num_ports:1 port:0 path:usb-0000:00:1d.0-1.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mine shows &amp;lt;code&amp;gt;port:0&amp;lt;/code&amp;gt; which corresponds to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Another way you can do it, because USB serial devices only show up in /dev when they are connected, is to see which files appear when you plug in you device. Leave the cable unplugged from your computer, then run the command below. It will print a newline and pause. While it's paused plug in the cable then press Enter:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
diff &amp;lt;(ls /dev) &amp;lt;(read;ls /dev)|grep &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; serial&lt;br /&gt;
&amp;gt; ttyUSB0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I found that &amp;lt;code&amp;gt;/dev/serial&amp;lt;/code&amp;gt; did not work, so I used &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank or say COMMLOST. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;3D_Printed_Parts&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3650</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3650"/>
				<updated>2020-08-25T03:35:50Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /*  Reading UPS Status */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using you package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following sections, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial to USB adapter, you can run the following command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/usbserial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should look for the &amp;lt;code&amp;gt;port:&amp;lt;/code&amp;gt; in the following output:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
usbserinfo:1.0 driver:2.0&lt;br /&gt;
1: module:ch341 name:&amp;quot;ch341-uart&amp;quot; vendor:1a86 product:7523 num_ports:1 port:0 path:usb-0000:00:1d.0-1.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mine shows &amp;lt;code&amp;gt;port:0&amp;lt;/code&amp;gt; which corresponds to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Another way you can do it, because USB serial devices only show up in /dev when they are connected, is to see which files appear when you plug in you device. Leave the cable unplugged from your computer, then run the command below. It will print a newline and pause. While it's paused plug in the cable then press Enter:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
diff &amp;lt;(ls /dev) &amp;lt;(read;ls /dev)|grep &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; serial&lt;br /&gt;
&amp;gt; ttyUSB0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I found that &amp;lt;code&amp;gt;/dev/serial&amp;lt;/code&amp;gt; did not work, so I used &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank or say COMMLOST. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3649</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3649"/>
				<updated>2020-08-25T03:25:19Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Finding Your Serial Port */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using you package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following sections, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial to USB adapter, you can run the following command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/usbserial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should look for the &amp;lt;code&amp;gt;port:&amp;lt;/code&amp;gt; in the following output:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
usbserinfo:1.0 driver:2.0&lt;br /&gt;
1: module:ch341 name:&amp;quot;ch341-uart&amp;quot; vendor:1a86 product:7523 num_ports:1 port:0 path:usb-0000:00:1d.0-1.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mine shows &amp;lt;code&amp;gt;port:0&amp;lt;/code&amp;gt; which corresponds to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Another way you can do it, because USB serial devices only show up in /dev when they are connected, is to see which files appear when you plug in you device. Leave the cable unplugged from your computer, then run the command below. It will print a newline and pause. While it's paused plug in the cable then press Enter:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
diff &amp;lt;(ls /dev) &amp;lt;(read;ls /dev)|grep &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; serial&lt;br /&gt;
&amp;gt; ttyUSB0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I found that &amp;lt;code&amp;gt;/dev/serial&amp;lt;/code&amp;gt; did not work, so I used &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3648</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3648"/>
				<updated>2020-08-25T03:24:59Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Finding Your Serial Port */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using you package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following sections, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial to USB adapter, you can run the following command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/usbserial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should look for the &amp;lt;code&amp;gt;port:&amp;lt;/code&amp;gt; in the following output:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
usbserinfo:1.0 driver:2.0&lt;br /&gt;
1: module:ch341 name:&amp;quot;ch341-uart&amp;quot; vendor:1a86 product:7523 num_ports:1 port:0 path:usb-0000:00:1d.0-1.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mine shows &amp;lt;code&amp;gt;port:0&amp;lt;/code&amp;gt; which corresponds to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Another way you can do it, because USB serial devices only show up in /dev when they are connected, is to see which files appear when you plug in you device. Leave the cable unplugged from your computer, then run the command below. It will print a newline and pause. While it's paused plug in the cable then press Enter:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
diff &amp;lt;(ls /dev) &amp;lt;(read;ls /dev)|grep &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;out&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; serial&lt;br /&gt;
&amp;gt; ttyUSB0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I found that &amp;lt;code&amp;gt;/dev/serial&amp;lt;/code&amp;gt; did not work, so I used &amp;lt;/code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3647</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3647"/>
				<updated>2020-08-25T03:11:08Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /*  Configuring Apcupsd */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using you package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following steps, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
I found that if I'm using a USB cable, I need to set the DEVICE to &amp;lt;code&amp;gt;/dev/ttyUSB0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're using a Smart serial cable with a serial-to-USB adapter, I found that these configurations worked:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyUSB0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3646</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3646"/>
				<updated>2020-08-25T03:07:04Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /*  Configuring Apcupsd */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using you package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following steps, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. Then set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3645</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3645"/>
				<updated>2020-08-24T06:26:41Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Disable Terminal Messages (Wall) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using you package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following steps, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. THen set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= 3D Printed Parts =&lt;br /&gt;
&lt;br /&gt;
Modular Battery Harness (2-battery or 4-battery): https://www.thingiverse.com/thing:4578235&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:DSC06104.JPG|200px]]&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=File:DSC06104.JPG&amp;diff=3644</id>
		<title>File:DSC06104.JPG</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=File:DSC06104.JPG&amp;diff=3644"/>
				<updated>2020-08-24T06:25:30Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3643</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3643"/>
				<updated>2020-08-24T06:14:36Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /*  Battery Wiring */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using you package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following steps, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. THen set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg|300px]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3642</id>
		<title>APC Smart-UPS</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=APC_Smart-UPS&amp;diff=3642"/>
				<updated>2020-08-24T06:13:49Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /*  Battery Wiring */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The following information applies to all APC Smart-UPS models. Most of this I personally tested using a Smart-UPS SC 1500 and a Smart-UPS 2200 (both are rack mount units).&lt;br /&gt;
&lt;br /&gt;
= Console Cables =&lt;br /&gt;
&lt;br /&gt;
To configure a Smart-UPS, you need to connect via console cable. Depending on your model, the unit may have a USB port, serial port, or both.&lt;br /&gt;
&lt;br /&gt;
== USB to RJ50 Cable ==&lt;br /&gt;
&lt;br /&gt;
The Smart-UPS uses a non-standard USB to RJ50 cable, which looks similar to an RJ45 but has 10 pins instead of 8. You might need to order a cable directly from APC or find a used one. The model number I ordered was &amp;lt;b&amp;gt;AP9827 940-0127E&amp;lt;/b&amp;gt; and I can confirm it works on both Smart-UPS SC 1500 and 2200.&lt;br /&gt;
&lt;br /&gt;
[[File:AP9827_940-0127E.jpg|frameless]]&lt;br /&gt;
&lt;br /&gt;
If you happen to have an RJ50 connector and a spare USB cable, you could make your own with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_USB_Pinout.jpg|550px]]&lt;br /&gt;
&lt;br /&gt;
== Serial Cable ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;IMPORTANT:&amp;lt;/b&amp;gt; You CANNOT connect a normal serial cable to the Smart-UPS. If you do connect a normal serial cable and terminate both ends, the Smart-UPS will likely shut down or exhibit other strange behaviors.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cable required for a serial port on a Smart-UPS is also proprietary and has a non-standard pinout. You need a &amp;quot;Smart Signalling&amp;quot; capable serial cable (RS-232). The model number I ordered was &amp;lt;b&amp;gt;940-1524C&amp;lt;/b&amp;gt; and I can confirm it works with the Smart-UPS SC 1500 and 2200. Note that the &amp;quot;15&amp;quot; in that model number is the length of the cable, so any model that varies in those digits will work the same.&lt;br /&gt;
&lt;br /&gt;
If you want to create your own serial cable, you will need a male DB9 connector and a female DB9 connector. Wire them up with the following pinout:&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Serial_Pinout.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using PowerChute (Windows) =&lt;br /&gt;
&lt;br /&gt;
= Monitoring Using Apcupsd (Linux) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd is an open source alternative to APC's PowerChute software for monitoring and configuring APC UPS devices. You can install it using you package manager. &amp;lt;i&amp;gt;Note: The following tutorials were performed on Debian-based Linux.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install using apt-get:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apt-get install apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding Your Serial Port ==&lt;br /&gt;
&lt;br /&gt;
Before you can configure apcupsd, you will need to figure out what serial port you're connected to. This is easy if you have only one serial device. The device file will be named something like &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt; where N is a number. Most likely you will have many serial ttys in the /dev directory, but most of them will not actually have a recognized UART device attached.&lt;br /&gt;
&lt;br /&gt;
To find which serial devices have a UART, you can run to following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo less /proc/tty/driver/serial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see an output similar this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0&lt;br /&gt;
1: uart:unknown port:000002F8 irq:3&lt;br /&gt;
2: uart:unknown port:000003E8 irq:4&lt;br /&gt;
3: uart:unknown port:000002E8 irq:3&lt;br /&gt;
4: uart:ST16650V2 port:0000E030 irq:16 tx:0 rx:0&lt;br /&gt;
5: uart:ST16650V2 port:0000E020 irq:17 tx:121720 rx:670672 brk:4&lt;br /&gt;
6: uart:unknown port:00000000 irq:0&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ignore the ones that say &amp;quot;unknown.&amp;quot; The ones that actually have a UART device will display the UART model. If you have more than one, you might need to use a process of elimination. I happen to know that my device is on line 5. The number on the far left corresponds to the device number N in the file name &amp;lt;code&amp;gt;/dev/ttySN&amp;lt;/code&amp;gt;. So I will configure apcupsd to use the device &amp;lt;code&amp;gt;/dev/ttyS5&amp;lt;/code&amp;gt;. If you're not sure which device is the right one, you can go ahead and continue [[#Configuring-Apcupsd|Configuring Apcupsd]] as I've specified in the following steps, and then follow the steps in [[#Reading-UPS-Status|Reading UPS Status]] to figure out if you've chosen the right device number.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Configuring-Apcupsd&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Configuring Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Before you start the apcupsd service there are a couple files you need to edit.&lt;br /&gt;
&lt;br /&gt;
Edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/code&amp;gt; and change the following lines to fit your needs:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE usb&lt;br /&gt;
UPSTYPE usb&lt;br /&gt;
DEVICE /dev/ttyS0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file contains comments that very thoroughly explain what parameters are available for each option.&lt;br /&gt;
&lt;br /&gt;
If you're using a serial cable, the UPSCABLE option needs to have the right model and UPSTYPE should be &amp;quot;apcsmart&amp;quot;. THen set the DEVICE option to device file.&lt;br /&gt;
&lt;br /&gt;
Here are my settings for serial:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
UPSCABLE 940-1524C&lt;br /&gt;
UPSTYPE apcsmart&lt;br /&gt;
DEVICE /dev/ttyS5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to edit the file &amp;lt;code&amp;gt;/etc/default/apcupsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set the value to &amp;quot;yes&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
ISCONFIGURED=yes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You are now ready to start the apcupsd service.&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping Apcupsd ==&lt;br /&gt;
&lt;br /&gt;
Start apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl start apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stop apcupsd:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Reading-UPS-Status&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Reading UPS Status ==&lt;br /&gt;
&lt;br /&gt;
Once you have apcupsd configured and running, you can get a readout of information about the UPS by running the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apcaccess&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is connected properly, you will see an output like this:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
APC      : 001,048,1107&lt;br /&gt;
DATE     : 2020-07-27 22:05:34 -0700&lt;br /&gt;
HOSTNAME : neuromancer&lt;br /&gt;
VERSION  : 3.14.14 (31 May 2016) debian&lt;br /&gt;
UPSNAME  : UPS_IDEN&lt;br /&gt;
CABLE    : Custom Cable Smart&lt;br /&gt;
DRIVER   : APC Smart UPS (any)&lt;br /&gt;
UPSMODE  : Stand Alone&lt;br /&gt;
STARTTIME: 2020-07-27 22:05:27 -0700&lt;br /&gt;
MODEL    : Smart-UPS SC1500&lt;br /&gt;
STATUS   : ONLINE&lt;br /&gt;
LINEV    : 122.0 Volts&lt;br /&gt;
LOADPCT  : 0.0 Percent&lt;br /&gt;
BCHARGE  : 100.0 Percent&lt;br /&gt;
TIMELEFT : 956.0 Minutes&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your APC is not connected, you will get a bunch of nonsense values, such as 0 volts, and the STATUS might be blank. This is how you know if you have configured apcupsd with the correct serial port. Note that it takes about 10 seconds after starting the apcupsd service before you will see proper values when running the apcaccess command.&lt;br /&gt;
&lt;br /&gt;
= Accessing UPS Configuration Terminal =&lt;br /&gt;
&lt;br /&gt;
The configuration terminal allows you to make configuration changes and perform a runtime calibration.&lt;br /&gt;
&lt;br /&gt;
First you must stop the ascupsd service if it's running:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo systemctl stop apcupsd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now run the apctest command:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
sudo apctest&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be presented with several options:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;result&amp;quot;&amp;gt;&lt;br /&gt;
1) Query the UPS for all known values&lt;br /&gt;
2) Perform a Battery Runtime Calibration&lt;br /&gt;
3) Abort Battery Calibration&lt;br /&gt;
4) Monitor Battery Calibration progress&lt;br /&gt;
5) Program EEPROM&lt;br /&gt;
6) Enter TTY mode communicating with UPS&lt;br /&gt;
Q) Quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Software_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Software Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
Calibrating the APC makes sure that the system has a good estimate of how long the unit can run on the installed batteries with a given load. You should perform a calibration about once or twice a year and every time you install new batteries.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# Make sure the batteries are fully charged.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;2) Perform a Battery Runtime Calibration&amp;lt;/code&amp;gt;.&lt;br /&gt;
# The batteries will drain entirely and the APC will eventually reboot and start charging the batteries again. This process must not be interrupted.&lt;br /&gt;
# Once the batteries are fully changed, the calibration is complete.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Manual_Runtime_Calibration&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Manual Runtime Calibration =&lt;br /&gt;
&lt;br /&gt;
This procedure is an alternative to the runtime calibration.&lt;br /&gt;
&lt;br /&gt;
Procedure:&lt;br /&gt;
&lt;br /&gt;
# With batteries installed, plug the unit into a power outlet and leave it on and charging for at least 24 hours.&lt;br /&gt;
# Disconnect any serial or USB cables from the unit.&lt;br /&gt;
# Plug a device into the APC that draws at least a 30% load and will not fluctuate by more than +/- 5%. Do not use an essential device as the calibration process will cause an abrupt shutdown. Something like lamps or a TV will do.&lt;br /&gt;
# Disconnect the APC from the wall outlet to force it to run on battery power.&lt;br /&gt;
# Allow the APC to run on batteries until it completely shuts off.&lt;br /&gt;
# Remove the load drawing devices and plug the APC back into the wall outlet. &lt;br /&gt;
# Allow the APC to charge until the batteries are fully charged. It will charge quicker if the unit is turned off.&lt;br /&gt;
&lt;br /&gt;
= Line Input Sensitivity =&lt;br /&gt;
&lt;br /&gt;
The APC senses irregularities in the power input and will switch to batteries power if the irregularities go beyond a certain threshold. Using the configuration terminal you can change the sensitivity of this threshold.&lt;br /&gt;
&lt;br /&gt;
The reason you might do this is if you have an old unit the capacitors in the sensing circuit might be wearing out and falsely triggering the failover. If this is happening to your unit, you might see it flapping back and forth between line and battery power, or it may even be stuck on battery power. If this is the case, you can try lowering the sensitivity using this procedure.&lt;br /&gt;
&lt;br /&gt;
First you can check the current sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Make sure apcupsd is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apcaccess&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Look for the line &amp;lt;code&amp;gt;SENSE    : High&amp;lt;/code&amp;gt;. The possible values are High, Medium, and Low.&lt;br /&gt;
&lt;br /&gt;
To change the sensitivity setting:&lt;br /&gt;
# Connect your PC to the APC via serial or USB cable.&lt;br /&gt;
# Stop the apcupsd service if it is running.&lt;br /&gt;
# Run the command &amp;lt;code&amp;gt;sudo apctest&amp;lt;/code&amp;gt;.&lt;br /&gt;
# From the terminal, choose the option &amp;lt;code&amp;gt;5) Program EEPROM&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Choose the option &amp;lt;code&amp;gt;4) Change sensitivity&amp;lt;/code&amp;gt;.&lt;br /&gt;
# At the prompt &amp;quot;Enter new sensitivity:&amp;quot; enter either a capital &amp;quot;H&amp;quot; (high), &amp;quot;M&amp;quot; (medium), or &amp;quot;L&amp;quot; (low). It will take a few seconds.&lt;br /&gt;
# You can now exit, start apcupsd again, and run the apcaccess command to confirm the change.&lt;br /&gt;
&lt;br /&gt;
If setting it to medium doesn't work, try setting to to low. If this does not solve your problem, you're looking at needing to replace capacitors.&lt;br /&gt;
&lt;br /&gt;
= Converting a 2-Battery UPS to a 4-Battery UPS =&lt;br /&gt;
&lt;br /&gt;
For a long time, I had an &amp;lt;b&amp;gt;APC Smart-UPS SC 1500&amp;lt;/b&amp;gt;, which holds 4 batteries. When it started having issues I discovered that you can buy the cheaper model &amp;lt;b&amp;gt;APC Smart-UPS SN 1000&amp;lt;/b&amp;gt;, which holds 2 batteries, and it's actually trivial to convert it to a 4-battery unit.&lt;br /&gt;
&lt;br /&gt;
If you open up the case and look in the battery bay you will see a metal plate. Simply remove this plate. That's it!&lt;br /&gt;
&lt;br /&gt;
[[File:APC_SN1000_Plate.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
The only additional thing you need to do is perform a [[#Software_Runtime_Calibration|Software Runtime Calibration]] or a [[#Manual_Runtime_Calibration|Manual Runtime Calibration]] with the new batteries installed.&lt;br /&gt;
&lt;br /&gt;
Also, if you're going to wire up your own battery harness, see the [[#Battery_Wiring|Battery Wiring]] section.&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;html&amp;gt;&amp;lt;a name=&amp;quot;Battery_Wiring&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; Battery Wiring =&lt;br /&gt;
&lt;br /&gt;
== 2-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg]]&lt;br /&gt;
&lt;br /&gt;
== 4-Battery Wiring ==&lt;br /&gt;
&lt;br /&gt;
[[File:APC_Smart-UPS_SC1500_Battery_Wiring_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
= Event Handling and Notifications =&lt;br /&gt;
&lt;br /&gt;
When an event occurs, apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; with a command line argument that invokes code within the corresponding switch case (read the script to see the available arguments).&lt;br /&gt;
&lt;br /&gt;
Before apcupsd invokes apccontrol, it will look for a file in &amp;lt;code&amp;gt;/etc/apcupsd&amp;lt;/code&amp;gt; that has the same name as the command line argument that it will pass to apccontrol and run that script first. For example, before apcupsd invokes &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol doshutdown&amp;lt;/code&amp;gt; it will look for a file called &amp;lt;code&amp;gt;/etc/apcupsd/doshutdown&amp;lt;/code&amp;gt; and run it if it exists. This way you can easily customize notifications and other actions to occur before apcupsd shuts your computer down.&lt;br /&gt;
&lt;br /&gt;
Another example: when the batteries need to be changed apcupsd will run the script &amp;lt;code&amp;gt;/etc/apcupsd/changeme&amp;lt;/code&amp;gt;. Edit this script to add a customized notification. I added some code to send me a text message.&lt;br /&gt;
&lt;br /&gt;
If you create a new script, be sure it has the correct ownership and permissions (according to the permissions of the scripts that are installed with apcupsd):&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
cd /etc/apcupsd&lt;br /&gt;
touch doshutdown&lt;br /&gt;
chown root:root doshutdown&lt;br /&gt;
chmod 755 doshutdown&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Disable Terminal Messages (Wall) =&lt;br /&gt;
&lt;br /&gt;
Apcupsd uses the &amp;lt;code&amp;gt;wall&amp;lt;/code&amp;gt; command to push a message to the terminals of every user on the system. If you don't want this, you can edit the file &amp;lt;code&amp;gt;/etc/apcupsd/apccontrol&amp;lt;/code&amp;gt; and replace the line:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=wall&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
WALL=:&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Links And Files =&lt;br /&gt;
&lt;br /&gt;
* Calibration: https://www.apc.com/us/en/faqs/FA284198/&lt;br /&gt;
* Serial Pinout: https://pinoutguide.com/UPS/apc_smart_cable_pinout.shtml&lt;br /&gt;
* Apcupsd Manual: http://www.apcupsd.org/manual/manual.pdf&lt;br /&gt;
* Customized Event Handling: http://apcupsd.org/manual/manual.html#customizing-event-handling&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg&amp;diff=3641</id>
		<title>File:APC Smart-UPS 2-Battery Wiring Diagram.jpg</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=File:APC_Smart-UPS_2-Battery_Wiring_Diagram.jpg&amp;diff=3641"/>
				<updated>2020-08-24T06:12:56Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=CSS_Styles&amp;diff=3640</id>
		<title>CSS Styles</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=CSS_Styles&amp;diff=3640"/>
				<updated>2020-08-13T01:15:15Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Collapsible Section */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Apply CSS Based on Attribute ==&lt;br /&gt;
&lt;br /&gt;
This just seems like less typing to me. Why type out &amp;lt;b&amp;gt;class=&amp;quot;something&amp;quot;&amp;lt;/b&amp;gt;? Especially in a wiki where you have to type it all the time.&lt;br /&gt;
&lt;br /&gt;
CSS:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
div[red] {&lt;br /&gt;
	color: red;&lt;br /&gt;
}&lt;br /&gt;
div[blue] {&lt;br /&gt;
	color: blue;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
HTML:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div red&amp;gt;&lt;br /&gt;
This should be red.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div blue&amp;gt;&lt;br /&gt;
This should be blue.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RESULT:&lt;br /&gt;
&amp;lt;div class=&amp;quot;box&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;This should be red.&amp;lt;/span&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:blue;&amp;quot;&amp;gt;This should be blue.&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Absolute Center (via Flexbox) ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
.absolute-center {&lt;br /&gt;
&lt;br /&gt;
	/* Internet Explorer 10 */&lt;br /&gt;
	display:-ms-flexbox;&lt;br /&gt;
	-ms-flex-pack:center;&lt;br /&gt;
	-ms-flex-align:center;&lt;br /&gt;
&lt;br /&gt;
	/* Firefox */&lt;br /&gt;
	display:-moz-box;&lt;br /&gt;
	-moz-box-pack:center;&lt;br /&gt;
	-moz-box-align:center;&lt;br /&gt;
&lt;br /&gt;
	/* Safari, Opera, and Chrome */&lt;br /&gt;
	display:-webkit-box;&lt;br /&gt;
	-webkit-box-pack:center;&lt;br /&gt;
	-webkit-box-align:center;&lt;br /&gt;
&lt;br /&gt;
	/* W3C */&lt;br /&gt;
	display:box;&lt;br /&gt;
	box-pack:center;&lt;br /&gt;
	box-align:center;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Wrap Text in &amp;lt;&amp;amp;#8203;pre&amp;gt; Tag ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
/* wrap text in pre tag, good for mobile because pre won't extend beyond screen width */&lt;br /&gt;
pre.wrap {&lt;br /&gt;
    white-space: pre-wrap;       /* Since CSS 2.1 */&lt;br /&gt;
    white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */&lt;br /&gt;
    white-space: -pre-wrap;      /* Opera 4-6 */&lt;br /&gt;
    white-space: -o-pre-wrap;    /* Opera 7 */&lt;br /&gt;
    word-wrap: break-word;       /* Internet Explorer 5.5+ */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Collapsible Section ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;title&amp;gt;TEST 2&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
@font-face {&lt;br /&gt;
  font-family: 'Open Sans';&lt;br /&gt;
  font-style: normal;&lt;br /&gt;
  font-weight: 300;&lt;br /&gt;
  src: local('Open Sans Light'), local('OpenSans-Light'), url(https://fonts.gstatic.com/s/opensans/v13/DXI1ORHCpsQm3Vp6mXoaTegdm0LZdjqr5-oayXSOefg.woff2) format('woff2');&lt;br /&gt;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;&lt;br /&gt;
}&lt;br /&gt;
body {&lt;br /&gt;
	font-family: &amp;quot;Open Sans&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
.collapse-link {&lt;br /&gt;
	display: table;&lt;br /&gt;
	color: #888;&lt;br /&gt;
	text-decoration: none;&lt;br /&gt;
	margin-bottom: 10px;&lt;br /&gt;
	-webkit-touch-callout: none;&lt;br /&gt;
	-webkit-user-select: none;&lt;br /&gt;
	-khtml-user-select: none;&lt;br /&gt;
	-moz-user-select: none;&lt;br /&gt;
	-ms-user-select: none;&lt;br /&gt;
	user-select: none;&lt;br /&gt;
}&lt;br /&gt;
.collapse-link:hover {&lt;br /&gt;
	color: #000;&lt;br /&gt;
	text-decoration: none;&lt;br /&gt;
	cursor: pointer;&lt;br /&gt;
}&lt;br /&gt;
.collapse-link:after {&lt;br /&gt;
	content: '\00276f';&lt;br /&gt;
	display: inline-block;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.collapse-link-expanded {&lt;br /&gt;
	display: table;&lt;br /&gt;
	color: #888;&lt;br /&gt;
	text-decoration: none;&lt;br /&gt;
	margin-bottom: 10px;&lt;br /&gt;
	-webkit-touch-callout: none;&lt;br /&gt;
	-webkit-user-select: none;&lt;br /&gt;
	-khtml-user-select: none;&lt;br /&gt;
	-moz-user-select: none;&lt;br /&gt;
	-ms-user-select: none;&lt;br /&gt;
	user-select: none;&lt;br /&gt;
}&lt;br /&gt;
.collapse-link-expanded:hover {&lt;br /&gt;
	color: #000;&lt;br /&gt;
	text-decoration: none;&lt;br /&gt;
	cursor: pointer;&lt;br /&gt;
}&lt;br /&gt;
.collapse-link-expanded:after {&lt;br /&gt;
	content: '\00276f';&lt;br /&gt;
	display: inline-block;&lt;br /&gt;
	transform: rotate(90deg);&lt;br /&gt;
}&lt;br /&gt;
.collapsible {&lt;br /&gt;
	display: none;&lt;br /&gt;
}&lt;br /&gt;
.collapsible-expanded {&lt;br /&gt;
	display: block;&lt;br /&gt;
	padding: 0px 20px 30px 20px;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
function ToggleCollapsible(link, boxId) {&lt;br /&gt;
	box = document.getElementById(boxId);&lt;br /&gt;
	if (link.className == &amp;quot;collapse-link&amp;quot;) {&lt;br /&gt;
		link.className = &amp;quot;collapse-link-expanded&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	else {&lt;br /&gt;
		link.className = &amp;quot;collapse-link&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	if (box.className == &amp;quot;collapsible&amp;quot;) {&lt;br /&gt;
		box.className = &amp;quot;collapsible-expanded&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	else {&lt;br /&gt;
		box.className = &amp;quot;collapsible&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
	&amp;lt;a class=&amp;quot;collapse-link&amp;quot; onclick=&amp;quot;ToggleCollapsible(this, 'options')&amp;quot;&amp;gt;More Options&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/a&amp;gt;&lt;br /&gt;
	&amp;lt;div id=&amp;quot;options&amp;quot; class=&amp;quot;collapsible&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;ul&amp;gt;&lt;br /&gt;
			&amp;lt;li&amp;gt;&amp;lt;a href=&amp;quot;#&amp;quot;&amp;gt;Some Option&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
			&amp;lt;li&amp;gt;&amp;lt;a href=&amp;quot;#&amp;quot;&amp;gt;Some Other Option&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
		&amp;lt;/ul&amp;gt;&lt;br /&gt;
	&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	<entry>
		<id>https://beardedmaker.com/wiki/index.php?title=CSS_Styles&amp;diff=3639</id>
		<title>CSS Styles</title>
		<link rel="alternate" type="text/html" href="https://beardedmaker.com/wiki/index.php?title=CSS_Styles&amp;diff=3639"/>
				<updated>2020-08-13T01:13:56Z</updated>
		
		<summary type="html">&lt;p&gt;Beard: /* Collapsible Section */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Apply CSS Based on Attribute ==&lt;br /&gt;
&lt;br /&gt;
This just seems like less typing to me. Why type out &amp;lt;b&amp;gt;class=&amp;quot;something&amp;quot;&amp;lt;/b&amp;gt;? Especially in a wiki where you have to type it all the time.&lt;br /&gt;
&lt;br /&gt;
CSS:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
div[red] {&lt;br /&gt;
	color: red;&lt;br /&gt;
}&lt;br /&gt;
div[blue] {&lt;br /&gt;
	color: blue;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
HTML:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div red&amp;gt;&lt;br /&gt;
This should be red.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div blue&amp;gt;&lt;br /&gt;
This should be blue.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RESULT:&lt;br /&gt;
&amp;lt;div class=&amp;quot;box&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;This should be red.&amp;lt;/span&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:blue;&amp;quot;&amp;gt;This should be blue.&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Absolute Center (via Flexbox) ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
.absolute-center {&lt;br /&gt;
&lt;br /&gt;
	/* Internet Explorer 10 */&lt;br /&gt;
	display:-ms-flexbox;&lt;br /&gt;
	-ms-flex-pack:center;&lt;br /&gt;
	-ms-flex-align:center;&lt;br /&gt;
&lt;br /&gt;
	/* Firefox */&lt;br /&gt;
	display:-moz-box;&lt;br /&gt;
	-moz-box-pack:center;&lt;br /&gt;
	-moz-box-align:center;&lt;br /&gt;
&lt;br /&gt;
	/* Safari, Opera, and Chrome */&lt;br /&gt;
	display:-webkit-box;&lt;br /&gt;
	-webkit-box-pack:center;&lt;br /&gt;
	-webkit-box-align:center;&lt;br /&gt;
&lt;br /&gt;
	/* W3C */&lt;br /&gt;
	display:box;&lt;br /&gt;
	box-pack:center;&lt;br /&gt;
	box-align:center;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Wrap Text in &amp;lt;&amp;amp;#8203;pre&amp;gt; Tag ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
/* wrap text in pre tag, good for mobile because pre won't extend beyond screen width */&lt;br /&gt;
pre.wrap {&lt;br /&gt;
    white-space: pre-wrap;       /* Since CSS 2.1 */&lt;br /&gt;
    white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */&lt;br /&gt;
    white-space: -pre-wrap;      /* Opera 4-6 */&lt;br /&gt;
    white-space: -o-pre-wrap;    /* Opera 7 */&lt;br /&gt;
    word-wrap: break-word;       /* Internet Explorer 5.5+ */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Collapsible Section ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;title&amp;gt;TEST 2&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
@font-face {&lt;br /&gt;
  font-family: 'Open Sans';&lt;br /&gt;
  font-style: normal;&lt;br /&gt;
  font-weight: 300;&lt;br /&gt;
  src: local('Open Sans Light'), local('OpenSans-Light'), url(https://fonts.gstatic.com/s/opensans/v13/DXI1ORHCpsQm3Vp6mXoaTegdm0LZdjqr5-oayXSOefg.woff2) format('woff2');&lt;br /&gt;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;&lt;br /&gt;
}&lt;br /&gt;
body {&lt;br /&gt;
	font-family: &amp;quot;Open Sans&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
.collapse-link {&lt;br /&gt;
	display: table;&lt;br /&gt;
	color: #888;&lt;br /&gt;
	text-decoration: none;&lt;br /&gt;
	margin-bottom: 10px;&lt;br /&gt;
	-webkit-touch-callout: none;&lt;br /&gt;
	-webkit-user-select: none;&lt;br /&gt;
	-khtml-user-select: none;&lt;br /&gt;
	-moz-user-select: none;&lt;br /&gt;
	-ms-user-select: none;&lt;br /&gt;
	user-select: none;&lt;br /&gt;
}&lt;br /&gt;
.collapse-link:hover {&lt;br /&gt;
	color: #000;&lt;br /&gt;
	text-decoration: none;&lt;br /&gt;
	cursor: pointer;&lt;br /&gt;
}&lt;br /&gt;
.collapse-link:after {&lt;br /&gt;
	content: '\00276f';&lt;br /&gt;
	display: inline-block;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.collapse-link-expanded {&lt;br /&gt;
	display: table;&lt;br /&gt;
	color: #888;&lt;br /&gt;
	text-decoration: none;&lt;br /&gt;
	margin-bottom: 10px;&lt;br /&gt;
	-webkit-touch-callout: none;&lt;br /&gt;
	-webkit-user-select: none;&lt;br /&gt;
	-khtml-user-select: none;&lt;br /&gt;
	-moz-user-select: none;&lt;br /&gt;
	-ms-user-select: none;&lt;br /&gt;
	user-select: none;&lt;br /&gt;
}&lt;br /&gt;
.collapse-link-expanded:hover {&lt;br /&gt;
	color: #000;&lt;br /&gt;
	text-decoration: none;&lt;br /&gt;
	cursor: pointer;&lt;br /&gt;
}&lt;br /&gt;
.collapse-link-expanded:after {&lt;br /&gt;
	content: '\00276f';&lt;br /&gt;
	display: inline-block;&lt;br /&gt;
	transform: rotate(90deg);&lt;br /&gt;
}&lt;br /&gt;
.collapsible {&lt;br /&gt;
	display: none;&lt;br /&gt;
}&lt;br /&gt;
.collapsible-expanded {&lt;br /&gt;
	display: block;&lt;br /&gt;
	padding: 0px 20px 30px 20px;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
function ToggleCollapsible(link, boxId) {&lt;br /&gt;
	box = document.getElementById(boxId);&lt;br /&gt;
	if (link.className == &amp;quot;collapse-link&amp;quot;) {&lt;br /&gt;
		link.className = &amp;quot;collapse-link-expanded&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	else {&lt;br /&gt;
		link.className = &amp;quot;collapse-link&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	if (box.className == &amp;quot;collapsible&amp;quot;) {&lt;br /&gt;
		box.className = &amp;quot;collapsible-expanded&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	else {&lt;br /&gt;
		box.className = &amp;quot;collapsible&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
	&amp;lt;a class=&amp;quot;collapse-link&amp;quot; onclick=&amp;quot;ToggleCollapsible(this, 'options')&amp;quot;&amp;gt;More Options&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/a&amp;gt;&lt;br /&gt;
	&amp;lt;div id=&amp;quot;options&amp;quot; class=&amp;quot;collapsible&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;a href=&amp;quot;#&amp;quot;&amp;gt;Show Archived Items&amp;lt;/a&amp;gt;&lt;br /&gt;
	&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Beard</name></author>	</entry>

	</feed>