LowPowerLab Forum

Hardware support => Moteino => Topic started by: snop on February 13, 2015, 08:00:48 AM

Title: Using Motionmote and raspberry pi - online interface
Post by: snop on February 13, 2015, 08:00:48 AM
Hi everybody! (-Hi Dr. Nick)

I got my Moteino R4 USBs in the mail a couple of days ago. My plan is to have a little "security system" at home where I have a moteino hooked up to a PIR-sensor in every room. These are communicating with my Raspberry Pi hooked up to a Moteino. Ive got the sensor to transmit to the gateway using MotionMote and Gateway examples. Now heres where it all stops. How can I publish the status of the sensors to a online interface? Anyone got any examples or som pointers for me?

Title: Re: Using Motionmote and raspberry pi - online interface
Post by: Felix on February 13, 2015, 08:23:27 AM
Read your data from the gateway serial port using your favorite program. I showed examples with python and lately with nodejs.
You can follow my example of putting my garage door and light switches online using this step through:
lowpowerlab.com/blog/2013/10/07/raspberrypi-home-automation-gateway-setup/
Customize it to your own sensor. It's very simple but it is fast.
I will continue to update this gateway to make it easier to use and add more sensors without the need to custom program each one.
Also if you want to publish/log your data you can have the script push it to a logging system like EmonCMS if you'd like, hosted on the same Pi or to a service online. Many possibilities.
Title: Re: Using Motionmote and raspberry pi - online interface
Post by: Prodigal on February 13, 2015, 08:30:06 PM
Hi Dr. Nick,

I just got my Moteino talking to my RPi over the serial ports.  Check out my blog posts here: http://beckermaker.blogspot.com/search/label/Home%20environmental%20sensor%20array (http://beckermaker.blogspot.com/search/label/Home%20environmental%20sensor%20array)

If you don't want to weed through my stream-of-consciousness posts, go to this web page  http://elinux.org/RPi_Serial_Connection (http://elinux.org/RPi_Serial_Connection) to get started.

Finally, after you get the serial connection working, here is a python program to test the connection.

import time
import serial

SERIALBAUD = 115200

# configure the serial connections (the parameters differs on the device you are connecting to)
ser = serial.Serial(
    port='/dev/ttyAMA0'
    , baudrate=SERIALBAUD
    , timeout=0.0
#    , parity=serial.PARITY_ODD
#    , stopbits=serial.STOPBITS_TWO
#    , bytesize=serial.SEVENBITS
)

print ("Serial tester ready and listening to " + port.name + " at " + SERIALBAUD)

while True :
    rcvRaw = '';
    rcvRaw = port.read(9999);

    if len(rcvRaw) > 0 :
        rcvLines = rcvRaw.split("\r\n");

        for rcvLine in rcvLines :
               print ("Incoming transmission: " + rcvLine);

       print (" ");

    else :
        print ("Sleeping");
        time.sleep(20);