Week 8-11
Advanced IoT Devices (ESP 32)
Introduction
In
this lecture, we learned about the ESP32 module, MPU6050 module,
and Micro SD card adapter. The goal was to become more familiar
with the ESP32 module. We used the I2C communication protocol
extensively to communicate between module. We further refined our
skills using EAGLE to create a PCB that incorporated the ESP32 and
MPU6050 modules.
Task 1
For Task 1, we needed to
install esp32 through the board manager. Once it was installed we
had to configure it in Arduino by
choosing the
'ESP32 Dev Module' board, the '11520 upload speed', the 'AVRISP
mkII' programmer. After it was configured, we were given a
simple blinking program to run and the results are shown in the
video below.
Task 2
For Task 2, we were the
connection layout for the ESP32 and MPU6050 and had to make the
connections as shown in Figure 1. Once the MPU6050 was connected
to the ESP32 we were given some code to run that would acquire
data from the MPU and plot the data in the Serial Plotter as shown
in the video below.
Task 3
For Task 3, we were presented with a
variation of different codes that had flaws in them that would
produce the incorrect plot. The fifth piece of code that was
presented gave us the correct plot as can be seen in the video
below.
Task 4
For Task 4, we added a micro SD card adapter so that we could store the data collected on an SD card, as shown in Figure 2. We were given some code that let us know that our SD card was communicating with your ESP board successfully. The result of the SD card communicating with the ESP board can be seen below in Figure 3.
Figure 2. ESP and SD card being connected together.
Task 5
For Task 5, we connected
the ESP, MPU, and SD card together so that the
data read from the MPU could be stored on the SD
card, the setup is shown in Figure 4. We then
had to modify the code given to receive all
AccX, AccY, and AccZ data in separate data files
'AccX.txt', 'AccY.txt', and 'AccZ.txt' and then
plot the data using python as shown in Figure 5.
Task 6
For Task 6, we had to change
the data type of AccX, AccY, and AccZ to
'float' and use the intermediate int16_t
variables AccX_temp, AccY_temp, and
AccZ_temp to store the 16-bit
accelleration data from the MPU sensor.
Then we used python to plot the data acquired as shown in Figure
6.
Task 7
For Task
7, we connected two ESP module
together, as shown in Figure 7,
but we need to get the MAC
address of each module, which
can be seen in Figure 8 and
Figure 9. We were given
code that needed to be uploaded
to the
master and the slave
respectively, then connect the
USB cable to the slave. Once the
code had been uploaded to both
ESPs then we could open the
serial plotter in Arduino and it
would show the data being
plotted in realtime as shown in
the video below.
Figure 7. Connecting two ESP
modules and MPU6050.
Task 8
For Task 8,
we needed to add the
SD card so that we
could store the data
the was transferred
from the master to the
slave from the MPU.
The setup is shown in
the Figure 10. Then we
had
to
alter
the code given to
receive the
acceleration data
from the master
wirelessly by the
slave and store the
data to the SD card.
After we plotted the
stored data using
python as shown in
Figure
11 and Figure 12.
Task 9
For
Task 9, we
needed to
clean up the
code for the
master and
slave, which
are both given
below. Then we
used the
cleaned up
code to
acquire data
to store on
the SD card
and used
python to plot
the data as
shown in
Figure 13.
Discussion
By
completing these tasks it gave me a better understanding of the
ESP32 module, MPU6050 module, and the I2C communication protocol.
I was able to refine my programming skills by seeing different
ways that code could be implemented. I was also to get more
experience with EAGLE as we created a module that used the ESP32
and MPU6050 modules, which Dr. Li is sending to PCBWay to get
fabricated as that will be our final project. This was a good
hands on learning experience.