Can't log on to the Arduino from phone...

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
rob drizzle
 
Posts: 127
Joined: Wed May 04, 2011 6:14 pm

Can't log on to the Arduino from phone...

Post by rob drizzle »

I was testing my arduino ethernet sketch and I can log on to it from my computer (on the same network) but when I try with my android phone (off network obviously) it does not find the site. What am I missing?

Here is the code for reference (IDE 1.0 and the hardware is a Arduino Ethernet).

Code: Select all

//byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xE3, 0xCA };
//byte ip[] = { 192, 168, 1, 3 };
//byte gateway[] = { 192, 168, 1, 1 };

/*
* Web Server
*
* A simple web server that shows the value of the analog input pins.
*/
#if ARDUINO > 18
#include <SPI.h> // needed for Arduino versions later than 0018
#endif
#include <Ethernet.h>
#include "PCD8544.h"
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xE3, 0xCA };
byte ip[] = { 192, 168, 1, 10 };
byte gateway[] = { 192, 168, 1, 1 };
EthernetServer server(80);

int tempPin = A2;
int humidPin = A1;
int temp2Pin = A0;
float TempVAL;
float TempVAL2;
float TempC;
float Temp2C;
float RH;

// pin 7 - Serial clock out (SCLK)
// pin 6 - Serial data out (DIN)
// pin 5 - Data/Command select (D/C)
// pin 4 - LCD chip select (CS)
// pin 3 - LCD reset (RST)
PCD8544 nokia = PCD8544(7, 6, 5, 8, 3);

void setup()
{
    Serial.begin(9600);
  Serial.println();
  nokia.init();
  nokia.setContrast(50);
  delay(500);
  
Ethernet.begin(mac, ip, gateway);
server.begin();

Serial.println(Ethernet.localIP());

  pinMode(humidPin, INPUT);
  pinMode(temp2Pin, INPUT);
  pinMode(tempPin, INPUT);

}
void loop()
{
  
    analogRead(humidPin);
  delay(10);
  int humid = analogRead(humidPin);
  delay(50);
  
  analogRead(tempPin);
  delay(10);
  TempVAL = analogRead(tempPin);
  delay(50);
  
  analogRead(temp2Pin);
  delay(10);
  TempVAL2 = analogRead(temp2Pin);
  delay(50);
  
  //TEMP
TempVAL = (((TempVAL / 1024) * 5) * 100); // convert value to kelvin
TempVAL = (TempVAL - 273); // convert value to celsius
TempC = TempVAL;
TempVAL = (TempVAL * 1.8 + 32); // convert value to farenheit

//TEMP2
TempVAL2 = (TempVAL2 / 1024) * 5;
Temp2C = (TempVAL2 - 0.5) * 100;
float temperatureF = (Temp2C * 9.0 / 5.0) + 32.0;

RH = (0.1577*humid - 25.868);

  nokia.setCursor(0, 0);
  nokia.print("Temp1= ");
  nokia.print(temperatureF);
  nokia.print("*F");
  nokia.print("Temp2= ");
  nokia.print(TempVAL);
  nokia.print("*F");
  nokia.print("Humid= ");
  nokia.print(RH);
  nokia.print("%");
  nokia.display();
  delay(2000);
  nokia.clear();
  
EthernetClient client = server.available();
if (client) {
// an http request ends with a blank line
boolean current_line_is_blank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// if we've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so we can send a reply
if (c == '\n' && current_line_is_blank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
// output the value of each analog input pin
//for (int i = 0; i < 6; i++) {
client.print("Temperture 1 = ");
client.print(TempVAL);
client.print("F, ");
client.print("Temperature 2 = ");
client.print(temperatureF);
client.print("F, ");
client.print("Humidity = ");
client.print(RH);
client.print("%");
//client.print(analogRead(i));
client.println("<br />");



//}
break;
}
if (c == '\n') {
// we're starting a new line
current_line_is_blank = true;
} else if (c != '\r') {
// we've gotten a character on the current line
current_line_is_blank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
client.stop();
}
}


  void setCursor(uint8_t x, uint8_t y);

User avatar
rob drizzle
 
Posts: 127
Joined: Wed May 04, 2011 6:14 pm

Re: Can't log on to the Arduino from phone...

Post by rob drizzle »

GOT IT!. Had to forward the port and use my public IP.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”