Raspberry Pi power supply to the Aruduino, through the PL2303 chip USB to TTL serial communication. The temperature of the greenhouse is detected and heated if it is below 19 degrees. The switch heating of the ceramic heating lamp is turned on by the serial control Arduino,arduino control relay.
The code for Arduino is as follows:
void Setup () {
Pinmode (3, OUTPUT);
Serial.begin (115200);
}
Char v;
void Loop () {
//read from serial,
//When got nothing, delay 1s and retry, write S to serial (Standby).
When the 30s got nothing, the close heater, write C to serial (close).
When got h means open heater, write h to serial (heating).
When got C means close heater, write C to serial (close).
v =-1;
Got nothing.
for (int i = 0; i < i++) {
if (serial.available () <= 0) {
serial.print (' S ');
Delay (+);
Continue;
}
v = serial.read ();
break;
}
Close when retry exceed.
if (v = =-1) {
serial.print (' C ');
Digitalwrite (3, low);
return;
}
Got specified command.
if (v = = ' h ') {
serial.print (' h ');
Digitalwrite (3, high);
return;
}
Serial.print (' C ');
Digitalwrite (3, low);
}
If it is not explicitly heated, it is not heated. The need for heating is specified via the serial port.
The wiring diagram is as follows:
USB to serial port PL2303 wiring:
VCC5V, connect to the Arduino vin and power the Arduino.
GND, connect to the Arduino gnd, power supply and communication.
RX, TX for Arduino, for communications.
TX, Rx for Arduino, for communications.
Temperature sensor DHT11 Wiring:
VCC5V, the 2-pin (vcc5v) of the pi is connected.
GND, 6 pins (Ground) of the Pi.
DATA, 12 pins (GPIO18,GPIO_GEN1) of the Pi.
Relay Wiring:
+, connect the 5v,arduino to the Arduino to power the relay.
-, connect the Arduino gnd, ground.
S, signal, connect Arduino's number 3rd pin.
When the acquisition temperature is less than expected, the H command is sent to the Arduino via the serial port.
Code reference: https://github.com/winlinvip/raspi-tools/blob/master/greenhouse.py
The final picture:
END