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):
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:
Let’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.