Ethernet with Arduino board
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Ethernet with Arduino board
Ok I have an open port on 80 and my IP is set. But I can not get the portal to find my ethernet board? "Unreachable" Do I have to use 2000?
Re: Ethernet with Arduino board
I split your post to separate the two options.
Yes, just change the code to 2000 instead of 80...
Make sure you have port forwarding on your router or the server won't be able to connect to your board.
Simplest way to test is just to browse http://IPADDRESS:PORT
This should give you "Reef Angel Controller Web Server"
Yes, just change the code to 2000 instead of 80...
Make sure you have port forwarding on your router or the server won't be able to connect to your board.
Simplest way to test is just to browse http://IPADDRESS:PORT
This should give you "Reef Angel Controller Web Server"
Roberto.
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Ethernet with Arduino board
Ok I've changed to 2000...port is open and pointed to 192.168.1.114...still "unreachable" I tested with http://192.168.1.114:2000 and I get the Reef Angel Controller Web Server with no problem
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Ethernet with Arduino board
There is a problem:
This page contains the following errors:
error on line 1 at column 161: Opening and ending tag mismatch: WMA line 0 and PMA
Below is a rendering of the page up to the first error.
81169977586224802550000
This page contains the following errors:
error on line 1 at column 161: Opening and ending tag mismatch: WMA line 0 and PMA
Below is a rendering of the page up to the first error.
81169977586224802550000
Re: Ethernet with Arduino board
Seems you are getting data corruption somehow.
Can you sniff the packets and send me the capture or PM me your wan ip?
Can you sniff the packets and send me the capture or PM me your wan ip?
Roberto.
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Ethernet with Arduino board
how do I sniff the packets?
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Ethernet with Arduino board
ok working on it...I can see the issue by refreshing the r99 page...I recognize the ATOHIGH, etc etc but it's failing
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Ethernet with Arduino board
PM SENT
Re: Ethernet with Arduino board
I can see it's getting corrupted towards the end of the string.
It starts messing up when it reaches PWMA
Code: Select all
<RA><T1>804</T1><T2>698</T2><T3>773</T3><PH>862</PH><R>248</R><RON>0</RON><ROFF>255</ROFF><ATOLOW>0</ATOLOW><ATOHIGH>0</ATOHIGH><EM>0</EM><REM>0</REM><PWMA>84/PWM><PWM>76<PWMD</RA
Roberto.
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Ethernet with Arduino board
What to do?
Re: Ethernet with Arduino board
Try increasing this:
to like 3000 or 4000
There are 2 places to change.
Code: Select all
if (millis()-lastmillisin>2000)
There are 2 places to change.
Roberto.
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Ethernet with Arduino board
Tried 3000 and 4000 and no change.
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Ethernet with Arduino board
I've messed with it quite a bit. Random data corruption. Weird
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Ethernet with Arduino board
Here's what I have now.
Code: Select all
/*
Web Server
A simple web server that shows the value of the analog input pins.
using an Arduino Wiznet Ethernet shield.
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
* Analog inputs attached to pins A0 through A5 (optional)
created 18 Dec 2009
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe
*/
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0x90, 0xA2, 0xDA, 0x0D, 0x28, 0x0E };
IPAddress ip(192,168,1,200);
IPAddress remoteserver(69,198,171,165); // forum.reefangel.com
EthernetClient clientout;
unsigned long lastmillisout=millis();
unsigned long lastmillisin=millis();
boolean sending=false;
char strout[400];
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(2000);
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(57600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection and the server:
Ethernet.begin(mac);
server.begin();
Serial.println(Ethernet.localIP());
}
void loop() {
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
// Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
while (client.available()) {
char c = client.read();
if (sending==false) Serial.write(c);
lastmillisin=millis();
}
while (Serial.available()){
char c = Serial.read();
client.print(c);
if (millis()-lastmillisin>4000)
{
Serial.println("Timeout incoming");
Serial.flush();
lastmillisin=millis();
client.stop();
}
}
if (millis()-lastmillisin>4000)
{
Serial.println("Timeout incoming");
Serial.flush();
lastmillisin=millis();
client.stop();
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
// Serial.println("client disonnected");
}
else
{
if (Serial.available())
{
memset(strout,0,sizeof(strout));
int b=Serial.readBytesUntil('\n',strout,sizeof(strout));
Serial.flush();
// Serial.println(b);
Serial.println("Connecting");
if (b>10)
{
sending=true;
Serial.print(strout);
Serial.println(" HTTP/1.0");
Serial.println();
if (clientout.connect(remoteserver, 2000))
{
Serial.println("Connected");
// while (Serial.available()){
// char c = Serial.read();
// clientout.print(c);
// }
clientout.print(strout);
clientout.println(" HTTP/1.0");
clientout.println();
lastmillisout=millis();
}
}
}
while (clientout.available()) {
char c = clientout.read();
Serial.print(c);
if (millis()-lastmillisout>8000)
{
Serial.println("Timeout connected");
lastmillisout=millis();
clientout.stop();
sending=false;
}
}
if (!clientout.connected())
{
clientout.stop();
sending=false;
}
}
if (millis()-lastmillisout>8000)
{
Serial.println("Timeout global");
lastmillisout=millis();
clientout.stop();
sending=false;
}
}
//GET /status/submitp.aspx?t1=806&t2=0&t3=0&ph=441&id=test&em=0&rem=0&key=&atohigh=0&atolow=0&r=0&ron=0&roff=255 HTTP/1.0
//GET /status/submitp.asp?t1=806&t2=0&t3=0&ph=441&id=test&em=0&rem=0&key=&atohigh=0&atolow=0&r=0&ron=0&roff=255 HTTP/1.0
//Host: forum.reefangel.com
//
//GET /status/submitp.aspx?t1=806&t2=0&t3=0&ph=441&id=test&em=0&rem=0&key=&atohigh=0&atolow=0&r=0&ron=0&roff=255 HTTP/1.0
//Host: forum.reefangel.com
//Connection: Keep-Alive
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Ethernet with Arduino board
Any thoughts? Could it be the code itself? Cable? The RA head unit?
Re: Ethernet with Arduino board
I don't know man...
It must be something in the serial stream or possibly baud rate mismatch.
This is probably caused by a slight shift in the crystal oscillator, which will cause the baud rate to shift slightly too, but if two are communicating a a preset value, the shift may be too much.
I'll see if I can load my board again during the weekend.
It must be something in the serial stream or possibly baud rate mismatch.
This is probably caused by a slight shift in the crystal oscillator, which will cause the baud rate to shift slightly too, but if two are communicating a a preset value, the shift may be too much.
I'll see if I can load my board again during the weekend.
Roberto.
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Ethernet with Arduino board
Cool. I'll keep playing with it
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Ethernet with Arduino board
Just wanted to check what my board type should be. Should I set to arduino UNO Ethernet or? That could be my issue even though I have no trouble uploading code. ?
Re: Ethernet with Arduino board
It doesn't make a difference... the mcu is the same.
Your Arduino IDE doesn't even have Arduino boards listed.
Your Arduino IDE doesn't even have Arduino boards listed.
Roberto.
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Ethernet with Arduino board
ok...with the stock webserver sketch I can get the output to work perfectly...but it's not the correct format...so I know it has to do with the code you supplied earlier..I'm just trying to figure out what part is wrong
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Ethernet with Arduino board
Are the //GET commands correct? I was about to look into those
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Ethernet with Arduino board
Ok I'll keep looking.
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Ethernet with Arduino board
Everything looks perfect in the code...dang... I'm not sure what's going on here. but I'll just have to wait and see what you come up with
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Ethernet with Arduino board
Thought! Anyway to increase the delay of serial read and the write or print? If we increase the delay there is less chance of corruption.
So not the frequency of the read (milli) but a delay between read/write
So not the frequency of the read (milli) but a delay between read/write
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Ethernet with Arduino board
Just an update: I plugged in the USB to TTL cable, launched command GET /r99 and returns the proper format with no errors on the serial monitor..so the ethernet module is to blame not the RA itself.
Re: Ethernet with Arduino board
Did you try decreasing the baud rate?
You will need to decrease on both boards.
In RA code, I'm pretty sure you can just end and begin a new rate like this:
It must be in the setup() and it must be after ReefAngel.Init()
You will need to decrease on both boards.
In RA code, I'm pretty sure you can just end and begin a new rate like this:
Code: Select all
Serial.end();
Serial.begin(19200);
Roberto.
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Ethernet with Arduino board
That's a good point. Trying now