Hi,
This is my first post and I am new to arduino. I am working on a class project where we are trying to setup a parking garage monitoring system. I have attached two photoelectric sensors to my arduino board and I have them recognized in a sketch. As one sensor is tripped it will display "car entered" and when the other is tripped it will display "car exit". I am trying to send an HTTP Post request from my arduino (with a wifi shield) to a server where it is being entered into a database and eventually sent to a website that other groups in the class are setting up.
Unfortunately I am relatively unexperienced in the programming world and I have no idea where to begin for this process. I will include my sketch from the sensors but I need to be able to send a packet to the "database team". The packet needs to include a Location ID(arbitrary name that I can make up), a count of cars (+1 for enter, -1 for exit), and a flag field (optional). If someone could please help me out that would be greatly appreciated. The location of the server is http://IP-Address-of-server/sensors/event.php
int sensorPin = A0; // select the input pin for the potentiometer
int sensorPin2 = A1;// input from second (exit) sensor
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
int sensorValue2=0;
int i = 0; //variable used to count
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
sensorValue2=analogRead(sensorPin2);
//Serial.println(sensorValue);
if(sensorValue < 150 && sensorValue > 141) { // value is less than 155 if sensor is detects something
i=0;
do {
if(sensorValue > 155 || sensorValue < 140) {
Serial.println("off");
break;
}
delay(100);
i++;
if(i==10) {
Serial.println("car entered");
i=0;
break;
}
}
while(1);
////////////
}
if(sensorValue2 < 155 && sensorValue2 > 140) { // value is less than 175 if sensor is detects something
i=0;
do {
if(sensorValue2>155) {
Serial.println("off");
break;
}
delay(200);
i++;
if(i==10) {
Serial.println("car exited");
i=0;
break;
}
}
while(1);
}
// turn the ledPin on
digitalWrite(ledPin, HIGH);
// stop the program for milliseconds:
//delay(sensorValue);
// turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for for milliseconds:
delay(sensorValue);
}