Sending serial monitor data to webpage PLEASE HELP

Hello I'm really really new to Arduino and I'm desperate for help on my project. I have a seat sensor which utilizes human capacitance to pick up a reading. I get exactly what I want in terms of the data displayed on the serial monitor and I have a working connection with my Arduino Yun on ehternet and wifi.

MY PROBLEM: all i want to do is display this exact data from the serial monitor onto a webpage that I can access. i have no idea how to alter my code to do this and I would really appreciate your help many thanks. Preferably I would like to do this via an ethernet cable rather than wifi because I need to demonstrate this at my school and they block their wifi

thanks for your time!

heres my code:

#include <CapacitiveSensor.h>
/*
INTRODUCTION: The following code is my first draft code for the seat sensor. It gives the value of
sensitivity in the receive pin for each second with a notification of every minute
passed to keep track of the time that the sensor is in operation.
The draft code uses a 1 Mega - Ohm resistor and a coper sheet for the sensing metal.
*/

CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2); // A 1 Mega-Ohm resistor is placed between the send and receive pin (pins 4 & 2)

unsigned long previousMillis = 0; // last time update
long interval = 6000; // interval at which to do something (milliseconds)

void setup() // run the setup once
{
Serial.begin(9600); // start the serial communication at 9600baud
cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off auto calibrate on channel 1 - just as an example

}

int minutes = 1; // initialize the minute variable to start incrementing from the first minute
int seconds = 0; // initialize seconds count from 0

void loop()
{
long start = millis(); // counter in milliseconds
long total1 = cs_4_2.capacitiveSensor(30); // adjust the sensitivity of total1 when sensor is touched/untouched

Serial.print("second "); // print the seconds value
Serial.print(seconds++); // increment seconds by 1 each iteration
Serial.print(" \t"); // line spacing

Serial.print("Seat Sensor Value: ");
Serial.println(total1); // print sensor value of total1
delay(1000); // delay to limit data for every second at serial port

if ((start - previousMillis) >= interval) // enter the 'if' statement every 60000 ms or 60 seconds
{
previousMillis = start;
Serial.print("MINUTE "); // print minutes value
Serial.print(minutes++ ); // increment minutes by 1 each time
Serial.print(" \t");
Serial.print("Seat Sensor Value: "); // prints seat sensor value field
Serial.println(total1); // prints value of total1
}

}

draft_code.ino (2.01 KB)

MY PROBLEM: all i want to do is display this exact data from the serial monitor onto a webpage that I can access

Is the Arduino going to act as a server? Or, is it going to act as a client? Client's make requests, like your browser requests html data that it renders as a web page.

Servers provide responses to requests. Servers can not pus data to clients.

No computer can push data to a web page.

I think I want it to be a client. I'm not too sure though, I mean I want the webpage to open up with the data that the arduino collects when i touch the sensor

Take a look at the example program Ethernet --> WebClient or Ethernet --> WebServer and see which will work best for your needs.

I mean I want the webpage to open up with the data that the arduino collects when i touch the sensor

The Arduino is, it seems, going to act as a client, requesting that the server store some information somewhere.

The browser is also going to be a client, requesting that the server spill the beams on the stored data.

The browser will need to be responsible for checking, periodically, to see if there is new data.

PaulS:
No computer can push data to a web page.

However, a served page can request that the client access again with a refresh request:

client.fastrprintln(F("Refresh: 10"));  // refresh the page automatically every 10 sec

So you can keep checking the seat as often as you like, and serve up a different response depending on what you read.

PaulS:
The Arduino is, it seems, going to act as a client, requesting that the server store some information somewhere.

The browser is also going to be a client, requesting that the server spill the beams on the stored data.

The browser will need to be responsible for checking, periodically, to see if there is new data.

Hi,do you know how i could implement this into my current code?

do you know how i could implement this into my current code?

There is an example of the Arduino as client with the Ethernet library.

You are going to need code on your server and on your Arduino if the Arduino is to act as a client.

The server code must know what to do when the Arduino makes a GET or POST with the data it wants displayed on the browser.

If the Arduino acts as a server then all the browser needs to know is how to make a simple GET request to the appropriate URL.

How much experience of web programming do you have?

...R

Robin2:
You are going to need code on your server and on your Arduino if the Arduino is to act as a client.

The server code must know what to do when the Arduino makes a GET or POST with the data it wants displayed on the browser.

If the Arduino acts as a server then all the browser needs to know is how to make a simple GET request to the appropriate URL.

How much experience of web programming do you have?

...R

Very little unfortunately, I really don't know what I need to add to my code to do this. I want the serial monitor data to open on an IP address within my Ethernet range

LOOK at the Ethernet --> WebServer example.

ieee488:
LOOK at the Ethernet --> WebServer example.

Hi, i think because i have a Yun the webserver example doesn't work when i try to access the ip address, it says the following:

This site can’t be reached

192.168.1.177 took too long to respond.

I really don't know what I need to add to my code to do this. I want the serial monitor data to open on an IP address within my Ethernet range

This makes absolutely no sense. The data can't "open on an IP address".

Hi, i think because i have a Yun the webserver example doesn't work when i try to access the ip address, it says the following:

This site can't be reached

192.168.1.177 took too long to respond.

Nice that you finally mention that you are using a Yun.

WHERE IS YOUR CODE?

PaulS:
This makes absolutely no sense. The data can't "open on an IP address".
Nice that you finally mention that you are using a Yun.

WHERE IS YOUR CODE?

Hello, this is my code which gets data into the serial monitor, i just need to send the serial monitor data to a section called 'seat sensor' on a menu bar on my http://localhost/homepage.html page:

#include <CapacitiveSensor.h>
/*
INTRODUCTION: The following code is my first draft code for the seat sensor. It gives the value of
sensitivity in the receive pin for each second with a notification of every minute
passed to keep track of the time that the sensor is in operation.
The draft code uses a 1 Mega - Ohm resistor and a coper sheet for the sensing metal.
*/

CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2); // A 1 Mega-Ohm resistor is placed between the send and receive pin (pins 4 & 2)

unsigned long previousMillis = 0; // last time update
long interval = 6000; // interval at which to do something (milliseconds)

void setup() // run the setup once
{
Serial.begin(9600); // start the serial communication at 9600baud
cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off auto calibrate on channel 1 - just as an example

}

int minutes = 1; // initialize the minute variable to start incrementing from the first minute
int seconds = 0; // initialize seconds count from 0

void loop()
{
long start = millis(); // counter in milliseconds
long total1 = cs_4_2.capacitiveSensor(30); // adjust the sensitivity of total1 when sensor is touched/untouched

Serial.print("second "); // print the seconds value
Serial.print(seconds++); // increment seconds by 1 each iteration
Serial.print(" \t"); // line spacing

Serial.print("Seat Sensor Value: ");
Serial.println(total1); // print sensor value of total1
delay(1000); // delay to limit data for every second at serial port

if ((start - previousMillis) >= interval) // enter the 'if' statement every 60000 ms or 60 seconds
{
previousMillis = start;
Serial.print("MINUTE "); // print minutes value
Serial.print(minutes++ ); // increment minutes by 1 each time
Serial.print(" \t");
Serial.print("Seat Sensor Value: "); // prints seat sensor value field
Serial.println(total1); // prints value of total1
}

}

martygenetty:
on my http://localhost/homepage.html page:

What server is hosting that web page?

It would be great if you could provide that information without having to be asked.

...R

Robin2:
What server is hosting that web page?

It would be great if you could provide that information without having to be asked.

...R

i dont know what you mean, you have to realise im not trying to be difficult, im just so very very new to all of this.

im using wampserver 3 if thats of any help, but again im not sure

"localhost" is the machine you are currently on - is that what you intend?

As for more information on GET and POST, check out
PHP - GET & POST Methods and
HTTP made really easy
to get a better understanding of how the pieces fit together. I found both of those quite helpful.

the machine im currently on? would that be just my laptop using windows 8 and wampserver 3?

I was not asking what computer the server is on in Reply #15.

I was trying to find out what server program is hosting the web page.

@martygenetty, if you have a web page working already then you must have created it somehow. How?

...R

Robin2:
I was not asking what computer the server is on in Reply #15.

I was trying to find out what server program is hosting the web page.

@martygenetty, if you have a web page working already then you must have created it somehow. How?

...R

I just used a html code for my homepage and php code for users to register and login. i dont think i have a server because my homepage isnt accessible to the web