Pi based SNMP monitoring probe

…or how to connect a Diesel generator to the Internet of Things™

We recently installed a 3 phase backup Diesel at one of our colo sites. In order to give our NOC a clear picture of whats going on with that engine at any time, I built a small SNMP monitoring probe from a Raspberry Pi and a PiFace Digital IO expansion board. The PiFace inputs are then connected to signal relays in the diesel gen controller.

Here’s a small, cheesy video to show it off:


To make the hardware do as needed, I wrote a “monitoring program” in Python. It reads the status of the Input Pins from the PiFace board and checks the inputs for these fault signals and parameters:

  • Mains power lost
  • Diesel generator engaged
  • Diesel generator fault
  • Room Temperature
  • Air condition unit 1 fault
  • Air condition unit 2 fault

I used temper.c from Relavak Labs for reading the temperature from a supercheap USB Temper1 sensor. The monitoring program generates SNMP traps for any status changes it observes, and updates a status webpage (Python CGI for Apache webserver) for display. Support for SNMP read/write access could be added, but I have not yet managed to compile a MIB for the little box. I however wrote a Python plugin for Nagios, so generator status information is now available to the network management system and any fault conditions will properly alert staff on duty.

I’ve put some BLINKENLIGHTS into my code, for debugging purposes, fun and nostalgia. The PiFace LEDs provide live visualization of my code’s doings:

  • LED1: Executing main monitor loop
  • LED2: Attempting read from USB sensor
  • LED3: Updating status to ramdisk
  • LED4: Feeding the watchdog (keepalive)
  • LED5: Valid temperature reading from USB sensor
  • LED6: Invalid temperature reading from USB sensor
  • LED7: Auxiliary relay active
  • LED8: Temperature alarm relay active

The monitoring program periodically feeds the Raspberry Pi’s hardware watchdog. If it fails to do so for any reason whatsoever at any time, the watchdog will trigger a reboot within the next 15 seconds, preventing the probe from failing silently. Also, because my code uses multiple threads, I had to hack PiFace’s pfio.py to add some crude synchronization to the SPI port read/write functions – nothing too strange.

Cost: Around USD 110 plus several days worth tinkering with Python and the Pi. As in, from an idea to a working, field deployed prototype in less than a week:

The final product

The power supply is a Meanwell 25W unit and all Pi, PiFace plus supply fit nicely into a wallmounted standard electric wiring box (cover removed for picture above). Of course, the mains socket for the probe is protected by a battery UPS. And yes, the wiring was properly done by a licensed electrician.

Given the Pi’s full blown TCP/IP stack and onboard processing capabilities, it integrates well into most every networked application while offering autonomy on certain levels: The Temperature alarm relay always reacts to overtemp conditions to enable auxiliary cooling – even if network connectivity is lost and the central station/SNMP manager becomes unreachable. The Pi/PiFace combo’s big plus is however it’s Linux OS, which makes writing solution-tailored code for simple command & control applications relatively easy and certainly enables rapid prototyping.

Say hello to the Internet of Things!

Advertisements

4 thoughts on “Pi based SNMP monitoring probe

  1. Pingback: ใช้ TEMPer1 วัดอุณหภูมิ แล้วส่งข้อมูลแบบ SNMP หรือไปควบคุมหลอดไฟ Hue | Raspberry Pi Thailand

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s