Use Arduino and two hobby servos to control physical servo gauges for cpu activity, memory usage, bandwidth, and more. The script uses the python psutil and pyserial modules. The psutil module provides an interface for retrieving information on all running processes and system utilization (CPU, disk, memory, network) providing service similar to command line tools such as ps, top, iostat, and netstat. The servo control portion of the project is based on Arduino-Python 4-Axis Servo Controlby Brian Wendt, and the Arduino sketch is essentially unmodified from the SerialServoControl Sketch on Sparkfun.
Connect the red, power lines of the servos to +5v, the black ground lines to GND, and the yellow signal lines to the desired output pins, 5 and 6 in the example (others can be used, but must be PWM capable
You can download my cheesy gauge overlay from here:
Print it out, cut out the gauges, and poke a hole in the lower center of the gauge. Remove the servo horn, slide the shaft through the hole in the gauge printout, and reconnect the servo horn on top of it.
The first step is to install the python psutil and pyserial modules. The easiest way to install it is using the python pip package manager. If you don’t have it installed already, you can install it using apt-get:
sudo apt-get install python-pip
Then install the psutil and pyserial modules:
sudo pip install psutil pyserial
Next, flash the sketch to the Arduino board. You can download it or copy and paste into the Arduino IDE.
Then download or copy and paste the Python script:
That’s it! To run the script:
Note:If you receive this error:
raise SerialException(“could not open port %s: %s” % (self._port, msg)) serial.serialutil.SerialException: could not open port /dev/ttyUSB0: [Errno 13] Permission denied: ‘/dev/ttyUSB0′
The problem is the default permissions of the /dev/ttyUSB0 (or /dev/ttyACM0) device. This can be fixed by running the command:
Always excercise caution when working with electronics. All software is provided on an "as is" basis without warranty of any kind, express or implied. Unless otherwise noted, all code content is licensed under the Apache 2.0 license