Hello Mario-r,
Yes, I have that line. This is the code I have:
#include<SPI.h>
#include<Ethernet.h>
#include <Adafruit_MAX31856.h>
#define DRDY_PIN 8
// Use software SPI: CS, DI, DO, CLK
//Adafruit_MAX31856 maxthermo = Adafruit_MAX31856(10, 11, 12, 13);
// use hardware SPI, just pass in the CS pin
Adafruit_MAX31856 maxthermo = Adafruit_MAX31856(9);
int index = -1;
int ethernetCS = 10;
int maxthermoCS = 9;
int SDcardCS = 4;
int pin;
int FanRelay = 2;
byte mac[] = {0xA8, 0x61, 0x0A, 0xAE, 0x98, 0x45};
IPAddress ip(192, 168, 0, 99);
EthernetServer server(80);
String readString;
void setup() {
pinMode(ethernetCS, OUTPUT);
digitalWrite(ethernetCS, HIGH); //disable Ethernet Shield
pinMode(DRDY_PIN, INPUT);
pinMode(maxthermoCS, OUTPUT);
digitalWrite(maxthermoCS, HIGH); //disable Adafruit_MAX31856 board
pinMode(SDcardCS, OUTPUT);
digitalWrite(SDcardCS, HIGH); //disable SD Card on the Ethernet Shield
Serial.begin(115200);
while (!Serial) delay(10);
Serial.print("Initializing Ethernet Shield...");
Ethernet.begin(mac, ip);
Serial.print("Server is at ");
Serial.println(Ethernet.localIP());
pinMode(ethernetCS, OUTPUT);
digitalWrite(ethernetCS, HIGH); //disable Ethernet Shield
Serial.println("MAX31856 thermocouple");
if (!maxthermo.begin()) {
Serial.println("Could not initialize thermocouple.");
while (1) delay(10);
}
maxthermo.setThermocoupleType(MAX31856_TCTYPE_K);
Serial.print("Thermocouple type: ");
switch (maxthermo.getThermocoupleType() ) {
case MAX31856_TCTYPE_B: Serial.println("B Type"); break;
case MAX31856_TCTYPE_E: Serial.println("E Type"); break;
case MAX31856_TCTYPE_J: Serial.println("J Type"); break;
case MAX31856_TCTYPE_K: Serial.println("K Type"); break;
case MAX31856_TCTYPE_N: Serial.println("N Type"); break;
case MAX31856_TCTYPE_R: Serial.println("R Type"); break;
case MAX31856_TCTYPE_S: Serial.println("S Type"); break;
case MAX31856_TCTYPE_T: Serial.println("T Type"); break;
case MAX31856_VMODE_G8: Serial.println("Voltage x8 Gain mode"); break;
case MAX31856_VMODE_G32: Serial.println("Voltage x8 Gain mode"); break;
default: Serial.println("Unknown"); break;
}
maxthermo.setConversionMode(MAX31856_ONESHOT_NOWAIT);
pinMode(maxthermoCS, OUTPUT);
digitalWrite(maxthermoCS, HIGH); //disable Adafruit_MAX31856 board
pinMode(ethernetCS, OUTPUT);
digitalWrite(ethernetCS, LOW); //enable Ethernet Shield
pinMode(FanRelay, OUTPUT);
digitalWrite(FanRelay, HIGH); //Fan On
delay(3000);
digitalWrite(FanRelay, LOW); //Fan Off
}
void loop() {
EthernetClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
//Serial.print(c);
if (readString.length() < 100) {
readString += c;
}
if (c == '\n') {
Serial.print(readString);
client.println("HTTP/1.1 200 OK");
if (readString.indexOf("?TEMP") > 0) {
digitalWrite(ethernetCS, HIGH); //disable Ethernet Shield
digitalWrite(maxthermoCS, LOW); //enable Adafruit_MAX31856 board
maxthermo.triggerOneShot(); // Trigger the reading
delay(500);
if (maxthermo.conversionComplete()) {
double Temp = maxthermo.readThermocoupleTemperature();
if (Temp > 37) {
digitalWrite(FanRelay, HIGH); //Fan On
}
if (Temp < 35) {
digitalWrite(FanRelay, LOW); //Fan Off
}
Serial.println(Temp);
digitalWrite(maxthermoCS, HIGH); //disable Adafruit_MAX31856 board
digitalWrite(ethernetCS, LOW); //enable Ethernet Shield
client.println("Temp: " + String(Temp));
}
else {
Serial.println("Conversion not complete!");
digitalWrite(maxthermoCS, HIGH); //disable Adafruit_MAX31856 board
digitalWrite(ethernetCS, LOW); //enable Ethernet Shield
client.println("Conversion not complete!");
}
}
if (readString.indexOf("?DO") > 0) {
index = readString.indexOf("?DO");
String pinStr = readString.substring((index + 3), (index + 5));
Serial.print("Digital Pin String: ");
Serial.println(pinStr);
pin = pinStr.toInt();
Serial.print("Pin Number: ");
Serial.println(pin);
String pinVal = readString.substring((index + 5), (index + 6));
Serial.print("Value To Write: ");
Serial.println(pinVal);
pinMode(pin, OUTPUT);
if (pinVal == "0") {
digitalWrite(pin, LOW);
}
else {
digitalWrite(pin, HIGH);
}
client.println("Written Value: " + pinVal);
}
readString = "";
delay(100);
client.stop();
}
}
}
}
}
When I finish the uploading, I receive the IP via serial port but when I disconnect the USB cable and send "ping 192.168.0.99" from a PC in the same network "192.168.0.50" I don't get replies.
This setup:
Arduino UNO +Ethernet shield + the code above
it work on Arduino UNO Rev3, but not on the Arduino UNO Rev4.
Thanks
Osiris
Thanks
Osiris