Thursday, October 18, 2012

OpenWrt antenna rotator

The goal

Make wireless lan antenna find best signal area for specified (My) network.

Usability

Low, just for fun.

Parts

  • TP-LINK MR3020 router flashed with OpenWrt
  • MR3020 power cable and original power supply
  • USB wireless card e.g TP-LINK TL-WN722N
  • USB hub
  • Yagi antenna
  • camera tripod
  • stepper motor (from old printer)
  • gears (as above)
  • signal wires

Code


Hardware


Media

Openwrt antenna rotator at work

Openwrt antenna rotator at work

Use Case

At the end of this page.

Description

Antenna

In this project I use Yagi antenna with modified cable, original was to heavy and caused rotating problems. 
Plastic handle, shipped with antenna is also modified by adding plastic gear from stepper motor (got from old printer). Gear fits perfect on antenna handle, and thanks to cable ties, construction is more robust.








Thin cable, removed from other TP-LINK antenna.
Gear mount is glued to plastic holder.
Gear and plastic holder, have holes for cable ties.
For more stable movement.

Camera tripod

This is a standard, cheapest camera tripod, I needed to make hole in the middle of camera grip, because stepper motor has long shaft.


Camera tripod with hole in the middle of camera grip.
Stepper motor PM55l-048...
Motor has accurate size.
Some cable ties...
At the end antenna on right place.
Final

Motor driver

If you want to know how to drive stepper motor by ULN2003, you can google it, there is a plenty of articles about.

ULN2003 is connected to attiny2313 on IO pins and attiny2313 is connected to MR3020 by RS232, no magic included. 


More about this driver can be found in section HARDWARE on head of this article.


RS232 Stepper motor control.
Ugly side.
Power supply is provided by MR3020 power supply cable, which was been modified by changing USB socket to female pin connector.

Modified original MR3020 power supply USB cable.
Female power connector.
RS232 connector cable.

Stepper motor is connected to the board by the same female connectors. The red one is +5V, other ones are connected to attiny2313 logic outputs.

Stepper motor female connectors.


Stepper motor control connected to MR3020 by RS232.

For more info about RS232 on MR3020, follow this link.

External wireless USB adapter.
USB hub and pendrive
MR3020 + USB hub + external wireless + RS232 stepper motor control.
Final
Connection view.

Use Case


I assume, that 'chanmon' is already compiled and installed on OpenWrt, and wireless interface name is 'mon0'.

Program has different types of operation:
  • Scanning beacons from channel 5. Output: bssid, channel, signal strength.
chanmon -i mon0 -c 5
  • Monitor one network without following channel from beacon. Following channels is ON by default
chanmon -i mon0 -c 5 --bssid XX:XX:XX:XX:XX:XX --nofollow
  • Track signal from one network. Antenna step delay is set to 300ms. Antenna will scan whole area (step from 00 to 90), and then go back to best signal position.
chanmon -i mon0 -c 5 --bssid XX:XX:XX:XX:XX:XX --nofollow --track --delay 300

Sample output in '--track' mode

Tracking output info

signal at 0 is -48, count 3
signal at 1 is -47, count 3
signal at 2 is -48, count 3
signal at 3 is -49, count 3
signal at 4 is -49, count 3
signal at 5 is -49, count 3
signal at 6 is -50, count 3
signal at 7 is -52, count 3
signal at 8 is -52, count 3
signal at 9 is -51, count 3
signal at 10 is -49, count 3
signal at 11 is -47, count 3
signal at 12 is -46, count 3
signal at 13 is -45, count 3
signal at 14 is -45, count 3
signal at 15 is -44, count 3
signal at 16 is -44, count 3
signal at 17 is -43, count 3
signal at 18 is -44, count 3
signal at 19 is -43, count 3
signal at 20 is -43, count 3
signal at 21 is -42, count 3
signal at 22 is -42, count 3
signal at 23 is -42, count 3
signal at 24 is -42, count 3
signal at 25 is -42, count 3
signal at 26 is -43, count 3
signal at 27 is -43, count 3
signal at 28 is -43, count 3
signal at 29 is -50, count 3
signal at 30 is -45, count 3
signal at 31 is -44, count 3
signal at 32 is -45, count 3
signal at 33 is -44, count 3
signal at 34 is -46, count 3
signal at 35 is -48, count 3
signal at 36 is -51, count 3
signal at 37 is -50, count 3
signal at 38 is -49, count 2
signal at 39 is -53, count 3
signal at 40 is -48, count 2
signal at 41 is -47, count 3
signal at 42 is -46, count 2
signal at 43 is -45, count 3
signal at 44 is -45, count 3
signal at 45 is -44, count 3
signal at 46 is -44, count 3
signal at 47 is -60, count 3
signal at 48 is -52, count 3
signal at 49 is -45, count 3
signal at 50 is -46, count 3
signal at 51 is -45, count 3
signal at 52 is -48, count 3
signal at 53 is -46, count 3
signal at 54 is -48, count 3
signal at 55 is -49, count 3
signal at 56 is -49, count 3
signal at 57 is -51, count 2
signal at 58 is -50, count 3
signal at 59 is -50, count 3
signal at 60 is -49, count 3
signal at 61 is -49, count 3
signal at 62 is -48, count 3
signal at 63 is -46, count 3
signal at 64 is -45, count 3
signal at 65 is -45, count 3
signal at 66 is -44, count 3
signal at 67 is -44, count 3
signal at 68 is -44, count 3
signal at 69 is -44, count 3
signal at 70 is -45, count 3
signal at 71 is -46, count 3
signal at 72 is -48, count 3
signal at 73 is -49, count 3
signal at 74 is -49, count 3
signal at 75 is -50, count 3
signal at 76 is -51, count 3
signal at 77 is -50, count 2
signal at 78 is -50, count 3
signal at 79 is -57, count 3
signal at 80 is -53, count 3
signal at 81 is -55, count 3
signal at 82 is -51, count 3
signal at 83 is -53, count 3
signal at 84 is -53, count 3
signal at 85 is -52, count 3
signal at 86 is -50, count 3
signal at 87 is -48, count 3
signal at 88 is -48, count 3
signal at 89 is -48, count 3
Best signal -42 at 21
Packet sum 265, avg 2
After correction, best signal -42 at 21
Widest range  from 21, to 25, center is 23
Maximum is in the wider range
Setting center from wider range


4 comments:

  1. very good project, id like it. Can you please advise me how to make it on arduino uno r3

    ReplyDelete
    Replies
    1. Hello,

      Hardware part (stepper motor driver) you can do very easily:

      1. http://assiss.github.io/arduino-zhcn/cn/Tutorial/MotorKnob.html
      2. Add serial communication like on my other post http://morethanuser.blogspot.com/2012/10/rs232-stepper-motor-control-attiny2313_22.html
      3. Connect to OpenWrt, run my program, and if you done everything right, it will be working.

      Ad.3 I don't have an Arduino, but I think, you can connect it pin-by-pin to OpenWrt (like I did), or over USB, Arduino should have something like usb<->rs232 controller. After connecting to OpenWrt, you should be able to see and talk to serial port of your Uno R3.

      If your question was about doing everything on Arduino, this is nearly (but not) impossible. You should have wireless module with monitor option, and do some heavy coding to get signal strength data from packets. I don't know if 16MHz of your Uno R3 can make it.

      Regards,
      Igor.

      Delete
  2. Very cool! Actually, I have a use case, where it is actually practical. We just bought an old caravan. I've seen that it is common on campsites to have wifi, but usually one antenna covering a large area. So, my idea was to replace the old TV antenna with a fairly broad-spectrum Yagi, and have three radios, basically one wifi for the internal Wifi network, one for the external network and an LTE modem if no Wifi is available. Then, scan for the strongest signal whether that may be wifi or LTE. I can connect the antenna cable based on whether I'm scanning for either.

    I was thinking about an OLinuXino board of some sort, with their GPIOs for the motor, an onboard Wifi, and a USB LTE modem and USB Wifi. Does that sound like a good idea?

    ReplyDelete