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.
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.
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?
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
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 (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.
I use pyserial for reading/writing to the serial port from python.
The python script in the link I gave you does use pyserial
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.
I followed the instructions from http://www.hobbytronics.co.uk/raspberry-pi-serial-port (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?
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.
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.
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.
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.
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?
It means there is no FLASH chip installed on the Moteino.
i think i almost got it, its just now the motionmote sketch is giving me trouble. when i try to compile it it gives me this error:
Arduino: 1.0.6 (Windows 7), Board: "Moteino"
LowPower\LowPower.cpp.o: In function `LowPowerClass::idle(period_t, adc_t, timer2_t, timer1_t, timer0_t, spi_t, usart0_t, twi_t)':
C:\Users\Sam\Documents\Arduino\libraries\LowPower/LowPower.cpp:153: multiple definition of `LowPowerClass::idle(period_t, adc_t, timer2_t, timer1_t, timer0_t, spi_t, usart0_t, twi_t)'
LowPower.cpp.o:C:\Users\Sam\AppData\Local\Temp\build3126858160797770351.tmp/LowPower.cpp:153: first defined here
LowPower\LowPower.cpp.o: In function `LowPowerClass::adcNoiseReduction(period_t, adc_t, timer2_t)':
C:\Users\Sam\Documents\Arduino\libraries\LowPower/LowPower.cpp:515: multiple definition of `LowPowerClass::adcNoiseReduction(period_t, adc_t, timer2_t)'
LowPower.cpp.o:C:\Users\Sam\AppData\Local\Temp\build3126858160797770351.tmp/LowPower.cpp:515: first defined here
LowPower\LowPower.cpp.o: In function `LowPowerClass::powerDown(period_t, adc_t, bod_t)':
C:\Users\Sam\Documents\Arduino\libraries\LowPower/LowPower.cpp:586: multiple definition of `LowPowerClass::powerDown(period_t, adc_t, bod_t)'
LowPower.cpp.o:C:\Users\Sam\AppData\Local\Temp\build3126858160797770351.tmp/LowPower.cpp:586: first defined here
LowPower\LowPower.cpp.o: In function `LowPowerClass::powerSave(period_t, adc_t, bod_t, timer2_t)':
C:\Users\Sam\Documents\Arduino\libraries\LowPower/LowPower.cpp:653: multiple definition of `LowPowerClass::powerSave(period_t, adc_t, bod_t, timer2_t)'
LowPower.cpp.o:C:\Users\Sam\AppData\Local\Temp\build3126858160797770351.tmp/LowPower.cpp:653: first defined here
LowPower\LowPower.cpp.o: In function `LowPowerClass::powerStandby(period_t, adc_t, bod_t)':
C:\Users\Sam\Documents\Arduino\libraries\LowPower/LowPower.cpp:737: multiple definition of `LowPowerClass::powerStandby(period_t, adc_t, bod_t)'
LowPower.cpp.o:C:\Users\Sam\AppData\Local\Temp\build3126858160797770351.tmp/LowPower.cpp:737: first defined here
LowPower\LowPower.cpp.o: In function `LowPowerClass::powerExtStandby(period_t, adc_t, bod_t, timer2_t)':
C:\Users\Sam\Documents\Arduino\libraries\LowPower/LowPower.cpp:797: multiple definition of `LowPowerClass::powerExtStandby(period_t, adc_t, bod_t, timer2_t)'
LowPower.cpp.o:C:\Users\Sam\AppData\Local\Temp\build3126858160797770351.tmp/LowPower.cpp:797: first defined here
LowPower\LowPower.cpp.o: In function `__vector_6':
C:\Users\Sam\Documents\Arduino\libraries\LowPower/LowPower.cpp:855: multiple definition of `__vector_6'
LowPower.cpp.o:C:\Users\Sam\AppData\Local\Temp\build3126858160797770351.tmp/LowPower.cpp:855: first defined here
LowPower\LowPower.cpp.o:C:\Users\Sam\Documents\Arduino\libraries\LowPower/LowPower.cpp:153: multiple definition of `LowPower'
LowPower.cpp.o:C:\Users\Sam\AppData\Local\Temp\build3126858160797770351.tmp/LowPower.cpp:153: first defined here
i know, its a lot, but i have no idea what it means. do you have any idea?
Looks like you have conflicting LowPower libraries. Make sure they are installed correctly and ONLY 1 instance is present in your Arduino/libraries folder.
Hmmm.... When I have the gateway hooked up to the Pi and I listen to the serial port it will say stuff like that it's listening and it can't find the flash chip. But when I hook up the MotionMote to the Pi and listen to it, nothing is ever there.
Can you try to take it one by one and solve each issue at a time?
What exactly is not working?
Can you use a PC and Arduino IDE instead of a Pi? Consider the Pi the end application, in the meantime try to get started with the Moteinos on a PC to get a feel how they work.
I'm using the arduino ide on my Pc too, I just happen to be using it on my Pi that time. My problem is I cannot seem to get my motionmote and my gateway to talk to each other. I've checked the settings, which are correct.
Did you try to load the Gateway sketch on your gateway and Node sketch on the MotionMote?
Did you double check all the settings in the sketches to make sure they match the hardware settings? Did you do this on your Pc?
Yes yes and yes. I'm already using the gateway for one moteino, and switching out the node sketch instead of the motionmote sketch makes no difference. While I double check the settings I'm going to try and change the settings from 868 to 915 mhz and see if that makes a difference.
They have to be the same frequency.
*sigh* I figured it out. While I was checking the settings I found out that the encryption key had to be 16 characters long, and I only had 10. I can't believe I never noticed this before, and therefore I'm very story for wasting your time on all of this. Then only thing now is to program it, and i know you told me before to look at your sump pump alert example, but thats really confusing with all that graphing code in there. All i want it to do it when theres a new message send a text that contains that message. what i'm not sure about is how i would get it to run the program when it receives a new message. i used this script https://github.com/iinnovations/iicontrollibs/blob/master/mote/piserialtest.py (https://github.com/iinnovations/iicontrollibs/blob/master/mote/piserialtest.py) and it only worked once. when i tried it again nothing would show up, and besides, the script checking the port so often that it is using up all the cpu on my pi and i only really need to check the port maybe every minute or so. i tried the other scripts that are in the same folder as that one but they don't work either.
Well glad you figured that out.
As for the SMS stuff .. that is about 2 years old now and it's basically an example script. There are potentially many ways of sending an SMS. That script used a gmail API to send an email to your carrier phone address which is basically your SMS address, that's all ...
OK this is my last question related to this (I hope) and if you can't answer it its fine I can work around it. I wrote a script for sending SMS when there's mail and displaying information on the oled screen when theres mail, my only concern is sometimes when I run the script, it doesn't pick up new lines on the serial port. After restarting the script one or two times it eventually works, and I could just leave the script running indefinitely, but I still would like to know why that happens.
You mean your script doesn't pick up the output from serial?
I think it could be the way you're reading the input from serial. Watch out for new lines (if you send any new line characters from the moteino). Then in python you can read 1 line at a time or just keep reading until certain criteria is met. I usually just read 1 line at 1 time. That means every piece of output (every phrase) from moteino has to end with newline, so that the script knows when to stop reading. Again, I've done that in my example, you can probably follow that. Otherwise I can't think of anything else. As long as you restart the script it should release/relock the serial port and just work.