Zoomkat's router/arduino/ssc-32 wifi bot

Below is the basic code for the simple Arduino server setup and the HTML control page.

Arduino server code:

[code]//zoomkat 10-17-10
//routerbot code
//for use with IDE 0018
//open serial monitor to see what the arduino receives
// http://arduino.cc/en/uploads/Tutorial/String.zip for WString.h

#include <WString.h>
#include <Ethernet.h>
#include <Servo.h>

byte mac] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip] = { 192, 168, 1, 102 }; // ip in lan
byte gateway] = { 192, 168, 1, 1 }; // internet access via router
byte subnet] = { 255, 255, 255, 0 }; //subnet mask
Server server(84); //server port

String readString = String(100);
String servo1 = String(10);
String servo2 = String(10);

Servo myservo1; // create servo object to control a servo
Servo myservo2;
//////////////////////

void setup(){

//start Ethernet
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();

//enable serial data print
Serial.begin(9600);
myservo1.attach(7);
myservo2.attach(6);
Serial.println(“bot1”); // so I can keep track of what is loaded
}

void loop(){
// Create a client connection
Client client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();

//read char by char HTTP request
if (readString.length() < 100) {

//store characters to string
readString.append©;
}

//if HTTP request has ended
if (c == ‘\n’) {

///////////////
Serial.println(readString);

//readString looks like “GET /?-1500-1500 HTTP/1.1”

  if (readString.length() >0) {
  Serial.println(readString);
        
  servo1 = readString.substring(7, 11);
  servo2 = readString.substring(12, 16);
  
  Serial.println(servo1);
  Serial.println(servo2);
  
  int n1;
  int n2;
  
  n1 = atoi(servo1); //convert string to number
  n2 = atoi(servo2);
  myservo1.writeMicroseconds(n1);
  myservo2.writeMicroseconds(n2);
  
  //myservo.write(n);
  readString="";
  } 

///////////////////

//now output HTML data header
client.println(“HTTP/1.1 204 Zoomkat”);
client.println();
client.println();
delay(1);
//stopping client
client.stop();

/////////////////////
//clearing string for next read
readString="";

}}}}}
[/code]

Control web page:

[code]

Zoomkat's Routerbot
Web Control Page

Zoomkat's Routerbot Control Page

Foward-Stop-Reverse

F-F|
S-F|
-Stop-|
S-R|
F-R|




Turn-L-Stop-Turn-R


F-L|
S-L|
-Stop-|
S-R|
F-R|

[/code]

OK, this is interesting!

Could you explain what you’re doing for the uninformed? ;>)

I take it you are using the Arduino Ethernet shield, which is wired into the wireless router (serial?).

You run the HTML code on the router (?).

The C code in the Arduino accesses the router (?).

A PC browser opens the router page at 192, 168, 1, 102 (or one of those numbers in the program.

The parameters are then accessible on the PC.

Can you elaborate?

Can something similar be done with the Lantronix?

(And I realize we will be getting a PC program to work as a control program from LM).

Looking to learn a little bit more…

Thanks!

Alan KM6VV

"Could you explain what you’re doing for the uninformed? ;>) "

Generally make a wireless “routerbot” as cheaply and simply as possible. Some powerful routers like the Buffalo ones in bridging mode might get 2,500’ line of sight range. Google for wifi shootout to see what large antennas can do. Also IP cams can be plugged directly into routers to give the bot some vision capability.

“I take it you are using the Arduino Ethernet shield, which is wired into the wireless router (serial?).”

The connection between the ethernet shield and the router is an ethernet connection (which can be a piece of cat3 four conductor phone wire with RJ45 connectors on each end). The ethernet shield functions similar to a network card in a pc. No RS232 type serial communication involved.

“You run the HTML code on the router (?).”

No, the router is stock with no mods. The HTML is just copy/paste in notepad on the desktop. If desired the arduino can serve up such simple web pages.

“The C code in the Arduino accesses the router (?).”

The arduino/ethernet shield communicates with the router just like a pc with a network card. The router sees the arduino as another connected pc or similar. The arduino handles the network traffic as well as the I/O with external devices

“A PC browser opens the router page at 192, 168, 1, 102 (or one of those numbers in the program.”

Yes, this is the IP address assigned to the arduino/ethernet shield. I used this as when the router is disconnected from the internet, as DNS lookups are not possible when disconnected. If the router was bridged to another router connected to the internet, then typical URLs like zoomkat.no-ip.com can be used in the web page. Port fowarding can be used on the net connected router so a connection to the arduino can be made from most anywhere, even a web connected Iphone on the other side of the world.

“The parameters are then accessible on the PC.”
“Can you elaborate?”

This particular web page is set up for only sending commands and receiving webcam feeds if desired. If one wants to also obtain data from the arduino and display it on the web page, then the page would be made with two frames to handle the two types of traffic. Not difficult, just use notepad and a little html knowledge.

“Can something similar be done with the Lantronix?”

I’m not familiar with the lantronix protocols, but I would think it would be more involved and difficult to make into a user GUI, particularly a web based one.

“(And I realize we will be getting a PC program to work as a control program from LM).”

I made some comments on the project when it was announced, but they immediately disappeared. As with other projects, I guess I’ll sit back and see how it goes.

“Looking to learn a little bit more…”

Lots of neat stuff out there.

Thanks Z,

The use of a wireless router is interesting, but a little bulky. I’m hoping to come up to speed with what I think can be done with the Lantronix. But I do have a spare WLAN router…

Ah yes, the “shield” is an add-on “expansion” card to the Arduino. So it’s just like an ethernet card for a PC. I suppose it could be added to a BBII as well? I think the Lantronix can do that as well (guess I’ll find out).

The Arduino Ethernet board

arduino.cc/en/Guide/ArduinoEthernetShield

Is sounding a lot like what I suspect the Lantronix can do. In the Blackfin Camera, the Blackfin talks to the Lantronix, but doesn’t need to use a LAN connection, just one of the high speed serial ports of the WLAN. Does that mean the Blackfin processor is implementing the TCP/IP stack for conversing with the WLAN? (I’m starting to confuse myself, so I’d better stop).

But as you mentioned, you’re not up on the Lantronix or Blackfin; no worries!

I know the Lantronix can support a LAN connection (with the appropriate magnetics), so it could talk to an internet card, and work like your card.

“The arduino Ethernet shield handles the network traffic…”
Yeah, that answers my question!

I copied your HTML code to a file, then opened it up with my PC browser. It looks like you’ve shown with one of your pix. Of course, I don’t have a 192, 168, 1, 102 connection (but I think I know what the Lantronix one I set up is), so I didn’t get anything, but I think I’m catching on slowly…

A few more hints and experiments should help.

I have a little HTML knowledge, looking for more! Yeah, a LOT of stuff out there!

Thanks for the tutorial (I’m looking for more on the web)!

Alan KM6VV

Zoomkat, you would probably save yourself a ton of hassle to just use a Wifi UART adapter.
forums.basicmicro.net/atom-f484/wifi-t9461.html

Furthermore, i want you to check this out.
hackaday.com/2009/09/25/with-zip … a-netbook/
and

I want to try using this eventually, but i need to save up first.
Also the zipit, has an internal serial port, you’ll need to do a little soldering, but it’s just 4 easy to access points.
Zipits Z2’s are less than $40 USD.

I’ll admit zoomkat, you got me beat when it comes to budget robotics. Those look like peanut butter jar lids as wheels. Which if reinforced actually sounds like a great idea come to think of it.
You can probably open up the router to decrease it’s weight and size, as well as allow you to move the antenna, which if i’m not mistaken is attached via a ULF connector.
Edit: Lay the router horizontally and then place the battery ontop of it? It’ll help center the gravity on it, and make it less top heavy. At least it looks like it’ll do that.

I looked at the zipits a couple of years back (below), but they looked like they would take a good bit of tinkering to get going. Maybe since then more hacking info is available. One can get an arduino 328 and W5100 ethernet shield on ebay for ~$60 including postage. Lot of technical info and activity on the arduino forum beyond bots (auto flushing toilets, etc.).

viewtopic.php?f=30&t=2655

A lot more is capable with it.
It supports debian linux without to much effort. It can be hacked in less than 5 minutes.
And linux supports plenty of programs, you just need to remember a few dozen commands.
Terminal applications are readily available.
People have even programmed an arduino using it.

And it would be easy enough to write your own programs, even internally.

Look into the Zipit Z2, i plan on getting on eventually.

Updated code for use with the 0021 arduino IDE.

//zoomkat 10-22-10
//routerbot code
//for use with Arduino IDE 0021
//open serial monitor to see what the arduino receives
// 

#include <SPI.h>
#include <Ethernet.h>
#include <Servo.h>

byte mac] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip] = { 192, 168, 1, 102 }; // ip in lan
byte gateway] = { 192, 168, 1, 1 }; // internet access via router
byte subnet] = { 255, 255, 255, 0 }; //subnet mask
Server server(84); //server port

String readString, servo1, servo2;
 
Servo myservo1;  // create servo object to control a servo 
Servo myservo2;
 //////////////////////

void setup(){

//start Ethernet
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();

//enable serial data print 
Serial.begin(9600); 
myservo1.attach(7);
myservo2.attach(6);
Serial.println("bot1"); // so I can keep track of what is loaded
}

void loop(){
// Create a client connection
Client client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();

//read char by char HTTP request
if (readString.length() < 100) {

//store characters to string 
readString += c; 
} 

//if HTTP request has ended
if (c == '\n') {

///////////////
Serial.println(readString);

//readString looks like "GET /?-1500-1500 HTTP/1.1"

      if (readString.length() >0) {
      Serial.println(readString);
            
      servo1 = readString.substring(7, 11);
      servo2 = readString.substring(12, 16);
      
      Serial.println(servo1);
      Serial.println(servo2);
      
      int n1;
      int n2;
      
      char carray1[6];
      servo1.toCharArray(carray1, sizeof(carray1));
      n1 = atoi(carray1); 
      
      char carray2[6];
      servo2.toCharArray(carray2, sizeof(carray2));
      n2 = atoi(carray2); 
      
      myservo1.writeMicroseconds(n1);
      myservo2.writeMicroseconds(n2);
      
      //myservo.write(n);
      readString="";
      } 
  ///////////////////
  
  //now output HTML data header
  client.println("HTTP/1.1 204 Zoomkat");
  client.println();
  client.println();
  delay(1);
  //stopping client
client.stop();

/////////////////////
//clearing string for next read
readString="";
  
}}}}} 

The below routers and antennas look like they would be good for use with an extended range routerbot.

radiolabs.com/products/wirel … router.php

radiolabs.com/products/wirel … ess-2.html

radiolabs.com/products/anten … tenna.html

One more possible addition for a larger router bot would be the below video server. It can serve up video from four seperate video inputs. As a plus, it uses analog NTSC input so the inexpensive secutity typecams can be used.

geeks.com/details.asp?invtid … -N&cat=VID

Arduino code for use with IDE 0019 and later.

//zoomkat 10-22-10
//routerbot code
//for use with IDE 0019 and later
//open serial monitor to see what the arduino receives
// 

#include <SPI.h>
#include <Ethernet.h>
#include <Servo.h>

byte mac] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip] = { 192, 168, 1, 102 }; // ip in lan
byte gateway] = { 192, 168, 1, 1 }; // internet access via router
byte subnet] = { 255, 255, 255, 0 }; //subnet mask
Server server(84); //server port

String readString, servo1, servo2; 
 
Servo myservo1;  // create servo object to control a servo 
Servo myservo2;
 //////////////////////

void setup(){

//start Ethernet
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();

//enable serial data print 
Serial.begin(9600); 
myservo1.attach(7);
myservo2.attach(6);
Serial.println("bot21"); // so I can keep track of what is loaded
}

void loop(){
// Create a client connection
Client client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();

//read char by char HTTP request
if (readString.length() < 100) {

//store characters to string 
readString += c; 
} 

//if HTTP request has ended
if (c == '\n') {

///////////////
Serial.println(readString);

//readString looks like "GET /?-1500-1500 HTTP/1.1"

      if (readString.length() >0) {
      Serial.println(readString);
            
      servo1 = readString.substring(7, 11);
      servo2 = readString.substring(12, 16);
      
      Serial.println(servo1);
      Serial.println(servo2);
      
      int n1;
      int n2;
      
      char carray1[6];
      servo1.toCharArray(carray1, sizeof(carray1));
      n1 = atoi(carray1); 
      
      char carray2[6];
      servo2.toCharArray(carray2, sizeof(carray2));
      n2 = atoi(carray2); 
      
      myservo1.writeMicroseconds(n1);
      myservo2.writeMicroseconds(n2);
      
      //myservo.write(n);
      readString="";
      } 
  ///////////////////
  
  //now output HTML data header
  client.println("HTTP/1.1 204 Zoomkat");
  client.println();
  client.println();
  delay(1);
  //stopping client
client.stop();

/////////////////////
//clearing string for next read
readString="";
  
}}}}} 

Network cam that might be of interest to modify and use on a router bot.

walmart.com/ip/Plustek-IPCAM … C/13021119

It also worked for me, but they don’t have any of the products in stock…

when i try to start controlling the robot it goes to internet explorer cannot display the webpage some one please help :cry: :cry: :cry:
matt

You will need to explain what hardware you are using, what code you are using, and specifically what you are doing that isn’t working.

Hey all!

Zoomkat I have used this code and it works great but, at least for me, with only 1 servo connected.
When I add a second servo and click the html link the command goes through and displays on the Arduino serial monitor as it should but on the next click whatever that may be, the Arduino crashs. Never happens with same code on 1 servo.

Have you seen this previously?

If you are talking about two servos in parallel using the same code and arduino servo signal pin, then it might be a power supply problem. How is your arduino and the servos being powered? If your code is modified for two servos, then it could be a code issue. As they say in the arduino forum, if your code is different you probably need to post it.

Thanks for the quick repsonce. :mrgreen:

Its exactly the same code. I have 1 servo in D6 and 1 in D2

Both were powered by the arduino and that was the problem! Once I added a seperate supply its all good.

Great code by the way, I shall need a few more servos so I will have a play with adding extra code.

Hey Zoomkat
I have the choice of either using the same exact netgear router you have in your demonstration or a much smaller router that would probably be more practical. The problem I’m having is what should i use for a power source? Should I use the power port on the arduino or could I pick up something at radio-shack that’s small enough to fit in my robots structure and power full enough to provide voltage for my router. I inserted an image to give you an idea of what I’m working with.

I used the netgear router because it is my normal router and was available. It uses 12v power from an unregulated wallwart (unloaded output is ~15v). All I had to do for the router was disconnect it from my cable modem and switch its power supply from the ~12v wallwart to the 12v drill battery. I used a 5v 7805 regulator chip to power the arduino and ssc-32 (the external power supply on either the arduino or the ssc-32 probably could be used to power both boards at 5v). For the servo power I used another 7805 regulator chip (with a diode on the ground leg to up the output voltage to ~5.7v) connected to the 12v battery. The “pocket router” should work, but may have only one Ethernet input. The netgear router has several ethernet inputs, so an IP cam for vision could also be connected.