Hi All,
I used the code available for the pulse sensor for ArduinoUNO and I am trying to send the BPM value to a web application server using a GET request. I am using the WiFi shield cc3000.
I realised that I am also able to connect to the server but timer is not working well. I'm only getting one value for BPM instead of a value measured according to the timer.
Can you tell me at least if it's possible what I'm trying to do?
I would be grateful if you helped me! Kind regards!
This is the code I'm using. I'm new to this so I'm sorry if I did not expose my problem in a proper manner. But i really need help ![]()
void setup(void)
{
Serial.begin(56700);
interruptSetup();
Serial.print(F("Initializing..."));
if(!cc3000.begin()) {
Serial.println(F("failed. Check your wiring?"));
return;
}
Serial.print(F("OK.\r\nConnecting to network..."));
cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);
Serial.println(F("connected!"));
Serial.print(F("Requesting address from DHCP server..."));
for(t=millis(); !cc3000.checkDHCP() && ((millis() - t) < dhcpTimeout); delay(500)) {
Serial.println("....waiting");
}
if(cc3000.checkDHCP()) {
Serial.println(F("OK"));
}
else {
Serial.println(F("failed"));
return;
}
ip = 0;
Serial.print(WEBSITE); Serial.print(F(" -> "));
while (ip == 0) {
if (! cc3000.getHostByName(WEBSITE, &ip)) {
Serial.println(F("Couldn't resolve!"));
}
delay(500);
}
}
void loop(void)
{
Serial.print("Connecting to server ");
cc3000.printIPdotsRev(ip);
Serial.println("...");
www = cc3000.connectTCP(ip, 80);
// Send request
if (www.connected()) {
if (QS == true){
serialOutputWhenBeatHappens(); // A Beat Happened, Output that to serial.
params = "&pulse="+BPM;
sendData(BPM);
QS = false; // reset the Quantified Self flag for next time
}
}
else {
Serial.println(F("Connection failed"));
return;
}
Serial.println("...Reading response");
/* Read data until either the connection is closed, or the idle timeout is reached. */
unsigned long lastRead = millis();
while (www.connected() && (millis() - lastRead < IDLE_TIMEOUT_MS)) {
while (www.available()) {
char c = www.read();
Serial.print(c);
lastRead = millis();
}}
www.close();
Serial.print(F("Cleaning up... "));
//client.close();
Serial.println(F(" socket closed. Waiting for 5 seconds before sending the request again."));
//wait some amount of time before sending data to the PHP service.
delay(5000);
}
void serialOutputWhenBeatHappens(){
if (serialVisual == true){ // Code to Make the Serial Monitor Visualizer Work
Serial.print("*** Heart-Beat Happened *** "); //ASCII Art Madness
//delay(60000);
Serial.print("BPM: ");
Serial.println(BPM);
Serial.print(" ");
} }
void sendData(int data){
www.fastrprint(F("GET "));
www.print(WEBPAGE+params);
www.fastrprint(F(" HTTP/1.1\r\n"));
www.fastrprint(F("Host: ")); www.fastrprint(WEBSITE); www.fastrprint(F("\r\n"));
www.fastrprint(F("\r\n"));
www.println();
}