Real Time Clock and More

This morning I added a DS3231 Real Time Clock to the measurement system Raspberry Pi.  I used THIS article to guide the way.  One mistake that I made at the end of the process cost me a lot of time.  I used the command  hwclock -r rather than sudo hwclock -r and kept getting an error message that no clock could be found.  After reading the error message more carefully I discovered that it was due to an access permission issue which adding sudo resolved.

Next up, I went about installing pysftp on the weather system Raspberry Pi 3.  This turned out to be a very involved, time consuming process.  I tried to use sudo apt-get install pysftp and got an error.  I tried pip install pysftp and got another error.  I tried pip3 install pysftp and it worked but only installed a version of pysftp for python3.  I tried pip2 install pysftp and got another error.

Finally after googling forever, I found THIS article which suggested that the problem was due to missing packages in the operating system required to build the pysftp for python2.  Based on that article I executed the command:

sudo apt-get install gcc libffi-dev libssl-dev python-dev

and then pip2 install pysftp and it worked!

On to testing pysftp…  First problem, discovered after over an hour of attempts… I needed to turn on SSH on the target machine (measurement system).  Silly me.

Once I enabled SSH on the target machine then this worked using interactive Python:

>>> import pysftp
>>> cnopts = pysftp.CnOpts()
>>> cnopts.hostkeys = None
>>> sftp = pysftp.Connection(‘192.168.1.000′,username=’username’,password=’password’, cnopts=cnopts)
>>> sftp.execute(‘ls’)
[‘Desktop\n’, ‘Documents\n’, ‘Downloads\n’, ‘Music\n’, ‘Pictures\n’, ‘Public\n’, ‘python_games\n’, ‘Templates\n’, ‘Videos\n’]
>>>

That last line is a python list of strings showing the directories on the in the remote machine’s home directory.  Success!

By the way, those are not my real IP address, username or passwords.

Now, I just need to put an appropriately formatted python script on the remote machine and see if I can get it to execute from the weather machine 🙂

UPDATE 12/19/17, 3:22PM

Starting to build the test scripts.  Discovered that there were two fundamental things I needed to do with the test script on the measurement machine in order to execute a python script as if it were a shell command.

I needed to include the path to the script in the $PATH environmental variable via:

export PATH=$PATH:/path/to/my/script/directory

I also needed to change the permissions on the script to make it executable.

 

Comments are closed.