This How-To describes how to start experimenting with the Moteino R2 or R3. The R2 is a low power (10mw) 433mhz FSK transceiver. The R3 is 100mw. Moteinos come on a 1″x1.5″ PC board. It contains a microcontroller which is a clone of the popular Arduino Uno, based on the ATmega328. The PC board also contains a RFM12B (R2) or RFM69HW (R3) 433mhz FSK transceiver module, from HopeRF. Using a simple quarter wavelength (6-inch wire) antenna, the moteino R2 has a range of about 30 feet. The R3 has a (outdoor) range of about 400 yards.
What Hardware To Buy:
You’ll need to purchase two Moteino R2s ($19ea) or R3s ($20ea). I got the RFM69HW option on my R3s, for $1 more. You also need a single FTDI adapter board ($14.50) from http://lowpowerlab.com/shop. There are several other sources for the FTDI adapter from $5. You may want to order optional flash memory with your Moteinos ($4 extra), if you want to be able to upload firmware wirelessly into a Moteino that is not connected to your computer’s USB port using the FTDI-adapter. I didn’t get the optional flash memory. If you don’t already have one, you’ll need to order an optional USB-A to mini-B cable ($2.50) when you order your FTDI-adapter. Total cost: about $55 plus shipping.
Each moteino can be powered either through the FTDI-adapter board when it is plugged into your computer’s USB port, or using an external ac-adapter producing 4vdc to 9vdc (or a 9v battery). For my initial testing I used a “universal” ac-adapter from my junk box, set to produce about 5vdc.
Test the Hardware:
When your two moteinos and your FTDI adapter and USB cable arrive, you’ll need to do the following to prepare your hardware for testing:
- Visit web-page http://lowpowerlab.com/moteino/ and click on the image under “moteino pinout”. This will show you where on the moteino board each external connection is located. Refer to this image while doing the following:
- Solder the 6-pin FTDI connector (supplied) to the 6-holes at the end of each of your two moteinos. Convention is to insert the connector so that you solder to the side of the moteino board containing the wireless “daughter” board. The 90 degree bend in the FTDI connector pins is then on the other side of the board.
- Solder a 6.5 inch piece of wire, to be used as an antenna, into the hole on the moteino board labeled “ant”.
- You will need to power your moteinos from an external ac-adapter or battery unless the moteino is plugged into a USB port on your computer. To facilitate this, solder a pair of wires to the two adjacent holes named “gnd” and “vin”. Supply +4 to +9VDC through the “vin” pin.
- Now your moteino looks like this:
- Plug the min-B cable connector into the FTDI adapter. Plug the other end of the FTDI adapter into the “receiver” (master) moteino. This is the moteino that came with the colored piece of tape on it. Make sure you connect the “gnd” pin on the FTDI adapter to the moteino connector’s “gnd” pin. It’ll look like this:
The pair of moteinos ordered from Low Power Labs come already programmed with a “test” program. The moteino with the colored tape on it is the “receiver” (a.k.a. master). The other moteino is the “transmitter” (a.k.a. slave). Plug the FTDI adapter into the “receiver” moteino and plug it into a USB port on your computer. Then run a “serial terminal” program on your computer, such as PuttyTel or HyperTerminal on Windows. I use “minicom” on my Linux computer. Configure the terminal program to use the USB serial port connected to the moteino (through the FTDI adapter). Set the termianl program’s RS232 parameters to: data-rate 115kb, 8 data bits, no parity, 1 stop bit, software (Xon/Xoff) flow-control. I was never able to set MyperTerminal on Windows to use software flow-control, so I used PuttyTel instead. A couple of seconds after plugging your “receiver” moteino into the USB port, you should see “Listening at 433 Mhz…” displayed by your terminal program. If you see gibberish, you’ve probably got one or more of the RS232 parameters set incorrectly.
Now power-up the other “transmitter” moteino, using an external ac-adapter or battery. It need not be connected to any computer. You should then see the small LED on both moteinos flash on and off about once per second. Also the “transmitter” moteino will send messages to the “receiver” moteino connected to your computer, and your terminal program should start displaying lines like “ 123 ABCDEFG…”. Each line will have one more letter than the previous line. The maximum indoor range between two moteino R2s is about 30 feet, and between (100mw) R3s it is about 500 yards. You can see a video of this test by visiting http://lowpowerlab.com/moteino. Then scroll down to the “you-tube review of moteino R2″ and start playing the video created by Alan, W2AEV.
Software to Download:
- Arduino development environment. Download this open-source software from http://arduino.cc/en/Main/Software. Versions are available for Windows, Mac OSX, and Linux, as well as source code. If you’re using any popular distribution of Linux, you can probably easily install this software using “yum” or “git”. On my Fedora linux OS, I used the command “yum install arduino”, and everything installed automatically. Just follow the installation instructions for the version of this software that you need.
- RFM12B “library” for Moteino R2. Download this from https://github.com/LowPowerLab/RFM12B. On Linux, you may need to first install “git” software. Then go to a folder you created for your moteino experiments, and type “git init” and then”git clone https://github.com/LowPowerLab/RFM12B”.
- RFM69 “library” for Moteino R3. Download this from https://github.com/LowPowerLab/RFM69.
- SPIFlash “library”. Download this from https://github.com/LowPowerLab/SPIFlash. On linux, this can be installed by going to the folder you created for your moteino experiments, and typing: “git clone https://github.com/LowPowerLab/SPIFlash”.
Configure Arduino Development Software:
Run “arduino”, the arduino development software. This software allows you to compile programs, called “sketches”, written in the “Arduino language”, and then upload them into the non-volatile memory on the ATmega328 processor on the moteino pc-board. The Arduino language is very much like C++.
The first time you run the Arduino dev software, you’ll need to use the “tools -> board” menus and select “Arduino Uno” as your processor (because the moteino is a clone of the Arduino Uno). Also use the “tools -> serial port” menus and select the USB port you use to connect to your moteino through the FTDI interface. You may not be able to select the USB port unless you’ve actually plugged in your moteino to a USB port. My USB port on my Linux computer is named /dev/ttyUSB0.
You also need to tell the Arduino dev software about the two libraries you downloaded above. To tell the Arduion dev software about the RFM12B (or RFM69) library, use the menus “Sketch -> Import Library -> Add Library”. A new window will pop-up allowing you to navigate to the folder where you installed the RFM12B library above. Select this folder, named “RFM12B” (or RFM69) and click “OK”. Now verify this worked by using the “Sketch->Import Library” menus. You should see the RFM12B (or RFM69) library has been added to the end of a pop-up list of libraries that the Arduino dev software knows about. Repeat the above process for the SPIFlash library.
Compile & run LED Blink program in moteino
Next we’ll compile and upload into your “receiver” moteino a simple example program named “Blink” that blinks the on-board LED on and off. Run the Arduino development software and use menus “File -> examples -> 01.basics ->Blink”. You’ll see the source program listed. Find the line that reads “int led = 13;” and change this line to read: “int led = 9;”. This change is needed because the moteino’s LED is connected to pin 9 instead of pin 13 as on most Arduinos.
Next compile the modified program using menus “Sketch->Verify/Compile”. Insure it compiled correctly, with no error messages. Then, with the receiver moteino plugged into your computer’s USB port, use menus “file -> upload”. You should now see the moteino’s LED blinking on and off.
Compile & load default software in moteinos
In order to restore the two moteinos to their default behavior, as shipped, you’ll need to compile and install the program named “Test_2way_node” into your “transmitter” moteino R2 and the program named “Test_2way_gateway” into your “receiver” moteino R2. Each of these two programs is located in the “Examples” sub-folder of the RFM12B library folder you installed above. For the moteino R3 “transmitter” the program is named “Gateway”, and for the R3 “receiver” it is named “Node”, in the RFM69/Examples sub-folder.
First, plug your “transmitter” moteino into your computer, run arduino dev software, and use menus “file -> open”. Then navigate to the RFM12B (or RFM69) folder, then to the “Examples” sub-folder, then to the “Test_2way_node” (or “Node”) sub-folder, and finally to file “Test_2way_node.ino” (or “Node.ino”). Click “open”. When you see the source file displayed, insure the NETWORKID and FREQUENCY matches the NETWORKID and FREQUENCY in the Test_2way_gateway (or Gateway) program. Then use “sketch->verify/compile” to compile the program and use “file->upload” to load it into your transmitter moteino. You should see the moteino’s LED blinking on and off as it transmits.
Next, plug in your “receiver” moteino into your computer and compile and upload the “Test_2way_gateway.ino” (or Gateway.ino) file into it, the same way as above.
Now, when you externally power-up your “transmitter” moteino and connect your “receiver” moteino to your computer running a serial terminal program, you’ll see the original behavior.