65 Nextion Display - no Arduino Nextion.h Library part 2 or 01B

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 มิ.ย. 2024
  • I have an updated video to this one at • 174 Using the #nextio...
    This video shows how to send commands to the Nextion Display from the Arduino without using the Nextion.h file. I show setting up the Nextion along with coding the Arduino. I believe this will work with any device that transmits RS232. If you have any questions ask in the comments section.
    If you enjoy the content considering donating a cup of coffee at ko-fi.com/cheapcontrols
    --------------------Minimal code required. I did not test but I am 90% confident.
    int i = 20;
    void setup() {
    // put your setup code here, to run once:
    Serial.begin(9600);
    Serial.println("Hello World");//fixed the capital E
    }
    void loop() {
    delay(2000);
    Serial.print("j0.val=" + String(i));
    Serial.write(0xff);
    Serial.write(0xff);
    Serial.write(0xff);
    i++;
    }
    You can sort and find videos better on at www.cheapcontrols.com
    I have started a group on Facebook to make it easier to interact with user-requested videos. Consider looking it up. pg/cheapcont...

ความคิดเห็น • 77

  • @mariuszkolosa6833
    @mariuszkolosa6833 3 หลายเดือนก่อน +1

    Bardzo Ci dziękuje. Od dwóch tygodni próbowałem połączyć Arduino Mega z Nextion. We wszystkich tutorialach był błąd w składni, dopiero u Ciebie jest poprawnie. Działa wszystko. Jeszcze raz bardzo Dziękuje.

    • @CheapControls
      @CheapControls  3 หลายเดือนก่อน +1

      Your Welcome, I am glad I was able to help.

  • @MalcolmHelicopter
    @MalcolmHelicopter 3 ปีที่แล้ว +1

    I commented earlier - but failed fully to express my profound appreciation of your excellent help. Thank you again! I’m getting numeric data to and from the Nextion now thanks to you. I would like also to send text in order to change the .txt property of various controls. I cannot so far get this to work. Any help will be strongly appreciated! I agree by the way that the usual libraries are best avoided entirely! Thank you again!

    • @CheapControls
      @CheapControls  3 ปีที่แล้ว

      I thought for sure I had a video on that but I can't find one. I will look again when I have a little more time.

    • @MalcolmHelicopter
      @MalcolmHelicopter 3 ปีที่แล้ว

      It’s OK thanks! I’ve just found the answer! The new text must be enclosed in double quotes and hence looks like : Serial1.print(“b0.txt=\”TestText\””);
      I’d simply forgotten about \” !

  • @serkanozkan8793
    @serkanozkan8793 4 ปีที่แล้ว +1

    Thanks man. very helpful and it works great.

  • @MohammedAlsadah
    @MohammedAlsadah 3 ปีที่แล้ว +2

    Hi,
    Thanks for your efforts
    I checked your video because I noticed some issue with the display, and the same issue happend at 7:39.
    Basically, when you enter a new line, the display will not read the first instruction, I guess there is a hidden charecter, so your program in fact started at j0.val=21, not 20. What I did to solve the issue is to send three high bytes to terminate what ever hidden after printing a new line, then I entered my instruction.
    Hope this helps to get more accurate results🌹

    • @CheapControls
      @CheapControls  3 ปีที่แล้ว +1

      good observation. Thanks for watching.

  • @beamertech1
    @beamertech1 4 ปีที่แล้ว +5

    You’ve been more than accommodating with your instructions. You need not self-deprecate.

  • @beforebefore
    @beforebefore ปีที่แล้ว +1

    Nice video series, thanks!
    While I'm waiting for my Enhanced 3.5" display to arrive, I've been creating my screens virtually. I'm using an onscreen "Number" object to display the numeric percentage of "progress", then copy that value (1-100%) to my Progress Bar. Within the Nextion display, I can calculate my "numeric progress" by diving two other values that my MCU will be sending to my display. I do this in math within the Page "Postinitialization Events"... but I'm not sure this will work as desired... because those Events won't be constantly refreshed... at least this is what I noticed by running Debug and sending new values to the virtual display with a "n1.val=400" command. When I do this, it does update the "n1" displayed value on the virtual screen, but it does not recalculate a new "Numeric Percentage" value, nor does it update the "Progress Bar" I'm trying to minimize the amount of Display work that the MCU will have to do, so I was hoping to let the controller in the disply do the math without intervention from the external MCU.
    Do I have to put this math elsewhere, or do something like use a Timer to force the math every 200ms or something? Will that even cause a Progress Bar refresh?

    • @CheapControls
      @CheapControls  ปีที่แล้ว

      The timer is a good solution to continually update an object. Just remember timers only run when the page is displayed so if you want to run the events when on a separate page you need to make the objects global and add a timer to each page. Good Luck! Thanks for taking the time to comment.

  • @dexterzhao1071
    @dexterzhao1071 ปีที่แล้ว +2

    Nice! Question: when you set default encoding iso-8859-2 in Nextion, how is it in Arduino? Arduino default is utf-8 should i stick to this encoding or change it to iso-8859-1 as well?

    • @CheapControls
      @CheapControls  ปีที่แล้ว

      I have never adjusted the encoding. I just leave it as default. If this is not a good answer, I might not understand the question. I may not have adjusted encoding.

    • @dexterzhao1071
      @dexterzhao1071 ปีที่แล้ว

      @@CheapControls Thx, and your Arduino IDE is utf-8 right?

  • @ejazmalik5899
    @ejazmalik5899 4 ปีที่แล้ว +1

    Good Work. Keep going for it.

    • @CheapControls
      @CheapControls  4 ปีที่แล้ว

      I will try my best

    • @ejazmalik5899
      @ejazmalik5899 4 ปีที่แล้ว +1

      @@CheapControls Don't give up on your channel. Every thing starts from 0.Gradually you will have Followers. Have a Nice Day

  • @suvedhborker3489
    @suvedhborker3489 4 ปีที่แล้ว +1

    Thank you so much for the wonderful explanation. I am already using this method of transmitting data from ardrino to mention. I have a question, I am using multiple pages in my project. I need to send some numeric data to page 2, how to do that using this method. Thanks

    • @CheapControls
      @CheapControls  4 ปีที่แล้ว +1

      th-cam.com/video/jXpgeZ7cmRo/w-d-xo.html Check out this video

    • @suvedhborker3489
      @suvedhborker3489 4 ปีที่แล้ว

      Thanks, that was really helpful.. Cheers

  • @jinken9613
    @jinken9613 4 ปีที่แล้ว +2

    thank you for sharing!

    • @CheapControls
      @CheapControls  4 ปีที่แล้ว +1

      You are very welcome. I very much enjoy making these videos.

  • @dedub222
    @dedub222 3 ปีที่แล้ว

    Great tutorial as always! I have a few questions that I would like guidance on if you have time.....
    1. I have multiple pages in my project, therefore which ever page has focus, that element assumes the value being sent. In other words there is more than 1 "j0" and "n0" Is there a way to sent that value to just one screen without the library?
    2. Part of my project is using the HT22 temperature and humidity sensor. Those are floats prewritten in the library. I'm having a hard time taking those and sending them to the Nextion. Is there a trick to that? (Maybe you already have a tutorial done on that topic?)

    • @CheapControls
      @CheapControls  3 ปีที่แล้ว +2

      1. You can make the items global. Then you access them with the page.n0.val instead of just n0.val check out this video th-cam.com/video/jXpgeZ7cmRo/w-d-xo.html.
      2. floats are a little different. If you have an Arduino float of 98.5 degrees. Multiply it by 10 and turn it into an integer then send it to the Nextion. The Nextion does not understand float values but they do have a display that sets a decimal point at a spot that you want. check out this video. th-cam.com/video/oJ4s6svG438/w-d-xo.html
      If you have more questions ask away.

    • @dedub222
      @dedub222 3 ปีที่แล้ว +1

      @@CheapControls You're indispensable! I actually found an easy way to fix my first problem, just rename the object so each page has something different! duh.. LOL, too easy. Thanks for the links too, I so appreciate you taking your time.

    • @CheapControls
      @CheapControls  3 ปีที่แล้ว

      I am glad you found your solution

  • @MalcolmHelicopter
    @MalcolmHelicopter 3 ปีที่แล้ว +1

    Terrific thank you.
    I tried also to change the .txt property of a text box, and a button. This did not work. Can you tell me why? Hope so!

    • @CheapControls
      @CheapControls  3 ปีที่แล้ว

      Go to the cheap controls website and submit a comment with your code. Then I will reply through Email. IF you are not comfortable you can join the cheap controls private facebook group.

    • @thienle2429
      @thienle2429 3 ปีที่แล้ว

      @@CheapControls me too ,i can't change .txt

    • @CheapControls
      @CheapControls  3 ปีที่แล้ว

      @@thienle2429 I have had a couple questions about this and I don't. Have video devoted to this. I will try to get one out over the next couple days.

  • @essouaiedameur7642
    @essouaiedameur7642 4 ปีที่แล้ว +1

    i have a quition please i need it for my degree projects how can connect a SD card to arduino for a database to save id and password for access i mean they're both serial (9600) does it make sence if i use it 1 time

    • @CheapControls
      @CheapControls  4 ปีที่แล้ว

      I have to be honest. I have no idea how you would put a database on an Arduino. Maybe a Raspberry Pi?

  • @jaakugleamshore8866
    @jaakugleamshore8866 4 ปีที่แล้ว +1

    I got some error when i want to change the serial connection to serial3 for my project. I just change serial.begin and serial.print("j0.val=" + string(i)); to serial3.begin and serial3.print("j0.val=" + string(i)); but it doesnt work. Can you give me some suggestion?

    • @CheapControls
      @CheapControls  4 ปีที่แล้ว

      Did you try Serial2? I have never used Serial3. I will try it on my next experiment. I don't think there is any difference between Serial2 and Serial3. Also what error message did you get?

    • @jaakugleamshore8866
      @jaakugleamshore8866 4 ปีที่แล้ว

      @@CheapControls I didnt try Serial2. There is no error notification, just cant showing in serial monitor. But its not a problem now. I just hook up serial3.print and serial.print too. serial3 for run command nextion and serial for showing state condition in serial monitor. Now the command from arduino due is well execute to my nextion and my nextion or arduino act can be read in serial monitor.

    • @jaakugleamshore8866
      @jaakugleamshore8866 4 ปีที่แล้ว

      But my big question that always i thinking is why serial3.print can't showing the command in serial monitor like you did in your video? Why dont act like serial.print does that the command can be read directly by serial monitor?
      I still learn it by watching your videos.

    • @CheapControls
      @CheapControls  4 ปีที่แล้ว

      The USB connector on the Arduino board is the same as serial.print This is the same used in the serial monitor. I do not think it can be changed. If you have the serial monitor running when you upload code to the Arduino you will notice the serial monitor will stop until the upload is completed because it can't do both at the same time. I hope that was clear.

  • @miteshkadam4421
    @miteshkadam4421 5 หลายเดือนก่อน +1

    In serial monitor after j0.val=data???
    Can you please explain why 3 question mark is there after data

    • @CheapControls
      @CheapControls  5 หลายเดือนก่อน

      commands are terminated by three 0xFF hex values. The serial monitor does not know how to handle extended ascii, so it interprets each 0xFF it as a "?"

  • @sayalijoshi5010
    @sayalijoshi5010 3 ปีที่แล้ว

    Can we change borderc too through arduino.
    I send the following command and nothing happened.
    Serial.print("page0.t5.borderc=50712");
    There was no change on the display.

    • @CheapControls
      @CheapControls  3 ปีที่แล้ว +1

      When you look at the attributes some are green and some are black. The ones in green you can alter in the code. The ones in black are not adjustable while the code is running. borderc is not adjustable within the code.

    • @sayalijoshi5010
      @sayalijoshi5010 3 ปีที่แล้ว

      @@CheapControls Ok. Thankyou for your input.

  • @punjabilog
    @punjabilog 3 ปีที่แล้ว +1

    Hi Sir I always love you videos. Can you please make videos to work with micropython I think its much easier then C++.
    Thanks

    • @CheapControls
      @CheapControls  3 ปีที่แล้ว

      I will look into this and see what it would take to maybe do a micropython set. I have never heard of micropython and always enjoy looking into new things.

  • @naveenvaid4318
    @naveenvaid4318 3 ปีที่แล้ว +1

    thanks sir but i have a one problem that i want to use this display for led brightness control with pwm with four switches on display one for on and second for off and two switches for increase integer value and second for decrement value but i face a problem that my switches give the serial data right but problem is that when i touch the given switch serial data will come and my arduino uno programme rotate in one loop. thnax if you help me i will so happy.

    • @CheapControls
      @CheapControls  3 ปีที่แล้ว

      I am sorry but I don't know what you mean by "arduino uno programme rotate in one loop" Will you try to explain again.

    • @naveenvaid4318
      @naveenvaid4318 3 ปีที่แล้ว

      @@CheapControls thanks sir but I done it

  • @imgoingtwo2780
    @imgoingtwo2780 2 ปีที่แล้ว

    Can you please help me with my project. All I need to do is have a number decrease by 1 everytime a pin reads "HIGH" on my arduino. I need it to start at 15 and decrease. If I could reset the value with a different HIGH reading that would be amazing too

    • @CheapControls
      @CheapControls  2 ปีที่แล้ว

      Normally this is the type of thing I would make a video on but I am going through a move and have to finish the house we are moving too by the 19th of the month. If you have time to wait I might be able to get to it next month. Your other option is to start working on the code and email it to me for review. If you go to www.cheapcontrols.com and submit a comment with your email. I will respond. Good Luck with whatever you choose and thank you for watching.

  • @sayalijoshi5010
    @sayalijoshi5010 2 ปีที่แล้ว +1

    Hello Sir,
    I actually used this page 0.t5.txt=\* *\ to send data from arduino to nextion display. This command worked on a small project consisting of only 1 blank page. When I used this same command on a big project with 10 pages, it never worked , the text box remained blank. Is there any error that I am making. How do I solve this problem?

    • @CheapControls
      @CheapControls  2 ปีที่แล้ว

      I thought I had a video on writing to other pages but I can't find it. When you write data to a field on a page not showing you have to make sure the field on the nextion is set to global.

    • @sayalijoshi5010
      @sayalijoshi5010 2 ปีที่แล้ว

      I have set the text field as global. I have even set the page at global scope. It still won't work.

    • @CheapControls
      @CheapControls  2 ปีที่แล้ว

      Then I am not sure why it is not working. If you want me to review your code you will need to go to www.cheapcontrols.com and submit a comment with your Email address. I will reply and ask for your hmi and arduino file.

  • @apostolosn5536
    @apostolosn5536 11 หลายเดือนก่อน

    Very nice series, thanks for sharing. I have a problem send an integer from adruino to a nextion text field. The value goes to the nextion but it is not updated. Here is what I do. I want to send a value from arduino to nextion to a text filed located on page1, so I use:
    Serial2.print("page 1"); // change the page to page 1
    Serial2.write(0xff);
    Serial2.write(0xff);
    Serial2.write(0xff);
    Serial2.print("va0.val=" + String(timer_delay)); // send the timer delay setting to Nextion
    Serial2.write(0xff);
    Serial2.write(0xff);
    Serial2.write(0xff);
    I want to send this to a text field name t0.txt on this page, how do I go about doing this so it refreshes the value in the txt filed immediately?

    • @CheapControls
      @CheapControls  11 หลายเดือนก่อน

      Change va0.val with t0.txt. You also have to add the quotes in Arduino it would be Serial.print("t0.txt=\"" + String + "\"") then write the three 0xff

    • @apostolosn5536
      @apostolosn5536 11 หลายเดือนก่อน

      @@CheapControls What I'm trying to do is have a txt object in nextion that is incremented or decremented using button on the nextion. This is a delay setting in a settings page. When you exit the settings page the nextion send the value to the Arduino which in turn stores the setting in eeprom. In the event of a system reset the nextion looses this setting so the Arduino retrieves it from eeprom and sends it to the nextion. I just can't figure out how to show this value in the txt field. I now that the nextion receives the value and stores in in the variable that I increment or decrement it is just that it is not shown in the text field. If i exit and re enter the page the value is shown corrctly in the txt field as it should.

    • @CheapControls
      @CheapControls  11 หลายเดือนก่อน

      is the scope of the text field local or global? When you choose global it will retain settings when you leave and return to a page. If you want the text to be changing while on another page you have two options. 1) on page initialize read the variable - this will make it appear that you are updating. 2) set the value as global and update while on the other page. Look at this video if global is not familiar th-cam.com/video/jXpgeZ7cmRo/w-d-xo.html If I am misunderstanding your question then I apologize and please go to www.cheapcontrols.com and submit a request on the help page. Sometimes email is easier to review code and exchange files.

  • @lombre7Squad
    @lombre7Squad 2 ปีที่แล้ว

    i wish to integrate a BN880 with compass and BME280. I can read them but i do not have acces to add them on my nextion 😞 . If u can do a tutorial about it, it will be really cool . Thanks for all of ur videos. really good job

    • @CheapControls
      @CheapControls  2 ปีที่แล้ว +1

      That would be cool! But, unfortunately all my equipment is packed up. I will try to do this after I get moved and my shop is set back up. Thank you for watching.

  • @jamescullins2709
    @jamescullins2709 4 ปีที่แล้ว +2

    How do you send a float val?

    • @CheapControls
      @CheapControls  4 ปีที่แล้ว

      I have been having trouble with some shipping. I can do this video in the Nextion Debug window. I am planning on one for next week. Thanks for the reccomendation.

    • @jamescullins2709
      @jamescullins2709 4 ปีที่แล้ว +1

      @@CheapControls Thank you, I figured it out. This works for me. I am looking fwd to seeing how you do it.
      char humO[11]; // in declarations at beginning of program.
      dtostrf(incomingHum, 8, 2, humO);
      Serial.print("humO.txt="); //
      Serial.print("\""); //
      Serial.print(humO); //
      Serial.print("\""); //
      Serial.write(0xff); //
      Serial.write(0xff);
      Serial.write(0xff);

    • @CheapControls
      @CheapControls  4 ปีที่แล้ว

      @@jamescullins2709 Most of my videos don't end up the way I plan them at the start. I have a good idea about how I want to do this one but I am not sure. I plan on avoiding the dtostrf but since I have not tested all my theories I may end up including it. I had planned on using readuntil in place of while serial available until I started shooting one of the videos and my plan crashed and burned. We will see how it goes.

    • @jamescullins2709
      @jamescullins2709 4 ปีที่แล้ว +1

      @@CheapControls Glad you're researching it to find other ways. I found if I needed to send a group of floats it would miss the first one, I just sent the first one twice and it would always display them all. Not elegant coding but it did work.Thanks

  • @ipjunior
    @ipjunior 4 ปีที่แล้ว

    Não consigo replicar no ESP32, pode me ajudar ?

    • @marklyle5666
      @marklyle5666 4 ปีที่แล้ว

      Which part is not working?

    • @CheapControls
      @CheapControls  4 ปีที่แล้ว

      I have been meaning to create another version with the Raspberry Pi and the ESP32. I will add it to my list of upcoming videos.

    • @ipjunior
      @ipjunior 4 ปีที่แล้ว

      @@marklyle5666 Eu recebo o print do codigo na console, mas não chega no t0.val no nextion.

    • @marklyle5666
      @marklyle5666 4 ปีที่แล้ว

      @@ipjunior t0 does not have a .val it would be t0.txt and would not work in this example. try a number instead n0.val or you need to escape the value you are sending back to the to.txt like this Serial.print("t0.txt \"") + Sring(1) + "\"") ; I am writing this out of memory I am not sure if it is a backslash or forward slash.

    • @CheapControls
      @CheapControls  4 ปีที่แล้ว +1

      @@ipjunior Did you get this going?