IoT Based Patient Health Monitoring System using ESP8266 and Arduino

I am working on IoT Based Patient Health Monitoring System using ESP8266 and Arduino and I got an error that

warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
if(esp8266.find(">"))
^
exit status 1

'class Timer' has no member named 'every'

So i changed the string to char but got error

request for member 'length' in 'cmd', which is of non-class type 'char'

#define USE_ARDUINO_INTERRUPTS true    
#define DEBUG true
#define SSID "*****"     // "SSID-WiFiname"
#define PASS "*****" // "password"
#define IP "184.106.153.149"      // thingspeak.com ip

#include <SoftwareSerial.h>
#include "Timer.h"
#include <PulseSensorPlayground.h>     // Includes the PulseSensorPlayground Library.   
Timer t;
PulseSensorPlayground pulseSensor;

char msg = "GET /update?key=**********"; 
SoftwareSerial esp8266(10,11);

//Variables
const int PulseWire = A0;       // PulseSensor PURPLE WIRE connected to ANALOG PIN 0
const int LED13 = 13;          // The on-board Arduino LED, close to PIN 13.
int Threshold = 550;           //for heart rate sensor
float myTemp;
int myBPM;
char BPM;
char temp;
int error;
int panic;
int raw_myTemp;
float Voltage;
float tempC;
void setup()
{
 
  Serial.begin(9600); 
  esp8266.begin(115200);
  pulseSensor.analogInput(PulseWire);   
  pulseSensor.blinkOnPulse(LED13);       //auto-magically blink Arduino's LED with heartbeat.
  pulseSensor.setThreshold(Threshold);   

  // Double-check the "pulseSensor" object was created and "began" seeing a signal. 
   if (pulseSensor.begin()) {
    Serial.println("We created a pulseSensor Object !");  //This prints one time at Arduino power-up,  or on Arduino reset.  
  }
  Serial.println("AT");
  esp8266.println("AT");

  delay(3000);

  if(esp8266.find("OK"))
  {
    connectWiFi();
  }
  t.every(10000, getReadings);
   t.every(10000, updateInfo);
}

void loop()
{
  panic_button();
start: //label
    error=0;
   t.update();
    //Resend if transmission is not completed
    if (error==1)
    {
      goto start; //go to label "start"
    } 
 delay(4000);
}

void updateInfo()
{
  char cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += IP;
  cmd += "\",80";
  Serial.println(cmd);
  esp8266.println(cmd);
  delay(2000);
  if(esp8266.find("Error"))
  {
    return;
  }
  cmd = msg ;
  cmd += "&field1=";    //field 1 for BPM
  cmd += BPM;
  cmd += "&field2=";  //field 2 for temperature
  cmd += temp;
  cmd += "\r\n";
  Serial.print("AT+CIPSEND=");
  esp8266.print("AT+CIPSEND=");
  Serial.println(cmd.length());
  esp8266.println(cmd.length());
  if(esp8266.find(">"))
  {
    Serial.print(cmd);
    esp8266.print(cmd);
  }
  else
  {
    Serial.println("AT+CIPCLOSE");
    esp8266.println("AT+CIPCLOSE");
    //Resend...
    error=1;
  }
}

boolean connectWiFi()
{
  Serial.println("AT+CWMODE=1");
  esp8266.println("AT+CWMODE=1");
  delay(2000);
  char cmd="AT+CWJAP=\"";
  cmd+=SSID;
  cmd+="\",\"";
  cmd+=PASS;
  cmd+="\"";
  Serial.println(cmd);
  esp8266.println(cmd);
  delay(5000);
  if(esp8266.find("OK"))
  {
    return true;
  }
  else
  {
    return false;
  }
}

void getReadings(){
  raw_myTemp = analogRead(A1);
  Voltage = (raw_myTemp / 1023.0) * 5000; // 5000 to get millivots.
  tempC = Voltage * 0.1; 
  myTemp = (tempC * 1.8) + 32; // conver to F
  Serial.println(myTemp);
  int myBPM = pulseSensor.getBeatsPerMinute();  // Calls function on our pulseSensor object that returns BPM as an "int".
                                               // "myBPM" hold this BPM value now. 
if (pulseSensor.sawStartOfBeat()) {            // Constantly test to see if "a beat happened". 
Serial.println(myBPM);                        // Print the value inside of myBPM. 
}

  delay(20);            
    char buffer1[10];
     char buffer2[10];
    BPM = dtostrf(myBPM, 4, 1, buffer1);
    temp = dtostrf(myTemp, 4, 1, buffer2);  
  }

void panic_button(){
  panic = digitalRead(8);
    if(panic == HIGH){
    Serial.println(panic);
      char cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += IP;
  cmd += "\",80";
  Serial.println(cmd);
  esp8266.println(cmd);
  delay(2000);
  if(esp8266.find("Error"))
  {
    return;
  }
  cmd = msg ;
  cmd += "&field3=";    
  cmd += panic;
  cmd += "\r\n";
  Serial.print("AT+CIPSEND=");
  esp8266.print("AT+CIPSEND=");
  Serial.println(cmd.length());
  esp8266.println(cmd.length());
  if(esp8266.find(">"))
  {
    Serial.print(cmd);
    esp8266.print(cmd);
  }
  else
  {
    Serial.println("AT+CIPCLOSE");
    esp8266.println("AT+CIPCLOSE");
    //Resend...
    error=1;
  }
}
}

char is only enough space for ONE character

so this does not fit and you are trying to store the pointer to the constant string into msg

try

const char *msg = "GET /update?key=**********";  // msg is a pointer to the text

or

char msg[] = "GET /update?key=**********";  // msg is a buffer that is initialised with the text (you can modify it)

to your question, find will accept either one char or an array with a length (it seems from the doc Stream.find() - Arduino Reference) so may be esp8266.find('>')) ... (note the simple quote to denote a char and not a cString)

sketch_dec16a:33:10: error: expected primary-expression before '.' token
33 | esp8266.begin(115200);
| ^

This error appeared for every single '.'

post the code you are trying to compile

(which platform is selected ?)

what do you mean by platform?

are you compiling for an esp8266 board?

wonder if esp8266 might not be a define somewhere. have your tried to name the Serial port esp8266Serial for example

SoftwareSerial esp8266Serial(10,11);

I will check and update you.
Thank you

are you aware of the fact that an ESP8266 nodeMCU-board can do all the work the Arduino is doing? This means the Arduino can be eliminated completely and just use a nodeMCU-board.

The EPS8266 and ESP32 can be programmed directly with the arduino-IDE
best regards Stefan

I am not fully aware of Arduino as I am still learning, but I will take into my consideration this fact and give it a try.
Thank you

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.