Funded by National Science Foundation (NSF)
Courtesy of Manufacturers
Instructor: Dr. Yier Jin, 352-294-0401, yier.jin@ece.ufl.edu
The goal of the IoT Smart Car is to introduce young students to the Internet of Things (IoT) through a fun and interactive lab. A car will be constructed and equipped with motors and sensors. The car can drive over the WiFi from the student's laptop and the sensors can be read remotely as well.
In Lab 1 the IoT Smart Car will be constructed and the microcontroller will be programmed.
In Lab 2 the IoT Smart Car will be driven over the WiFi using Node-RED. Then a Node-RED dashboard will be created to drive the car.
In Lab 3 sensors will be added to the IoT Smart Car. The sensor readings will then be monitored using the Node-RED dashboard.
There should be a base, two motors, a battery holder, wires, screws, two back wheels, and one front wheel. Follow the instructions that came with the car to assemble it.
Next take a look at the motor shield. Use some of the leftover screws from the pack to screw the motor shield onto the top of the car. Make sure you screw it on with the screw terminals facing towards the battery pack and that you leave enough room for a small breadboard.
You will see that there are terminals with screws to open and close them. These are labeled A-, A+, B-, B+, VM, GND, VIN, and GND.
Take the red wire coming from the battery pack and screw it into the VIN terminal. Take the black wire coming from the battery pack and screw it into the GND terminal. When you are screwing these wires into the terminal make sure the metal end of the wire is touching the metal contacts of the terminal. You want to make sure there will be an electrical connection.
Now the motor shield will have power, and when the NodeMCU microcontroller that will be used in this lab can be powered from the motor shield.
There should be two more pairs of red and black wires that came with the car kit. Attach one red wire to the A+ and the other red wire to the B+. Then attach one black wire to the A- and the other black wire to the B-.
Solder the red wire from A+ to the bottom of the motor on the right wheel (oriented to the car). Solder the black wire from A- to the top of the motor on the right wheel. Then solder the red wire from from B+ to the bottom of the motor on the left wheel. Then solder the black wire from B- to the top of the motor on the left wheel.
Download the Arduino IDE from the website here. Choose the Windows Installer if you are on a Windows computer and choose the Mac OS link if you are on a Mac. Follow the instructions in the installer to install the IDE.
After installing, open up the Arduino IDE.
Open a new file by navigating to File > New. Copy and paste the contents of the file here into this new file. At the top of the file you will see variables under WiFi VARIABLES.
Change YOUR_WIFI_NAME to the name of your WiFi network. Change YOUR_WIFI_PASSWORD to the password for your WiFi network. Finally change YOUR.IP.ADDRESS to the IP address of your computer.
On Windows, your IP address on the network can be found by opening terminal and running
Back in the Arduino IDE navigate to Sketch > Include Library > Manage Libraries.... Search for PubSubClient and install the one by Nick O'Leary. After that installs, search for SimpleDHT and install the one by Winlin.
Plug the NodeMCU into your laptop using a micro-USB cable. Then go to Tools > Port and select the COM which shows up on Windows, or the /dev/... file which shows up on Mac. Upload the program to the board by clicking on the Upload button, which looks like a right arrow, or go to Sketch > Upload.
Now the vehicle is programmed and ready to receive commands over the network!
In the next tutorial we will set up Node-RED which is a program that will allow us to send commands to the smart car over the WiFi. See the next lab here.