csmsx / mark0

A pure-Python getting-started plant growth data collector for RasPi.
MIT License
4 stars 3 forks source link
indoor-farming python raspberry-pi raspbian-jessie

Mark 0

Requirements

Usage

Mark 0 relies on a daemon and a collection program. Usages in 3 steps:

  1. Ensure your Pi timezone settings.
  2. Launch the daemon.
  3. Run the program, or register it for periodic execution (e.g. with cron).

The following procedure is based on cron to run every hour. All programs run as the default pi user. The environment variable WORK_DIR is set to the repository path.

$ sudo timedatectl set-timezone Asia/Tokyo # Replace Asia/Tokyo by your timezone, e.g. UTC.
$ cd $WORK_DIR
$ sudo pip install -r requirements.txt
$ ./devices.d
$ crontab -e
# Add entry:
# 0 * * * * /usr/bin/python /path/to/collect.py

In the crontab, please edit the path to the collect.py script.

Troubleshooting

Suspension in syslog

If you see many "suspensions" in /var/log/syslog, exactly at the time you expect collect.py execution by cron, you are probably hitting an old rsyslog bug (circa 2015-2016). The fix exists for long, but it is not applied up to and including Raspbian Jessie. The workaround is to remove the command that pipes to /dev/console in /etc/rsyslog.conf (usually at the bottom of a default configuration).

Typical syslog symptom:

Aug  2 23:16:25 raspberrypi rsyslogd-2007: action 'action 17' suspended, next retry is Wed Aug  2 23:17:55 2017 [try http://www.rsyslog.com/e/2007 ]

References:

Dropped output from cron

You may see dropped output in cron:

CRON[8380]: (CRON) info (No MTA installed, discarding output)

This is NOT a problem, however a missed opportunity. It means cron has detected the command writes to stdout. cron expects then a redirection to a file, a mail reader, a mail server, etc.

The output from collect.py contains the sensor readings. If you want to have both an "heartbeat" email and an idea of the sensor values, you can install postfix and set MAILTO= to the target email address in your crontab.

Alternatively you can just drop the output explicitly by redirecting to /dev/null, or redirect to any file (e.g. in /var/log).

Copyrights & Thanks

This work relies on external libraries: