Dalaman is nice. Glad you liked it. Thanks for the advices again.
David I am in trouble again. I am working on this project running on Nextion 3,2" display. I managed to send the Hum and temp values to Nextion with the codes below. I also want to activate gauges showing the same value on gauges however Arduino IDE returns the following failure;
myNextion.setComponentText("temperature", String(x, 1));
myNextion.setComponentText("humidity", String(y, 1));
myNextion.setComponentValue("temp_gauge", String(x));
myNextion.setComponentValue("hum_gauge", String(y));
Note that the code is running just fine if I delete the last 2 setting value lines above !
D:\NebatHydro\Arduino\TFT LCD\NebatLab\dht21\dht21\dht21.ino: In function 'void loop()':
dht21:44: error: no matching function for call to 'Nextion::setComponentValue(const char [11], String)'
myNextion.setComponentValue("temp_gauge", String(x));
^
D:\NebatHydro\Arduino\TFT LCD\NebatLab\dht21\dht21\dht21.ino:44:54: note: candidate is:
In file included from D:\NebatHydro\Arduino\TFT LCD\NebatLab\dht21\dht21\dht21.ino:12:0:
C:\Program Files (x86)\Arduino\libraries\nextion-master/Nextion.h:73:11: note: boolean Nextion::setComponentValue(String, int)
boolean setComponentValue(String component, int value);
I am too idle to read the Nextion docs. I would guess that the setComponentValue() requires a special kind of String() method.
If x is a float, you might need a precision e.g. you don't want any decimals
myNextion.setComponentValue("temp_gauge", String(x, 0));
myNextion.setComponentValue("hum_gauge", String(y, 0));
Seriously, it is your job to read documentation for your project.
David.
I can't resist to try to help.
The compiler already tried to help you:
C:\Program Files (x86)\Arduino\libraries\nextion-master/Nextion.h:73:11: note: boolean Nextion::setComponentValue(String, int)
boolean setComponentValue(String component, int value);
So you should take the advice and try:
myNextion.setComponentValue("temp_gauge", x);
myNextion.setComponentValue("hum_gauge", y);
if x and y are the values to present.
If the compiler still complains:
myNextion.setComponentValue("temp_gauge", int(x));
myNextion.setComponentValue("hum_gauge", int(y));
Thanks David, I am a beginner (as beginner as one can be. I was just a skipper before
) I will someday understand those documentation but now I am just following logical steps and worked so far. When it doesn't, fortunately you can't resist not to help ![]()
Anyway, your advise worked. Now both values and gauge needles are working like crazy. Now the problem is they are working too crazy that they blink. I add a delay but not helping. The % and °C texts dissappeared. Nothing was assigned to them and they re appear if I erase the set value for gauges lines.
Not asking just stating the progression
all advises much appreciated ![]()
I have never used Nextion. And have never read the Nextion docs.
I just assumed that there must be a myNextion.setComponentText(String, String) method if your temperature statement works. i.e. you convert the float value to a formatted String.
But there is probably a myNextion.setComponentText(String, int) method too. An int does not need formatting.
It is your job to Google for the Nextion docs.
Having overloaded methods in C++ is handy from one point of view. But you have to look up exactly what arguments are required for each variant.
In C you would just give a descriptive name for each specific function. e.g. setComponentText_int(char *, int)
There are many Nextion users. Please paste/attach complete sketches that show your problem if you want people to give accurate replies.
David.
Thank you David.
setComponentText(String, String);
and
setComponentValue(String component, int value);
look similar, but are different!
And they do have meaningful names.
Oops. My eyesight was not very good !
It also demonstates how it is unwise to reply to subjects that I am not familiar with.
David.