How to fix errors with the ESP32 / ESP8266 and Firebase.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
if you are trying to create a database with Firebase and if you're having trouble with the esp3208 to 66 device you are at the right place welcome to electronics simplified so without wasting any time all you got to do is connect a device I am going to use a esp32 so just snap it on with a data cable so this is the first mistake just fix it do not use a power cable this cable is right and it's fantastic next you got to go to your console your Firebase console and create a project now I have already signed in I'm just going to start off by making a project since since this is real time data Okay so I'm going to name it as real-time data and you can see the slug created click on continue and Google analytics we don't need this so basically disable it and click on create a project now this may take a while once you create the project now why Firebase Firebase is really you know dependable and it is free there are some more options that you could use but Firebase is more preferred now your project is ready and you can click on continue once you click on continue it's time to see your project here click on build and then go to authentication because we are going to set the authentication method and since we are just in our testing phase we are going to create a an anonymous user we won't set it up with email or password anything as such for the moment we will be doing it a little later so the sign in method click on anonymous once you click on Anonymous just enable the option first there is no there are no credentials here and this is basically a big big threat so for the moment we'll let it be and we'll go ahead then we are going to go to the real time database click on Real Time database create one click on create the database and then will be ready again this might take a while to create and it's going to create a database on the closest server now my location is it's it's in Asia so I'm going to choose Singapore and click on next now you can start in locked mode if you are actually doing a build up project for yourself or for some company but we are in the test mode still because we are fixing errors then click on enable once we click on enable on the database will be created you can go to the database and you'll see some important information here it's created the link the database link so copy the link and paste it paste it on a notepad for the moment so I'm not going to hide in any details because after the project is over I'm going to delete it since actually you're supposed to keep this details private and also make sure that you do not misuse any of this information here next we need the web API key so you can go to settings go to Project settings and find the web API key so here it is you copy it and then paste it so once you paste the web API key I think that's all that is needed for an anonymous user now in my case I'm using the esp32 so I'm going to keep this Library wi-fi.h but if you are using the esp8266 just uncomment this line I mean not uncomment the comment but uncomment the line that is there and then comment the wi-fi.it okay like this so I'll keep it back in place and this file is ESP client this library is actually available in the description I will be providing you the link just download it as a zip and once you download it okay I want you to go and use it use the same version because this is compatible with Firebase the the recent ones have some changes made and you might have some trouble so locate the locate the zip file it's in Firebase database thereafter just select it and just say open I already have it added so there you go now you can fill in the other details now the details here okay let's start with the SSID replace it with your Wi-Fi name now most of the people they they do it well here I mean there is no problem so far the problem occurs once it comes to an authentication user with the details I'll be showing that to you later in the video if you feel the video is too long you can actually go and check the timeline so I'm going to put in the other details so this is the web API key and then just paste it in here then find the database URL again just paste it from from the project that you had created so copy and then paste it now the code again will be in the description for anonymous user and authenticated user Make sure you use the right code for the right one now here the sign up over here is set as false it's basically because oh this is just the initial condition this is basically the initial condition a sign up is set as false because as an anonymous authentication we are going to create a new user every single time I'll show you where exactly that happens here it is it's blank okay and it just say sign up to be true later on we are just creating a new user every single time so this is the anonymous login okay or sign in so everything here if you I mean here we are just logging in some data onto the database and that data is going to change after every 15 seconds so the data is going to update now what is this data here for just for the purpose of sampling we are creating random numbers okay I'll show you where exactly so we could change that 15 seconds there so here we have a random number between 0 to 10 and this is basically here we have an integer and this section we have a float so we are going to randomly have two numbers that are going to be logged in into our database there's nothing special as for now you can replace this later on with the sensor readings now let's go to a board esp32 mine is uh do it development kit one so let me see where exactly it is it's not here and you have to choose a right board you need to know what board you have actually purchased so this is the one do the other settings so here my upload speed is 115200 and yeah there you go it needs to match it's not really you don't really need to match that actually but on a safer side and then on the com Port yes now once you compile it okay it's gonna really take long you can really take a break here the the best part here is if you have any problem with your uploading I have another video where I have solved problems with the esp8266 you can go and check out that video it's going to be again be there in the description okay I'm going to fast forward this that really took long it took approximately four minutes so there you go it's done compiling now it's time to upload I don't know how long it's going to take now the compilation process is basically where your you know your machine tries to convert it into a machine readable code for the SP device so that process could be initially be long but I am assuming that this time it should be a little bit starter okay so like I guessed it is kind of faster this time and yeah floating next time okay still compiling it has to start uploading and there you go like I told you if you have any kind of error here you could go and check the esp8266 error is fixed okay that would help you more in this situation for now we are just focusing on the database issues so once the code is done uploading here you will be able to see the data being logged into our database I'll show you in a short while so do not hesitate if this uploading takes really long it does take up approximately around four to five minutes in some cases and sometimes it's a lot more quicker but then the USB device is do have the tendency to communicate in this manner so there you go I have made it faster for you and then now it's time to go and check our serial monitor so press Ctrl shift and M and get the serial monitor make sure your board space is the same as what you had set it in your code now connecting to Wi-Fi Now many of you have an issue here the ESP devices need to be reseted so you need to reset the device just click on reset on your device and then it will try to connect again to the Wi-Fi and hopefully it succeeds so yeah it did succeed in my case if you did not please let me know in the comments now you can see that everything is okay passed and if the type integer is passed and the float is also passed so I'm going to check it in my database so it's time to go to the console and check the database so in the database you'll be able to see a table called test and under it you can see two values now these data I mean this data is going to be uploaded or updated after every 15 seconds I'm going to wait here for the next 15 seconds just to see whether it's really updating so it does update and we can see that the real-time data is being updated and the code is here this is the link so the link is actually available in the description you could use this same code for your project so now I've basically come to the authentication section and I'm going to show you that there are two Anonymous users now every single time that your USB device connects it's going to create an anonymous user okay now we are going to try and add the email and password because we need to really know who is logging in the data okay so for that purpose we are going to use email slash password now I recommend you not to use your personal email to do this but I'm going to show you with the help of my email at the moment later I'll be using another ID so just disable this email link and click on Save now the new authentication method is set so I can actually use email and passwords now now it's time to add a user so go to users and click add user now type in your email okay I'm going to type in my email here it's going to be Electronics engineering three so make sure that your email is actually a Gmail account and you cannot use any other email here you could use it but then there are some other you know configurations that would be complicated for you so using a Gmail is way more better so I set the password as something at one two three that's not my password Okay so we are actually going to refer to this uuid later for now we are going to keep it here this is basically the unique identity number set for a user now we have a email set and we also have the password set now everybody here feels that we can just replace it with with you know you can just go to the code and replace this details but that's not how it works so I'm going to try and show you what actually could happen and maybe some of you have actually performed this by creating an email and password okay so this is the code here just copy the entire code the code again will be in the description I mean here you go just refill all this information again and put in your email and password okay so that's the email address I'm going to copy it and then paste it there and my password I know that I type my password as something at one two three so and there's no way you can see your password here so I'm gonna edit that now you know that this is not going to work okay still I'm going to upload and show you that it really doesn't work then and this is not the right way and that's not the password and that's not even my email password okay so and please do not try to add your email password into this section it really does not need your email password for the Authentication so now I'll just upload this this is really incorrect so what do we do with the uuids some of them paste the uuid instead of the password and try to upload it okay see the connections again in you can upload check all the other settings first everything looks fine here and in this chord basically I have tried not to log in any data you could try to login data by taking the reference of some other code okay I'm just going to upload this code for now this code is basically for authentication where you'll be able to see whether the right right user is communicating with the database so I would be taking my previous code and trying to login data now just do not copy you know a part or or a bunch of code from the previous code and just paste it and expect it to work okay I'll just show you what many users do so if you do not have sufficient knowledge about Arduino code with the ID I recommend you not to do this okay basically do not do this do not do this some people just copy it and then paste you know a bunch of code expecting it to function the same way because the previous code worked and now this code is also you know entitled to work according to them no that's not how it works okay it's exactly not how it works because there are a lot of parameters that are not defined there are a lot of parameters that are not assigned that a lot of configurations that are missing anyways I'll show you what would actually happen for some reason the code will code would still work because it would compile and again this is going to take a decade okay so now for the purpose of security I have another account created and I'm going to go again to the same setup okay copy the same URL this is basically the same steps that we did earlier for a database and paste it and update it with a new database URL then we're also going to use you know the user ID basically make sure that the web API key is also updated and this might not happen in your case because I recommend you to you know always use a older I mean a newer email ID for your esp32 or esp8266 do not use your personal email account okay so there you go just take this entire code copy it because this is the one that I'm going to use for Authentication now there you go just put in the details be quick real quick I'm gonna be fast forwarding this and then update it with the right email address because last time I use the wrong email address there you go copy the email address and then paste the password now again I come back to the same point where do we get this password now for this password you'll have to go to your account details okay so some of you might use different things there don't enter your email ID password and all of that because you've got to see where exactly that password is being used so you're going to go to your Account Details click on manage your account then go to security click on security and then go to two-step verification over here you can go and check your app password so add an app password Here I already have an existing app password so I'm going to delete this one so that I can actually show you how to add a new one so basically just delete this existing one and just go to the custom name and you can write ESP since this is ESP data and then click on generate now this is the app password that I ESP actually needs so copy this password and save it now make sure that you do not share this with anyone and you keep it pasted somewhere because you cannot get the password again your Google account is not going to show you this token or this password again so keep it pasted and we're going to paste it right here now save this account because I mean I'm Gonna Save this code so I'm gonna save this as data logging this is since this is authentication I'm going to save it as Authentication and then click on Save this time around I'm just going to upload the code and I think everything should work here fantastic smooth and I don't think that there should be any error now so most of you will come to this point and will be sorted since now you know from where and how to generate the password okay your status but look I still have a problem I still have an error um it still says that there is a status error and it cannot get my uid so in this case what would you do so in this case since I know that most of my details are correct in the code coming from the email address to data URL to the web API key I would go to my Firebase data connection and actually delete my user Okay so just try to check first um okay so the solution here would be trying to create trying to add the user again maybe there could be some other problem okay now this is a problem I have faced in real time okay I am actually recording this and I didn't expect this error to occur still I'm gonna try and fix this by trying to delete this user first so I'm going to reset password and say okay now I remember what exactly happened now the thing is that we did not paste our password right here so there is no way to update the password and resetting is a different thing altogether I'm going to create a new I mean the sign in method is already there I'm going to add a new user again so go to user and click on add user put in your email now the email that I'm using is testing simplified Plus so and paste the password as well so some of you might copy the password correctly okay the app generated password and then paste it here and then even add the user so now what's wrong here is basically my email address so what I recommend you to do is make sure when you create a new email address make sure that you have your email address itself copied so these are some errors that I have covered up okay so in case if you like this video you can like it and you could mention to me in the comments what are the types of Errors you have because these are all noted down from the comments and I try to make up a video for this so I got to see that I'm gonna delete this account again because I know that my email ID is incorrect there so I'm going to add again the user put in the right email address it's testing es simplified at gmail okay so the best thing is to just copy it since I created a new account okay it's my memory is volatile okay I'm gonna copy this and then paste it and then say add now everything looks fine and now this time I hope that we do not get any more errors so no need to upload this code again because the email here looks fine I'm going to just try to reconnect it to the Wi-Fi you know it's connecting to the Wi-Fi and now everything looks no I didn't connect to the Wi-Fi it's requesting now the token is ready and we have received our uid so with this uid you can now login data into your database you can connect more sensors lock get in whatever data you want so I'll be showing you some sensors some devices and how to control a door lock make sure you subscribe to this channel
Info
Channel: Electronics Simplified
Views: 3,469
Rating: undefined out of 5
Keywords: Firebase, Web Development, Error Fixing, Real-time Database, Cloud Firestore, Authentication, Security Rules, Cloud Functions, Hosting, Analytics, Performance Monitoring, Crashlytics, Cloud Messaging, Cloud Storage, Cloud Functions for Firebase, SDK, JavaScript, Node.js, React, Angular, Vue.js, Android, iOS, Web API.
Id: 6cWhEmgBhbo
Channel Id: undefined
Length: 27min 10sec (1630 seconds)
Published: Sun Apr 23 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.