Hi everyone, I ask you a question about a simple project that I am realizing … Why when I boot up, if I do not connect the LAN cable to the ethernet shield, since I do not get the IP addresses, the sketch does not start up when do I not connect the LAN? How can I solve it without distorting everything?
thanks for the answers in advance
Here is the sketch I use:
#define BLYNK_PRINT Serial
#include <Blynk.h>
#include <FastIO.h>
#include <I2CIO.h>
#include <LCD.h>
#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidCrystal_SR.h>
#include <LiquidCrystal_SR2W.h>
#include <LiquidCrystal_SR3W.h>
#include <Wire.h>
#include <DHT.h>
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define W5100_CS 10
#define SDCARD_CS 4
char auth[] = "...";
IPAddress server_ip (.,.,.,.);
#define DHTPIN 2 // What digital pin we're connected to
#define DHTPIN1 3 // What digital pin we're connected to
#define ONE_WIRE_BUS 7
#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321
#define deum 8
#define vlv 9
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DHT dht(DHTPIN, DHTTYPE);
DHT dht1(DHTPIN1, DHTTYPE);
BlynkTimer timer;
WidgetLED LEDdeum(V3);
WidgetLED LEDvlv(V4);
int virtualbutton;
byte range = 3;
int val = 0;
float h, t, h1, t1, td, td1, s1;
String deu, valve;
byte ultimo_pulsante;
byte page = 0;
byte freccia_su[8] = {
B00000,
B00000,
B00100,
B01110,
B11111,
B00000,
B00000,
B00000,
};
byte freccia_giu[8] = {
B00000,
B00000,
B00000,
B11111,
B01110,
B00100,
B00000,
B00000,
};
byte grado[8] = {
B00010,
B00101,
B00010,
B00000,
B00000,
B00000,
B00000,
B00000,
};
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
BLYNK_WRITE(V1) {
val = param.asInt(); // assigning incoming value from pin V1 to a variable
range = range + val;
Serial.println("pulsante remoto");
}
BLYNK_WRITE(V2) {
virtualbutton = param.asInt();
Serial.println("Interruttore remoto");
Serial.print("virtual= ");
Serial.print(virtualbutton);
}
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
{
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V0, range);
Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);
Blynk.virtualWrite(V7, h1);
Blynk.virtualWrite(V8, t1);
Blynk.virtualWrite(V9, s1);
Blynk.virtualWrite(V10, td);
Blynk.virtualWrite(V11, td1);
}
void setup() {
pinMode(SDCARD_CS, OUTPUT);
digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
//timer.setInterval(myEthernetTimeout, myfunction);
//timer.setInterval(blynkInterval, checkBlynk); // check connection to server per
lcd.begin(20, 4);
lcd.clear();
lcd.createChar(1, freccia_su);
lcd.createChar(2, freccia_giu);
lcd.createChar(3, grado);
lcd.setCursor(0, 0);
lcd.print("CONTROLLO ");
lcd.setCursor(0, 1);
lcd.print("DEUMIDIFICAZIONE");
lcd.setCursor(0, 2);
lcd.print("Premere ENTER ");
lcd.setCursor(0, 3);
lcd.print("per accedere ai menu");
page = 0;
Serial.begin(9600);
pinMode(deum, OUTPUT);
pinMode(vlv, OUTPUT);
//Ethernet.begin();
Blynk.begin(auth, server_ip, 8442);
// You can also specify server:
//Blynk.begin(auth, "blynk-cloud.com", 8442);
//Blynk.begin(auth, IPAddress(server_ip), 8442);
dht.begin();
sensors.begin();
// Setup a function to be called every second
timer.setInterval(1000L, sendSensor);
digitalWrite (deum, HIGH);
digitalWrite (vlv, LOW);
}
void loop() {
Serial.println("Inizia");
sensori();
Blynk.run();
timer.run();
onoff();
lettura_pulsanti();
richiama_update();
if ((page == 4) || (page == 5) || (page == 6) || (page == 7) || (page == 8) || (page == 4)) {
Serial.println("OK");
Serial.println("OKK");
updateLcd();
}
}