Hello everyone,
Thanks in advance. I am creating a device which able to upload MAX30102 sensor value along with lat lon (GSM location) into the online MySQL database. Individual code for both SIM800L (Lat Lon location) upload successfully and MAX30102 beatAVG value showing the BPM. But when I integrate both codes, it is not working. Only one time it able to upload values, after that it fails with 500,0 sometime** 302,0** error code using the serial monitor. In serial monitor, it shows a wrong or partial response. Now I am stuck. Please help me to resolve it.
In both images, I red marked partial responses:
serial_error-->Responce:NTERNET. Which supposed to be Responce:INTERNET
serial_error 1--> Responce:com.com:3002". which supposed to be Responce:"lbs-simcom.com:3002"
Unable to fetch Lat, Lon also.
**NB: If I used the only SIM800L without MAX30102 then responses are perfect and able to upload data to the server. Using both codes button press also not working after a few seconds. **
Nice resume however it does not help us answer your question. We need the basics like your code. The errors are useless at this point as I have no clue how and why there were generated. I am basing this on the fact that either button works OK, that indicated the phy layer is correct. The button problem when two are pressed tells me it is a software problem and without that we cannot help.
Hi, gilshultz thank you for your replay. Allow me to apologize for the delay. I mentioned before button pressed with button state works perfectly in individual code for SIM800L but when I integrate MAX30102 codes button state only works in the first click within 20-30 seconds after system initializing. After that, some times it works sometime not. I think when Arduino entered in MAX30102 sensor value collection loop(10000ms), in that time it fails. May be using interrupt can resolve button state problem I assume. I attached the code which may help you to identify the problem. I split my whole code into two sections to upload.
Header and setup section:
#include <SoftwareSerial.h>
#include <Wire.h>
SoftwareSerial SIM800(7, 8);
#include "MAX30105.h"
#include "heartRate.h"
MAX30105 particleSensor;
String apn = "INTERNET";
String data1;
int _timeout;
String _buffer;
String clktime;
String number = "+8801719207600";
String responce = "";
String Longitude = "";
String Latitude = "";
String loc_data = "lbs-simcom.com:3002";
char Received_SMS;
const int buttonPin3 = 13;
int buttonState3 = 0;
int lastButtonState3 = 0;
short DHT_OK=-1,MLX_OK=-1;
const byte RATE_SIZE = 4;
byte rates[RATE_SIZE];
byte rateSpot = 0;
long lastBeat = 0;
int bpmbeat;
float beatsPerMinute;
int beatAvg;
const long eventTime_1_LDR = 10000; //in ms
const long eventTime_2_temp = 5000; //in ms
unsigned long previousTime_1 = 0;
unsigned long previousTime_2 = 0;
String Data_SMS;
String SIM800_send(String incoming)
{
SIM800.println(incoming); delay(400);
String result = "";
while (SIM800.available())
{
char letter = SIM800.read();
result = result + String(letter);
}
return result;
}
void prepare_message()
{
int first_comma = responce.indexOf(',');
int second_comma = responce.indexOf(',', first_comma+1);
int third_comma = responce.indexOf(',', second_comma+1);
for(int i=first_comma+1; i<second_comma; i++)
Longitude = Longitude + responce.charAt(i);
for(int i=second_comma+1; i<third_comma; i++)
Latitude = Latitude + responce.charAt(i);
}
String incoming = "";
void setup() {
Serial.begin(9600);
_buffer.reserve(50);
Serial.println("System Started...");
SIM800.begin(9600);
responce = SIM800_send("ATE1");
Serial.print ("Responce:"); Serial.println(responce);
if (!particleSensor.begin(Wire, I2C_SPEED_FAST))
{
Serial.println("MAX30105 was not found. Please check wiring/power. ");
while (1);
}
Serial.println("Place your index finger on the sensor with steady pressure.");
particleSensor.setup();
particleSensor.setPulseAmplitudeRed(0xFF);
particleSensor.setPulseAmplitudeGreen(0);
delay(1000);
}
My next suggestion is to get rid of the delays, you are missing data because the system is busy doing nothing but waiting on a timer tick. Include a Schematic, not a frizzy thing.