     Serial.println("connection failed");
     return;
   }
+
+  // We now create a URI for the request
+  String body = "diastolic=";
+  body += diastolic;
+  body += "&systolic=";
+  body += systolic;
+  body += "&hr=";
+  body += hr;
+
+  String post = String("POST /api.php/bp HTTP/1.1\r\n") +
+               "Host: " + host + "\r\n" +
+               "Content-Type: text/plain\r\n" +
+               "Content-Length: " + body.length() + "\r\n\r\n" + // must be twice
+               body + "\r\n" +
+               "Connection: close";
+
+  Serial.println("Full request:");
+  Serial.println(post);
   
-  // We now create a URI for the request
-  String url = "/input/";
-  url += streamId;
-  url += "?private_key=";
-  url += privateKey;
-  url += "&diastolic=";
-  url += diastolic;
-  url += "&systolic=";
-  url += systolic;
-  url += "&hr=";
-  url += hr;  
-  
-  Serial.print("Requesting URL: ");
-  Serial.println(url);
-  
-  // This will send the request to the server
-  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
-               "Host: " + host + "\r\n" + 
-               "Connection: close\r\n\r\n");
+  client.print(post);
   delay(10);
-  
+
   // Read all the lines of the reply from server and print them to Serial
-  while(client.available()){
+  while (client.available()) {
     String line = client.readStringUntil('\r');
-//    Serial.print(line);
-  }
-  
+    Serial.print(line);
+  }
+
   Serial.println();
   Serial.println("closing connection");
 }

    // Blink it
    blinkLED();

  }else{
    Serial.println("Hmm, I2C bus activity detected, but nothing to do.");
  }
}

void blinkLED(){

  for (int i = 0; i < 4; i++){    
    digitalWrite(4, HIGH);  // Turn the LED off
    delay(100);             
    digitalWrite(4, LOW);   // Turn the LED on (active low)    
    delay(100);
  }
}
void busActivityDetected(){

  busActivity = true;
}

int getMeasurementCount(){

  int addr = 0x00;
  byte rdata = 0x00; 

  // Get current number of measurements at 0xFF
  Wire.beginTransmission(0x50); 
  Wire.write(0xFF);
  Wire.endTransmission();
  Wire.requestFrom(0x50,1);
    
  if (Wire.available()){
    rdata = Wire.read();
    error = 0;
  }else{
    error = I2C_ERROR;
    // Wait a little for things to settle
    delay(300);
    return 0;
  }

  if (rdata == 0){
    Serial.println("Nothing stored.");
    return 0;
  }
  
  return rdata;
}

void refreshLastMeasurements(int addr){
  
  byte rdata = 0x00; 

  // read measurement
  Wire.beginTransmission(0x50); 
  Wire.write(addr);
  Wire.endTransmission();
  Wire.requestFrom(0x50,4);

  if (Wire.available() != 4){
    Serial.println("Less than 4 bytes found?");
    return;    
  }

  hr = Wire.read();

    systolic += 1;
}

void uploadMeasurements() {

  Serial.print("connecting to ");
  Serial.println(host);

  // Use WiFiClient class to create TCP connections
  WiFiClient client;
  const int httpPort = 80;
