Hi Team,
Can you help me out on this please.
I have the ethernet shield and the below code uploaded and running.
I am getting data output from both serial and intranet ip address as long as it is one machine.
Ie. I type the ip address onto a machine which the arduino is not connected and the data is displayed correctly. If I go to another machine and type in the ip address I get that data but the the first machine looses connection and I get IP address not found.
Is the arduino Ethernet shild limited to one machine reading at once or is it to do with the time delay.
Much appreciate your help.
Here’s the generic code…
/*
Arduino and Ethernet
*/
#include <SPI.h>
#include <Ethernet.h>
byte mac = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
byte ip = {192,168,1,66}; // don’t forget to change this IP address for your own situation
EthernetServer server(80);
void setup()
{
Ethernet.begin(mac, ip);
Serial.begin(9600);
server.begin();
}
float voltage=0;
float sensor=0;
#define SENSOR_COUNT 1
const int analog_pins[SENSOR_COUNT] = {1};
void loop()
{
EthernetClient client = server.available();
if (client) {
// an http request ends with a blank line
boolean current_line_is_blank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// if we’ve gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so we can send a reply
if (c == ‘\n’ && current_line_is_blank) {
// send a standard http response header
client.println(“HTTP/1.1 200 OK”);
client.println(“Content-Type: text/html”);
client.println();
client.println("");
client.println("");
client.println("");
client.println(“Greenhill Mushrooms”);
client.println("<meta http-equiv=“refresh” content=“1”>");
client.println("");
client.println("");
client.println(“
Greenhill Mushrooms
”);client.println(“
Room Monitoring System
”);client.println("");
client.println("");
for(int I=0; I < SENSOR_COUNT; I++){
int sensorValue = analogRead(analog_pins*);*
- float voltage;*
_ { voltage = ((sensorValue) * (5.15 / 1023.0));}_
- if (voltage < 0){ voltage = 0.00;}*
_ voltage = voltage * 10;_
_ voltage = voltage * 2;_
- client.print(“Room “);*
client.print(analog_pins*);
_ client.print(”'s Temperature is “);_
_ client.print(voltage);_
_ client.println(”_
_”); // new line *_
* Serial.print("Sensor Value is : ");*
* Serial.print(sensorValue);*
* Serial.println();*
* Serial.print("Sensor Voltage is : ");*
* Serial.print(voltage, 3);*
* Serial.println();*
* delay (3000);*
* }*
* break;*
* }*
* if (c == ‘\n’) {*
* // we’re starting a new line*
* current_line_is_blank = true;
_ }_
_ else if (c != ‘\r’) {_
_ // we’ve gotten a character on the current line*_
* current_line_is_blank = false;
_ }_
_ }_
_ }_
_ // give the web browser time to receive the data*_
* delay(1);*
* client.stop();*
* }*
}
Regards
Witsend.