Hi,
I am trying to read data from MAX30100 and MLX90614 and upload it to Mysql DB using ESP8266.
The values read fine, if I do not use the postData() in void loop().
/*
#include<stdio.h>
#include<stdlib.h>
#include <Wire.h>
#include "MAX30100_PulseOximeter.h"
#include <Adafruit_MLX90614.h>
//Adafruit_MLX90614 mlx = Adafruit_MLX90614();
#define REPORTING_PERIOD_MS 3000
#include <ESP8266WiFi.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <ESP8266HTTPClient.h>
const char *ssid = "NIROSH's Galaxy F62";
const char *password = "netq3507@";
WiFiClient wifiClient;
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP);
// PulseOximeter is the higher level interface to the sensor
// it offers:
// * beat detection reporting
// * heart rate calculation
// * SpO2 (oxidation level) calculation
PulseOximeter pox;
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
uint32_t tsLastReport = 0;
String formattedDate;
int number,i=0;
static float x;
int lower=70,upper=80;
String apiKeyValue = "tPmAT5Ab3j7F9";
// Callback (registered below) fired when a pulse is detected
void onBeatDetected()
{
Serial.println("Beat!");
}
void setup()
{
Serial.begin(115200);
WiFi.begin(ssid, password);
while ( WiFi.status() != WL_CONNECTED ) {
delay ( 500 );
Serial.print ( "." );
}
// Print local IP address and start web server
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
// Initialize a NTPClient to get time
timeClient.begin();
Serial.print("Initializing pulse oximeter..");
// Initialize the PulseOximeter instance
// Failures are generally due to an improper I2C wiring, missing power supply
// or wrong target chip
if (!pox.begin()) {
Serial.println("FAILED");
for(;;);
} else {
Serial.println("SUCCESS");
}
mlx.begin();
// The default current for the IR LED is 50mA and it could be changed
// by uncommenting the following line. Check MAX30100_Registers.h for all the
// available options.
// pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);
// Register a callback for the beat detection
// pox.setOnBeatDetectedCallback(onBeatDetected);
timeClient.setTimeOffset(3600);
}
void loop()
{
// Make sure to call update as fast as possible
pox.update();
timeClient.update();
formattedDate = timeClient.getFormattedDate();
number=(rand()%(lower-upper+1))+lower;
// Asynchronously dump heart rate and oxidation levels to the serial
// For both, a value of 0 means "invalid"
if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
Serial.print("Heart rate:");
Serial.print(pox.getHeartRate());
Serial.print("bpm / SpO2:");
Serial.print(pox.getSpO2());
Serial.println("%");
Serial.print("Object = "); Serial.print(mlx.readObjectTempF()); Serial.println("*F");
x=mlx.readObjectTempF();
Serial.println(formattedDate);
Serial.print("BP ="); Serial.println(number);
tsLastReport = millis();
}
if(WiFi.status()== WL_CONNECTED){
HTTPClient http;
// delay(50);
http.begin(wifiClient,"http://192.168.1.216/test/postdata.php");
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
// http.POST("api_key=" + apiKeyValue + "&patient_id=" + i + "×tamp=" + formattedDate /+ "&Time=" + String(timeClient.getFormattedTime())/ + "&Temp=" + x + "&HeartRate=" + pox.getHeartRate() +"&Spo2=" + pox.getSpO2() + "&BP=" + number +"");
Serial.println("api_key=" + apiKeyValue + "&patient_id=" + i + "×tamp=" + formattedDate /+ "&Time=" + String(timeClient.getFormattedTime())/ + "&Temp=" + x + "&HeartRate=" + pox.getHeartRate() +"&Spo2=" + pox.getSpO2() +"&BP=" + number + "");
}
}