Moteino + RasPi + PIR sensors

Started by snop, January 13, 2015, 05:28:38 AM

snop

Hi!
I am a computer engineer student whos doing a project at school where I think im going to need this:Moteino + RasPi + PIR sensors. I am completely new to working with hardware and need some pointers.

My project is to detect motion in a room and then notify a Raspberry Pi. I´ve been doing som research and I think this is what I need: A Moteino (https://lowpowerlab.com/shop/index.php?_route_=moteino-r4) Can this send signals to the Raspberry? PIR motion sensor (https://lowpowerlab.com/shop/index.php?route=product/product&product_id=113) After what I can see theese two can be put together with a 9 V battary. And that is all I ned for the transmittor? Do I need anything else than an Raspberry to recieve?

I am very greatful for all the help/pointers I can get

Felix

Hi,
You can do it very simply as you stated. All you need is a Moteino, a PIR sensor, and a battery on the sender side.
Note that the PIR sensor has a voltage regulator that has a dropout of about 0.250v on it, an also more importantly a diode that has a huge dropout of about 0.7v. So in total there is a dropout of about 1v. If you want to make the PIR sensor work down to lower voltages. I will point you to the MotionMote guide to modify your PIR sensor if you want to do that. That will make it work from 5V down to 3V. Otherwise it will work just fine from a 9V battery but it will be less efficient, still the battery should last for months if you sleep the Moteino the right way, as shown in the MotionMote code.
On the receiver end you will need another Moteino to attach to your Pi.
There is also a motion kit available if you want a case and more bells and whistles.

snop

Thanks for the reply Felix. Would it be possible to use the PowerBoost 1000 Basic: http://www.adafruit.com/products/2030 to supply power. if so I would perhaps need to replace the Moteino with the Moteino USB? (Are they the same, only with and without usb?) https://lowpowerlab.com/shop/index.php?_route_=Moteino/moteinousb.
Should I have this on the receiver end also? Looks easier to hook up to the Raspberry.

Felix

Hm ... yes for the boost but I don't see why you'd do that.

snop

Sorry to bother you.

I was wondering if you had any guide on how to hook up the rasPi to the Moteino?

I have now ordered a Raspberry Pi and a couple of Moteino-USB.
While waiting for the hardware I´m trying to do some more research on how this actually will work, considering this is all completely new to me.

Felix

You have 2 ways:
- connect through USB if you have a MOteinoUSB, then you will have a new serial port showing up on your Pi (it will be something like ttyAMAx)
- connect through the side headers: GND, VIN for power (from PI GND and 5V) and RX (moteino) to TX (Pi) and TX (moteino) to RX (Pi), then you will need to use the default serial port (typically ttyAMA0)

obstler42

Quote from: snop on January 21, 2015, 06:19:34 AM
Sorry to bother you.

I was wondering if you had any guide on how to hook up the rasPi to the Moteino?

I have now ordered a Raspberry Pi and a couple of Moteino-USB.
While waiting for the hardware I´m trying to do some more research on how this actually will work, considering this is all completely new to me.

You could also hook up the RFM69 module directly to the RasPi as in

https://github.com/abouillot/HomeAutomation/tree/master/piGateway

I've been running that gateway for about a week now without any problems, so far very stable. Only issue is that ACKs don't work on the RasPi side, so you cannot rely on sendwithRetry() on the Moteino nodes.

The provided sample piGateway code posts the received data to a local MQTT server, and anything else can simply subscribe to the relevant MQTT topics: FHEM, mqttwarn, etc.

Felix

I would highly recommend using a Moteino or similar board that does the relaying of messages and host the RFM69 logic. It's a much much better idea than to leave it up to Pi which is not a real time OS and you have no guarantee about timings, that is probably why your ACKs arrive too late from the Pi.

obstler42

I think the problem with ACKs is in the code and not timing -- even when I set the sendwithRetry() timeout to 1000ms the node still doesn't get ACKs.

While the basic design discussion (arduino or not) and most of the pros and cons of the solutions have been discussed already in other threads, I simply dislike having to use the serial port for this type of communication: it adds another layer on top, you have to define your own protocol for talking over the character-based serial port etc. Haven't looked if there are good serial samples for both Arduino and RasPi side ready to use...

I'd actually prefer to connect an Ethernet module to the Arduino and have it talk to the mqtt server directly, but coudn't get it working reliably with the ENJ modules I had around (probably memory issues); have some wiznet modules on order and will try again when I get those.

TomWS

Quote from: obstler42 on January 21, 2015, 04:53:59 PM
I think the problem with ACKs is in the code and not timing -- even when I set the sendwithRetry() timeout to 1000ms the node still doesn't get ACKs.

While the basic design discussion (arduino or not) and most of the pros and cons of the solutions have been discussed already in other threads, I simply dislike having to use the serial port for this type of communication: it adds another layer on top, you have to define your own protocol for talking over the character-based serial port etc. Haven't looked if there are good serial samples for both Arduino and RasPi side ready to use...

I'd actually prefer to connect an Ethernet module to the Arduino and have it talk to the mqtt server directly, but coudn't get it working reliably with the ENJ modules I had around (probably memory issues); have some wiznet modules on order and will try again when I get those.
First, I'll say right up front that I know NOTHING about the Pi implementation, but, given what I know about other embedded Linux platforms and how 'I/O' is just another stream file, the problem may be timing related.  In my experience, Acks from Moteinos occur within 2 mS of a recognized send and, because Acks aren't themselves 'ack'd, if you miss them, they're gone...
Tom