Author Topic: Raspberry PI as a sensor with I2C comm to moteino  (Read 781 times)

loseymark

  • Jr. Member
  • **
  • Posts: 58
  • Country: us
Raspberry PI as a sensor with I2C comm to moteino
« on: May 31, 2016, 09:54:46 PM »
I have a garage door monitor I built with a couple of reed switches, a Raspberry PI, and a python program to check the door status. The python program checks for doors open too long and doors open after a given time. The door status and alert events are written to a PostgreSQL database and displayed on a home web page. The web page and the database run on separate Raspberry PIs as well.

I wanted to keep my existing functionality, but I want my Home Automation Gateway to be a main status display point. To put the garage door monitor status on the gateway, I am turning a PI into a sensor with I2C communication between the PI and a moteino. The garage PI continues to do just what it did before, but now when there is an open/close event or an alert event, the garage PI uses pyro (Python Remote Objects) to send a command to another PI I call “PIMOTE” which communicates via I2C to the moteino which in turn communicates to the gateway via RFM69.

I chose I2C because it lets me have the PI as a master, and numerous moteino I2C slaves and makes it easy to implement the logic to communicate with multiple slaves. I also only needed simple numeric command arguments rather than text, which would have been more suited to serial communication.

Additionally, I have one moteino for both doors and the sketch uses radio.setAddress() to make the single moteino show up on the gateway as multiple nodes.

Eventually I will add other functions to the pimote to add gateway nodes monitoring things that a PI can do in place of a sensor. My next project will be to integrate my home security system with the gateway by scraping SMS messages sent by the security system when it is armed or disarmed or when alerts occur. There is no other way of integrating the security system, well, at least not without voiding the warranty.

I have attached a text document with code examples.