|
Post by papa on Jun 4, 2016 21:58:06 GMT
Anarduino miniwirelesses (MW) are pretty neat Arduino compatibles: 3.3 volts, small size [33 x 23mm (1.3 x 0.9in)], installed RFM69 radio, 128mb SPI Flash Memory, Real Time Clock. Moteinos are another neat, similar project but according to my calculations, while a miniwireless presently costs $19.20, a comparably equipped Moteino costs $28.28 shipped.
Again MWs are something like a Moteino & cheaper, but their documentation & realized possibilities do not seem as far along. One of those tantalizing possibilities is Wireless Programming (WP): From a computer send Arduino code wirelessly to a node's SPI Flash Memory which a tweaked bootloader moves into sketch memory & restarts, the node now running the newly installed sketch.
Apparently, wireless programming has been done on a miniwireless, but I could not find all the complete & ready pieces for doing it.
In this thread, I'll do my best to provide that complete documentation for wirelessly programming a miniwireless node with a demo sketch. Farther in this thread I'll posted the WP necessary code to add to a computourist style node plus a full sketch with a wireless programming option.
|
|
|
Post by papa on Jun 5, 2016 0:10:16 GMT
Wirelessly Program (WP) an Anarduino Miniwireless Node Outline
- Obtain a WP-compatible bootloader for miniwireless (MW) & related boards.txt entries. - Burn the bootloader on an Anarduino miniwireless - Obtain necessary MW-compatible libraries (similar, but different from Moteino) - Obtain & as necessary build a 3.3 volt Arduino compatible (not necessarily a MW) to run the WirelessProgrammingAnarduino_Gateway sketch. (This is in addition to the main computourist style Gateway for the whole RFM69 network.) - Obtain & upload a MW-compatible sketch for a WirelessProgrammingAnarduino_Gateway on a 3.3 volt Arduino compatible - Obtain & upload a MW-compatible sketch for a WirelessProgramming_node to a MW - (?? Experiment a bit with the WP_node while it's connected to USB & the Serial Monitor is running at 115200 baud. See the sketch for commands you can give for reading, writing, & erasing the MW's SPI flash memory.) - Notice the LED blink rate on the node. - Disconnect the WP-node from USB & connect it to power other than USB. - Download & install Python 2.7 (the needed Python script is not yet compatible with Python 3.x) - Download & install pyserial for python 2.7 - Obtain & place Wireless Programming script for python - Connect WirelessProgramming_Gateway to the USB of the computer hosting Python - Noticeably change the LED blink rate of the WirelessProgramming_node sketch - ONLY compile (do NOT upload) the new version of the WirelessProgramming_node sketch - Find the .hex file the IDE built for new version of the WirelessProgramming_node sketch, copy it to the Python folder, & give it a short name. - Have information needed for WP: NodeID of the target node, shortened name of the .hex file, & the serial port to which the WP_Gateway is connected. - Open Windows cmd (Linux Terminal?) & run the commands to wirelessly program the target node on a miniwireless & watch transfer evidence on the screen scroll & finish. - Notice that the WP_node's LED blinks at the new rate. - Insert key entries from the WP_node sketch into other node sketches so they can be wirelessly (re-)programmed.
|
|
|
Post by papa on Jun 5, 2016 0:47:52 GMT
Burning DualOptiboot for miniwireless, "The Easy Way" Using the Arduino IDE (Necessary Setup)
There is also a "Hard Way" that is slower, but might be more reliable if one is having problems. It is documented in this thread starting with the Jun 1, 2016 at 8:09pm. That said, the following Easy Way has been quick & reliable for me (once set up). The following is a bit tedious. Once set up, if it works, this is a much easier & faster way to burn the bootloader than the Hard Way. As shown in detail above, this method: 1) uploads the IDE Example sketch ArduinoISP to a 3.3 volt Arduino compatible (Bunono Uno?). 2) connects a miniwireless to that 3.3 volt Arduino (see above table for wiring). 3) & connects the 3.3 volt Arduino to your computer via USB. Important: If your Arduino IDE is open, close it.Find the main boards.txt file that was installed with your Arduino IDE. Mine is at C:\Program Files (x86)\Arduino\hardware\arduino\avr. Open that boards.txt (about 25 or 26 kb) in a good text editor like Notepad++. My installed boards.txt starts like this ... In boards.txt, scroll down below the Ardino Uno sections that starts & ends like this (... indicating omitted lines): Just after the #####... that ends the Uno section & just before the Arduino Duemilanove or Diecimila section, paste in the following lines: ^^ the above added lines were updated on 6/9/2016. To try the (larger) debugging version of the bootloader (& give up 1024 more bytes of sketch memory), find the 3 cases above of "# For debug bootloader ..." & to the start of the line above it, add # & at the start of the line below it, delete #. For example, for the first case, you should end up with: #miniwireless.bootloader.high_fuses=0xda # For debug bootloader ... miniwireless.bootloader.high_fuses=0xd8 Here is a handy fuse calculator. Set it to ATmega328P. Near the bottom, one can enter a set of EXTEND, HIGH, & LOW fuse settings & then above see what those settings encode. On your computer find where the Arduino IDE install put the bootloaders folder. On my Windows computer, it's at C:\Program Files (x86)\Arduino\hardware\arduino\avr\bootloaders. If you don't have that folder create it in your equivalent of C:\Program Files (x86)\Arduino\hardware\arduino\avr\. In your equivalent of C:\Program Files (x86)\Arduino\hardware\arduino\avr\bootloaders, create a new miniwireless folder (hereafter called the "miniwireless bootloader folder." Download the whole Mr. Light DualOptiboot zip file & note where it stores on your computer. To the miniwireless bootloader folder, copy only optiboot_miniwireless.hex & optiboot_miniwireless_debug.hex (found in the zip file's AtmelStudio folder). Open the Arduino IDE. Through its menu, click to Tools/Board. Near the top of the list you should see something like Arduino Yun, Arduino/Genuino Uno, AND Anarduino_MiniWireless ... Select Anarduino_MiniWireless, but stop there for now.
|
|
|
Post by papa on Jun 5, 2016 1:13:20 GMT
Burning DualOptiboot for miniwireless, "The Easy Way" Using the Arduino IDE (Necessary Hardware Setup #2)
Important: Have the FTDI programmer & its USB cable disconnected from miniwireless & computer. Don't risk frying your boards by having two power sources connected to them later. I believe that for the sake of the MW's RFM69 radio, its important (for burning the MW bootloader) to use something like an Arduino compatible that runs throughout on 3.3 volts. I'm confident this way is safe. To a Buono Uno switched to 3.3 volts, upload File/Examples/ArduinoISP. Unplug Buono it from USB Between Buono Uno & miniwireless, make the connections in the table below using male to male jumper cables. I used the same colors of wires as the entries' backgrounds to help keep things straight.Since miniwireless 3.3v, d5 (via 10K ohm resistor) & d10 (via 10K ohm resistor) all need 3.3v from the Buono, connect the Buono's 3.3v socket to the positive power rail of a solderless breadboard (BB). Then to the BB's positive power rail, connect MW's 3.3v, d5, & d10 (again the last two digital pins through a 10K ohm resistor). The d5 & d10 pullups are to keep possible miniwireless signals there from interfering with the bootloader burning. ^^ Click on table for larger view I adapted the above table from here though it resembles other Arduino as ISP hookups I've used. Check all your connections especially anything related to 3.3 volts or GND.
|
|
|
Post by papa on Jun 5, 2016 1:21:20 GMT
"Doing the Deed" Burning DualOptiboot for miniwireless, "The Easy Way" Using Arduino IDE
The following presupposes you have already completed ALL the above "Easy Way" posts (boards.txt) additions, downloads, wiring). This means your miniwireless is wired to the Arduino as ISP 3.3 volt board using the connections listed in the last post. In turn connect the Arduino as ISP 3.3 volt board to your computer's USB.Open the Arduino IDE. Using the File/Preferences/Settings menu, choose "Show verbose output during ... upload." Using Tools/Board menu, make sure the Board is Anarduino_MiniWireless. Using Tools/ Programmer menu, select Arduino as ISP. Using Tools/Port:, make sure the programming Arduino has a port assigned.
Again, be sure to set Tools/Programmer to Arduino as ISP. OK, now you should be ready for Tools/Burn Bootloader. Pretty quickly (much more so than the Hard Way mentioned above), it should be finished, one hopes successfully. When successful, reset Tools/Programmer to AVR ISP.
If the burn is not successful, click [copy error messages] & paste them to a text editor where you can more easily study them. See if you can learn from the error messages & correct the problem. Above all check that you followed the above instructions.
|
|
|
Post by papa on Jun 5, 2016 1:31:04 GMT
Testing the miniwireless with the new bootloader (DualOptiboot): Will sketches upload to it?
Important: Disconnect the Arduino as ISP from the computer's USB. Disconnect all connections between the miniwireless & the other board. Connect the FTDI power / programmer to the miniwireless & connect the FTDI to the computer's USB. Open a known working sketch in the Arduino IDE (one that outputs to the Serial Monitor?). Which board will you set in Tools/Board? For me, after burning DualOptiboot for miniwireless using the above Easy Way methods, the board setting that worked is Anarduino_MiniWireless Upload the sketch. Did the upload succeed? Does the programmed miniwireless work as expected? If successful this completes these necessary steps for Wirelessly Programming a miniwireless: - Obtain a WP-compatible bootloader for miniwireless (MW) & related boards.txt entries. - Burn the bootloader on an Anarduino miniwireless
|
|
|
Post by papa on Jun 5, 2016 1:36:40 GMT
Wirelessly Program (WP) an Anarduino Miniwireless (MW) Node
I got much help for the following steps in this thread from the first half of this video about wireless programming on Moteinos, but I had to hunt & tweak what was needed for miniwireless. - Obtain necessary MW-compatible libraries (similar, but different from Moteino) Important: Do NOT use the Moteino versions of these two libraries. Use these miniwireless versions I found under the name of rrobinet: Download the SPIFlashA.h library here. Download the WirelessAnarduinoHEX69.h library here. Note the folder where their .zip files are stored. In the Arduino IDE, use the menu Sketch/Include Library/Add .zip library... Navigate to the folder holding the two libraries .zip files. One at a time, select & open them to install.
|
|
|
Post by papa on Jun 5, 2016 2:04:52 GMT
Wirelessly Program (WP) an Anarduino Miniwireless (MW) Node
- Obtain & as necessary build a 3.3 volt Arduino compatible (not necessarily a MW) to run the WirelessProgrammingAnarduino_Gateway sketch. (This is in addition to the main computourist-style Gateway for the whole RFM69 network.) Added 12/17/2016: To be clear, using this WirelessProgrammingGateway & the wirelessly programmable node offered below requires a computourist style gateway. See here for documentation on building & programming such a gateway. Have a 3.3 volt Arduino compatible with a RFM69 radio installed: an Arduino Miniwireless with radio already installed or the following with an added RFM radio: a Buono Uno switch to 3.3 volts, a 3.3 volt Pro Mini or ... If you're not using a Miniwireless, solder wires to your RFM radio so you can connect it to the Arduino compatible according to this table: RFM69 radio
| Arduino compatible
| 3.3 volts >
| 3.3 volts
| GND >
| GND | DIO0 >
| D2 | NSS >
| D10 | MOSI >
| D11 | MISO | D12 | SCK | D13 |
To only ANT on the RFM69, connect wire (about 3 inches for RFM69 915MHz) for an antenna. Optional: You can also solder a 100 ohm resistor to an LED. To Arduino GND, connect the wire that leads to the slightly flat side of the LED base. To D9, connect the other wire. When the node is programmed, this LED will pulse with a heartbeat indicating it is waiting for code to pass on wirelessly.
|
|
|
Post by papa on Jun 5, 2016 2:16:45 GMT
Wirelessly Program (WP) an Anarduino Miniwireless (MW) Node
- Obtain a MW-compatible sketch for a WirelessProgrammingAnarduino_Gateway on a 3.3 volt Arduino compatible (not necessarily a MW) (This is in addition to the main Gateway.) WirelessProgrammingAnarduino_gateway_pub.ino (5.71 KB) << Download this WirelessProgrammingAnarduino_gateway_pub sketch. It's mostly from the Lowpowerlab.com version for Moteinos, but has key edits I made for the miniwireless based on what rrobinet posted. Necessary customizing for the WirelessProgrammingAnarduino_Gateway sketch: Line 53, leave NODEID as 254 or change, but use a number unique in your network. Line 54, match this NETWORKID to the rest of your node network
Lines 56-58, UNcomment only what matches your RFM69 radio's frequency
Line 59, replace xxxxxxxxxxxxxxxx with the 16 byte ENCRYPTKEY you use in your network.
Line 60, UNcomment ONLY if your RFM69 radio's part # includes an "H" for high power.
Save the sketch. Connect the WirelessProgrammingAnarduino_Gateway node to your computer's USB & upload the sketch. If the serial monitor is opened, it will output "Start wireless gateway..." If you installed the optional LED (post above), it should pulse with a heartbeat indicating it is waiting for code to pass on wirelessly.
For now, disconnect the WirelessProgrammingAnarduino_Gateway node from USB.
|
|
|
Post by papa on Jun 5, 2016 3:01:25 GMT
Wirelessly Program (WP) an Anarduino Miniwireless Node
- Obtain & upload a MW-compatible sketch for a WirelessAnarduinoProgramming_node (WAP) to a MW In the Arduino IDE, use the menu File/Examples & scroll to probably near the bottom to WirelessAnarduinoHEX69-master, click on that & then on WirelessAnarduinoProgramming_node. Necessary customizing of the WirelessAnarduinoProgramming_node: (Similar to customizing of the Gateway sketch above)
Line 44, assign a unique NODEID for this node Line 45, match the NETWORKID of the rest of your network, probably 100 Lines 47-49 UNcomment only what matches your miniwireless' RFM69 radio frequency comment the other frequencies Line 50, UNcomment only if your RFM69 radio's part # has an "H" for high power. Line 53, use same ENCRYTKEY as the rest of your network Line 54, BLINKPERIOD is originally 500. Change it to be much higher (1000 ?) or lower (200 ?) Save the customized sketch & Via an FTDI programmer/power, upload the sketch to the miniwireless. Notice the LED blink rate on the node. - ?? Experiment a bit with the WAP_node while it's connected to USB & the Serial Monitor is running at 115200 baud. See the sketch for commands you can give for reading, writing, & erasing the MW's SPI flash memory. In the sketch, see lines 91ff for the one letter command codes to enter at the top of the Serial Monitor. - Important: Disconnect the WirelessAnarduinoProgramming_node from USB & connect it to power other than USB. It won't offer anything useful for your computourist-style OpenHAB network, but it should be ready to be programmed wirelessly.
|
|
|
Post by papa on Jun 5, 2016 3:29:48 GMT
Wirelessly Program (WP) an Anarduino Miniwireless Node (Updated 6/7/2014)
At a minimum, you need to download & install Python 2.7 ( not Python 3.x because the python script we'll use is not ready for it), pyserial for python 2.7, & a Wireless Programming python script. For Windows:- You can use a Graphic User Interface suite that Luis Rodrigues (thanks!) packaged for Moteinos that will work for miniwireless with the above preparations: From here, download Moteino_Wireless_GUI_V2.0.zip. From that .zip file's Program folder, extract & install python & pyserial. - From that .zip file's Moteino_WP_GUI folder also extract Moteino_Wireless_GUI.exe to the folder where you installed python (c:\python27 ??). If desired you can rename the program to Miniwireless_WP_GUI.exe For Linux: - From here, get python 2.7. From here, get pyserial 2.7. For all operating systems: For the Wireless Programming python script: Luis Rodrigues tweaked Lowpowerlab.com's original WirelessProgramming.py script & here is a version where I replaced "Moteino" with "miniwireless." Extract & place it in the python folder. >> WirelessProgramming.py (7.9 KB) P.S. for Windows, here's the official sources of Python & pyserial if needed: - From here, download & install Python 2.7 (the needed Python script is not yet compatible with Python 3.x). Make note of the folder where Python installs, hereafter called "the Python Folder." - From here, download & install pyserial for python 2.7
|
|
|
Post by papa on Jun 5, 2016 3:49:32 GMT
Wirelessly Program (WP) an Anarduino Miniwireless Node (Updated 6/7/2016) To use Luis Rodrigues' Windows GUI, skip to the next post.
- In the python folder, rename the python script (WirelessProgramming.py) to the shorter name WP.py. - Connect the WirelessProgrammingAnarduino_Gateway to the USB of the computer hosting Python - Noticeably change the LED blink rate of the WirelessAnarduinoProgramming_node (WAP) sketch, line 54. - In the Arduino IDE, use the menu file/preferences to check select "Show verbose output during: compilation." - ONLY compile (do NOT upload) the new version of the WirelessAnarduinoProgramming_node sketch. - In the output at the bottom of Arduino IDE, select & copy the bottom several lines & paste them in the text editor. In that pasted text, copy the path to the .hex file that the IDE built for the new version of the WirelessAnarduinoProgramming_node sketch. Use the path, to find & copy the .hex file to the Python folder, & give it a short name. - Have the information needed for Wireless Programming: NodeID of the target node, shortened name of the .hex file, & the serial port to which the WirelessProgrammingAnarduino_Gateway is connected. - Notice the WAP_node's present LED blink rate - Open Windows cmd (Linux Terminal?) change directory to the Python folder. Run the commands to wirelessly program the target node on a miniwireless & watch transfer evidence on the screen scroll & finish. For example, the following command would run the python script WP.py to wirelessly program target node 81 with the file Demo_150 (LED blink rate 150) via the serial port COM3 (where the WirelessProgrammingAnarduino_Gateway is connected): python WP.py -t 81 -f Demo_150.hex -s COM3- Notice that the WirelessAnarduinoProgramming_node's LED blinks at the new rate. If successful, you've wirelessly programmed a node. Hooray!
|
|
|
Post by papa on Jun 7, 2016 17:04:57 GMT
Wirelessly Program (WP) an Anarduino Miniwireless Node Using Luis Rodrigues' Windows GUI:
- Connect the WirelessProgrammingAnarduino_Gateway to the USB of the computer hosting Python - Noticeably change the LED blink rate of the WirelessAnarduinoProgramming_node (WAP) sketch, line 54. - In the Arduino IDE, use the menu file/preferences to check select "Show verbose output during: compilation." - ONLY compile (do NOT upload) the new version of the WirelessAnarduinoProgramming_node sketch. - Have the information needed for Wireless Programming: Destination node number (NODEID) & the COM Port number to which the programming Moteino (for us: WirelessProgrammingAnarduino_Gateway) is attached. - Notice the WAP_node's present LED blink rate - In the Python folder, run the GUI program. As prompted, provide the node number & the Gateway's serial port. Next the GUI program will take you to the temp folder holding compilation files to get the HEX file to send. Sort the folders with latest dates at the top. Open the top, most recent folder. Look for the smallest file that ends in .hex & does NOT include bootloader in its name. Select that file. Keep going to start the process. If the program stops with a timeout, start the program again. If it works, much stuff will scroll the screen & it will end with "Great Success." For example, the following inputs would wirelessly program target node 81 with the file Demo_150 (LED blink rate 150) via the serial port COM3 (where the WirelessProgrammingAnarduino_Gateway is connected): Destination node: 81 COM port: 3 HEX file to send: Demo_150.hex - Notice that the WirelessAnarduinoProgramming_node's LED blinks at the new rate. If successful, you've wirelessly programmed a node. Hooray! The next two posts will list sketch lines needed for Wireless Programming first on an Anarduino miniwireless & second on a Moteino. The post after that will offer a complete multi-choice sketch with Wireless Programming options for miniwireless & Moteino.
|
|
|
Post by papa on Jun 7, 2016 19:45:49 GMT
After the Preparations in the Above Posts, Adding Wireless Programming to a Computourist-Style Node Sketch For Anarduino miniwireless (Tested & Working)
1) Just before the line "// CONFIGURATION PARAMETERS," add lines like this ... // #define MWMEM // to use Anarduino miniwireless SPI Flash memory, incl wireless programming // Caution: SLEEPY probably negates wireless programming One UNcomments ^^ the 1st line (delete //) to activate using miniwireless SPI Flash memory. 2) A little after a configuration area, add a section like this... #ifdef MWMEM // Anarduino miniwireless, with SPI Flash Memory different from Moteino #include <SPIFlashA.h> //get it here: github.com/rrobinet/SPIFlashA. #include <WirelessAnarduinoHEX69.h> //get here: github.com/rrobinet/WirelessAnarduinoHEX69 #define FLASH_SS 5 // FLASH SS on D5 for miniWireless. ///////////////////////////////////////////////////////////////////////////// // SPI_CS - CS pin attached to SPI flash chip (5 for miniWireless) // MANUFACTURER_ID - OPTIONAL, 0x12018 SPANION S25FL127S ///////////////////////////////////////////////////////////////////////////// SPIFlashA flash(FLASH_SS, 0x12018); // For Anarduino miniWireless with SPANION S25FL127S #endif // ifdef MWMEM ^^ One needs to download the two .h libraries listed & install their .zip files via the Arduino IDE. Find where the receiveData() function is declared. Its first lines are ... /*======== RECEIVEDATA function: receive data from gateway over radio */ // bool receiveData() { bool validPacket = false; if (radio.receiveDone()) // check for received packets {
^^ On the next line after the "{" at the end of the above section, 3) insert the following lines ... // check if wireless programming gateway is trying to reach this node // to wirelessly upload it a new sketch #ifdef MWMEM // miniwireless CheckForWirelessHEX(radio, flash, true); // Key to wireless programming #endif MWMEM
^^ After this above new section, original lines from the receiveData() function should continue, starting with the following lines ... if (radio.DATALEN != sizeof(mes)) // wrong message size means trouble #ifdef DEBUG Serial.println("invalid message structure..") The setup() function starts like this ... //===================== SETUP function====================== void setup() { ^^ Somewhere soon after this line, 4) add the following lines... #ifdef MWMEM // initialize miniwireless SPI Flash memory so it's receptive flash.initialize() ; #endif // ifdef MWMEM
If you've done the preparations earlier in this thread & added the lines in this post, you should have added a Wireless Programming option to a miniwireless node.
|
|
|
Post by papa on Jun 8, 2016 0:12:03 GMT
After the Preparations in the Above Posts, Adding Wireless Programming (WP) to a Computourist-Style Node Sketch For Moteino (NOT Tested)
In the previous post, note 4 action items, numbered 1) - 4) in bold. This post lists the Moteino WP changes in relation to 1) - 4). A) Just after the # 1) addition of lines in the last post, add lines like this ... // #define MOTEMEM // to use Moteino SPI Flash memory, incl wireless programming // Caution: SLEEPY probably negates wireless programming One UNcomments ^^ the 1st line (delete //) to activate using Moteino SPI Flash memory. B) Just after the # 2) addition of lines in the last post, add a section like this... #ifdef MOTEMEM // LowPowerLab.com Arduino, possibly with SPI Flash Memory #include <SPIFlash.h> //get here: https://www.github.com/lowpowerlab/rfm69 #include <WirelessHEX69.h> //get here: https://www.github.com/lowpowerlab/rfm69 #ifdef __AVR_ATmega1284P__ #define FLASH_SS 23 // Moteino MEGAs have FLASH SS on D23 #else #define FLASH_SS 8 // FLASH SS on D8 for Moteino #endif // ifdef __AVR_ATmega1284P__ ///////////////////////////////////////////////////////////////////////////// // flash(SPI_CS, MANUFACTURER_ID) // SPI_CS - CS pin attached to SPI flash chip (8 for Moteino) // MANUFACTURER_ID - OPTIONAL, 0x1F44 for adesto(ex atmel) 4mbit flash, Moteino // 0xEF30 for windbond 4mbit flash, Moteino // 0xEF40 for windbond 16/64mbit flash, Moteino ///////////////////////////////////////////////////////////////////////////// SPIFlash flash(FLASH_SS, 0xEF30); //EF30 for windbond 4mbit flash, Moteino #endif // ifdef MOTEMEM ^^ One needs to download the two .h libraries listed & install their .zip files via the Arduino IDE. Find where the receiveData() function is declared. Its first lines are ... /*======== RECEIVEDATA function: receive data from gateway over radio */ // bool receiveData() { bool validPacket = false; if (radio.receiveDone()) // check for received packets { ^^ On the next line after the "{" at the end of the above section, C) Just after the #3) addition of lines in the last post, insert the following lines ... #ifdef MOTEMEM // miniwireless CheckForWirelessHEX(radio, flash, true); // Key to wireless programming #endif MOTEMEM
^^ After this above new section, original lines from the receiveData() function should continue, starting with the following lines ... if (radio.DATALEN != sizeof(mes)) // wrong message size means trouble #ifdef DEBUG Serial.println("invalid message structure..") The setup() function starts like this ... //===================== SETUP function====================== void setup() { ^^ Somewhere soon after this line, D) Just after the code lines in #4) above, ( corrected 12/17/2016), add the following lines ... #ifdef MOTEMEM // initialize Moteino SPI Flash memory so it's receptive flash.initialize() ; #endif // ifdef MOTEMEM If you've done the preparations earlier in this thread & added the lines in this post, I hope you've added a Wireless Programming option to a Moteino node.
|
|
|
Post by papa on Jun 8, 2016 0:32:04 GMT
Depending on Preparations in the Above Posts,A Multi-Choice, Computourist-Style Node SketchWith Wireless Programming (WP) Options for Anarduino miniwireless (tested & working) & for Moteino (NOT Tested)
New, corrected version as of 12/17/2016
computourist_node_v2.2Mf2_choices_pub.ino (59.3 KB) ^^ This sketch includes the Wireless Programming options from the last two posts AND other options. For wireless programming, this Mf2 version should correct a serious flaw.The approach here is "One Sketch - Many Functions:" Choose one to a few desired functions (too many may cause problems) for programming an Arduino compatible to be a DIY Home Automation node. One selects options by UNcommenting #define lines (delete starting //) & deselects other options by commenting #define lines (add/leave starting //).
For using sketch options besides wireless programming, see the documentation for other utilizations of the multi-choice sketch approach: [ Multi-Choice End Node, Garage & Door End Nodes, Node Senses Temps in Enclosed or Liquid Areas, Water Level Monitor Node, & Battery-Powered Node for Mailbox, etc.] Needed Customizations for the Above Sketch including Wireless Programming:
For example, let's assume you want to create the last garage node in my thread Garage & Door End Nodes, & want to add wireless programming to it. See that other thread for wiring the node. Then use the following customizations with the sketch in this post: As the sketch's line 2 notes, customizing possibilities starts on line 142. UNComment Line 184 so it reads #define SWITCH2B [no // at its start] Uncomment Line 190 so it reads #define MWMEM [for miniwireless] ... OR UNcomment Line 193 so it reads #define MOTEMEM [for Moteino] Line 196, probably uncomment #define GW24 to use computourist's latest gateway Line 198, choose a unique NODEID for this node (this number will be how you target the node for wireless programming. Line 199, use the same ENCRYPTKEY as in your main Gateway & other nodes in your home automation network Line 200, probably UNcomment it so you can see debugging info on the Arduino IDE's Serial Monitor Lines 202-204, uncomment only ONE frequency to match your RFM69 radio Line 205, uncomment only if your RFM69 radio has an H in its part # Then for the first set up of this node, via a USB connection, upload the customized sketch to the miniwireless or Moteino. After that you should be able to use the above posts to wirelessly reprogram the node.
|
|
|
Post by papa on Jun 10, 2016 2:15:35 GMT
I updated the board.txt additions for Jun 2, 2016 at 7:38pm post in the Wireless Programming thread & Jun 4, 2016 at 7:47pm post in this thread. The regular bootloader is 1K, 1024 bytes & the debugging bootloader is more than 1K so the next available bootloader reserve size is 2K or 2048 bytes. The added boards.txt always allowed 1K for the regular bootloader, but now with the update the available sketch memory matches at 31K, 31744. The update also explains how to burn the debugging version of the bootloader.
|
|
|
Post by papa on Dec 17, 2016 17:14:41 GMT
A new version of the Multi-Choice node sketch is offered above in the Jun 7, 2016 at 7:32pm post.
For wireless programming, this should correct a small, but serious flaw:
I learned that a node with the earlier sketch version would wirelessly reprogram itself AND restart the new sketch.
However, if the node lost power, it would NOT restart the sketch when power was restored unless the reset button was pushed. This is a serious flaw, since a miniwireless' small size encourages us to put it in confined places where pushing the reset button is a hassle.
The problem in the previous version was how I sent the flash.initialize() command to the miniwireless' external SPI flash memory. I had it too early in void setup() & in DEBUG mode, flash.initialize() was sent twice.
In the process of researching this problem, I reviewed, USED, & tweaked the above documentation. I believe it is accurate, EXCEPT not having a Moteino, I do not know if that part is correct.
|
|