Good day.
I em making a gsm scale , basicly a scale which will send me a gsm message onece in a day with the current weight on the weight sensor .
I programed ewerything , and it is ok , but the problem is with sending a number(the weight) via message. i get an error (
exit status 1
no matching function for call to 'GPRS::sendSMS(const char [14], float)' )
Can you please help me. Here is the program what em i doing wrong.
#include <Wire.h> #include "HX711.h"
HX711 scale(A1, A0); #include <GPRS_Shield_Arduino.h> #include <SoftwareSerial.h> #define PIN_TX 7 #define PIN_RX 8 #define BAUDRATE 9600 #define PHONE_NUMBER "0038766433055" #define MESSAGE scale.get_units()
GPRS gprsTest(PIN_TX,PIN_RX,BAUDRATE);//RX,TX,BaudRate
void setup()
{
while(!gprsTest.init()) {
delay(1000);
Serial.print("init error\r\n");
}
scale.set_scale(20390.f);
scale.tare();
}
void loop()
{
Serial.print("sending");
delay(5000);
gprsTest.sendSMS(PHONE_NUMBER,MESSAGE);
delay (86395000);
}
I em using hx711 with sensors from a body scale.And a sim900 gsm module.
And i get a error:
no matching function for call to 'GPRS::sendSMS(const char [14], float)'
I hope i corectly used the dtostrf if not can you please help me I did not sleep last night because of this.
Can it be the liibrary that is the problem. I originalu used the start code and library from (GitHub - Seeed-Studio/GPRS_SIM900: library for GPRS shield with sim900 module.). In this example there is a send message option , and in
#define MESSAGE (some text under " ")
So i expect that it is predefined that the MESSAGE must be just text.
I dont know where to change this so it can send buh text and numbers.
There must be something else . I think there is a comand which converts all of it , or in the library of the gsm somewhere is a comand which says "hey accept just text" but i dont know where it is i dont know how to search.
That is the reason why i em here i need your help.
The problem is that i dont need anything else.
I bought a ina125 to replace hx711 but the problem is that it is not so common to se in arduino projects and there is not much on the internet about using it with a weight sensor and a arduino. But that to side , all is working ok , i hucked up a display and on four bridge weight sensor 4*50 kg the hx711 is working realy good so i dont need anything better .
I got the arduino to send a text massage via gsm so the gsm module all is workig. I just have the problem of sending the weight via gsm because the library and the base code i em using is not good and i cant find a more suitable code and a library for the sim900.
I have a problem .
I em using a sim 900 and i want to make a gsm scale. It is ment to sent weight every 24h on my phone via gsm .
I have a problem with the library. It won't accept a float to sent. By the library it just wants a string. Here is a code and i tryed to convert but dont know how.
When i dont add:#define weightString String
i get an error:
exit status 1
'weightString' was not declared in this scope
and dtostrf (scale.get_units(),10,2,weightString); is red.
the #define weightString String i wanted to tell arduino that it is a string and to define it as a string so that the library wont make problems because it only accepts strings.
On this
#include <Wire.h>
#include "HX711.h"
HX711 scale(A1, A0);
#include <GPRS_Shield_Arduino.h>
#include <SoftwareSerial.h>
#define PIN_TX 7
#define PIN_RX 8
#define BAUDRATE 9600
#define PHONE_NUMBER "0038766433055"
#define weightString String
GPRS gprsTest(PIN_TX,PIN_RX,BAUDRATE);//RX,TX,BaudRate
void setup()
{
double scale.get_units();
char charVal[10]; //temporarily holds data from vals
String stringVal = ""; //data on buff is copied to this string
dtostrf(scale.get_units() , 10, 2, charVal); //4 is mininum width, 4 is precision; float value is copied onto buff
while(!gprsTest.init()) {
delay(1000);
Serial.print("init error\r\n");
}
scale.set_scale(20390.f);
scale.tare();
}
void loop()
{
for(int i=0;i<sizeof(charVal);i++)
{
Serial.print(charVal[i]);
}
for(int i=0;i<sizeof(charVal);i++)
{
stringVal+=charVal[i];
}
Serial.print("sending");
delay(5000);
gprsTest.sendSMS(PHONE_NUMBER,(stringVal);
delay (86395000);
}
I get an error :
exit status 1
expected initializer before '.' token
and double scale.get_units();
#define weightString String
i wanted to tell arduino that it is a string and to define it as a string so that the library wont make problems because it only accepts strings.
Well that is not what you tell the compiler. #define tells the compile "replace before compiling every occurrence of the first word by the second one". To define a variable of a given type you say int j; for example to create a Variable j of type int.
I would suggest you hit ctrl-T in the IDE before posting, your braces and parentheses look unbalanced or ill aligned. For example at the end gprsTest.sendSMS[color=red][b]([/b][/color]PHONE_NUMBER,(stringVal); you are missing a closing [color=red][b])[/b][/color]
You should also read about char buffers versus String class. Also look at what functions expect as parameters for example in your library:
int sendSMS(char* number, [color=red]char* data[/color]);
So no need to build up a String object (and if really want to do that one day - rather than adding character after character, ensure buffer is properly terminated with '\0' and use a String constructor directly. See the String class description)
int sendSMS(char* number, [color=red]char* data[/color]);
So no need to build up a String object (and if really want to do that one day - rather than adding character after character, ensure buffer is properly terminated with '\0' and use a String constructor directly. See the String class description)
My plan is to make a beehive gsm scale. i have a hx711 dht22 , and the plan is to via sim900 send a sms in which will be "W=65.7kg T= 22 C H=54%" so i need a string and a String Object Constructor.
But that to side i firstly need to convert the weight to a string* because if i put the float to send my library or i dont know what makes a problem . Look at this :
C:\Program Files\Arduino\libraries\GPRS_SIM900-master/GPRS_Shield_Arduino.h:99:10: note: no known conversion for argument 2 from 'float' to 'char*'
exit status 1
no matching function for call to 'GPRS::sendSMS(const char [14], float)'
and : gprsTest.sendSMS(PHONE_NUMBER, scale.get_units()); is red .
So i suppose that the problem is in it.
and the plan is to via sim900 send a sms in which will be "W=65.7kg T= 22 C H=54%" so i need a string and a String Object Constructor.
No you don't NEED a string object constructor - you just need to build up a char array in the right way which can be very easily done with standard c functions.
and an error :
exit status 1
expected constructor, destructor, or type conversion before '(' token
and : dtostrf(scale.get_units(), 4, 3, charVal); is red.
If i paste the
By the way, in that call, 4 defines the length of the output string that you want, and 3 defines the number of characters after the decimal point. With 3 digits after the decimal point, the decimal point, and one or more characters before the decimal point, you will NOT fit all the data in a 4 character field. So, why are you asking for a 4 character string?
//temporarily holds data from vals
char charVal[10];
//4 is mininum width, 3 is precision; float value is copied onto buff
dtostrf(123.234, 4, 3, charVal);
monitor.print("charVal: ");
monitor.println(charVal);
so what is the problem now.
PaulS:
By the way, in that call, 4 defines the length of the output string that you want, and 3 defines the number of characters after the decimal point. With 3 digits after the decimal point, the decimal point, and one or more characters before the decimal point, you will NOT fit all the data in a 4 character field. So, why are you asking for a 4 character string?
That is not the problem i dont need to see anything i dont care about the result. That is less important will it send 0.00023 kg or 23 kg i dont care now it will be fixed in the future but now is the problem of converting a float to string.