First off let me start by just saying how excited I am about these boards. This is obviously just my opinion, but I have used more arduino clones then I can count, and the moteinos are absolutely brilliant. I'm already ripping teensy boards out of my automation equipment.
That being said I'm having a little trouble with the wireless uploading. I'm pretty sure this is purely a lack of understanding on my part and I think I just need a little guidance. I am able to get the moteinos talking back and forth, verified the connections are good, set the settings in the sketch for the proper flash chip, etc. I have the node sketch uploading to one moteino, and I have the gateway sketch uploaded to another. Here's where my confusion starts.... How do I now use the gateway board to receive the sketch from the IDE and pass it along? I realize I cant just upload from the IDE as that is just going to rewrite the gateway node sketch. I'm obviously missing something here.
*** LIGHT BULB MOMENT ****
I just remembered as I was falling asleep last night my brain recalled something to do with there being a python script??? Am I on the right track? Normally I would go research before posting, but I'm gonna go ahead and post this now in case I am wrong, or just in case there is someone else who gets caught at this point as well. Thanks again for such an awesome contribution the arduino world!
Basically the IDE has no knowledge how to do wireless programming .. I wish :P
So you have to use another method to tell the gateway Moteino how to transmit it. The gateway sketch, as is, expects a certain "protocol", as described in my wireless programming posts.
Here's all the info I posted on this topic: http://lowpowerlab.com/blog/category/moteino/wireless-programming/ (http://lowpowerlab.com/blog/category/moteino/wireless-programming/)
So yeah, you are missing the python script which is found here: https://github.com/LowPowerLab/WirelessProgramming
Instructions are within :)
Lars has shared some of his experience with wireless uploading in this thread: http://lowpowerlab.com/forum/index.php/topic,80.0.html (http://lowpowerlab.com/forum/index.php/topic,80.0.html)
Hope this helps, let me know how it goes...
O.K. getting closer I think. I apologize in advance for not being able to figure out what seems to be a rather simple process. I'm hoping it's just due to the fact that I've never used python before. In any case, here is my current progress and stumbling block...
(p.s. I did look over the blog post you linked and read the comments in the source codes and just not seeing the answers I think I'm looking for)
If I'm understanding correctly, the process is:
- Create a HEX file from a sketch (I'm unsure if this part is correct, and if it is, the only way I see to do this is to use the .hex file generated by the IDE from the temp folder?)
- **Install python if you want this to work ;) * *
- Run the python script from cmd line using desired parameters. )
I tried running the python script but I am getting an error back:
File "C:{MyFilePath}\WirelessProgramming.py" line 32
print "-d Set DEBUG=TRUE"
SyntaxError: invalid syntaxThis may very well be because I'm not understanding how to properly create/utilize the hex file. Again sorry for needing this broke down in this much detail, but I've never attempted uploading to an arduino in any way outside of and IDE. Thanks again for the help.
No need to apologize!
Yes, you create the HEX file from the IDE (turn on verbose compilation from the preferences to see where the HEX will be dumped - usually a temp folder).
Grab that hex and put it in the same directory as the WirelessProgramming.py script.
Then run the script with the optional parameters (tell it which serial port the gateway Moteino is).
If the target Moteino is on the same or other computer, you could also open a serial terminal to that to see the programming in progress.
That's a syntax error.
What version of Python did you install?
I have Python 2.7.3
Ahhhhhh... I now remember why I became so frustrated during my one attempt to explore python a while back. The inconsistency of syntax between python 2.6 and 3.0. 3.0 doesn't use print but rather print(). I will re-install 2.6 and continue working through this.
***EDIT***
now that I see your post I will install python 2.7.3 just to be safe
OK, making more progress! Now that there was finally something worth making me go through the pain of properly configuring python for a windows environment, I may actually get into it a bit. I am now able to execute the wirless.py file from cmd line and it attempts to start sending the file but I'm still getting errors.
I know there is some form of communication between the gateway and the node because I just get a general Moteino timeout error when the node is not powered on, but I am getting:
Moteino: [Timeout receiving FLASH image from SERIAL, aborting...FLX?OK]
Any guidance here would be much appreciated.
Oh... one other interesting observation... Passing arguments via command line doesn't seem to have any effect on the script when it is run... I had to change the filename, and com port in the file itself before I was able to get it to use these settings.
The target has to have a FLASH chip soldered on it.
It has to be ready to receive a wireless hex image - it should be loaded with the example sketch from here:
https://github.com/LowPowerLab/RFM69/tree/master/Examples/WirelessProgramming_node
The only thing this sketch does beside listening to incoming flash image is blink the LED.
The frequency and encryption key should be the same.
For arguments use "script.py -param value"
But hardcoding the values is also ok I guess, that's the least of your issues right now.
Yep, I have a flash chip on the node. I set the correct value for the flash chip manufacturer, and I get "Flash Init O.K." when I first power on the node.
However I have the RFM12B chips on these Moteinos so I'm using the node sketch found here:
https://github.com/LowPowerLab/RFM12B/blob/master/Examples/WirelessProgramming_node/WirelessProgramming_node.ino
No encryption key or frequency in that sketch (I believe because it's not used for these chips?)
I don't know if this has anything to do with the problem or not, but the sketch above does not have the SPIFlash included in it. I had to import the library to get it to compile. I assumed it was just a mistake that it had been left out, but maybe not.
Adding a screen cap just in case any of this gives some insight:
You're right, they were missing the #include <SPIFlash.h>
I made some changes to that lib, and forgot to add that to the examples.
Other than that, if you got the RFM12B or Moteino R2 then you should be good to go.
Still timing out at the gateway?
What does the target output on the serial?
Yeah still getting the same timeout. Does that error mean that the gateway is timing out while trying to get the image through its serial connection? Or does that mean it is timing out while waiting for something from the node?
Unfortunately, I only have one FTDI adapter so I can read the target input while sending from the gateway :(
(I probably should have thought that through a little better).
O.K., lets make things really fun. I was sitting at my desk reading through the different code examples to see if I missed anything else, while at the same time sending the python command to gateway node over and over (for no reason other then boredom), but then all the sudden...BOOM! I start getting a successful transmit. Of course, it only happened once and has now gone back to giving the same error as before. Does the sketch being uploaded need to retain the majority of code from the original node sketch (everything outside of the blinky loop portion) in order to continue to give it the ability to listen?
YAY! You just programmed an Arduino through thin air!
Feels good when things work eh?
Yes, the uploaded sketch replaces the previous sketch.
So you would need to add your code to the example sketch, then upload that. Then you can continually update it in place.
Yeah, I will say it's pretty amazing!
But..... I'm back at the same point again. I re-uploaded the node sketch to the node. saved the node sketch itself as the hex file, but still getting the same error as before... Which really boggles my mind now that I know everything seems to be correct to allow it to work. Nothing should come into play as far as radio interference when we're talking about them being inches away from eachother, right?
Also I just noticed that the you can see a clear indication that the two units are exchanging data as the nodes blinking light will stay on or stay off for the time period that the gateway is attempting to transmit, and then goes back to a steady blink as soon as the script timesout
Hmm ... they don't have to be that close, just within range.
Can you check what the output is at the target?
Try it with the example sketch which should be blinking the LED. What I usually do is compile that sketch with a SLOW and FAST blinking speeds, and I wirelessly reprogram the target by alternating between the HEXes so I get a visual feedback when the sketch was uploaded successfully.
When it fails, does it fail immediately or does the transmission start and then fails somewhere in the middle?
That attached image is pretty much what I get every time. It doesn't seem like it ever really starts the transmission at all. (except that one gloriously teasing time!). When I get home in a little bit I'm gonna try connecting the serial output from the node into a spare teensy and repeating the input back out the usb serial on the teensy.... yeah that should work, I think.
This to me looks like the gateway Moteino is not responding...
Not sure what else to suggest other than get latest code and libs from github if you haven't already done so. There have been some changes to this area not too long ago, also to the SPIFlash lib.
Moteinos are 3.3V levels, Teensy I believe is 5V, but if you only wire the Moteino-TX to the Teensy-RX you should be good, then run an echo sketch on the Teensy...
Partial update...
When I got home this evening I had to setup python on my lappy so I just figured I'd uninstall arduino, python, and all the related libraries and start from scratch just to be safe. Made sure I had all the latest files from github. I reloaded the node and gateway sketches and got the exact same response I had been seeing from my desktop all day. However, randomly and unpredictably, every 15 or so attempts everything will work. I've got it to work maybe 5 times now. I made sure to get a simultaneous success without reloading anything to the node to make sure the node hex I was uploading was not at fault after an initial sketch upload. The only change I made to the node and gateway sketches where to change the frequency to rf433, which I believe the antenna wire I received was cut to length for. The only other thing I'll mention even though I don't think it's related us that I've had to install pyserial after each python install assuming that was the correct serial module to use.
I have not yet attached to moteino to a serial input but I will be doing that soon and will let you know what I get.
I think the gateway Moteino might not be restarted by the python access.
Try this - right when you hit ENTER to run the script, short the RST and GND pins for a split second to cause a reset, see if that makes a difference.
Bottom line is that this should work every time, with virtually no fails, unless something unexpected happens during transmission.
I will try this shortly but if I think it's reseting because I get the serial print from the gateway each time that says "Start...", but I'm not sure if that really means it's reseting, I do know that when I upload a sketch from ide to the moteino they are not reseting so maybe so.