In this article, I will be sharing how to use ESP8266 to get data like Temperature, Pressure, Climate etc. And YouTube data like Subscribers & Total view count. and display the data on the Serial monitor and LCD. The data will be fetched online so no additional sensors are needed for this one. The website used here is RemoteMe.org. Check out the previous tutorial about RemoteMe here if you haven’t already.
So let’s get started…
- 16*2 LCD display
- Momentary Switch
- 220-ohm Resistor
- 10k ohm Potentiometer
- Arduino IDE
- RemoteMe (Account)
Setting Up Variables at RemoteMe:
In this step, we will set up variables which will send data to our microcontroller. First head to RemoteMe.org and follow the steps:-
- First head over to RemoteMe.org and sign in to your account.
- Next, go to “Variables” ( It is on the Left side in the menu).
- In the Variables option, there will be an empty page, with “Add” option on the top right corner. Click on that. A pop-up will appear.
- In the pop-up fill the name of the variable. It depends on what you want (Subscriber Counts, View Counts or Weather Info).
- Now select server type “Remote”, the Group depends on what you want YouTube or weather data.
- If you select “YouTube“, You will need channel ID which you can find on YouTube, Just go to YouTube and search the channel you want, Open it and copy the code in URL. ( Check the images for reference)
- Now in the Remote Mode option select what you want Subscriber count or Views count. And submit the data. It will create a variable. Similarly make more variables for other data you want.
Setting Up Device on RemoteMe:
Once the Variables are made, head to the “Devices” option. It is just above “Variables“. Here you have to create a new device.
- To create new device, Select the option on top right corner.
- Select “New Network Devices” from the drop-down menu. A pop-up will appear
- First, select the type of device you are using. (For Arduino and NodeMCU, select Arduino)
- Name the device something like YouTube/Weather, whatever you want.
- Give a device ID, it can be anything but for the first device give ‘1’.
- Now submit. A new device will appear.
- Click on the burger menu on the device. (Represented by 3 horizontal lines) and select “Code Generator Wizard”.
- Now choose Variables, Select all and click on Next.
- Enter your WiFi name and Password. In the Token Menu select token. Click on Next.
- Turn On the debug option and Click next.
- Here you can see the code for Arduino. It will be automatically generated and you can download it.
The code downloaded can be now uploaded to the Microcontroller. For the code to work you need some libraries which you can install from the Library Manager.
To Install Libraries:-
- Goto >> Sketch >> Include Library >> Manage Libraries.
- In the search bar enter the name of the libraries. (ESP8266WiFi, ESP8266WiFiMulti & RemoteMe)
- Install the Libraries.
Now you can upload the code and open Serial Monitor to watch the data.
Below I have provided a code which is edited a bit to make the results more presentable. You can download the code, add your WiFi name & password in the required fields. Also, add the Device ID which is used on the previous step (‘1’).
To add token manually goto RemoteMe >> Applications >> Tokens. Copy the Token and paste it on the code. Upload and check the Serial Monitor for results.
NOTE:- To program ESP boards with Arduino IDE, you have to setup the IDE which if you have no idea about, you can check this tutorial.
Download the code from here: weather.ino
Displaying Data on LCD:
Now that you have successfully displayed data on ‘Serial Monitor’, You can move on to display the data on an LCD screen so the project can be more portable.
Follow the steps carefully:-
- First place the NodeMCU board (ESP8266) on a breadboard, Connect its ‘3.3v’ to the ‘+ve’ rail of the breadboard and ‘Gnd’ to ‘-ve’ rail.
- Connect a push button next to the MCU and connect its one pin to ‘-ve’ rail of breadboard through a ‘220 ohm’ resistor. And connect the same pin to ‘D2’ pin of the MCU. Connect the other pin of the push button to ‘+ve’ rail of the breadboard.
- Now connect the LCD on the breadboard and follow the connections carefully.
- VSS >> -ve rail of breadboard.
- VDD >> +ve rail.
- V0 >> Middle terminal of potentiometer. (connect other two terminals to -ve and +ve)
- RS >> D2
- RW >> -ve rail.
- E >> D3 of MCU
- D4 >> D5
- D5 >> D6
- D6 >> D7
- D7 >> D8
- A >> +ve rail of breadboard through a 220 ohm resistor.
- K >> -ve rail
I know this is a bit confusing but check out the picture to get a better idea.
With that been done, the connections are ready, Now just have to upload the code.
The code needs to be edited in order to work with LCD.
Let’s edit the previous code:-
So after the changes are made, You can upload the code to the board and you should see “connected…” being displayed on LCD as well as on the Serial monitor.
Download the edited code :- arduino.ino
Once the code is up and running, you can test if everything works fine.
When the ESP board is connected to the network, LCD will display “Connected…”
Pressing the button will display Weather (Temperature and Pressure info), pressing again will display YouTube Subscribers and Total views.
You can edit the code to display other information like Time, weather condition etc. as well.
Hope you like the post, If you have any questions or face any problem, you can let me know in the comment section. I will reply as soon as possible.