Hi, i am trying to make a communication between app created in mit inventor and arduino nano with ethernet module so i set up a http web server on arduino and when i change url on the app it shows error that its unable to get a response with a specified url but arduino receives the response just fine as it should.
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { mac adress }; //server stuff
IPAddress ip(192, 168, 1, 177);
EthernetServer server(80);
#define ONE_WIRE_BUS 5
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer;
String command;
const int relay = 6;
void setup(void) {
Serial.begin(9600);
sensors.begin();
sensors.getAddress(insideThermometer, 0);
sensors.setResolution(insideThermometer, 9);
pinMode(relay, OUTPUT);
digitalWrite(3,LOW);
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
while (true);
}
Serial.print("Server IP Address: ");
Serial.println(Ethernet.localIP());
server.begin();
}
float measure_temp() { // Changed return type to float
sensors.requestTemperatures();
float tempC = sensors.getTempC(insideThermometer);
return tempC; // Return temperature value
}
void loop(void) {
float temperature = measure_temp(); // Assign the return value of measure_temp() to a variable
//Serial.print("Tempereature: ");
Serial.println(temperature); // Print the temperature value
//digitalWrite(relay, HIGH);
//delay(500);
//digitalWrite(relay, LOW);
//delay(500);
// Listen for incoming clients
EthernetClient client = server.available();
if (client) {
String strtemp = String(temperature);
client.println(strtemp);
client.println("Ahoj");
String request = client.readStringUntil('\r');
int pathStart = request.indexOf(' ') + 1; // Find the position of the first space character
int pathEnd = request.indexOf(' ', pathStart); // Find the position of the next space character after the first space
String requestedPath = request.substring(pathStart, pathEnd); // Extract the substring between the two space characters
requestedPath.remove(0, 1); // odstrani sa /
if (requestedPath != "favicon.ico" && requestedPath != "alvik/2.1.0"){
command = requestedPath;
Serial.print("Request: ");
Serial.println(requestedPath);
}
client.stop();
Serial.println("Client disconnected");
}
if (command == "zap"){
digitalWrite(relay, HIGH);
}
if (command == "vyp"){
digitalWrite(relay, LOW);
}
}
Is there anyone who knows what to do?