diff --git a/In work/Temp. sensors/Ard_mic_SHT31/Ard_mic_SHT31.ino b/Arduino/Temp Hum sensors/Ard_mic_SHT31/Ard_mic_SHT31.ino similarity index 100% rename from In work/Temp. sensors/Ard_mic_SHT31/Ard_mic_SHT31.ino rename to Arduino/Temp Hum sensors/Ard_mic_SHT31/Ard_mic_SHT31.ino diff --git a/In work/Temp. sensors/Ard_mic_SHT31_W5500/Ard_mic_SHT31_W5500.ino b/In work/Temp. sensors/Ard_mic_SHT31_W5500/Ard_mic_SHT31_W5500.ino new file mode 100644 index 0000000..0087b38 --- /dev/null +++ b/In work/Temp. sensors/Ard_mic_SHT31_W5500/Ard_mic_SHT31_W5500.ino @@ -0,0 +1,99 @@ +// SHT31 configuration +#include "Adafruit_SHT31.h" + +Adafruit_SHT31 sht31 = Adafruit_SHT31(); + +#define SHT31_RST_PIN 16 + +void resetSensor() { + pinMode(SHT31_RST_PIN, OUTPUT); + digitalWrite(SHT31_RST_PIN, LOW); + delay(10); + digitalWrite(SHT31_RST_PIN, HIGH); + delay(10); +} +// +// W5500 configuration +#include +#include + +// Configure MAC address and IP: +byte mac[] = {0x61, 0x2C, 0xF2, 0x09, 0x73, 0xBE}; + +// the real one IPAddress ip(10, 11, 1, 22); // Static IP + + +// Define CS and RST pins: +#define W5500_CS_PIN 10 // 8 in E LEGO +#define W5500_RST_PIN 9 //10 in E LEGO +IPAddress serverIP(10, 44, 1, 238); // Computer +IPAddress W5500_ip(10, 11, 1, 22); // Change the last digit + +// Don't change +const int port = 5005; +EthernetClient client; +// + + +void setup() { + // put your setup code here, to run once: + + // SHT31 First readout + Serial.begin(9600); + while (!Serial); + Serial.println ("Looking for SHT31"); + + if (!sht31.begin(0X44)) { + Serial.println("Couldn't find SHT31"); + while (1) delay(100); + } + Serial.println("SHT31 Found"); + float t = sht31.readTemperature(); + float h = sht31.readHumidity(); + + if (!isnan(t)) { + Serial.print("Temperature (C)= "); Serial.println(t);} + + if (!isnan(h)) { + Serial.print("Humidity = "); Serial.println(h); } + + + // W5500 first readout + pinMode(W5500_RST_PIN, OUTPUT); + digitalWrite(W5500_RST_PIN, HIGH); + delay(250); + digitalWrite(W5500_RST_PIN, LOW); + delay(250); + digitalWrite(W5500_RST_PIN, HIGH); + delay(1000); + + // Initialize Ethernet: + Ethernet.init(W5500_CS_PIN); + Ethernet.begin(mac, W5500_ip); + delay (1500); + + Serial.print("W5500 IP: "); + Serial.println(Ethernet.localIP()); + + // Send a message through socket + Serial.print("Sending test message"); + delay (1000); + if (client.connect (serverIP, port)) { + client.write("test"); + client.stop(); + Serial.print("Test Message sent"); + } else { + Serial.print("Connection failed");} + + + +} + + + + + +void loop() { + // put your main code here, to run repeatedly: + +}