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
}
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.
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
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
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
}
"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.
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