Need help programming Arduino

i need your help on a small project. The idea is to connect to the Arduino W5100 Shield and connect a 18B20 digital thermometer to it. But in this situation I have a thermometer already connected to Arduino and in the local network I can already see the readings of this thermometer. But still to normal operation it is necessary that still it was possible to see in the local network the diagram.
// OneWire DS18S20, DS18B20, DS1822 Temperature Example
// The DallasTemperature library can do all this work for you!
#include <OneWire.h>
#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0x??, 0x??, 0x??, 0x??, 0x??, 0x?? // Enter your ethernet MAC address. You will find it behind your arduino board.
IPAddress ip(192, 168, 1, 102); // Set your IP address for Arduino Board

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

OneWire ds(2); // on pin 10 (a 4.7K resistor is necessary)

void setup(void) {
// Open serial communications and wait for port to open:
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only

// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
Serial.print("server is at ");

void loop(void) {
byte i;
byte present = 0;
byte type_s;
byte data[12];
byte addr[8];
float celsius, fahrenheit;

if ( ! {
Serial.println(“No more addresses.”);

Serial.print(“ROM =”);
for( i = 0; i < 8; i++) {
Serial.write(’ ');
Serial.print(addr[i], HEX);

if (OneWire::crc8(addr, 7) != addr[7]) {
Serial.println(“CRC is not valid!”);

// the first ROM byte indicates which chip
switch (addr[0]) {
case 0x10:
Serial.println(" Chip = DS18S20"); // or old DS1820
type_s = 1;
case 0x28:
Serial.println(" Chip = DS18B20");
type_s = 0;
case 0x22:
Serial.println(" Chip = DS1822");
type_s = 0;
Serial.println(“Device is not a DS18x20 family device.”);

ds.write(0x44); // start conversion, use ds.write(0x44,1) with parasite power on at the end

delay(1000); // maybe 750ms is enough, maybe not
// we might do a ds.depower() here, but the reset will take care of it.

present = ds.reset();;
ds.write(0xBE); // Read Scratchpad

Serial.print(" Data = “);
Serial.print(present, HEX);
Serial.print(” “);
for ( i = 0; i < 9; i++) { // we need 9 bytes
data[i] =;
Serial.print(data[i], HEX);
Serial.print(” “);
Serial.print(” CRC=");
Serial.print(OneWire::crc8(data, 8), HEX);

// Convert the data to actual temperature
// because the result is a 16 bit signed integer, it should
// be stored to an “int16_t” type, which is always 16 bits
// even when compiled on a 32 bit processor.
int16_t raw = (data[1] << 8) | data[0];
if (type_s) {
raw = raw << 3; // 9 bit resolution default
if (data[7] == 0x10) {
// “count remain” gives full 12 bit resolution
raw = (raw & 0xFFF0) + 12 - data[6];
} else {
byte cfg = (data[4] & 0x60);
// at lower res, the low bits are undefined, so let’s zero them
if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms
else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
//// default is 12 bit resolution, 750 ms conversion time
celsius = (float)raw / 16.0;
fahrenheit = celsius * 1.8 + 32.0;
Serial.print(" Temperature = “);
Serial.print(” Celsius, “);
Serial.println(” Fahrenheit");

// listen for incoming clients
EthernetClient client = server.available();
if (client) {
// Serial.println(“new client”);
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c =;
// Serial.write©;
// if you’ve gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == ‘\n’ && currentLineIsBlank) {
// send a standard http response header
client.println(“HTTP/1.1 200 OK”);
client.println(“Content-Type: text/html”);
client.println(“Connection: close”); // the connection will be closed after completion of the response
client.println(“Refresh: 5”); // refresh the page automatically every 5 sec



Welcome To My Home


Room Temperature = “);







      // Date and Time script
      client.print("<script language='javascript'>");
      client.print("var today = new Date()");
      client.print("document.write(today); //--> </script>");

    if (c == '\n') {
      // you're starting a new line
      currentLineIsBlank = true;
    else if (c != '\r') {
      // you've gotten a character on the current line
      currentLineIsBlank = false;
// give the web browser time to receive the data
// close the connection:

// Serial.println(“client disconnected”);

This part is clear enough It appears this code will likely accept a connection to its assigned IP address on port 80 and supply the temperature from the thermometer as a response to an http request.
You appear to be saying that that works as expected.

This part is unclear. What is a diagram?


Sorry Diagrama It’s Temperature chart

So you need to create such a chart from the individual temperatures over some period of time and display it on the web page? My first though is that an Arduino (assuming thats what you are using as opposed to something like a teensy that is a 32 bit arm processor or one of the node cpu family) won’t have enough storage space without an sd card or something like it to store the data.


Today in the Google search engine, I realized that without SD card in my project, do not be afraid. Since the data will be stored on the SD card. And one week I think for the data will suffice.

Then you will need to get the data in to the form of a graph over time and format it as a web page. The usual method of doing that would be gnuplot on a PC. I don’t know if there is a package for the arduino that will do that (I suspect there may be if you search for it with google). Search for an arduino project that plots time series data on a web page would be my suggestion.


1 Like

OK, the main thing is to collect statistics for the design work.

If you want the data on a PC rather than the arduino itself your life becomes much easier. I’d dump the temperature data via the serial port to a PC and do the collection and plotting there with more powerful tools. For backup you can also write the data to the sd card on the arduino in case something happens to the pc.


ok. only how to program Arduino for this task?

now I see only the current temperature on the server by ip

It will depend on how you choose to do it and what you need. For instance the easiest one would be to collect the data on the arduino and store it on the sd card using something like this:

which logs the sensor data on the sd card on the arduino. When you have a weeks worth of data (or how ever long you choose) transfer the sd card to the pc, read the data and process it with tools such as matlab or gnuplot on the pc. If you need real time data, then you would need to find a tutorial on sending data via the serial port to a PC and logging it there (I expect google will find some, there are tutorials on doing almost anything with an arduino around).