How to send serial information to Arduino

Discussion in 'Arduino IDE' started by bennyboom, Apr 7, 2015.

  1. bennyboom

    bennyboom New Member

    Joined:
    Nov 26, 2013
    Messages:
    3
    Likes Received:
    0
    Hello

    I have built an electronic card with an Atmega 328 and a RFM69.

    [​IMG]

    I have attached some sensors to this card like DS18B20.
    WIth 2 cards, one in receiver mode and other one in emitter mode, I can send datas wireless over 433Mhz.

    I would like now to collect this datas on udoo to store them and display them with a web interface.

    When I have tested my card , i have use a FTDI to connect my card on my computer, but now I would like to send serial data on udoo.

    I have tried to connect my card on Arduino DUE like this
    My Card --> Due
    GND --> GND
    VCC --> 3,3V (my card has no power regulator to support over 3,3v for now)
    RX --> RX0
    TX --> TX0

    When I launch Arduino IDE and open the console , I see some character but nothing understanding, and some second after my Udoo board is freezed.
    I have to kill java arduino process or worst power off/on .

    Do you have an idea about this problem ?
    Thanks for your help,

    Regards

    Ben
     
  2. fetcher

    fetcher Member

    Joined:
    Mar 9, 2014
    Messages:
    166
    Likes Received:
    20
    If you're trying to use TX0, RX0 to communicate with your board, the trouble is that these pins are normally reserved for a data channel between the Udoo's two CPUs, the main i.MX6 Linux processor and the Arduino-side SAM3X. Two serial devices trying to transmit on the same pin at the same time will conflict, resulting in garbage data at best.

    If you don't currently need the SAM3X (Arduino) side of the Udoo for anything, and just want to capture serial data in Linux, you can remove the conflict by holding the SAM3X in RESET state-- either place a jumper on J16, near the microUSB ports in back, or do "echo 0 >/gpio/gpio0/value" to have the i.MX6 assert RESET. This puts all SAM3X pins in high-impedance (floating) state, and should allow TX0/RX0 to be taken over by your board. Note that TX/RX labels on those pins are from the perspective of the Arduino, and may be backwards from what you'd expect-- if it still doesn't work the first time, try reversing them.

    To get serial data into the i.MX without sacrificing the SAM3X, there are two additional, normally unused i.MX6 UARTs available-- UART3 (/dev/ttymxc2 since numbering starts at zero) and UART5 (/dev/ttymxc4), which can be mapped to pins on the the large double-row header. The default kernel unfortunately doesn't have these enabled, so to use them you'd need to install the kernel source code package via git (Kernel_Unico), edit a couple of config files (board-mx6_seco_UDOO.c and board-mx6qd_seco_UDOO.h, assuming a Quad), recompile and install the new kernel. See this old post for more detail: http://www.udoo.org/forum/enabling-serial-ports-t1457.html, as well as the Pinouts diagram and alternate pin functions table (both PDFs) available in the Downloads area here.

    A third option would be to upload a sketch to the SAM3X to make it serve as a serial bridge, repeating data bidirectionally between TX0/RX0 (i.MX6 <-> SAM3X channel) and one or more of the alternate UARTs available on the SAM3X side-- TX1/RX1 (Arduino "Serial1"), TX2/RX2 (Serial2), or TX3/RX3 (Serial3). The main TX0/RX0 UART is just "Serial". You'd need to have a loop alternately polling, e.g. Serial1.available and Serial.available to allow data flow both ways, receiving data on one port when it becomes available and sending it out the other. With careful programming, the Arudino could still be doing other things at the same time.

    I'd only bother with that last method if you'd already used up both of the spare i.MX6 UARTs but still needed more (and didn't want to resort to USB-Serial dongles), or if you want to combine multiple serial serial data flows coming into the various SAM3X ports into one aggregate stream back to the Linux side, making it into a sort of multiplexer... or have the SAM3X independently act on received data. Otherwise it wouldn't be worth the trouble.
     
  3. bennyboom

    bennyboom New Member

    Joined:
    Nov 26, 2013
    Messages:
    3
    Likes Received:
    0
    Thank you so much ! It's exactly the answer I was waiting :)
     

Share This Page