Component Documentation: 110V~220V AC All-Purpose Temperature Control Controller with Sensor 2 Relay Output Thermostat STC-1000
The STC-1000 is a temperature control controller designed for use in various IoT applications. It features a built-in temperature sensor, two relay outputs, and supports a wide range of input voltages (110V~220V AC). This component is ideal for controlling heating, ventilation, and air conditioning (HVAC) systems, refrigeration units, and other temperature-critical devices.
Input Voltage: 110V~220V AC
Temperature Range: -50C to 120C (-58F to 248F)
Temperature Accuracy: 1C (1.8F)
Relay Output: 2x SPDT (Single Pole Double Throw) relays, 10A @ 250V AC
Sensor Type: Built-in thermistor temperature sensor
Operating Frequency: 50/60 Hz
Dimensions: 73mm x 53mm x 33mm (2.87in x 2.09in x 1.3in)
The STC-1000 has the following pinout:
VCC: 110V~220V AC input
GND: Ground
T1: Temperature sensor input
R1: Relay 1 output
R2: Relay 2 output
SET: Set button input
-/+: Display adjustment buttons
### Example 1: Basic Temperature Control using Arduino
In this example, we'll use an Arduino board to read the temperature from the STC-1000 and control two relays to turn on/off a heating element and a fan.
```c++
// Define pins for the STC-1000
const int tempPin = A0; // Temperature sensor input
const int relay1Pin = 2; // Relay 1 output
const int relay2Pin = 3; // Relay 2 output
void setup() {
// Initialize relay pins as outputs
pinMode(relay1Pin, OUTPUT);
pinMode(relay2Pin, OUTPUT);
}
void loop() {
// Read temperature from STC-1000
int tempVal = analogRead(tempPin);
float temperature = (tempVal 5.0 / 1024.0) - 50.0; // Convert to Celsius
// Set temperature thresholds
const float heatingThreshold = 20.0; // Turn on heating element below this temperature
const float coolingThreshold = 25.0; // Turn on fan above this temperature
// Control relays based on temperature
if (temperature < heatingThreshold) {
digitalWrite(relay1Pin, HIGH); // Turn on heating element
digitalWrite(relay2Pin, LOW); // Turn off fan
} else if (temperature > coolingThreshold) {
digitalWrite(relay1Pin, LOW); // Turn off heating element
digitalWrite(relay2Pin, HIGH); // Turn on fan
} else {
digitalWrite(relay1Pin, LOW); // Turn off heating element
digitalWrite(relay2Pin, LOW); // Turn off fan
}
delay(1000); // Wait 1 second before reading temperature again
}
```
### Example 2: Home Automation using ESP32 and Wi-Fi
In this example, we'll use an ESP32 board to connect the STC-1000 to a Wi-Fi network and control two relays remotely using a mobile app.
```c++
#include <WiFi.h>
#include <HTTPClient.h>
// Define pins for the STC-1000
const int tempPin = 32; // Temperature sensor input
const int relay1Pin = 15; // Relay 1 output
const int relay2Pin = 2; // Relay 2 output
// Wi-Fi credentials
const char ssid = "your_wifi_ssid";
const char password = "your_wifi_password";
// Set up Wi-Fi client
WiFiClient client;
HTTPClient http;
void setup() {
// Initialize relay pins as outputs
pinMode(relay1Pin, OUTPUT);
pinMode(relay2Pin, OUTPUT);
// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
Serial.println("Initializing HTTP client...");
}
void loop() {
// Read temperature from STC-1000
int tempVal = analogRead(tempPin);
float temperature = (tempVal 5.0 / 1024.0) - 50.0; // Convert to Celsius
// Send temperature data to a remote server using HTTP
http.begin("http://your_server_ip/temperature");
http.addHeader("Content-Type", "application/json");
String temperatureData = "{""temperature"": " + String(temperature) + "}";
int httpResponseCode = http.POST(temperatureData);
http.end();
// Control relays based on remote commands
if (httpResponseCode == 200) {
String responseBody = http.getString();
if (responseBody == "heating_on") {
digitalWrite(relay1Pin, HIGH); // Turn on heating element
} else if (responseBody == "cooling_on") {
digitalWrite(relay2Pin, HIGH); // Turn on fan
} else {
digitalWrite(relay1Pin, LOW); // Turn off heating element
digitalWrite(relay2Pin, LOW); // Turn off fan
}
}
delay(1000); // Wait 1 second before reading temperature again
}
```
These examples demonstrate how to use the STC-1000 in various contexts, including basic temperature control with Arduino and home automation with ESP32 and Wi-Fi.