gateway address

Good afternoon I'm new to the community and I'm in need of help. I'm trying to make an automation system being a PC connecting to several arduinos, one at a time (pulling). I am using the ethernet shield W5100. I am using the ethernet.h library and my problem is that I will use them in an extensive network where I have several subnets. When I program the network mask to 255.255.255.0 and I define the gateway as eg. 192.168.0.1, arduino normally runs on the network. When I set the network mask to / 26 (255.255.255.192) and set the gateway to 192.168.0.65, the arduino accepts the schedule but does not work. That is, the gateway address must be the first address of the network as long as it is 1. Has anyone had this problem yet?

Be more specific about what you mean by "does not work".

If you don't have a gateway router at 192.168.0.65, then anybody will have this problem. Also, your w5100 IP address must be within the localnet range of the gateway and any other localnet device.

SurferTim: Be more specific about what you mean by "does not work".

If you don't have a gateway router at 192.168.0.65, then anybody will have this problem. Also, your w5100 IP address must be within the localnet range of the gateway and any other localnet device.

"does not work" means "does not connect" I'll try to be clearer on the problem: If I have a router with gateway set to 192.168.0.1, network mask 255.255.255.0 and set arduino IP to 192.168.0.66, arduino connects to the network. If I change the router's gateway to 192.168.0.65 with network mask 255.255.255.192 and keep the arduino address at 192.168.0.66, it will not connect to this network.

192 decimal = 1100 0000 which means only 0 to 63 are allowed

both your gateway and your Arduino are out of network so to speak

ieee488: 192 decimal = 1100 0000 which means only 0 to 63 are allowed

both your gateway and your Arduino are out of network so to speak

I agree with you that for 192 we will have 64 allowed addresses. In case having a network mask of 255.255.255.192 (/ 26) we will have the gateway address at 192.168.0.65. Since the arduino IP is at 192.168.0.66, both are on the same network. Just to add more information that I did not report in the main post, the gateway address 192.168.0.65 was set on arduino.

JPDS: I agree with you that for 192 we will have 64 allowed addresses. In case having a network mask of 255.255.255.192 (/ 26) we will have the gateway address at 192.168.0.65. Since the arduino IP is at 192.168.0.66, both are on the same network. Just to add more information that I did not report in the main post, the gateway address 192.168.0.65 was set on arduino.

JPDS: I agree with you that for 192 we will have 64 allowed addresses. In case having a network mask of 255.255.255.192 (/ 26) we will have the gateway address at 192.168.0.65. Since the arduino IP is at 192.168.0.66, both are on the same network. Just to add more information that I did not report in the main post, the gateway address 192.168.0.65 was set on arduino.

You can argue or you can change your IP addresses.

Your choice.

.

What do you mean "does not connect"? To the internet? To a localnet server?

If you mean the internet, do you have a router at 192.168.0.65 that has internet access?

If you mean a localnet server, what IP dies it have?

He's using his PC as the gateway.

ieee488: You can argue or you can change your IP addresses.

Your choice.

.

If you are telling me that I have to change the IP address, I would like you to suggest which gateway and arduino addresses I should put to a network with masking / 26 or 255.255.255.192.

SurferTim: What do you mean "does not connect"? To the internet? To a localnet server?

If you mean the internet, do you have a router at 192.168.0.65 that has internet access?

If you mean a localnet server, what IP dies it have?

SurferTim: What do you mean "does not connect"? To the internet? To a localnet server?

If you mean the internet, do you have a router at 192.168.0.65 that has internet access?

If you mean a localnet server, what IP dies it have?

SurferTim: What do you mean "does not connect"? To the internet? To a localnet server?

If you mean the internet, do you have a router at 192.168.0.65 that has internet access?

If you mean a localnet server, what IP dies it have?

ieee488: He's using his PC as the gateway.

ieee488: He's using his PC as the gateway.

I'm talking about localnet. I made a drawing of how the system would look, but I do not know how to pluck it here. There are several routers connected by the cloud to a master router and the router on the server or PC. These networks already exist and I have to use the available addresses of each one. In the example the gateway of the router is 192.168.0.65 because the mask is / 26 or 255.255.255.192 and the ip of the arduino 192.168.0.66. and so it does not connect to the server. in a test other than the network, if you put mask 255.255.255.0 and gateway 192.168.0.1, there it connects. Conclusion only connects if the gateway has the final octet 1. How do I post the drawing here?

SurferTim: What do you mean "does not connect"? To the internet? To a localnet server?

If you mean the internet, do you have a router at 192.168.0.65 that has internet access?

If you mean a localnet server, what IP dies it have?

I'm talking about localnet. I made a drawing of how the system would look, but I do not know how to pluck it here. There are several routers connected by the cloud to a master router and the router on the server or PC. These networks already exist and I have to use the available addresses of each one. In the example the gateway of the router is 192.168.0.65 because the mask is / 26 or 255.255.255.192 and the ip of the arduino 192.168.0.66. and so it does not connect to the server. in a test other than the network, if you put mask 255.255.255.0 and gateway 192.168.0.1, there it connects. Conclusion only connects if the gateway has the final octet 1. How do I post the drawing here?

I get this much: The IP of the Arduino is 192.168.0.66/26 The IP of the router (gateway) is 192.168.0.65/26 The IP of the localnet server to which you are trying to connect is....??

With the drawing here I believe you can understand now.

I asked a simple question. What is the IP of the server?

Here is the configuration and all the ip addresses used in the arduino test. The differences are the gateway change and the / 26 netmask.
I believe I am now passing on all the information.

You aren't making sense. Is the router b IP 192.168.0.1 or 192.168.0.65? Are you changing the network settings in router b for your tests?

The routers B addresses have changed according to the drawing and in this case the arduino does not connect to the server. It seems that this connection only happens when the arduino uses the default gateway, in this case 192.168.0.1) (top design). When we change to a subnet and there we change the gateway to 192.168.0.65, the connection is not established In the drawing I show the two versions of the test, the one that connects and the one that does not connect with the respective addresses.

SurferTim: You aren't making sense. Is the router b IP 192.168.0.1 or 192.168.0.65? Are you changing the network settings in router b for your tests?

The addresses of Router B have changed as per the drawing. I put the two versions of the test, the one that connects and the one that does not connect with their addresses. If anyone could perform these real tests, without the use of simulator, I would appreciate the posting of the results here. From the results I got, although the arduino accepts the default gateway programming defaut, but in reality it only uses the final defaut gateway (.1)

You should post your code.

Follow the arduino code used in the subnetting tests / 26

#include <SoftwareSerial.h>

#include <SPI.h>
#include <Ethernet.h>
byte mac = { 0xDE, 0xAD, 0xBE, 0xFF, 0xFF, 0xAA };
byte server = {10,7,31,70};
IPAddress ip(10,7,31,66);
IPAddress gateway(10,7,31,65);
IPAddress subnet(255,255,255,192);

SoftwareSerial sim800(4, 9); // RX, TX

//-----------------------ESTAÇÃO AMERICANA---------------

//----------------------Portas Analogicas----------------

float sensorTemp = A0; // sensor de temperatura

//-----------------------Portas Digitais------------------

int sensorTensao1 = A1; // sensor tensão alternada vca1
int sensorTensao2 = A2; // sensor tensão alternada vca2
int sensorTensao3 = A3; // sensor tensão alternada vca3

int sensorVcc24 = A4; // sensor tensão cc bateria 24v
int sensorVcc48 = A5; // sensor rele 48v

int sensorPorta = 2; // sensor da porta da estação telecom
int sensorFonte1 = 3; // rele fonte 1
int sensorFonte2 = 4; // rele fonte 2

int sensorMoto = 5; //

//--------------------------Váriaveis----------------------

int valorTemp;
float leituraTemp;

int valorRele;
int valorLamp;

EthernetClient client;

void setup() {

pinMode(sensorPorta,INPUT);
pinMode(sensorFonte1,INPUT);
pinMode(sensorFonte2,INPUT);
pinMode(sensorMoto,INPUT);

sim800.begin(9600);
delay(1000);
Serial.begin(9600);
delay(500);
Ethernet.begin(mac, ip);
delay(100);
Serial.print("Numero IP Arduino: ");
Serial.println(Ethernet.localIP());
delay(1000);

}
//---------------------CÁLCULO TEMPERATURA--------------------

void calculoTemp()
{
leituraTemp = analogRead(sensorTemp);
valorTemp = ((5.0 * leituraTemp * 100.0) / 1023.0);
Serial.println(valorTemp);
}

void loop()
{

Serial.println(“connecting…”);

client.connect(server, 80);
if(client.connected())
{

Serial.println(“conectado”);
delay (3000);

if(digitalRead(sensorPorta) == LOW)
{

Serial.println(“Enviando SMS, um momento…”);

sim800.write(“AT+CMGF=1\r\n”);
delay(1000);

sim800.write(“AT+CMGS=”+5519992577838"\r\n");
delay(1000);

sim800.write(valorTemp);
delay(1000);

sim800.write((char)26);
delay(1000);

Serial.println(“Feito”);

delay(3000);

}

//---------------------------FASE 1-------------------------

int valorTensao1 = analogRead(sensorTensao1);

//----------------------------FASE 2------------------------

int valorTensao2 = analogRead(sensorTensao2);

//---------------------------FASE 3-------------------------

int valorTensao3 = analogRead(sensorTensao3);

//-------------------------PORTA---------------------------

int porta = digitalRead(sensorPorta);

//-----------------------SENSOR 48VCC---------------------

int valorVcc48 = analogRead(sensorVcc48);

//-----------------------SENSOR 24VCC--------------------

int valorVcc24 = analogRead(sensorVcc24);

//-----------------------FONTE 1-------------------

int valorFonte1 = digitalRead(sensorFonte1);

//-----------------------FONTE 2-------------------

int valorFonte2 = digitalRead(sensorFonte2);

//-----------------------MOTOTRBO-------------------

int valorMoto = digitalRead(sensorMoto);

//----------------------ESCREVE NA SERIAL-------------------

Serial.println(valorTemp);
Serial.println(valorTensao1);
Serial.println(valorTensao2);
Serial.println(valorTensao3);
Serial.println(valorVcc48);
Serial.println(valorVcc24);
Serial.println(valorFonte1);
Serial.println(valorFonte2);
Serial.println(valorMoto);
Serial.println(porta);

calculoTemp(); //-- Chama subrotina de calculo da temperatura----

//----------------ENVIA DADOS PARA SERVIDOR-------------------------

client.print( “GET /projeto_telecom/recebe_americana.php?temp=”);
client.print(valorTemp);
client.print("&");
client.print(“vca1=”);
client.print(valorTensao1);
client.print("&");
client.print(“vca2=”);
client.print(valorTensao2);
client.print("&");
client.print(“vca3=”);
client.print(valorTensao3);
client.print("&");
client.print(“vcc48=”);
client.print(valorVcc48);
client.print("&");
client.print(“vcc24=”);
client.print(valorVcc24);
client.print("&");
client.print(“porta=”);
client.print(porta);
client.print("&");
client.print(“fonte1=”);
client.print(valorFonte1);
client.print("&");
client.print(“fonte2=”);
client.print(valorFonte2);
client.print("&");
client.print(“moto=”);
client.print(valorMoto);
client.print("&");

//client.print(“lamp=”);
//client.print(valorLamp);
//client.print("&");

client.println( " HTTP/1.0");
client.println( “Content-Type: text/html” );
client.println( “Connection: close” );
client.println();
client.println();
delay(10000);

}
else {

Serial.println(“connection failed”);
}

client.stop();
}

teste arduino.txt (5.42 KB)

Here is your problem. This computes a dns server, gateway and subnet mask as: dns server = 10.7.31.1 gateway = 10.7.31.1 netmask = 255.255.255.0

   Ethernet.begin(mac, ip);

Use this instead:

   Ethernet.begin(mac, ip, gateway, gateway, subnet);