0
\$\begingroup\$

I am trying to make a device that shows Temperature sensors data and their graphical illustration at the same time. I have 4 texts (that show temperatures) and 4 gauges (that works as temperature indicators) on Nextion. I am collecting temperature data and convert these to gauge picture values like below

// I am collecting sensor data with OneWire Library

dtostrf(temp1, 3, 1, buffer);
tmp1.setText(buffer1); // write 1. sensor temp to nextion tmp1 text

dtostrf(temp2, 3, 1, buffer);
tmp2.setText(buffer2); // write 2. sensor temp to nextion tmp2 text

dtostrf(temp3, 3, 1, buffer);
tmp3.setText(buffer3); // write 3. sensor temp to nextion tmp3 text

dtostrf(digitalread(switch_pin), 1, 0, buffer);
tmp4.setText(buffer4); // write 4. sensor temp to nextion tmp4 text

tmp1gauge.setPic(map(temp1, 0, 50, 38, 47)); //Convert temp1 data to tmp1gauge.picc as 38..47

tmp2gauge.setPic(map(temp2, 0, 30, 38, 47)); //Convert temp2 data to tmp2gauge.picc as 38..47

tmp3gauge.setPic(map(temp3, 0, -15, 38, 47)); //Convert temp3 data to tmp3gauge.picc as 38..47

tmp4gauge.setPic(map(digitalread(switch_pin), 0, 1, 38, 47)); //Convert switch_pin data to tmp4gauge.picc as 38/47

Because of negative inconsistency of nextion, I'm using text and there is no problem to show data. But as you can see, I'm sending data 8 (4 for temp(s) and 4 for picture(s)) times for every cycle and this interrupts some other button press communications. Finally, I think that let me send all these data within one string (after combining all sent data) or array and explode on Nextion side then place necessary values to right elements. But, problem is that Icouldn't find any (way) function to do this within Nextion. Is there any one who can help me to do this? thanks..

I am trying to investigate to send data as string with comma separated to a nextion variable and use substr command in Nextion but negative numbers and comma positions might be issue I think.

NOTE: This question is more about Nextion Programming not only the arduino part.

\$\endgroup\$
  • \$\begingroup\$ You need to show us some effort and ask a more specific question. Why do you think you would have an "issue" with the substr function? \$\endgroup\$ – Elliot Alderson Feb 1 at 15:10
  • \$\begingroup\$ @ElliotAlderson Sub str command works like "substr t0.txt,t1.txt,0,2" ; 0 is starting point and 2 is length. But in my case there are some negative values (it increase the length of value), so length of result can be vary and this would be result to faulty cropping (let's say in my opinion)(If there would be a function like explode(), i could use it as "explode according to comma" but there is no.). If there is a way to specify the length of each data (I don't know how to), it can be used. \$\endgroup\$ – Alper Feb 1 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.