The sample MotionMote sketch is posted here. Don’t forget to change the radio settings before uploading. For the lowest possible consumption remove the D5/D6 LED handling code, or simply delete the content of the
#define LED_HIGH and
#define LED_LOW directives – mind that doing this also means there is no visual indication when motion/packets are transmitted.
You will program the MotionMote PCB through the 6 pin “FTDI” serial connector with the help of a USB-FTDI Adapter such as this one. The 1×6 header remains unpopulated and you simply use another male header to hold against this header when you do the sketch upload. Or you may choose to solder a straight 1×6 male header for more convenience, but ensure you solder it on the battery side so it can fit in the case.
Once you have the Moteino AVR boards package installed in Arduino IDE, select Moteino-8Mhz as the target board. The boards are loaded with the Dualoptiboot bootloader which accepts new firmware/sketch serial uploads at 57600baud, making them more/less equivalent to a Moteino-8Mhz.
You have 2 options to power the board during programming:
- The board by default will be powered by the battery only. In this case you insert the battery and quickly upload the sketch, to avoid draining a constant 15mA from the battery. Once the upload is complete the consumption will fall to a mere few microamperes.
- There is a “JPW” jumper that can be bridged with solder to provide power through the FTDI header. In this case do not insert a battery during programming. But the important thing to remember is to only power the board from a 3.3V FTDI adapter, since there is no LDO on the board and the radio/flash memory can only take up to 3.6V!
Below is an illustration of an FTDI Adapter attached with a temporary (unsoldered) 1×6 right angled header, ready to program the MotionMote R4:
The red LED_BUILTIN (D9) is on the bottom, along with the other SMD components. This will flash just like a Moteino LED during uploads, but thereafter will be unused. Once the sketch is successfully loaded, the MotionMote is already functional and you’re ready to fully assemble it inside the enclosure, revisit the assembly step for this detail.
If you’re using the PiGateway GUI this will make it easy to integrate and trigger motion events.