Overview

This guide walks you through the various ways to program your Moteinos. It includes details about any extra hardware required.

ArduinoIDE

You can use the official Arduino IDE which is not fancy but it’s the easy way to get started and is widely used and documented.

Here’s how easy it is to upload a blink program to a Moteino using an FTDI-Adapter (MoteinoUSB has FDTI built in):

There are 2 IDE options in my personal preferred order:

  • I recommend an older stable version of Arduino: 1.0.6 which is fast and works well. You can download 1.0.6 from the official page or from here as a last resort. I really dislike all recent 1.6.x versions, although they got a library and board manager which can be helpful.
  • If you want to use the latest Arduino stable release you can get it from here (it is v1.6.7 – Dec/2015).

Then you will need to install the Moteino libraries from my GitHub repository. Arduino has a library installation tutorial, so I will not repeat that information here. One thing that is important is to download the repositories as ZIP files, then rename their contents (remove the “-master” in the folder name) then put them in your {ArduinoSKETCHES}/libraries. You will need at the minimum 2 libraries: RFM69 and SPIFlash for basic RFM69 sketches but there are many more. For LoRa transceivers (RFM95/96) please see this page for the library link. Here is my example path and content of the RFM69 library installed:Library_PathThis {ArduinoSKETCHES} folder is configured from the Arduino preferences under File>Preferences, you can leave the default configuration or you can move it to a different custom location like I did:
Library_PathPreferences

If you are using an older version of the IDE (1.0.6 or 1.5.x), you need to manually install the Moteino core files to add the Moteino and MoteinoMEGA in the Tools>Boards menu. You can skip this if you have a regular Moteino or MoteinoUSB (you can upload by choosing Tools>Boards>Arduino UNO). Download the whole repository ZIP, then extract the Moteino.zip from that master zip file and extract it in your {Arduino}/hardware folder (up to 1.0.6). If you run a recent IDE version (1.6.5+) then copy Moteino/avr from the ZIP into {Arduino}/arduino/avr and append Moteino/avr/boards.txt from the ZIP into {Arduino}/arduino/avr/boards.txt.  After an IDE close/reopen Moteino and MoteinoMEGA should show as new targets under the Boards menu.

Once the libraries and the core are installed, and you reopened the Arduino IDE for changes to take effect, then you can open the Gateway and Node examples from the examples menu (under RFM69 library). Choose your target board under Tools>Boards>Moteino or MoteinoMEGA (or Arduino UNO if you skipped the core instalation and have a regular non-MEGA Moteino). Change the serial port to match that to which the target Moteino is connected to (Tools>Serial Port). Click Upload to run the Gateway sketch on the first Moteino (first adjust the FREQUENCY and IS_RFM69HW settings to match your transceiver hardware version), then repeat for the Node sketch. You can then open the serial monitor for the gateway Moteino (the far upper right icon in the IDE) and choose 115200 baud and No Line Ending settings at the bottom. For the gateway this is what you should be seeing:
Serial_gateway_IDEOnce you understand how to use the IDE you are ready to upload other example sketches from the RFM69 library, or create your own. You will find that as examples get more complex, more libraries are required to be installed.

The LowPowerLab forum is a great active place to post your Moteino projects or ask for help/support when you get stuck.

codebender


Unfortunately codebender announced they are shutting down on or after Oct. 20, 2016. Hence forth this page is only kept for reference and it will eventually be removed. The codebender programming instances below might become inactive, display an error or show a blank space once codebender shuts down these services. You are encouraged to start programming or move your code in the Arduino IDE


Programming your Moteino is easy with codebender, an online tool that allows you to create, edit, store, share your Arduino sketches. It runs right from your browser. There is nothing to install on your computer (except a browser plugin) and no libraries to keep track of. However you may find that some libraries are outdated since codebender does not maintain libraries, but relies on the library authors to push changes, so that may be a disadvantage.

To be able to use codebender you will need to create an account, then install a browser plugin that allows access to your computer’s serial ports, which in turn make it possible to reset and upload sketches to your Moteinos (or whatever other board you may have and they support). Also you need to choose your target board, protocol (USBtinyISP for Moteino) and serial port it’s attached to, then click “Run on Arduino” and that will compile/upload the sketch. That’s about it.

To upload sketches from codebender or from codebender embedded browser code snippets, you will need to first create an account, and install their browser plugin which allows your browser to control your computer’s serial ports (to upload sketches to your Moteino or other boards they support). They have a getting started guide that will guide you through that.

If you’re codebender-ready, try uploading this sample Blink sketch for Moteino/MEGA. This will blink the onboard LED fast if there is no FLASH chip onboard, and slow if the FLASH is installed. Choose your target board, protocol (USBtinyISP for Moteino) and serial port it’s attached to, then click “Run on Arduino” and that will compile/upload the sketch. That’s it, your Moteino should be blinking:

Once you feel comfortable with this sketch you can click “Clone & Edit” and that will take you back to your CodeBender account where you can keep your own modified version of it to work with.

Let’s try a more advanced set of sketches for Moteino. If your Moteinos have a transceiver (let’s assume RF69) you should try to establish wireless communication. You will need at least 2 Moteinos to make a wireless link. This is easy with the Gateway and Node examples from the RFM69 library on codebender. Since each Moteino transceiver has it’s own settings, you will need to clone and edit your own versions of these sketches. The important settings to match your hardware are: FREQUENCY and IS_RFM69HW. For instance if your Moteino has a RF69W-433mhz you would leave the default settings in the Gateway sketch:

Once you upload this to one of your Moteinos it will be ready to listen to messages from a Node. You can open the codebender serial monitor in the browser or you can open it on your computer from a terminal like Putty. This is what you should see in the browser once your Gateway sketch is running (in this example I have a FLASH chip installed which generates the MAC message):

Serial_gateway

Then load your Node sketch on the other Moteino (or on more Moteino sender nodes, but remember to change the NODEID setting to make it unique for each sender). When you connect a new Moteino to your computer there will be a new serial port, make sure to chose the new serial port for the Node sketch otherwise you will overwrite the Gateway sketch on the previous Moteino. Here it is for your convenience, again assuming you have a Moteino with RF69W-433mhz:
Once this is done you should now see messages streaming into the Gateway serial monitor. You should see something like this:

Serial_nodeLet’s include the serial monitor here as well, so you can open it from the browser, that’s one of the things that make codebender so cool:
There are other example sketches in the RFM69 library which you should check out. Knowledge of C++ will definitely help with understanding the code and what it does. If you need more help with something specific you can head over to the LowPowerLab forum which is a great space to post your Moteino projects and ask questions or get support for your LowPowerLab products.