Hello List. I'm new here, but working with the arduino 2 to two years. Excuse my bad English, I am Brazilian.
My problem is as follows:
I have a simple project where I use Arduino Ethernet Shield and Duemileve. The project has been running for 15 days for free.
But now what happens is the following, if I connect the Arduino only on the external source, LEDs accessing but he did not start the program. If I plug in a USB Arduino, the program starts normally.
If I plug in a USB Arduino, and then he started the program I connect the external USB deligar and it still works, but if I try to disconnect and reconnect only with the external SOURCE, accessing the LEDs, but the program does not initializes.
Does anyone know what component of my Arduino Ethernet Shield, or may be defective?
#include <SPI.h>
#include <Ethernet.h>
#include <OneWire.h>
#include <DallasTemperature.h>#define ONE_WIRE_BUS 8 //Sensor Digital Dallas DS18B20 Externo
volatile int porta = LOW;
const int buttonPin = 4;
int buttonState = 0;
int contador = 300;float temp;
int tempPin = 0;OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer;byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(177,54,53,8);
IPAddress gateway(187,42,53,1);
IPAddress subnet(255, 255, 255, 0);
IPAddress dns(179, 28, 156, 1);IPAddress server(189,18,142,19);
EthernetClient client;
void setup() {
pinMode(buttonPin, INPUT);
//Ethernet.begin(mac, ip);
Ethernet.begin(mac, ip, dns, gateway, subnet);
Serial.begin(9600);
delay(1000);
Serial.println("connecting...");sensors.begin();
}void loop()
{
if (client.available()) {
char c = client.read();
Serial.print(c);
}
delay(50);
buttonState = digitalRead(buttonPin);
if ( porta != buttonState ) {
porta = buttonState;
//connectToServerAci();
connectToServer();
contador = 300;
}
if ( contador == 0 ) {
//connectToServerTemp();
//connectToServerTemp2();
connectToServer();
contador = 300;
}
contador--;
}void connectToServer() {
Serial.println("connecting to server...");temp = analogRead(tempPin);
temp = (((temp/1023)*5)*100)-288;if (client.connect(server, 80)) {
Serial.print("Temperature Interna: ");
Serial.println(temp);sensors.requestTemperatures();
Serial.print("Temperatura Externa: ");
Serial.println(sensors.getTempCByIndex(0));Serial.print("Porta 0: ");
Serial.println(porta);Serial.println("connected");
client.print("GET /LeitorTemperaturaGeral.php?tp1=");
client.print(temp);
client.print("&tp2=");
client.print(sensors.getTempCByIndex(0));
client.print("&ac1=");
client.print(porta);
client.println(" HTTP/1.0");
client.println();
} else {
Serial.println("connection failed");
}
Serial.println("disconnecting.");
client.stop();
}void connectToServerAci() {
Serial.println("connecting to server...");if (client.connect(server, 80)) {
Serial.println("connected");
Serial.print("Acionamento Porta 1: ");
Serial.println(porta);
client.print("GET /LeitorTemperatura.php?tipo=ac1&valor=");
client.print(porta);
client.println(" HTTP/1.0");
client.println();
}
else {
Serial.println("connection failed");
}
Serial.println("disconnecting.");
client.stop();
}void connectToServerTemp() {
Serial.println("connecting to server...");temp = analogRead(tempPin);
temp = (((temp/1023)*5)*100)-288;Serial.print("Temperature Interna: ");
Serial.println(temp);if (client.connect(server, 80)) {
Serial.println("connected");
client.print("GET /LeitorTemperatura.php?tipo=tp1&valor=");
client.print(temp);
client.println(" HTTP/1.0");
client.println();
}
else {
Serial.println("connection failed");
}
Serial.println("disconnecting.");
client.stop();
}void connectToServerTemp2() {
Serial.println("connecting to server...");
sensors.requestTemperatures();Serial.print("Temperatura Externa: ");
Serial.println(sensors.getTempCByIndex(0));if (client.connect(server, 80)) {
Serial.println("connected");
client.print("GET LeitorTemperatura.php?tipo=tp2&valor=");
client.print(sensors.getTempCByIndex(0));
client.println(" HTTP/1.0");
client.println();
}
else {
Serial.println("connection failed");
}
Serial.println("disconnecting.");
client.stop();
}