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

Bringing in serial data through UART on 20-Pin connector

Home Forums Mayfly Data Logger Bringing in serial data through UART on 20-Pin connector

Viewing 2 reply threads
  • Author
    Posts
    • #14112
      Kurt Rosenberger
      Participant

      Hello

      I’m just getting started with the Mayfly, and am trying to bring in met data from an Airmar PB-100, using a GPS sketch I found for the Arduino (it is formatted as NMEA-0183, as they were built for boats). But my first hurdle is to even get the data in. I have an RS-422-TTL converter to bring the data in on the UART (I know this thing works because I’m successfully using one with a RasPi), but am unclear how I specify the pin for RX0 on the 20-pin header – is it A5, D0, RX0? All the examples I see for specifying pins seem to be referring to one of the digital pins. Any advice would be greatly appreciated.

       

      Thanks

      Kurt

    • #14113
      Shannon Hicks
      Keymaster

      Are you sure you need to use UART 0 for your incoming data from your deice?  The RX0/TX0 pins on the 20-pin header are directly wired to the main UART 0 of the Mayfly, which are the same pins that are used when programming the Mayfly board via your computer (using either the USB port of the FTDI header).  So if you have a device connected to RX0/TX0 of your Mayfly, and that device is actively sending data to the Mayfly, then you won’t be able to program your Mayfly while that device is connected, or view data on the IDE via the SerialMonitor.  Unless you’re using UART 1 for something else (like a bee module in the Mayfly bee socket) then I would suggest you connect your serial device to UART 1 using the RX1/TX1 pins instead.

      If you want to use one of the other digital pins (the other 20-pin header on the adjacent side of the Mayfly) then you could use one of the pins like D4, D5, D6, D7, D10, D11, or a few others, but only if you aren’t using those pins by something else on your board or in your sketch, and only if you implement SoftwareSerial via libraries.  However, SoftwareSerial has issues and limitations, so it’s better to use a hardware UART instead if it’s free.

    • #14114
      Sara Damiano
      Moderator

      I’m just seconding what Shannon said about using the hardware UART – always use hardware UART unless you definitely cannot.  In your case where you’ll be parsing long NMEA sentences, I’d recommend actually re-wiring your Bee/modem to give your GPS the better connection if you’re trying to use both.  In your code, you just use “Serial1” to communicate over the RX1/TX1 exactly like you would use “Serial”  when writing to the computer.  AltSoftSerial is the next best alternative – on the Mayfly with AltSS Rx will be on pin 6 and Tx on pin 5 (and only those pins).  Like Shannon said, you can use any pin that allows pin-change interrupts for SoftwareSerial (which is nearly any digital pin on the Mayfly) but you are more likely to have misread data using it.

Viewing 2 reply threads

You must be logged in to reply to this topic.