177 #ESP32 WIFI with the #Nextion Display with a multi-line text object #best

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to cheap controls we make videos on things that we struggled with hoping to help you so you don't consider subscribing and hitting that bell for this video i'm going to switch my control module from a nano to an esp32 i've been getting some requests for it in the comments of the youtube videos and i just so happen to need to use one for work i have to set up some communication between some computers and i'm thinking this might be a good way to do it and then if i hook up an action i might even be able to do some troubleshooting or see if i've got any errors between my connection now i'm going to be learning this along with everyone else on this so i'm going to start off kind of basic and for this one i'm just going to configure the network connect see if i can see some ssids and get the signal strength of the ssids and then display them on the nextion itself the model i have is a 30 pin unit and i'm going to get learn this just along with everyone else so i'm not sure what the difference is between them i bought a 30 pin and a 38 pin and they seem to be quite a bit different but i'm going to go with this 30 pin module because i i've noticed that it uses serial port 2 on these pins 6 and 7 down here and that means i won't have to alter my code i'll be able to treat my arduino code just as if i was using a mega so that's really the only reason i'm doing it as far as connections that's all i'm going to be using as far as connecting to it otherwise i'm going to be using the commands that are in the esp32 itself since it supports wi-fi now for the arduino portion of this as i said before i'm going to use serial port 2 but i'm going to have to comment out these lines just like i was using a mega and then i also have to install the driver or the the board manager and some libraries now that i have that all set up i've got to change my pin mode here 13 is the built-in led on the nano but for this one it's pin 2. and then over in the delay i have to do the same thing so now i should be able to upload this but when you upload it sometimes you have to press a button and i'm going to go over that while i'm uploading it here you can see i have it compiling down here and pretty soon it will go to loading and then i have to push this button and it's right up here on the esp and i found that sometimes i have to press that button and sometimes i don't i don't think i really had to that time but you can see that the light is flashing every second so really all we've done at this point is is make the light act like the blink experiment in the nano and eventually i want to look into how to not use this wi-fi library but for now we're going to add a library to the arduino code or to the esp and it's the wi-fi.h the other thing is is at first we're going to report the ssids we're going to do a search for ssids and we're going to do that in the serial monitor so i'm going to change this delay length to 10 000 or 10 seconds so that way we're only scanning every 10 seconds and we don't flood the serial monitor too quickly down in this area everything will stay the same we're going to keep this input function because we will be pulling data from the action eventually and i want to run this asynchronous delay and then this will just ignore for now we'll go over to the delay tab now and right now all we're doing is turning that light off and on and they make it pretty simple all i have to do is do this wi-fi dot scan networks and it will return an integer of how many networks that it currently finds that we're seeing now i'm in my house so i'm not going to see very many networks i did set up a cheap controls one just so that we can play with it a little bit if we return 0 in other words we don't find any networks we're going to say no networks found now if there is a wireless networks and we find them then we're going to go down to here and for each network we're going to have an integer i and we'll call those networks or we'll search from and it's as simple as calling the function wi-fi dot ssid and then we put a number in there if we wanted to just find the first one we could put zero but in this case we're going to count them all and see how many there are we're also going to look for the strength of the signal and we do that with this with this wi-fi dot rssi and then the same variable once again if we were just looking for the first one we found we could put a 0 in there but we it will come back as an integer so we have to put string in front of it so we'll serial print the ssid a space and then the strength so we're going to give this a shot we'll upload it and see what happens and i have two networks and you can see that it's just gonna keep going doing those every 10 seconds showing the different networks and it shows the signal strength for each network so so far so good now we'll see if we can get it going with connection now in the next shin we're going to do this very simply we don't have a whole lot going on i'm going to have this text field right here i'm i'm going to have it set up as multi-line and that way i can just display my ssids in here but when i go to send the ssids from the arduino i need to know how to put a new line in because if you look at the the text field over here it looks like it's one word find ssids but we know that's not true because if i click on it here it brings up this multi-line and we can add another line to it like that if i go okay then we know we have three lines so i have this button down here and i'm going to send this out in debug just to see what we're sending after these that isn't displaying so i have this print s t 0 dot text out the serial port so i'll go into debug now and we'll see what it is we're sending so we're going to see it down here when i press it and you can see i've left it in hex because i know find is four characters so first four and then it's got a zero d and a zero a and a zero d is a carriage return and zero a is line feed and if i hold my mouse over it you can see the find the 0d0a ssids 0d 0a and then hello so when we send the data back from the arduino we have to include a carriage return and a line feed between each ssid and the signal strength and then in order to request that the esp32 looks for the ssids we're going to use this button here and i'll put a link down in the description of why i use what i use here or go into more detail on it but we're just going to print and we're going to print c colon c which is our delimiter that says we have a command the command is going to be gss or get ss id and then a value of 0 1 in this case we're not going to look for a value whenever we get the command gss we're going to do a search for those ssids and then send them back up to the nextion so that's really all there is to the next in this case now i'm going to run this in debug i'm not going to have an actual display i had really planned on doing this with an intelligent display but i had some issues with it today so instead i'm just going to do it in debug and i'm going to use this text field i thought about using a combo box over here but of course that won't work except unless you have an intelligent display and i could have done the intelligent display in the debug but i thought this is a little more interesting because we're going to do a multi-line field and so we have to send that carriage return in that line feed so now we'll switch back over to the arduino okay i don't want it to be doing this portion of it anymore in the delay so i'm going to comment this out instead we're going to go over to the input area whenever there's serial data available on the main tab over here we're going to run this input function which is in this tab and in the input function we're going to collect the data one character at a time and if we exceed the length of three and it's not sequel and c we're going to reset that data from display but if it is c colon c we're going to go down here and we're going to pull the command out of it in this case gss and we're going to pull the value out of it even though we're not going to use it and then we'll print that but here's where we're going to change this from test command i always leave that in there in case i just want to do a quick test and now if the command is equal to gss we're going to want to do something in this case we would print test command cmd and the value which would be 0 1 but we're not going to worry about that right now either instead we're going to do the same thing we did on the other page we're going to have an integer of n and we're going to do the wi-fi wi-fi.scan networks which will give us the number of networks that are that we can see but we're also going to have to initiate a string called upload string and then that way we can create the string we're going to send up to the connection display we're also going to report the same thing if n is equal to zero in other words if we can't see any networks we're going to serial print line no networks found to the local monitor but we're going to change that upload string to say none found and that's what we'll send to the connection and it should show up in that t 0 field but if there are networks we're going to do once again a similar thing we're going to go through each network only the first time through if it's equal to 0 we're just going to get the ssid and the signal strength but every time after that if it's greater than 0 we're going to put this carriage return in line feed and we do that by an escape sequence of an r and an escape sequence of an n or a backslash r backslash n and since we put at the beginning here it will actually be at the end of the last command that was put out and then this way on the last command that we do we won't add it to the end so they'll only be in between each each individual ssid and then once we collect the ssid we're going to add it or append it to that upload string and we're going to do the same thing with the signal strength so we're going to get the the name of the network and the signal strength and so then we're going to serial print t0 text and whenever we do text we have to have the quotes so we'll escape that out with the backslash so that'll insert a quote into the string and then the upload string and then we have to have another quote and then we have to end it with that 0ff three times and i have that in this variable and that's all there is to it we should now be collecting the wi-fi networks for on the asp-32 and then sending them up to the nextion display so we'll give it a shot here and hopefully it works well the upload worked and what's strange is during the day when i was kind of messing around with it to create the video i had to press that button almost every single time but this evening it seems to be just going without pressing that boot button i'm not 100 sure why that is that way but if anyone knows go ahead and put it in the comments first i have to connect it to the arduino and you do that by coming over here to this mcu input and i know that my arduino is connected to 10 so there should be a second one and there is com21 and then we'll connect to it and i set the 9600 in the setup of the arduino so we have it started i'm going to press this button we should get something down here and then we should get something back here and we did and you can see we've got two networks they both have a single strength of 50 which are negative 50 which makes sense because they're both coming out of the same router and if i go over here you can see that we have that 0d0a in between the different ssids it's really nice i'm really looking forward to messing with these but so far really the only difference i can see is the fact that i believe they're a little bit faster they have multiple serial ports on them and they're really cheap like i got three of them for 20 bucks so i felt like that was a pretty good buy well that's about it for this video if you like what you saw consider giving me a thumbs up also consider subscribing to the channel thanks for watching
Info
Channel: Cheap Controls
Views: 5,799
Rating: undefined out of 5
Keywords: arduino, nextion, nolibrary, tutorial, LCD, coding, nextiondisplay, nextion_display, electronics, arduino programming, arduino programming tutorial, arduino programming basics, arduinos, arduinonano, arduinomega2560, arduinotutorial, arduino project, sync vs async, synchronous, asynchronous, arduino tutorial, arduino uno, nextion tutorial, ESP32, esp32 tutorial
Id: JtQOjuO6Ok0
Channel Id: undefined
Length: 15min 3sec (903 seconds)
Published: Fri Jun 24 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.