Skip to the content
PCBKitNew board
2 layersArduino relay, the printed circuit board in 3D

Guardian is an advanced, fully automated hydroponics system designed to optimize plant growth and maximize yield. Utilizing micro-controllers and pH fuzzy logic control, it ensures precise nutrient delivery, enables remote monitoring, and achieves remarkable water savings while increasing crop productivity.

Copper layers
2
Thickness
1.6 mm
Parts
58
Nets
42
Pads
167
Tracks, vias
329, 0
Pours
2
Routed
Yes
KiCad
KiCad 5 (file 20171130)
Created
21 Mar 2021
Updated
20 May 2023

Overview

Arduino relay is an open-source printed circuit board by bhaskar9980, from the bhaskar9980/Guardian repository on GitHub, published under the MIT licence. It is a 2-layer board with 58 parts on 42 nets, routed with 329 tracks and 0 vias.

It is built around the DHT11, SFH617A-1 and BC547. Its parts include 18 resistors, 11 connectors, 4 ICs, 4 diodes and 4 transistors. It belongs with the home automation and IoT boards and the ESP32 and AVR (ATmega, ATtiny) boards of this library.

Main components

3

README

README.md

AHS logo

Guardian

Guardian is an advanced, fully automated hydroponics system designed to optimize plant growth and maximize yield. Utilizing micro-controllers and pH fuzzy logic control, it ensures precise nutrient delivery, enables remote monitoring, and achieves remarkable water savings while increasing crop productivity.


Open in Visual Studio Code

Table of contents

Render of Guardian

Render

Parameters Measured

  • Temperature (DHT)
  • Humidity (DHT)
  • Tank Water Level
  • Reservoir Water Level
  • Plant Motor
  • Reservoir Motor
  • Mist Motor
  • Lighting

DataBase

  • Any DataBase can used to store the Data and control the System Remotely
  • For this project I have used FireBase - A Realtime DataBase

A Few Pictures of FireBase Firebase Firebase

Controllable Parameters

Motors and Light

There are two Modes for Controlling the Motors and lighting

DigitsStatusMode
0OffManual Override Mode ON
1OnManual Override Mode ON
2-Manual Override Mode OFF

Humidity and Temperature

We can Manually Control/ Automate the Threshold Values of Humidity and Temperature as per the crop

Light Interval

We can Manually control/ Automate the Intervals of Lighting to control the Temperature as per the requirements of the crop

Motor Running Duration

We can Manually control/ Automate the Intervals of running Plant Motor for regular watering as per the requirements of the crop

The Schematic diagram

The Schematic and PCB designs are made using KiCAD. Find the files here: KiCad_PCB_design

The Schematic Diagram of Master board

Schematic

  • The Master board has an ESP32, DS1307 RTC clock, AT24C512 EEPROM and an I2C LCD display.
  • The Master board has a JST connecter port to connect to slave board.

The Schematic of Slave Board

Schematic

  • The slave board has an Arduino Nano, DHT11 sensor, 4 relays.
  • The master board and slave board are connected with I2C bus.

PCB Layout

The PCB Layout of Master board

PCB_layout

The PCB Layout of Slave board

PCB_layout

Building the Hardware

Master board

PCB_layout

Total Setup Overview

PCB_layout

Find more pictures in Images folder

Using I2CSB library

This Arduino compatible library is made to simplify the communication paradigm that happens between master ESP32 and slave Arduino Nano.

I2CSB stands for I2C Slave board

The slave arduino nano does the following:

  • controls 4 relays named as
  1. Bucket Motor connected to pin 10
  2. Plant Motor connected to pin 9
  3. Mist Motor connected to pin 7
  4. Light Pin connected to pin 6
  • Is connected to a DHT11 Temperature and Humidity sensor on pin 4.
  • Has two set of water level sensors and each water level sensor can detect 3 distinct points in the used buckets.

You can fetch the slave code here Arduino_slave.ino

The Master ESP32 can access these function using the I2CSB Library. As the name suggests the communication happens in I2C protocol.

How to add the library

To use the library just navigate to I2CSB and download it as zip file. Later in arduino IDE add this library using library manager and get started with the library using examples.

How to use the functions in the library

  1. First instantiate the class I2CSB with a slave address
cpp
#define Slave_address 0x2F
I2CSB DB1(Slave_address);
  1. Initialize the I2C communication by calling Wire.begin()

  2. The library has following functions

Function nameWhat is returnedreturn typeArguments
1. isConnected()true if slave is connectedboolno arguments
2. getLevel()Level encoded in single bytebyteno arguments
3. getTemperature()Temperatureintno arguments
4. getHumidity()Humidityintno arguments
5. setOutputs()True if the outputs are set correctly False if fails to setbool4 bool variables

Handling the Errors and Miscommunication

The library also can monitor communication error or Miscommunication took place. This is how:

  1. For isConnected() function the master sends a request to get water level. If there is no error in the received information then the function returns True. In the event of death of slave or the slave is not connected or there is a communication error the function returns False.
  2. For getLevel() function the return type is byte and the encoded level information in the byte is as follows x LA2 LA1 LA0 0 LB2 LB2 LB0 Here LA2,1,0 are points in sensor A and LB2,1,0 are points in Level B sensor. The x bit carries the error information. If there is no error in the communication then x = 1 else x = 0.
  3. For getTemperature() function then return type is integer. And the DHT11 sensor can measure the temperatures between 0 to 60degC with a resolution of 1degC. So the information we get out of the sensor can never hit negative temperature. So the function returns -10 if there is any error and returns value between 0 and 60 if there is no error.
  4. Similarly for getHumidity() function, the return type is int and has values between 20 to 80. so if there is any error then the returned value will be -10.
  5. For setOutputs() the return value is True if there is no error in communication as well as the outputs are set as expected. The arguments in setOutputs() function is in this order setOutputs(BucketMotor, PlantMotor, MistMotor, LightPin)

The communication definition

  • The communication is built on I2C protocol.
  • The master sends a byte contains the function the slave has to performs along with the arguments encoded in the single byte.
  • The master requests the slave 200 milliseconds later to send the fetched data/ performed action feedback encoded in 3 bytes as follows.
Function nameSent ByteReceived bytes
2. getLevel()0xAA0xAA 0xYY 0xYY
3. getTemperature()0xCA0xCA 0xYY 0xYY
4. getHumidity()0x5c0x5C 0xYY 0xYY
5. setOutputs()0x600x60 0xYY 0xYY
1. isConnected()0xAA0xAA 0xYY 0xYY
  • The first byte is the data that is sent by master to slave so that the master can verify that slave performed correct action. and there was no miscommunication happened.
  • The second two bytes are identical. If they match then the master decides that the information received is correct and and proceeds to decode the bytes.
  • The isConnected() function is same as getLevel() function with a different data type. Because I was lazy to write a new function for that purpose.
  • The example code can be found here Example_code.ino.

This library can be used as a base to make any type of simple arduino I2C slave device.

Using EEPROM Database

Find the database library here DataBase.

The data structure:

  • The following data is stored in EEPROM Every minute.
DataBytes takenRange
Day, Hour, Minute in the month2 bytes44640
Temperature1 byte0 to 60 degC
Humidity1 byte20 to 80%
Level Array1 byte0x00 to 0x77
  • In a nutshell each data set consumes 5 bytes so the EEPROM can log the data for complete 9 days.
  • The pointer of next address to be written locally on EEPROM because if arduino restarts the local pointer on arduino will be lost and the new data is re-written on EEPROM.
  • The EEPROM used here is AT24C512 which can store 512 Kbits or 64 KBytes which are byte addressable. So the address value range is from 0x0000 to 0xFFFF which is exactly same size that an integer(2 bytes) takes in an Arduino.
  • Therefore the first two bytes in the EEPROM is reserved to write the address pointer.
  • The following table represents the data structure employed.
AddressData
0 , 1Address pointer
2 - 6Data set 1
7 - 11Data set 2
12 - 16Data set 3
(5n-3) - (5n+1)Data set n

Functions

The library offers following functions:

Function nameargumentsreturn value
storeAtEEPROM Object, Address, Day, Hour, Minute, Temperature, Humidity, Waterlevel arrayvoid type
resetAddressEEPROM Objectvoid
getDataAtEEPROM Object, Address, Data-literalData
getNextAddressEEPROM ObjectAddress of next Dataset to be written
resetAddressEEPROM Objectresets the address pointer to initial value

Usage

  • Include the library DataBase and I2C_EEPROM on arduino IDE.
  • create an I2C_eeprom object
c++
I2C_eeprom ee(0x50, I2C_DEVICESIZE_24LC512);
  • Create a DataBase object
c++
DataBase DB;
  • Begin the EEPROM object ee using ee.begin().

Control System

ControlSystem

Sample of Guardian

Guardian

License

Code released under the MIT License. Docs released under Creative Commons.

Parts

58
QtyValueFootprintReferences
121kResistor_SMD:R_1206_3216MetricR1, R2, R3, R4, R5, R6, R7, R8, R17, R18, R19, R20
125VConnector_Pin:Pin_D1.0mm_L10.0mmTP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP15, TP16, TP17, TP18
647kResistor_SMD:R_1206_3216MetricR11, R12, R13, R14, R15, R16
41N4007Diode_THT:D_DO-41_SOD81_P10.16mm_HorizontalD1, D2, D3, D4
4BC547Package_TO_SOT_THT:TO-92L_WideQ1, Q2, Q3, Q4
4FINDER-36.11Relay_THT:Relay_SPDT_Finder_36.11K1, K2, K3, K4
4SFH617A-1Package_DIP:DIP-4_W7.62mmU4, U5, U6, U7
1Arduino_Nano_v3.xModule:Arduino_NanoA1
1Bucket_MotorConnector_Wago:Wago_734-132_1x02_P3.50mm_VerticalJ4
1DHT11Connector_JST:JST_EH_B3B-EH-A_1x03_P2.50mm_VerticalJ10
1I2C_LCDConnector_JST:JST_EH_B4B-EH-A_1x04_P2.50mm_VerticalJ15
1LED_AConnector_JST:JST_EH_B4B-EH-A_1x04_P2.50mm_VerticalJ11
1LED_KConnector_JST:JST_EH_B4B-EH-A_1x04_P2.50mm_VerticalJ12
1LightsConnector_Wago:Wago_734-132_1x02_P3.50mm_VerticalJ5
1Mains_PowerConnector_Wago:Wago_734-132_1x02_P3.50mm_VerticalJ1
1Mist_MotorConnector_Wago:Wago_734-132_1x02_P3.50mm_VerticalJ3
1Plant_MotorConnector_Wago:Wago_734-132_1x02_P3.50mm_VerticalJ2
1Sensor_1Connector_JST:JST_EH_B4B-EH-A_1x04_P2.50mm_VerticalJ7
1Sensor_2Connector_JST:JST_EH_B4B-EH-A_1x04_P2.50mm_VerticalJ6

Questions

What parts does the Arduino relay use?

58 parts, built around the DHT11, SFH617A-1 and BC547. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Arduino relay KiCad files?

From the bhaskar9980/Guardian repository on GitHub, at the commit this page was made from: the board is PCB_designs/KiCad_PCB_design/Arduino_Relay/Arduino_relay.kicad_pcb. PCBKit opens the board in the browser, with nothing to install.

Can I use the Arduino relay design in my own project?

Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).

Similar boards

  • 2 layers39 × 49.5 mmBM2, the printed circuit board in 3D

    BM2

    bask185/Train-Science-DIY

    38 parts3
  • 2 layers98.1 × 101.3 mmClimatecontrolpcb, the printed circuit board in 3D

    Climatecontrolpcb

    Sharan21-cmd/climate-control-pcb-design

    A compact and efficient Climate Control PCB designed for monitoring and regulating temperature and humidity using embedded electronics.

    16 parts1
  • 2 layers130 × 80 mmArduinoNanoPjt1, the printed circuit board in 3D

    ArduinoNanoPjt1

    thihakyawjob/PCBDesign

    All PCB Files

    62 parts1
  • 2 layers109.9 × 105.6 mmClimateController, the printed circuit board in 3D

    ClimateController

    Pablo-Ortiz-Lopez/ClimateController

    ESP8266 based device which handles the climate of a room.

    23 parts
  • 2 layers49 × 43 mmIncubator, the printed circuit board in 3D

    Incubator

    Sanjay-083/PCB_design

    17 parts
  • 2 layersMain automatic manifold, the printed circuit board in 3D

    Main automatic manifold

    Febriyandi12/Desain_PCB

    Kolaborasi untuk update desain pcb yang telah di research

    59 parts1