Thursday, October 18, 2012

RS232 and OpenWrt on TP-LINK MR3020

The goal

Enable your MR3020 OpenWrt router to communicate with microcontrolers via RS232 port in both ways.

Usability

High.

Parts

  • TP-LINK MR3020 router flashed with OpenWrt
  • pin connectors
  • signal cable

Description

Recently I needed another router for Openwrt, my previous MR3420 went down, I accidentally burn him :)

This one is a beauty, it's small and has capabilities that fit my needs: CPU:Atheros AR7240@400MHz, Ram:32M, Flash:4M, USB 2.0 and of course most important for me - RS232 port.






TP-LINK MR3020
Board with soldered pins for RS232.
RS232 connector with cable. TX, RX, GND, VCC
Those 4 pins should be driven by low voltage (3.3V), so basically it needs a level converter to work with 5V microcontroller, but I took a chance and plugged it into atmega32 on 5V, and ... it's working :)

As a default, RS232 port is used for debug kernel messages (you need to recompile the kernel to disable that behaviour), furthermore there is a console running on this port, so it need to be turned off.

I'm to lazy to recompile kernel, so I just disabled  serial console. Debug kernel messages was still on serial port, so on the other side of the wire (microcontroler) I wrote a program which uses my custom protocol with pseudo data validation. It's working for now, so I don't bother anymore, of course MCU has more work to do, but who cares.

Default port path from device is /dev/ttyATH0, you can use it the same way, as standard linux port e.g. screen /dev/ttyATH0 9600.

My ugly custom connector































































































5 comments:

  1. Hi, great job!

    How did you disable serial console?

    ReplyDelete
    Replies
    1. Hi, thanks :)

      Change file /etc/inittab, comment out serial console initialization (example below), save and reboot your router.

      # ttyATH0::askfirst:/bin/ash --login

      Remember, debug messages from kernel will be still printed on serial port.

      Regards,
      Igor.

      Delete
  2. Hello, what do you use for this?

    I´m electronic and informatic. I want control relays with a PIC16F84A and Router HG556a with OpenWRT.

    Thanks, and I see you.

    ReplyDelete
    Replies
    1. Hi,
      If your PIC16F84A can do serial, attach it to serial port of your router http://wiki.openwrt.org/toh/huawei/hg556a#serial and then checkout my post "OpenWrt antenna rotator". I communicate with Atmega8 by rs232 from OpenWrt on MR3020. I never wrote anything on PIC* but I think it should be quite similar. On my post you will find a link to source code on Atmega8, maybe you could use it as a help to your project.
      Regards,
      Igor.

      Delete
  3. Ok, very thanks for your response. I see the form to do this and I comment you in a time. Thanks

    ReplyDelete