I am going to share my 1st IOT experience. Like we all know IOT stands for Internet Of Things. So what does this actually mean? It means a way to communicate devices through a network. If we think deeply, everything around us whether it's a smartphone or a smart light has an IoT implementation. We all know how to use this but have you ever wondered how this is practically done. If you don't know then don't worry because you came to the right spot to learn about it.
Let us Start our IoT journey with an Arduino
Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs — light on a sensor, a finger on a button, or a Twitter message — and turn it into an output — activating a motor, turning on an LED, publishing something online
The above definition is just an entry point to a world of new possibilities and new perspectives. In order to properly understand how this device works we need to see the IDE (Integrated development environment). We use this IDE in order to compile the C code and upload it to the board.
this beautiful and cute IDE was the starting point of my IoT journey. but later on, I found out that there is a better and efficient way of doing IoT projects via using a NodeMCU board.
Now the question is why NodeMCU ?
It has an ESP8266 based System on a Chip and is designed for electronics and IoT Projects. The NodeMCU now has extensive support, a huge community and a plethora of libraries that you can use. The most interesting fact is that it is cheaper than the Arduino Uno development board and consumes very low current. It also has built-in WiFi.
Install NodeMCU in Arduino IDE
Go to preference in the Arduino IDE either by File -> Preference or Arduino -> Preference
Then paste this URL (http://arduino.esp8266.com/stable/package_esp8266com_index.json) in the Additional Boards Manager URLs as shown then click OK.
After that Go to Tools -> Board ->Board Manager. Then search ESP8266
Then download this package. After you complete. Then select the NodeMCU 1.0 board from Tools -> Boards. After that select the PORT from Tools -> Port.
Now you are set to program in NodeMCU ;)
Test if the Board is working
Connect the NodeMCU to your laptop using a micro USB port. Then select Blink as shown.
When you select Blink a pop-up window will be appeared as shown
Now hit the tick icon and wait until it says upload complete. If everything goes as planned then the NodeMCU will start to blink.
Have you understood this?
Since you are not superhuman. You have not understood this code properly. so let us code this in a less complicated fashion.
This is a much simpler Blink program. Here we defined the led pin to be D3. Then inside the setup, we set the pinMode of the led to be OUTPUT. Then we digitally written led to be HIGH and after 1s or 1000ms the LED is set to LOW the after 1s or 1000ms the LED is SET to be HIGH. If we have not created a circuit like below. Then you should change the led variable to LED_BUILTIN to activate the Built-in led.
Why don't we control this with our smartphone 😉
1st of all Go to Tools -> Manage Libraries then search Blynk and download it.
After you install it then Go to PlayStore then download Blynk “https://play.google.com/store/apps/details?id=cc.blynk&hl=en_IN&gl=US”
Open the App then SignUp.
After you logged in then you will see a window as shown. Then click New Project.
After that enter the name that you want to give. In my case I gave led2. Then select the Board as shown
After that click the plus icon and add a button. Then configure the button by clicking on it and editing the PIN as shown.
After these are done, your app is set. Now you need to properly code and use the AUTH token which you will get in your mail as soon as you create your project.
Now you need to choose an example program from the given example codes as shown.
Then click the BlynkBlink. Then a popup code will appear. Inside there change the AUTH Token to your AUTH. and then compile and upload to the board. After that click the play button from the app and turn the BUTTON ON and OFF.
Yesss It will workkkkkkk.
This is just the beginning. Through this blog, we learned the very fundamentals. There is always a lot more to understand.
Inspired from IoT Session taken by Iqbal and Sharan