Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, a web toolkit designed to help citizens, conservation practitioners, municipal decision-makers, researchers, educators, and students advance knowledge and stewardship of fresh water. New to EnviroDIY? Start here

Serial communication

The Mayfly has two serial UART ports. They are designated 0 and 1, and can also be referred to as TXD0/RXD0 or TXD1/RXD1. When using them in an Arduino sketch, one is called “Serial” and the other is called “Serial1”.

The default Xbee port is to TXD1/RXD1, which you can access by using the “Serial1” commands.  You can change the default settings by cutting the traces on SJ8 and SJ9 and adding a solder jumper to connect the Xbee to UART0, but be aware that it can cause conflicts with the computer since UART0 is what is used by the IDE to program the board.  Only change these jumper settings if you take precautions to not have communications to or from the Xbee while the Mayfly is connected to a computer.

The following sketch is an example of how you can print out text to the serial terminal (UART 0) and then to the Xbee port (UART 1).  It uses a baud rate of 9600 for the Xbee port since that’s the default address of most Xbee modules.