-
Notifications
You must be signed in to change notification settings - Fork 0
/
bedroom co
64 lines (42 loc) · 3.14 KB
/
bedroom co
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Bedrooms Automation Documentation
## Overview
This Arduino Uno code is designed for automating the bedrooms. It includes the integration of DHT11 sensor data for temperature and humidity monitoring, and it controls various lights and appliances based on user input and received server data.
## Hardware Components
- ESP8266 WiFi module
- DHT11 Temperature and Humidity Sensor
- LEDs for Room 1 Light, Room 2 Light, Room 1 Plug, and Room 2 Plug
- Push buttons for controlling each appliance and light
## Dependencies
- [ESP8266WiFi library](https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WiFi)
- [WifiClientSecureBearSSL library](https://github.com/esp8266/Arduino/tree/master/libraries/WiFiClientSecureBearSSL)
- [ESP8266HTTPClient library](https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266HTTPClient)
- [Adafruit Sensor library](https://github.com/adafruit/Adafruit_Sensor)
- [ArduinoJson library](https://arduinojson.org/)
- [DHT Sensor library](https://github.com/adafruit/DHT-sensor-library)
## Pin Configuration
| Arduino Pin | Component | Purpose |
|-------------|---------------------------|---------------------------------------|
| D1 | DHT11 Sensor | Digital input for temperature and humidity sensing |
| D2 | Room 1 Plug | Output for controlling room 1 plug |
| D3 | Room 2 Light | Output for controlling room 2 light |
| D4 | Room 2 Plug | Output for controlling room 2 plug |
| D5 | Room 1 Light PushButton | Input for toggling room 1 light |
| D6 | Room 1 Plug PushButton | Input for toggling room 1 plug |
| D7 | Room 2 Light PushButton | Input for toggling room 2 light |
| D8 | Room 2 Plug PushButton | Input for toggling room 2 plug |
## Code Structure
The code is structured into the setup and loop functions. The setup function initializes pins, connects to WiFi, and sets up the initial state. The loop function continuously reads sensor data, updates the device states based on push button input, and sends/receives data from the server.
## Functionality
- **Temperature and Humidity Monitoring**: Utilizes the DHT11 sensor to monitor temperature and humidity in the bedrooms.
- **Device State Control**: Push buttons are used to toggle the state of each device (Room 1 Light, Room 1 Plug, Room 2 Light, Room 2 Plug).
- **Server Communication**: The code communicates with a server, sending sensor data and receiving updated states for devices.
## Communication Protocol
The code uses JSON for communication with the server. It sends a JSON payload containing sensor data and receives JSON data with updated device states.
## Troubleshooting
- Ensure proper WiFi connection.
- Check the server response for JSON parsing errors.
- Verify the connections of sensors and actuators.
## Note
This code is specific to the bedrooms, and some constants may need adjustment for different configurations.
---
Feel free to customize this documentation to add any specific details or additional notes relevant to your project.