Please help

Hi All,
Hoping you can help a newby. I have the below code which keeps giving me error message:

Error Message:

\LoadCellThingSpeak.ino: In function ‘void loop()’:

\LoadCellThingSpeak.ino:74:14: warning: uninitialized const ‘buf’ [-fpermissive]

const char buf[16]; // buf array can hold up to 16 characters.

^~~

\LoadCellThingSpeak.ino:75:43: warning: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]

String strTemp = dtostrf(temp, 4, 1, buf); // “buf” will be the actual name of the array and strTemp is being equalled to it as a string.

^

In file included from \Documents\ArduinoData\packages\arduino\hardware\avr\1.8.1\cores\arduino/Arduino.h:23:0,

from sketch\LoadCellThingSpeak.ino.cpp:1:

\documents\arduinodata\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\stdlib.h:666:14: note: initializing argument 4 of ‘char* dtostrf(double, signed char, unsigned char, char*)’

extern char *dtostrf(double __val, signed char __width,

^~~~~~~

\LoadCellThingSpeak.ino:92:27: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]

if (SoftSer.find(“Error”))

^

\LoadCellThingSpeak.ino:111:23: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]

if (SoftSer.find(">"))

^[/i]

Code Below:::

// This code is a compilation of my own and others work, unfortunately I can’t reference the authors I used
// as I have forgotten the sites I have taken from. But feel free to use and abuse this as much as you like.
// I hope it’s useful and have fun,
// James.

// So this is the code that we’re going to be using. It looks long but mostly it’s just me commenting on what
// the code does. If you’re not using a BMP 180, just remove the associated code.

#include <SoftwareSerial.h> // Up to this point we’ve been using the RX TX pins(0 and 1) on the Arduino to communicate
// with the ESP8266 by entering commands in the serial monitor command line. The SoftwareSerial library allows
//those commands to be sent, and responses received via code and the digital input/output pins.

#include <Wire.h> // Used to communicate with the BMP 180 via I2C.
#include <Adafruit_BMP085.h> // For BMP 180.
Adafruit_BMP085 bmp; // For BMP 180.

int ledPin = 13; // LED 13 will be used to let the user know when the code has looped back again.

// ThingSpeak Write API key, this can be found in your channel under API Keys and you’ll want the “Write API Key”.
String apiKey = “API KEY”;

#define SSID “SSID” // Remove the text but keep the “”
#define PASS “PASSWORD”// Same as above, keep the “”

// connect pin 11 to TX of the ESP8266 (Yellow wire if you’ve been following the videos.)
// connect pin 10 to RX of the ESP8266 (Blue wire if you’ve been following the videos.)
SoftwareSerial SoftSer(11, 10); // Everywhere from here on when you see SoftSer, it is being used as a command
// in the same way you’d use Serial.print() or Serial.begin() only over pins 11 and 10 instead of the USB port.

void setup()
{
// Setting pin 13, the LED indicator, to output.
pinMode(ledPin, OUTPUT);

if (!bmp.begin()) // For BMP 180.
{
Serial.println(“BMP180 sensor not found”);
while (1) {}
}

// Begins serial communication at a baud of 9600.
Serial.begin(9600);

// Begins software serial communication at a baud of 9600.
SoftSer.begin(9600);

}

void loop()
{
// Connecting to your internet source------------*
// For your first time using this script, uncomment the below section of script and enter your router details above (SSID and Password).
// After you successfully upload data, this can be commented back out as the ESP8266 will remember the router details.
/String join=“AT+CWJAP=”"; // Join accesspoint
join+=SSID;
join+="","";
join+=PASS;
join+=""";
SoftSer.println(join);
delay(5000);
/
//-----------------------------------------------*

// blink LED on board
digitalWrite(ledPin, HIGH);
delay(200);
digitalWrite(ledPin, LOW);

float temp = bmp.readTemperature(); // If you’re not using a BMP 180, remove bmp.readTemperature(); and enter the
// analog pin you’re reading from e.g: “float temp = analogRead(pin3);”

// convert float to string-------------*
const char buf[16]; // buf array can hold up to 16 characters.
String strTemp = dtostrf(temp, 4, 1, buf); // “buf” will be the actual name of the array and strTemp is being equalled to it as a string.

// dtostrf(floatvar, StringLengthIncDecimalPoint, numVarsAfterDecimal, charbuf);

// floatvar ---- float variable
// StringLengthIncDecimalPoint ---- This is the length of the string that will be created
// numVarsAfterDecimal ---- The number of digits after the decimal point to print
// charbuf ---- the array to store the results
//-------------------------------------*
Serial.println(strTemp); // Prints the recorded temperature to the serial print.

// TCP connection
String cmd = “AT+CIPSTART=“TCP”,”";
cmd += “184.106.153.149”; // api.thingspeak.com
cmd += “”,80";
SoftSer.println(cmd);

if (SoftSer.find(“Error”))
{
Serial.println(“AT+CIPSTART error”);
return;
}

// Putting together the GET string, this command structure can be found on your
// ThingSpeak channel in Data Import/Export, under “Update Channel Feed - GET”.
String getStr = “GET /update?api_key=”;
getStr += apiKey;
getStr += “&field1=”;
getStr += String(strTemp);
getStr += “\r\n\r\n”;

// send data length
cmd = “AT+CIPSEND=”;
cmd += String(getStr.length());
SoftSer.println(cmd);

if (SoftSer.find(">"))
{
SoftSer.print(getStr); // Send data.
}
else
{
SoftSer.println(“AT+CIPCLOSE”);

Serial.println(“AT+CIPCLOSE”); // If this shows on the serial monitor the data did not send.
}
// The AT+RST command resets the ESP8266, I’m doing this because data is uploaded much more reliably.
SoftSer.println(“AT+RST”);
// ThingSpeak needs on average, a 15 second delay between updates. Change this to whatever suits your application
// e.g: delay(600000) is ten minutes.
delay(15000);

You’ll maybe notice the lack of the word “error” in the messages you posted, but
const char buf[16]; // buf array can hold up to 16 characters. a buffer that is a constant, but not initialised isn’t going to be a lot of use to you.

Remove the 'const' here :

const char buf[16];

As for the "SoftSer.find" errors, try using single quotes here

if (SoftSer.find('>'))

and

char text[] ="Error";
if (SoftSer.find(text))

Thanks for the reply! I have revised my code and get the below error now. LESEPT im not sure what you mean by the last suggestion?

CODE::

// This code is a compilation of my own and others work, unfortunately I can’t reference the authors I used
// as I have forgotten the sites I have taken from. But feel free to use and abuse this as much as you like.
// I hope it’s useful and have fun,
// James.

// So this is the code that we’re going to be using. It looks long but mostly it’s just me commenting on what
// the code does. If you’re not using a BMP 180, just remove the associated code.

#include <SoftwareSerial.h> // Up to this point we’ve been using the RX TX pins(0 and 1) on the Arduino to communicate
// with the ESP8266 by entering commands in the serial monitor command line. The SoftwareSerial library allows
//those commands to be sent, and responses received via code and the digital input/output pins.

#include <Wire.h> // Used to communicate with the BMP 180 via I2C.
#include <Adafruit_BMP085.h> // For BMP 180.
Adafruit_BMP085 bmp; // For BMP 180.

int ledPin = 13; // LED 13 will be used to let the user know when the code has looped back again.

// ThingSpeak Write API key, this can be found in your channel under API Keys and you’ll want the “Write API Key”.
String apiKey = “API KEY”;

#define SSID “SSID” // Remove the text but keep the “”
#define PASS “PASSWORD”// Same as above, keep the “”

// connect pin 11 to TX of the ESP8266 (Yellow wire if you’ve been following the videos.)
// connect pin 10 to RX of the ESP8266 (Blue wire if you’ve been following the videos.)
SoftwareSerial SoftSer(11, 10); // Everywhere from here on when you see SoftSer, it is being used as a command
// in the same way you’d use Serial.print() or Serial.begin() only over pins 11 and 10 instead of the USB port.

void setup()
{
// Setting pin 13, the LED indicator, to output.
pinMode(ledPin, OUTPUT);

if (!bmp.begin()) // For BMP 180.
{
Serial.println(“BMP180 sensor not found”);
while (1) {}
}

// Begins serial communication at a baud of 9600.
Serial.begin(9600);

// Begins software serial communication at a baud of 9600.
SoftSer.begin(9600);

}

void loop()
{
// Connecting to your internet source------------*
// For your first time using this script, uncomment the below section of script and enter your router details above (SSID and Password).
// After you successfully upload data, this can be commented back out as the ESP8266 will remember the router details.
/String join=“AT+CWJAP=”"; // Join accesspoint
join+=SSID;
join+="","";
join+=PASS;
join+=""";
SoftSer.println(join);
delay(5000);
/
//-----------------------------------------------*

// blink LED on board
digitalWrite(ledPin, HIGH);
delay(200);
digitalWrite(ledPin, LOW);

float temp = bmp.readTemperature(); // If you’re not using a BMP 180, remove bmp.readTemperature(); and enter the
// analog pin you’re reading from e.g: “float temp = analogRead(pin3);”

// convert float to string-------------*
char buf[16]; // buf array can hold up to 16 characters.
String strTemp = dtostrf(temp, 4, 1, buf); // “buf” will be the actual name of the array and strTemp is being equalled to it as a string.

// dtostrf(floatvar, StringLengthIncDecimalPoint, numVarsAfterDecimal, charbuf);

// floatvar ---- float variable
// StringLengthIncDecimalPoint ---- This is the length of the string that will be created
// numVarsAfterDecimal ---- The number of digits after the decimal point to print
// charbuf ---- the array to store the results
//-------------------------------------*
Serial.println(strTemp); // Prints the recorded temperature to the serial print.

// TCP connection
String cmd = “AT+CIPSTART=“TCP”,”";
cmd += “184.106.153.149”; // api.thingspeak.com
cmd += “”,80";
SoftSer.println(cmd);

if (SoftSer.find(“Error”))
{
Serial.println(“AT+CIPSTART error”);
return;
}

// Putting together the GET string, this command structure can be found on your
// ThingSpeak channel in Data Import/Export, under “Update Channel Feed - GET”.
String getStr = “GET /update?api_key=”;
getStr += apiKey;
getStr += “&field1=”;
getStr += String(strTemp);
getStr += “\r\n\r\n”;

// send data length
cmd = “AT+CIPSEND=”;
cmd += String(getStr.length());
SoftSer.println(cmd);

if (SoftSer.find(’>’))
{
SoftSer.print(getStr); // Send data.
}
else
{
SoftSer.println(“AT+CIPCLOSE”);

Serial.println(“AT+CIPCLOSE”); // If this shows on the serial monitor the data did not send.
}
// The AT+RST command resets the ESP8266, I’m doing this because data is uploaded much more reliably.
SoftSer.println(“AT+RST”);
// ThingSpeak needs on average, a 15 second delay between updates. Change this to whatever suits your application
// e.g: delay(600000) is ten minutes.
delay(15000);
}

ERROR::

\LoadCellThingSpeak.ino: In function ‘void loop()’:
\LoadCellThingSpeak.ino:92:27: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]

if (SoftSer.find(“Error”))

^

Again, you will no doubt notice the absence of the word “error” in what you posted.

Understand there isn't the word error, however i am getting a warning and when i run serial monitor nothing happens?

In setup, try

// Begins serial communication at a baud of 9600.
  Serial.begin(9600);
  Serial.println (F("Ready..."));

How about now?

Unfortunately nothing.

Just to note, i don't actually have the sensors wired in.

I have found code that uses the sensors for temperature. i will be modifying this code (when i can get it to work) to utilise load cell data from an HX711.

Will that matter?

Did you remember to move the Serial.begin to the top of setup?

TheMemberFormerlyKnownAsAWOL:
Again, you will no doubt notice the absence of the word "error" in what you posted.

and the absence of code tags around the code

The problem is here :

 if (SoftSer.find("Error"))

It seems that find needs a char not a string. This is why changing double quotes to single quotes in the other case made it work.

Try changing this line with what I suggested :

char text[] ="Error";
if (SoftSer.find(text))

If it doesn't work, you'll need to find another way of searching for that word.

And edit your posts to put code tags around your codes so that they are more comfortable to read for our old eyes...

lesept:
The problem is here :

 if (SoftSer.find("Error"))

It seems that find needs a char not a string.

.find(), found in Stream.h, can take char, char *, byte, or byte *. The char * and byte * can be used as a string (null terminated) or with a third argument containing a character count. The function does NOT take a 'const char *' which is the type of a C literal constant like "Error". This is most likely a mistake on the part of the library author and is a common holdover from the days before the 'const' keyword.

To get rid of the warning message:

 if (SoftSer.find((char *)"Error"))

This tells the compiler to treat the 'const char *' as a 'char *' which is a type the function accepts.

For a single character you can use either:

 if (SoftSer.find((char *)">"))

or

 if (SoftSer.find('>'))

The first one casts the "const char *" to a "char *" and the second uses a 'char' in place of a "const char *".

Strangely, this problem was fixed in November 2017!

But the fix doesn't show up in my 1.8.10 build from May 2019. :frowning:

Thanks heaps johnwasser. The warning codes go and all is ok.

My next problem is im getting nothing out of the serial monitor! None of my AT commands are working?

Any answer to reply #8?

Sorry, yes i did update that code. See below updated code. I’m still getting nothing out of the serial monitor:

// This code is a compilation of my own and others work, unfortunately I can't reference the authors I used
// as I have forgotten the sites I have taken from. But feel free to use and abuse this as much as you like.
// I hope it's useful and have fun,
// James. 

// So this is the code that we're going to be using. It looks long but mostly it's just me commenting on what 
// the code does. If you're not using a BMP 180, just remove the associated code. 

#include <SoftwareSerial.h> // Up to this point we've been using the RX TX pins(0 and 1) on the Arduino to communicate 
// with the ESP8266 by entering commands in the serial monitor command line. The SoftwareSerial library allows       
//those commands to be sent, and responses received via code and the digital input/output pins. 

#include <Wire.h> // Used to communicate with the BMP 180 via I2C.
#include <Adafruit_BMP085.h> // For BMP 180.
Adafruit_BMP085 bmp; // For BMP 180.

int ledPin = 13; // LED 13 will be used to let the user know when the code has looped back again.

// ThingSpeak Write API key, this can be found in your channel under API Keys and you'll want the "Write API Key". 
String apiKey = "APIKEY";

#define SSID "SSID" // Remove the text but keep the ""
#define PASS "PASSWORD"// Same as above, keep the ""

// connect pin 11 to TX of the ESP8266 (Yellow wire if you've been following the videos.)
// connect pin 10 to RX of the ESP8266 (Blue wire if you've been following the videos.)
SoftwareSerial SoftSer(11, 10); // Everywhere from here on when you see SoftSer, it is being used as a command
// in the same way you'd use Serial.print() or Serial.begin() only over pins 11 and 10 instead of the USB port.

void setup() 
{
  // Setting pin 13, the LED indicator, to output.
  pinMode(ledPin, OUTPUT);

  if (!bmp.begin()) // For BMP 180.
  {
    Serial.println("BMP180 sensor not found");
    while (1) {}
  }
  
  // Begins serial communication at a baud of 9600.
  Serial.begin(9600);
  Serial.println (F("Ready..."));
  
  // Begins software serial communication at a baud of 9600.
  SoftSer.begin(9600); 

}

void loop() 
{
  // Connecting to your internet source------------*
  // For your first time using this script, uncomment the below section of script and enter your router details above (SSID and Password).
  // After you successfully upload data, this can be commented back out as the ESP8266 will remember the router details.  
  /*String join="AT+CWJAP=\""; // Join accesspoint
  join+=SSID;
  join+="\",\"";
  join+=PASS;
  join+="\"";
  SoftSer.println(join);
  delay(5000);*/
  //-----------------------------------------------*


  // blink LED on board 
  digitalWrite(ledPin, HIGH);
  delay(200);
  digitalWrite(ledPin, LOW);


  float temp = bmp.readTemperature(); // If you're not using a BMP 180, remove bmp.readTemperature(); and enter the 
  // analog pin you're reading from e.g: "float temp = analogRead(pin3);"

  // convert float to string-------------*
  char buf[16]; // buf array can hold up to 16 characters. 
  String strTemp = dtostrf(temp, 4, 1, buf); // "buf" will be the actual name of the array and strTemp is being equalled to it as a string.
  
  // dtostrf(floatvar, StringLengthIncDecimalPoint, numVarsAfterDecimal, charbuf);

  // floatvar ---- float variable
  // StringLengthIncDecimalPoint ---- This is the length of the string that will be created
  // numVarsAfterDecimal ---- The number of digits after the decimal point to print
  // charbuf ---- the array to store the results
  //-------------------------------------*
  Serial.println(strTemp); // Prints the recorded temperature to the serial print.

  // TCP connection
  String cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += "184.106.153.149"; // api.thingspeak.com
  cmd += "\",80";
  SoftSer.println(cmd);
  
  if (SoftSer.find((char *)"Error")) 
  {
    Serial.println("AT+CIPSTART error");
    return;
  }

  // Putting together the GET string, this command structure can be found on your
  // ThingSpeak channel in Data Import/Export, under "Update Channel Feed - GET". 
  String getStr = "GET /update?api_key=";
  getStr += apiKey;
  getStr += "&field1=";
  getStr += String(strTemp);
  getStr += "\r\n\r\n";

  // send data length
  cmd = "AT+CIPSEND=";
  cmd += String(getStr.length());
  SoftSer.println(cmd);

  if (SoftSer.find('>')) 
  {
    SoftSer.print(getStr); // Send data.
  }
  else 
  {
    SoftSer.println("AT+CIPCLOSE");
    
    Serial.println("AT+CIPCLOSE"); // If this shows on the serial monitor the data did not send.
  }
  // The AT+RST command resets the ESP8266, I'm doing this because data is uploaded much more reliably. 
  SoftSer.println("AT+RST");
  // ThingSpeak needs on average, a 15 second delay between updates. Change this to whatever suits your application
  // e.g: delay(600000) is ten minutes.
  delay(15000);
}

So, when I asked if you’d moved the Serial.begin to the top of setup, you hadn’t.

Fix that.
Get back to us.

Do what Prince says and set the serial monitor to 9600 baud

Ok so it seems to work so far.

Can i just ask one more question. Below is the code, then following is the code from my load cell that i want to use. I want to replace the BMP sensor data and replace it with the load cell data. I want to upload the load cell data points to Thinkspeak. Can anyone help?

// This code is a compilation of my own and others work, unfortunately I can't reference the authors I used
// as I have forgotten the sites I have taken from. But feel free to use and abuse this as much as you like.
// I hope it's useful and have fun,
// James. 

// So this is the code that we're going to be using. It looks long but mostly it's just me commenting on what 
// the code does. If you're not using a BMP 180, just remove the associated code. 

#include <SoftwareSerial.h> // Up to this point we've been using the RX TX pins(0 and 1) on the Arduino to communicate 
// with the ESP8266 by entering commands in the serial monitor command line. The SoftwareSerial library allows       
//those commands to be sent, and responses received via code and the digital input/output pins. 

#include <Wire.h> // Used to communicate with the BMP 180 via I2C.
#include <Adafruit_BMP085.h> // For BMP 180.
Adafruit_BMP085 bmp; // For BMP 180.

int ledPin = 13; // LED 13 will be used to let the user know when the code has looped back again.

// ThingSpeak Write API key, this can be found in your channel under API Keys and you'll want the "Write API Key". 
String apiKey = "APIKEY";

#define SSID "SSID" // Remove the text but keep the ""
#define PASS "PASSWORD"// Same as above, keep the ""

// connect pin 11 to TX of the ESP8266 (Yellow wire if you've been following the videos.)
// connect pin 10 to RX of the ESP8266 (Blue wire if you've been following the videos.)
SoftwareSerial SoftSer(11, 10); // Everywhere from here on when you see SoftSer, it is being used as a command
// in the same way you'd use Serial.print() or Serial.begin() only over pins 11 and 10 instead of the USB port.

void setup() 
{
   // Begins serial communication at a baud of 9600.
  Serial.begin(9600);
  Serial.println (F("Ready..."));
  
  // Setting pin 13, the LED indicator, to output.
  pinMode(ledPin, OUTPUT);

  if (!bmp.begin()) // For BMP 180.
  {
    Serial.println("BMP180 sensor not found");
    while (1) {}
  }
  
 
  
  // Begins software serial communication at a baud of 9600.
  SoftSer.begin(9600); 

}

void loop() 
{
  // Connecting to your internet source------------*
  // For your first time using this script, uncomment the below section of script and enter your router details above (SSID and Password).
  // After you successfully upload data, this can be commented back out as the ESP8266 will remember the router details.  
  /*String join="AT+CWJAP=\""; // Join accesspoint
  join+=SSID;
  join+="\",\"";
  join+=PASS;
  join+="\"";
  SoftSer.println(join);
  delay(5000);*/
  //-----------------------------------------------*


  // blink LED on board 
  digitalWrite(ledPin, HIGH);
  delay(200);
  digitalWrite(ledPin, LOW);


  float temp = bmp.readTemperature(); // If you're not using a BMP 180, remove bmp.readTemperature(); and enter the 
  // analog pin you're reading from e.g: "float temp = analogRead(pin3);"

  // convert float to string-------------*
  char buf[16]; // buf array can hold up to 16 characters. 
  String strTemp = dtostrf(temp, 4, 1, buf); // "buf" will be the actual name of the array and strTemp is being equalled to it as a string.
  
  // dtostrf(floatvar, StringLengthIncDecimalPoint, numVarsAfterDecimal, charbuf);

  // floatvar ---- float variable
  // StringLengthIncDecimalPoint ---- This is the length of the string that will be created
  // numVarsAfterDecimal ---- The number of digits after the decimal point to print
  // charbuf ---- the array to store the results
  //-------------------------------------*
  Serial.println(strTemp); // Prints the recorded temperature to the serial print.

  // TCP connection
  String cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += "184.106.153.149"; // api.thingspeak.com
  cmd += "\",80";
  SoftSer.println(cmd);
  
  if (SoftSer.find((char *)"Error")) 
  {
    Serial.println("AT+CIPSTART error");
    return;
  }

  // Putting together the GET string, this command structure can be found on your
  // ThingSpeak channel in Data Import/Export, under "Update Channel Feed - GET". 
  String getStr = "GET /update?api_key=";
  getStr += apiKey;
  getStr += "&field1=";
  getStr += String(strTemp);
  getStr += "\r\n\r\n";

  // send data length
  cmd = "AT+CIPSEND=";
  cmd += String(getStr.length());
  SoftSer.println(cmd);

  if (SoftSer.find('>')) 
  {
    SoftSer.print(getStr); // Send data.
  }
  else 
  {
    SoftSer.println("AT+CIPCLOSE");
    
    Serial.println("AT+CIPCLOSE"); // If this shows on the serial monitor the data did not send.
  }
  // The AT+RST command resets the ESP8266, I'm doing this because data is uploaded much more reliably. 
  SoftSer.println("AT+RST");
  // ThingSpeak needs on average, a 15 second delay between updates. Change this to whatever suits your application
  // e.g: delay(600000) is ten minutes.
  delay(15000);
}

Code i want to integrate in lieu of the BMP sensor data.

//-------------------------------------------------------------------------------------
// HX711_ADC.h
// Arduino master library for HX711 24-Bit Analog-to-Digital Converter for Weigh Scales
// Olav Kallhovd sept2017
// Tested with      : HX711 asian module on channel A and YZC-133 3kg load cell
// Tested with MCU  : Arduino Nano, ESP8266
//-------------------------------------------------------------------------------------
// This is an example sketch on how to use this library
// Settling time (number of samples) and data filtering can be adjusted in the config.h file

// This example shows how to calibrate the load cell and optionally save the calibration  
// value to EEPROM, and also how to change the value.
// The value can later be fetched from EEPROM in your project sketch.

#include <HX711_ADC.h>
#include <EEPROM.h>

//HX711 constructor (dout pin, sck pin):
HX711_ADC LoadCell(2, 3);

int eepromAdress = 0;

long t;

void calibrate() {
  Serial.println("***");
  Serial.println("Start calibration:");
  Serial.println("It is assumed that the mcu was started with no load applied to the load cell.");
  Serial.println("Now, place your known mass on the loadcell,");
  Serial.println("then send the weight of this mass (i.e. 100.0) from serial monitor.");
  float m = 0;
  boolean f = 0;
  while (f == 0) {
    LoadCell.update();
    if (Serial.available() > 0) {
      m = Serial.parseFloat();
      if (m != 0) {
        Serial.print("Known mass is: ");
        Serial.println(m);
        f = 1;
      }
      else {
        Serial.println("Invalid value");
      }
    }
  }
  float c = LoadCell.getData() / m;
  LoadCell.setCalFactor(c);
  Serial.print("Calculated calibration value is: ");
  Serial.print(c);
  Serial.println(", use this in your project sketch");
  f = 0;
  Serial.print("Save this value to EEPROM adress ");
  Serial.print(eepromAdress);
  Serial.println("? y/n");
  while (f == 0) {
    if (Serial.available() > 0) {
      char inByte = Serial.read();
      if (inByte == 'y') {
        #if defined(ESP8266) 
        EEPROM.begin(512);
        #endif
        EEPROM.put(eepromAdress, c);
        #if defined(ESP8266)
        EEPROM.commit();
        #endif
        EEPROM.get(eepromAdress, c);
        Serial.print("Value ");
        Serial.print(c);
        Serial.print(" saved to EEPROM address: ");
        Serial.println(eepromAdress);
        f = 1;

      }
      else if (inByte == 'n') {
        Serial.println("Value not saved to EEPROM");
        f = 1;
      }
    }
  }
  Serial.println("End calibration");
  Serial.println("For manual edit, send 'c' from serial monitor");
  Serial.println("***");
}

void changeSavedCalFactor() {
  float c = LoadCell.getCalFactor();
  boolean f = 0;
  Serial.println("***");
  Serial.print("Current value is: ");
  Serial.println(c);
  Serial.println("Now, send the new value from serial monitor, i.e. 696.0");
  while (f == 0) {
    if (Serial.available() > 0) {
      c = Serial.parseFloat();
      if (c != 0) {
        Serial.print("New calibration value is: ");
        Serial.println(c);
        LoadCell.setCalFactor(c);
        f = 1;
      }
      else {
        Serial.println("Invalid value, exit");
        return;
      }
    }
  }
  f = 0;
  Serial.print("Save this value to EEPROM adress ");
  Serial.print(eepromAdress);
  Serial.println("? y/n");
  while (f == 0) {
    if (Serial.available() > 0) {
      char inByte = Serial.read();
      if (inByte == 'y') {
        #if defined(ESP8266)
        EEPROM.begin(512);
        #endif
        EEPROM.put(eepromAdress, c);
        #if defined(ESP8266)
        EEPROM.commit();
        #endif
        EEPROM.get(eepromAdress, c);
        Serial.print("Value ");
        Serial.print(c);
        Serial.print(" saved to EEPROM address: ");
        Serial.println(eepromAdress);
        f = 1;
      }
      else if (inByte == 'n') {
        Serial.println("Value not saved to EEPROM");
        f = 1;
      }
    }
  }
  Serial.println("End change calibration value");
  Serial.println("***");
}

void setup() {
  Serial.begin(9600); delay(10);
  Serial.println();
  Serial.println("Starting...");
  LoadCell.begin();
  long stabilisingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilising time
  LoadCell.start(stabilisingtime);
  if (LoadCell.getTareTimeoutFlag()) {
    Serial.println("Tare timeout, check MCU>HX711 wiring and pin designations");
  }
  else {
    LoadCell.setCalFactor(1.0); // user set calibration value (float)
    Serial.println("Startup + tare is complete");
  }
  while (!LoadCell.update());
  calibrate();
}
void loop() {
  //update() should be called at least as often as HX711 sample rate; >10Hz@10SPS, >80Hz@80SPS
  //longer delay in sketch will reduce effective sample rate (be carefull with delay() in the loop)
  LoadCell.update();

  //get smoothed value from the data set
  if (millis() > t + 250) {
    float i = LoadCell.getData();
    Serial.print("Load_cell output val: ");
    Serial.println(i);
    t = millis();
  }

  //receive from serial terminal
  if (Serial.available() > 0) {
    float i;
    char inByte = Serial.read();
    if (inByte == 't') LoadCell.tareNoDelay();
    else if (inByte == 'c') changeSavedCalFactor();
  }

  //check if last tare operation is complete
  if (LoadCell.getTareStatus() == true) {
    Serial.println("Tare complete");
  }

}