Raspberrypi and Arduino control greenhouse temperature

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.