|
Hi,, I read most members post for 3G/GPRS and I did as they suggest to solve and run the GET request on 3G/GPRS but it does not work with me!!! So, can one assist me to find where are the error in above code.....?
#include "DHT.h"
#define DHTTYPE DHT11 // DHT 11 is the type of sensor that I used
// sensors pins of the room#1 #define temhum1 A15 //analog #define lig1 A8 //analog #define mot1 35 #define doo1 A5 //analog #define vib1 33 //===================================== // sensors pins of the room#2 #define temhum2 2 //digital #define lig2 A9 //analog #define mot2 43 #define doo2 A4 //analog #define vib2 39 //===================================== // sensors pins of the room#3 #define temhum3 3 //digital #define lig3 A10 //analog #define mot3 34 #define doo3 A3 //analog #define vib3 30 //=====================================
char data[1024]; int data_size; int led = 13; int onModulePin = 2; // the pin to switch on the module (without press on button)
int x = 0;
char server[ ]="server21.000webhost.com"; //Altrevista char port[ ]="80";
// sensors variable of the room#1 float temp1; float humi1; int light1; int motion1; int door1; int vibr1; //===================================== // sensors variable of the room#2 float temp2; float humi2; int light2; int motion2; int door2; int vibr2; //===================================== // sensors of the room#3 float temp3; float humi3; int light3; int motion3; int door3; int vibr3; //=====================================
int vibsensorValue1; int vibsensorValue2; int vibsensorValue3;
DHT dht3(temhum2, DHTTYPE); DHT dht2(temhum3, DHTTYPE);
void switchModule(){ digitalWrite(onModulePin,HIGH); delay(2000); digitalWrite(onModulePin,LOW); }
void setup(){
Serial.begin(115200); // UART baud rate delay(2000); pinMode(led, OUTPUT); pinMode(onModulePin, OUTPUT); pinMode(temhum1, INPUT); pinMode(temhum2, INPUT); pinMode(temhum3, INPUT); pinMode(lig1, INPUT); pinMode(lig2, INPUT); pinMode(lig3, INPUT); pinMode(mot1, INPUT); pinMode(mot2, INPUT); pinMode(mot3, INPUT); pinMode(doo1, INPUT); pinMode(doo2, INPUT); pinMode(doo3, INPUT); pinMode(vib1, INPUT); pinMode(vib2, INPUT); pinMode(vib3, INPUT); dht3.begin(); // temp. & humi. sensor at room#3 read dht2.begin(); // temp. & humi. sensor at room#2 read sensorsValues(); // get the sensors status switchModule(); // switches the module ON
for (int i=0;i< 5;i++) { Serial.print("Countdown: "); Serial.print(i);Serial.println("-->"); delay(5000); } Serial.println("AT+CGSOCKCONT=1,\"IP\",\"wap.fido.ca\""); //internet.fido.ca // Fido-core-appl1.apn Serial.flush(); while(Serial.read()!='K'); }
void loop() {
Serial.print("AT+CHTTPACT=\""); //Connects with the HTTP server Serial.print(server); Serial.print("\","); Serial.println(port); Serial.flush(); sensorsValues(); // get the sensors status x=0; do{ while(Serial.available()==0); data[x]=Serial.read(); x++; }while(!(data[x-1]=='T'&&data[x-2]=='S')); //waits for response "REQUEST" Serial.print("GET /updateCurrentStatus.php?"); Serial.print("temp1=");Serial.print(temp1); Serial.print("&humi1=");Serial.print(humi1); Serial.print("&light1=");Serial.print(light1); Serial.print("&movement1=");Serial.print(motion1); Serial.print("&temp2=");Serial.print(temp2); Serial.print("&humi2=");Serial.print(humi2); Serial.print("&light2=");Serial.print(light2); Serial.print("&movement2=");Serial.print(motion2); Serial.print("&temp3=");Serial.print(temp3); Serial.print("&humi3=");Serial.print(humi3); Serial.print("&light3=");Serial.print(light3); Serial.print("&movement3=");Serial.print(motion3); Serial.println(" HTTP/1.1"); Serial.println("Host: aljarous.comze.com"); Serial.println("Content-Length: 0"); Serial.write(0x0D); Serial.write(0x0A); Serial.write(0x0D); Serial.write(0x0A); Serial.write(0x1A); //sends ++ while(Serial.read()!='K'); while(Serial.read()!=' ');
do{ while(Serial.available()==0); data[x]=Serial.read(); x++; }while(!(data[x-1]=='/'&&data[x-2]=='<')); //Program stops at first occurence of "</"
Serial.println(data);
while(1); }
void sensorsValues() {
// the Arduino will read all sensors status then assigne them to its variable vibsensorValue1 = digitalRead(vib1); // variable to store the value coming from the sensor vibsensorValue2 = digitalRead(vib2); // variable to store the value coming from the sensor vibsensorValue3 = digitalRead(vib3); // variable to store the value coming from the sensor int i; for(i=1 ; i<4 ; i++) { readTempHumi(i); readDoor(i); readVib(i); readMotion(i); readLight(i); } }
Regards aljarous
|