How to connect Ultrasonic sensor data readings into enc28j60 webserver?

I have this project and I wanted to put the data readings of my ultrasonic sensor in enc28j60 webserver. I’m new to this stuff and I was kinda having troubles doing it :frowning:

here is my code for my sensor

#include <NewPing.h>

#define TRIGGER_PIN  4  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     3  // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 400 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

void setup() {
  Serial.begin(9600); // Open serial monitor at 115200 baud to see ping results.

void loop() {
  delay(300);                      // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
  unsigned int uS =; // Send ping, get ping time in microseconds (uS).
  Serial.print("Water Level: ");
  Serial.print(uS / US_ROUNDTRIP_CM); // Convert ping time to distance and print result (0 = outside set distance range, no ping echo)

This for my enc28j60 webserver. (It has a temperature sensor in it that can read in webpagel. But with the ultrasonic i can’t get it done.)

// This is a demo of the RBBB running as webserver with the Ether Card
// 2010-05-28 <>

#include <EtherCard.h>
#include <OneWire.h>  
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 2

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);  

// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
static byte myip[] = { 192,168,1,203 };
static byte gwip[] = { 192,168,1,1 };
byte Ethernet::buffer[500];
BufferFiller bfill;

int Celsius = 0;
int Fahrenheit = 0;

const int read = A0; //Sensor AO pin to Arduino pin A0
int value;          //Variable to store the incomming data

int temp=0;
int Timer=0;
int Animation=0;

void setup () {
  if (ether.begin(sizeof Ethernet::buffer, mymac, 10) == 0)
    Serial.println( "Failed to access Ethernet controller");
  ether.staticSetup(myip, gwip);
  //Begin serial communication

static void ReadTemp()
  Celsius = sensors.getTempCByIndex(0);
  Fahrenheit = sensors.toFahrenheit(Celsius);
  value = analogRead(read);

//  Here we build a web page and pass the t and h values into it
static word homePage() {
  long t = millis() / 1000;
  word h = t / 3600;
  byte m = (t / 60) % 60;
  byte s = t % 60;
  bfill = ether.tcpOffset();
  "HTTP/1.0 200 OK\r\n"
    "Content-Type: text/html\r\n"
    "Pragma: no-cache\r\n"
    "<meta http-equiv='refresh' content='1'/>"
    "<title>Temp server</title>" 
    "<body bgcolor=pink>"
    "<h1>Temp in Celsius: $D C</h1>"
    "<h1>Temp in Fahrenheit: $D F</h1>"
   Celsius, Fahrenheit, h/10, h%10, m/10, m%10, s/10, s%10);
  return bfill.position();

void loop () {
  Timer  = Timer+1;
  word len = ether.packetReceive();
  word pos = ether.packetLoop(len);

  if (pos)  // check if valid tcp data is received
    ReadTemp(); //sends data to web page


But with the ultrasonic i can't get it done.)

Why not? The hardcoded page contains text and place holders where the values from variables will be substituted.

Changing the text seems simple enough. Changing the number of place holders seems simple enough. Changing the number of variables whose values are to be used seems simple enough. Changing the names of the variable(s) whose values are to be used seems simple enough.