Inspect my previous project.
Step 1: Designing the Mobile Remote Lamp PCB
I designed a PCB for this project on KiCad, named Mobile Remote Lamp and Weather Station V2.0. All components and products I used in this project have built-in connections and pin outputs on the board. I used Arduino Nano as the center of the board due to its efficiency as compared to other alternatives. Check out the pin output instructions to see all supported components by the board.
You can inspect the board schematic on Schematics.
Also, you can buy and inspect my PCB design on PCBWay from here :)
You can view the board pinout from here.
Warning: Under the Relay_2 connector on the board, I connected A6 and A7 pins as the output pins; but they cannot be used as outputs due to the chip settings. So, I used the spare pins - 12 and 13 - on the J1 connector as the output pins for the 2-Way Relay Module, and therefore A6 and A7 pins on the Relay_2 connector became spare pins.
Step 2: Developing an Android Application (Remote Lamp)
I wanted to control my lighting system and its joyful features using my mobile phone :) Hence, I developed an Android application named Remote Lamp with a user-friendly interface on MIT App Inventor 2. It transmits specific characters to the HC-06 Bluetooth Module for each command as explained in Commands. You can inspect the building blocks of the application by zooming in to the blocks figure.
For those who want to download directly on their phone, I leave the application .apk file in Files.
- Clicking the Weather button, activate the Weather Screen - transmits 't'.
- Clicking Lamp (1) buttons, turn on or off Lamp (1) - transmits '5', '7'.
- Clicking Lamp (2) buttons, turn on or off Lamp (2) - transmits '6', '8'.
- Choosing options in the LEDs slider, turn on or off yellow, blue, green, red LEDs - transmits '0', '1', '2', '3', '4'.
- Choosing options in the RGB slider, change the RGB color as red, green, blue, yellow, purple, cyan, white, or off - transmits 'r', 'g', 'b', 'y', 'p', 'w', 'o'.
- Clicking Wheels buttons, turn right and left wheels or stop them - transmits 'a', 's', 'd'.
- Open the notification bar by clicking the Exit button:
- Clicking the Home Screen button, activate the Home Screen - transmits 'h'.
- Clicking the OK button, close the application and disconnect Bluetooth.
Step 3: Programming Arduino Nano
Download the required libraries:
LiquidCrystal_I2C | Download
DHT | Download
- Include the SoftwareSerial library to communicate with the HC-06 Bluetooth Module.
- Initiate the bluetooth module. Connect the defined RX pin (4) to the TX pin on the bluetooth module.
- Include DHT.h library.
- Define the dht object.
- Include LiquidCrystal_I2C and Wire libraries to run I2C module.
- Set the LCD address to 0x27 for a 16 chars and 2 line display.
- Define custom characters for the LCD.
- Activate the bluetooth module and initiate the DHT11 module.
- You do not need to take any further action to define SDA and SCL pins in Wire library due to embedded SDA and SCL settings on Arduino Nano.
- Define the home screen settings.
- Adjust the RGB color to white at the home screen initializing.
- In getDataFromDHT11() function, get weather information - temperature (celsius / fahrenheit) and humidity - using built-in functions.
- Wait until the DHT11 module is ready.
- If the Weather Screen is requested by a command ('t'), print the weather information generated by the DHT11 Temperature and Humidity Sensor.
- If the Bluetooth module is available and receiving characters from the Android application, execute the requested command depending...Read more »