Start automatically on power-up

Hello this is my first post and I thank you in advance, I have an arduino uno and when load an sketch only works when I click on serial monitor. If I do not plug to the computer doesn't work, but if i plug to the computer and click monitor-serial the sketch starts properly.

This is the code and thanks

//Se importan las librerías
#include <SPI.h>
#include <Ethernet.h>
#include <OneWire.h> 
#include <DallasTemperature.h>

//Se declara la IP y la MAC
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0F, 0x4C, 0x44 };
IPAddress ip(***,***,***,****);
IPAddress myDns(147,96,1,9);

// Inicializa la instancia client
EthernetClient client;
// Direccion del servidor
char server[] = "*************************";
 
//Se declara el pin donde se conectará la DATA
#define Pin 2
//Se establece el pin declarado como bus para la comunicación OneWire 
OneWire ourWire(Pin); 
//Se instancia la librería DallasTemperature
DallasTemperature sensors(&ourWire); 


//Se inician los sensores 
  void setup() {
  delay(1000);
  Serial.begin(9600);
  sensors.begin(); 
// Se inicia la conexion con el servidor
  Ethernet.begin(mac, ip, myDns);
}
 

void loop() {
  // Se conecta al servidor en el puerto 80 (web)
  if (client.connect(server, 80)) {
    // Envia el dato al puerto serial
    sensors.requestTemperatures(); 
    client.print("GET /********.php?v1=******&v2=*******&v3=");
    client.print(sensors.getTempCByIndex(0));
    client.println(" HTTP/1.1");
    client.print("Host: ");
    client.println(server);
    client.println("User-Agent: Arduino-Ethernet");
    client.println("Connection: close");
    client.println();
  } 
  else {
    // Si la conexion fallo se desconecta
    Serial.println("Error al conectarse al servidor");
    Serial.println("Desconectando...");
    client.stop();
  }
  delay(30000);  
}

Sorry for my English

If I do not plug to the computer doesn't work

How are you powering the Arduino, ethernet shield, and sensors when not connected to the PC?

I think it IS starting properly, but you don't see anything happen until you open the monitor. Opening the monitor resets the board and the program starts over, so it looks to you like it wasn't running before you opened the monitor.

Put some code into blink an LED and I'm sure you'll see it blink before you open the monitor.

but you don't see anything happen until you open the monitor.

Presumably, one could look at the server end and see whether anything was being sent.

I power the arduino with an USB DC power. And when i click un monitor serial the sketch start and call the PHP and insert a row un the BBDD. But when the arduino doesnt plug to a pc doesnt work

PaulS:

but you don't see anything happen until you open the monitor.

Presumably, one could look at the server end and see whether anything was being sent.

Fair enough....

raiden715:
I power the arduino with an USB DC power. And when i click un monitor serial the sketch start and call the PHP and insert a row un the BBDD. But when the arduino doesnt plug to a pc doesnt work

My suggestion still stands though: blink the pin 13 LED in setup and maybe again in loop somewhere and be sure it is or isn't actually running the sketch

I power the arduino with an USB DC power.

Capable of delivering how much current? Handwaving is next to useless here.

When i plug the arduino to the pc and click monitor serial the sketch works, the PHP works and in the BBDD create a new row right. But if i plug the arduino to the pc without click monitor serial doesnt work. And if i plug the arduino yo the dc power witout pc doesnt works.

And excuse my bad english again

Did you do what I suggested and blink the led on pin 13 to see if the sketch is actually running?

The sketch only works with pc plugged and click monitor serial