Week 8
Wireless connection
Wireless connection
This week we are assigned to Communicate wirelessly with a Smart Circuit via a Graphical User Interface on the phone or PC. by building a simple smart circuit that contains at least TWO action components and using Coding on Arduino IDE.
So i used theTemperature/Humidity monitor i made using DHT11 sensor and an LCD and started coding it so i can control the circuit wirelessly, so i will use the bluetooth module and the mobile app as an input instead of the potentiometer.
So let's see how can we made this.🤩
220 ohm Resistors
DHT11
(temp/humidity sensor)
Bluetooth Module
RGB LED
LCD 12C
Breadboard
5V Adapter
Arduino UNO with arduino caple
Jumper Wires
Now from the componenets on the right side choose the componenets we're going to use :
1- Breadboard 2- RGB LED (Action component) 3- Temperature sensor
4- LCD 12C (Action component)
5- Two resistors of 22o ohm
6- Arduino UNO 7- Bluetooth module
Now lets see the wiring pprocess of the circuit:
1- First take two wires (Red one) from the 5V of the arduino to the (+Ve) of the breadboard and (Black one) from the GND to the (-Ve) of the breadboard.
2- Connect the RGB LED with two resistors of 220 ohm in series with the (RED) & (BLUE) colores on the breadboard, then connect them to the (2) & (3) Digital pins on Arduino.
3- Connect the cathode of the RGB to the (-Ve) on the breadboard.
4- Then connect the Temperature sensor the ground to (-Ve) and the VCC to the (+Ve) on the breadboard, and then the middle pin to Digital pin (4) in Arduino.
5- Connect the bluetooth module (Vcc ==> +Ve) , (GND ==> -Ve) , (TX ==> RX on arduino) , (RX ==> TX on arduino)
6- Connect the LCD as following: (VCC ==> +Ve ) , (GND ==> -Ve) , (SDA ==> A4) , (SCL ==> A5)
(1)
First i included the DHT11 library,
then i defined DHT pin on (4) and i defined its type (DHT11)
then i included the LCD 12C library
and i added two integers for the two pins of (Red&Blue) of the RGB on pin 2&3
now add one character (char) naming incomingData = '0' for the data the arduino should recieve from the app through the bluetooth module.
(2)
Now in the void setup i added dht.begin to start the sensor
then the lcd.init to initialise the LCD and the lcd.backlight to turn on the backlight of the LCD.
also i added the Serial.begin (9600) to use the serial monitor to read the data the arduino should recieve.
(3)
Now make the voide loop,
start by writing while (Serial.available() == 0) so that the serial monitor not read anything unless it recives data.
and incominData = Serial.read() to define the incoming data as the reading of the serial monitor.
making the LCD clear , and then say
if (incomingData == '1') [ if we press button 1 on the app]
then make the RGB Red colore HIGH (turn it ON) , and the RGB Blue colore LOW (turn it OFF)
and then write on the LCD "Temp=(the sensor read)" "Celesius"
(4)
Complete the voide loop,
if (incomingData == '2') [ if we press button 2 on the app]
then make the RGB Red colore LOW (turn it OFF) , and the RGB Blue colore HIGH (turn it ON)
and then write on the LCD "Humidity=(the sensor read)" "%"
then wait for 2000ms in a clear LCD
In the physical wiring
I uploaded the code on Arduino to test it
The code wasn't uploading at first and it was sending a message "exit status 1" and after asking my instructor i recognised that it means that i should take off the TX & RX wires from the arduino before uploading the code on arduino, then put them after uploading, so i did that and it worked well.
Temperature & Humidity Monitor wireless code