Main Menu

Moteino Receiver

Started by Zeldatwili, October 31, 2014, 05:57:54 PM

Zeldatwili

Alright so I got the motion sensor working (I hope/think anyway... it seems to blink whenever theres motion so im assuming its working...) so now I just need to program the receiver, I just dont know how. I could probably take some things from the sketch from the motion sensor, but that would just be identifying the moteino. I would like to be able to take the message received from the Moteino and implement it into python on my pi so I can send a message from that.

Felix

Why not just use the Gateway example?
https://github.com/LowPowerLab/RFM69/tree/master/Examples/Gateway

Adjust the settings so you match the networkID, frequency, HW setting, encryption etc. And then have the MotionMote send to ID=1. Your gateway should then receive the MOTION messages from the MotionMote.

Zeldatwili

Alright so I got the code on that now. Is the light suppose to flash when it receives something? If it is then I must have done something wrong... anyway so is it possible to just have the Moteino connected to the GPIO ports, since its just receiving a message? Or would it be better just to have it connected to the usb? I've looked here on the forum and it seems like theres just one GPIO pin thats kind of tricky... Either way, once it is connected how do I implement the messages it receives into a python script?

Felix

I am not sure what exactly you refer to when you say tricky GPIO. You can connect the receiving/"master" Moteino through USB (either via a FTDI adapter or directly if you have a MoteinoUSB) or through GPIO (4 wires: GND, VCC, TX, RX). TX will go to the Pi/computer's RX and vice versa. For python you will need to get the pyserial module so you can open the serial port in the python script and read lines/characters from the Moteino.
Here is an example python script I wrote for the Sump Pump monitor. It reads the messages that Moteino sends through the serial port, and sends them to EmonCMS for logging/graphing: https://github.com/LowPowerLab/SumpPumpAlert/blob/master/Gateway.py

Zeldatwili

Sorry it's been so long, high school is so much work.
Anyway so I just decided to connect the moteino the the USB port on the Raspberry Pi. I found https://github.com/iinnovations/iicontrollibs/blob/master/mote/serialhandler.py this python code to use on the Pi,  and after some debugging I got it to say that it was monitoring the serial port. So I turned on the motion mote, made sure it was working and then waved a it a few times,  but nothing ever showed up on the Pi. Do you have an idea of what I've done wrong? Is the light on the moteino support to blink when it does something, because mine never blinks.

Felix

I use pyserial for reading/writing to the serial port from python.

Zeldatwili

The python script in the link I gave you does use pyserial

Felix

Oh I didn't notice they do the import in the functions ...
Make sure your serial port is enabled for general use. The system uses it by default.

Zeldatwili

I followed the instructions from http://www.hobbytronics.co.uk/raspberry-pi-serial-port this website and followed all the instructions except testing the serial port. Either way, I think the problem lies somewhere with the moteinos talking to each other, because I looked through the code for the gateway and at the very end I found a part where it looks like it makes the LED blink 3x. The only time I see the LED blink on my moteino is when it first starts up, and then it never blinks again. I triple checked the settings to make sure they were all correct, so those are out of the question, unless I'm really stupid and I'm just missing something really obvious, which I doubt. Do you have any ideas?

Felix

First you need to test if your motion sensor works. You can simulate a sensor trip by touching D3 to 3.3V. That generates an interrupt and should send a message to your receiver. The sensor should do the same when there is motion. If your power is less than 4V on the motion sensor then it might never work because of the regulator and diode that it has. I have a guide how to remove those to make it work down to 3.3V: http://lowpowerlab.com/motionmote/#pirsensor
Once you know your sensor works and moteino transmits on motion, then move on to testing pyserial...
Take a divide-et-impera approach. Don't test everything together until the last step when you know all the individual parts work.

Zeldatwili

#10
I know the motion sensor works because the light blinks whenever I move in front of it, and I did remove those things before hand.

Felix

So far it sounds like you can't get a packet from the motion sensor to your receiver. I suggest going back a few steps and getting Gateway and Node examples running to make sure those will work.

Zeldatwili

The gateway was already running on the Raspberry Pi moteino so I just had to add the node example to the motionmote. After I got the sketch uploaded I noticed the light on the motionmote moteino blinking very rapidly, judging by the code every 150ms. So I started up the Raspberry Pi with the moteino gateway connected but again it never blinks. I will do a little more experimenting but I don't think I will find much.

Zeldatwili

I went to the arduino ide and went to serial port monitor and selected 115200 baud and when I did the message "SPI Flash Init FAIL! (is chip present?)" shows up. What does this mean?

Felix

It means there is no FLASH chip installed on the Moteino.