ESP8266/IoT B.Tech/Diploma Beginner

Getting Started with Arduino IoT Cloud with ESP8266

Guide for Getting Started with Arduino IoT Cloud with NodeMCU ESP8266 & controlling of LED from Dashboard or Sending Sensor Data to Cloud

  • Suitable forB.Tech/Diploma ESP8266/IoT students
  • Build time1-2 weeks
  • LevelBeginner
  • Available atAjvika Labs, Kakinada

About this project

Overview: Arduino IoT Cloud with ESP8266
Basically, this is the getting started about Arduino IoT Cloud where we will learn about using the Arduino IoT Cloud with ESP8266.
Recently the Arduino Community launched their IoT platform called Arduino IoT Cloud. The Arduino IoT Cloud provides an end-to-end solution that makes building connected projects easy for makers, IoT enthusiasts, and professionals from start to finish. The platform enables different methods of interaction, including HTTP REST API, MQTT, command-line tools, Javascript, and WebSockets. You can connect multiple devices to each other and allow them to exchange real-time data. You can also monitor data from anywhere using a simple user interface. To learn more about the Arduino IoT Cloud, you can go through the
documentation
part.
In this getting started tutorial, we will control an LED from the Arduino IoT Cloud Dashboard. Similarly, we will send the sensor data to the cloud dashboard and visualize it in various beautiful widgets. You can also do the
Home Automation
Project using Arduino IoT Cloud.
Bill of Materials
While before getting started with Arduino IoT Cloud, we need some hardware. The first component that we need is the ESP8266 Based Board. I prefer Wemos D1 Mini Board for this purpose. You can also use NodeMCU Board. We will also need a sensor. For the demo, I am using an MPU6050 Gyroscope Accelerometer sensor that can measure tilt angle. To use the switch feature you can use a 5mm LED of any color along with a 220-ohm resistor.
You can purchase all these components from Amazon.
S.N.
Components Name
Quantity
Purchase Links

NodeMCU ESP8266 Board

Amazon
AliExpress

LED 5mm Any Color

Amazon
AliExpress

MPU6050 Gyroscope Accelerometer Sensor

Amazon
AliExpress

Jumper Wires

Amazon
AliExpress

Breadboard

Amazon
AliExpress

USB Cable

Amazon
AliExpress
Circuit & Hardware
Make a simple connection as shown in the image above. Connect the MPU6050 to the I2C Pin and LED to any digital pin like GPIO0.
Setting up Arduino IoT Cloud DashBoard
Let us set up the Arduino IoT Cloud dashboard. To do that visit the
Arduino Digital Store
Link.
You need to create an Arduino account or simply sign in if you created the account earlier. Click on IoT Cloud. You will be taken to the dashboard where you need to set up everything.
Creating Thing
Click on Create Thing now. You can see here the setup section as well as the sketch and serial monitor section.
You need to add a variable now & give it any name. For example for controlling an LED, I will give it the name LED. From the variable type, select anything like Light as we need to send the 1 and 0 commands. The variable will be automatically declared as Cloud Light LED. You can assign the variable permission as either read-write or read-only. So for LED, you can assign Read & Write both. Finally, Click on Add Variable. This will create a variable successfully.
Similarly, add another variable for MPU6050 as we need to measure the tilt angle. So click on add variable and give it any name like X. From the variable list, select angle. So a variable will be automatically declared. Assign the permission as read-only since we are only reading the sensor value. Finally, click on add variable. So the 2nd variable for angle will be added.
Assign another two variables for the Y and Z angles as well.
Setting Up Device
Now we need to set up the device. To do that select Device. Since ESP8266 is a 3rd party device, we will select a 3rd party device. From the list select ESP8266 Board. And from the model select your ESP8266 Type. Then, Click on Continue.
Name the device anything you would like.
A device ID and a Secret Key have been generated. These are very important while parameters in coding. You need to copy it or simply click on download the PDF.
Go back to the dashboard and click on Continue. So you are finally done with the device setup.
Setting Up Network
Now we also need to configure the Network. So click on Network Setup. Enter the WiFi SSID, Password & Secret Key here that you downloaded earlier. Then click on save.
Setting Up Dashboard
Go to the dashboard to set up the widgets.
Click on this edit sign. Then click on Add here. From this widget list, select switch as we want to turn ON & OFF the LED. Give any name to the switch. Then link a variable as LED from the list. Then, click on Link Variable.
Similarly, add another three widgets for X angle, Y Angle & Z Angle. You can select Gauge, Chart, or Numeric Value for each three variables. Give widget any name, then select a linked variable. From the value range, select the minimum and maximum angle range from 0 to 360.
So, our widget display dashboard is ready now.
Source Code/Program
The source code for using the Arduino IoT Cloud with ESP8266 is easy to use as some of the commands and declarations are automatically generated.
Go to the sketch tab. So a default sketch based on different variables will be created. There are some header files defined and parameters are set for LED. So we need to modify the code.
The modified code for the 3 tabs are given below.
Main_Code.ino

#include "arduino_secrets.h"
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://cloud.arduino.cc/
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
CloudLight lED;
CloudAngle x;
CloudAngle y;
CloudAngle z;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
#include<Wire.h>
const
int
MPU_addr
=
0x68
;
int16_t
AcX
AcY
AcZ
Tmp
GyX
GyY
GyZ
;
int
minVal
=

;
int
maxVal
=

;
double
;
double
Y
;
double
Z
;
void
setup
(
)
{
// Initialize serial and wait for port to open:
Serial
begin
(
9600
)
;
pinMode
(

OUTPUT
)
;
Wire
begin
(
)
;
Wire
beginTransmission
(
MPU_addr
)
;
Wire
write
(
0x6B
)
;
Wire
write
(

)
;
Wire
endTransmission
(
true
)
;
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay
(
1500
)
;
// Defined in thingProperties.h
initProperties
(
)
;
// Connect to Arduino IoT Cloud
ArduinoCloud
begin
(
ArduinoIoTPreferredConnection
)
;
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel
(

)
;
ArduinoCloud
printDebugInfo
(
)
;
}
void
loop
(
)
{
ArduinoCloud
update
(
)
;
MPU6050_Read
(
)
;
// Your code here
}
void
onLEDChange
(
)
{
if
(
lED
==

)
{
digitalWrite
(

HIGH
)
;
}
else
{
digitalWrite
(

LOW
)
;
}
// Do something
}
void
MPU6050_Read
(
)
{
Wire
beginTransmission
(
MPU_addr
)
;
Wire
write
(
0x3B
)
;
Wire
endTransmission
(
false
)
;
Wire
requestFrom
(
MPU_addr

true
)
;
AcX
=
Wire
read
(
)
<<

Wire
read
(
)
;
AcY
=
Wire
read
(
)
<<

Wire
read
(
)
;
AcZ
=
Wire
read
(
)
<<

Wire
read
(
)
;
int
xAng
=
map
(
AcX
minVal
maxVal

)
;
int
yAng
=
map
(
AcY
minVal
maxVal

)
;
int
zAng
=
map
(
AcZ
minVal
maxVal

)
;
=
RAD_TO_DEG *
(
atan2
(
yAng
zAng
)
+
PI
)
;
Y
=
RAD_TO_DEG *
(
atan2
(
xAng
zAng
)
+

Technologies used

ESP8266ArduinoMQTTWiFiBLEMPU6050JavaJavaScriptI2CREST API

Hardware components

  • ESP8266
  • Arduino
  • MPU6050

Software & tools

  • MQTT

What you get

  • Working project / hardware kit, tested before delivery
  • Complete source code with explanation
  • Project demo and guidance for your viva
  • Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed. Payment is in two parts: • 50% advance to start the project • Remaining 50% before delivery Note: • Documentation and PPT are not included by default • If you need documentation/PPT, it can be arranged for extra time and cost We'll confirm the exact timeline and cost with you after reviewing your requirements.