Nextion 3.5 inch NX4832T035 float value

Hi,

I'm using nextion 3.5 inch (NX4832T035) and trying to show GPS latitude value, as you know lat & lon are floats, so i put a float item in to designer as x0 when i try to define that item it returns error;

defining as;

NexFloat x0 = NexFloat(0, 11, "x0");

returning

'NexFloat' does not name a type; did you mean 'NexText'?

some guys referred this https://nextion.tech/forums/topic/xfloat-declaration/ but the topic is gone.

If i use NexNumber instead of NexFloat then it shows as 410607234 but what i need to show is "41.0607234",i've tried convert into text with dtostrf but as far as i understand it doesn't convert 32bit float values so it gives me "41.0607220".

Any ideas?

In "NexFloat x0" NexFloat needs to be a "type". Then You use it as a call to a function, " = NexFloat( , , ). That looks really odd to me. Do I miss something?

Railroader:
In “NexFloat x0” NexFloat needs to be a “type”. Then You use it as a call to a function, " = NexFloat( , , ). That looks really odd to me. Do I miss something?

here is how i define other objects;

NexNumber n0 = NexNumber(0, 7, "n0");
NexNumber n1 = NexNumber(0, 8, "n1");

how the definition works;

NexObjectType nameoftheobject = NexObjectType(page_id, object_id, "name of the object");

So if you want to define a text area you should;

NexText textobject1 = NexText(0, object_id, "textobject1");

wtih this logic for a float area you need to use NextFloat, but it returns error, most of the guides suggest that you need to use nextnumber instead of float but the problem is i’m going to use coordinates so all coordinates are float, and dtostrf can not handle 32bit floats so i can’t convert to text, on the other hand i can use first 3 digitals after comma but as you might now “41.0607234” and “41.060” completely different coordinates so i need to use all digits.

This is beyond my knowledge but hopefully a more knowing helper steps in.

I don't bother with the Nextion number boxes, I use text boxes and use Serial.print or sprintf to convert numbers to text for display. See my tutorial using Nextion displays with Arduino.

PerryBebbington:
I don’t bother with the Nextion number boxes, I use text boxes and use Serial.print or sprintf to convert numbers to text for display. See my tutorial using Nextion displays with Arduino.

Can you provide url for your tutorial? my nextion works on Serial3 i’ve tried ;

Serial.print("n3.txt=\"yourtext\"");

or

Serial3.print("n3.txt=\"yourtext\"");

no luck so far.

Look in the display section of the forum, it is pinned at the top.

Note that I do not use any library and my methods are different from what you might be used to. They do however work once you understand them.

Serial3.print("n3.txt=\"yourtext\"");

n3 is a number box, you can't send text to a number box, you need a text box for text.

PerryBebbington:
Look in the display section of the forum, it is pinned at the top.

Note that I do not use any library and my methods are different from what you might be used to. They do however work once you understand them.

it is quite helpfull thanks for your time, it works as below;

Serial3.print("t2.txt=\"yourtext\"");
Serial3.write(0xff);
Serial3.write(0xff);
Serial3.write(0xff);

but i have a question please forgive my ignorance as far as i understand "0xff" is terminator command, why we are sending this command 3 times?

I have a question please forgive my ignorance as far as i understand "0xff" is terminator command, why we are sending this command 3 times?

Because that's the way ITEAD (who make Nextion displays) designed it to work. I think it is because if it was only required once there is a risk that if there happened to be an 0xff in the data then it would get interpreted as a terminator instead of data. When I devised my methods I used 0xa5 as the terminator because I wanted something different to what ITEAD use. I am considering whether I should change it, however it works well so why bother? Plus it gives me a simple way to distinguish what I do from what is built in to the Nextion.

PerryBebbington:
Because that's the way ITEAD (who make Nextion displays) designed it to work. I think it is because if it was only required once there is a risk that if there happened to be an 0xff in the data then it would get interpreted as a terminator instead of data. When I devised my methods I used 0xa5 as the terminator because I wanted something different to what ITEAD use. I am considering whether I should change it, however it works well so why bother? Plus it gives me a simple way to distinguish what I do from what is built in to the Nextion.

i owe you a cold beer or hot coffee,you pick :slight_smile: Thanks.

now my car has gps info screen, thanks for your help :slight_smile:

I owe you a cold beer or hot coffee,you pick

Beer please :slight_smile:
Although as I suspect you don't live near Nottingham I'll settle for some Karma.

PerryBebbington:
Beer please :slight_smile:
Although as I suspect you don't live near Nottingham I'll settle for some Karma.

i visit UK a lot, as a man said in a good movie "i don't know who you are, i don't know where you live, but i'll find you and i'll buy you a beer" :slight_smile:

You have your karma my dear sir :slight_smile:

Ok, well, I am about 6 miles north of Nottingham, so if you are ever in the area look me up :slight_smile:

PerryBebbington:
Ok, well, I am about 6 miles north of Nottingham, so if you are ever in the area look me up :slight_smile:

definitely will do