Reservoir module

In this chapter, we are setting up the module for the nutrient reservoir based on an Arduino Nano V3 and nRF24L01+ wireless transceiver. Optionally an Arduino RF-Nano could be used, that has the wireless transceiver already integrated. 

The module is responsible for:

Gbox420 sketch: Gbox420_Nano_Reservoir
SketchUp 3D Warehouse: Gbox420 - ShowRoom - Reservoir and Rolling weight platform tabs
Or visit the Gbox420 GitHub page and download the entire project.

If you decide to use a different pin layout from what is shown below,  update the Settings.h file, look for variables ending with Pin


RF-Nano

Arduino RF-Nano has the nRF24L01 wireless transceiver already integrated. Here are a few test scripts you can run to make sure the wireless communication works:


Verify the Arduiono and nRF24L01+ connection

By updating the wireless transmission rate:

Test-WirelessConnection_Nano.ino

Expected test result: 'Data Rate' row should have changed from 1MBPS to 250KBPS

Relay data between two nRF24L01+ transceivers

You will need a second RF-Nano or an Arduino board with a nRF24L01+ transceiver for this test. Tests the two-way communication between a Transmitter and a Receiver by exchanging a set of pre-defined structs (groups of different data types) known by both parties. One device will initiate the communication (Transmitter) by passing the commandTemplate struct. When the Receiver gets this command, it returns it to the transmitter with a pre-cached responseTemplate struct. A maximum of 32bytes of data can be exchanged in one transmission.

Transmitter:  Test-WirelessTransmitter.ino
Receiver: Test-WirelessReceiver.ino

Expected test result: Both devices printing the exchanged data to their serial outputs.

Relay multiple packets of data between two nRF24L01+ transceivers

When you need to transfer data larger than 32 bytes, it must be split into multiple transmissions. The transmitter will send multiple commands in a fixed order containing different pre-defined structs known by both parties. When the Receiver gets this command it confirms it back to the transmitter with a pre-cached response and based on the current command's SequenceID it loads the next response into the ACK cache. Templates of the data exchanged: WirelessCommands_Test.h 

Transmitter:  Test-WirelessTransmitter_MultiPackets.ino
Receiver: Test-WirelessReceiver_MultiPackets.ino

Expected test result: Both devices printing the exchanged data to their serial outputs.

Rf-Nano

ATmega328P microcontroller integrated with NRF24L01 transceiver
32 KB flash
8 analog pins14 digital pins (6 PWM)Datasheet
Amazon.com 

Buzzer

When a module starts up or receives a command a piezoelectric buzzer provides audio feedback. To protect the buzzer from excess current make sure to have a minimum 200Ω resistor between the Arduino port and the + side of the buzzer. If you find the volume too loud use a larger resistor. I took a few sound intensity measurements using different resistance values: 220Ω - 71dB, 330Ω - 69dB, 1kΩ - 59dB, 3kΩ and above are inaudible.

+ pin: Arduino 2 (digital output). Connected through a resistor to limit current and volume: 200Ω(loud) - 1kΩ(quiet)

- pin: Arduino GND (Ground)

Test-Buzzer sketch

Expected test result: Plays the Star Wars theme song

Piezo buzzer

5V, 25 mA
Amazon.com 

Metal film resistor

200 Ω - 1 kΩ  , 0.25 W
Amazon.com 

Bypass capacitors

Bypass capacitors or decoupling capacitors are added between each power and ground line to filter out noise from the power supply and make the entire circuit more stable. Here is an excellent video from EEVblog that explains bypass capacitors. 

Be mindful that electrolytic capacitors are polarized, meaning they can only be connected one way in a circuit. The negative lead is generally marked on the capacitor with a bar or "-" symbol, connect this to Ground (or the more negative line). Do not mix up the polarity as this will heat up and destroy the capacitor in a few seconds. Ceramic capacitors have no polarity, they can be connected in any direction. The capacitance of both capacitors can be changed based on the power needs, as long they support a minimum of 16V voltage.

DC input 12V
2200 uF - 16V Electrolytic capacitor + pin: +12V DC

2200 uF - 16V Electrolytic capacitor - pin: Ground

0.1 uF - 50V Ceramic capacitor pin 1: +12V DC

0.1 uF - 50V Ceramic capacitor pin 2: Ground


DC step down output 7V
1000 uF - 16V Electrolytic capacitor + pin: DC step down Vo+ output

1000 uF - 16V Electrolytic capacitor - pin: Ground

0.1 uF - 50V Ceramic capacitor pin 1: DC step down Vo+ output

0.1 uF - 50V Ceramic capacitor pin 2: Ground


Arduino 5V

470 uF - 16V Electrolytic capacitor + pin: Arduino 5V

470 uF - 16V Electrolytic capacitor - pin: Ground

0.1 uF - 50V Ceramic capacitor pin 1: Arduino 5V 

0.1 uF - 50V Ceramic capacitor pin 2: Ground

Arduino 3.3V
10 uF - 16V Electrolytic capacitor + pin: Arduino 3.3V
10 uF - 16V Electrolytic capacitor - pin: Ground
0.1 uF - 50V Ceramic capacitor pin 1: Arduino 3.3V
0.1 uF - 50V Ceramic capacitor pin 2: Ground

Electrolytic capacitor

470 - 2200 uF, 16 V or above
Amazon.com

Ceramic capacitor

0.1 - 100 uF, 16V or above rated
Amazon.com

DC step down power supply

To convert the 12V power input and feed the Arduino Nano a DC to DC step down power supply is used. These buck converters are cheap, power-efficient, have a small physical size, and support a wide range of DC input voltages. To adjust the output voltage you will need to have a multimeter tool to monitor the output voltage while changing the adjuster screw. Be careful: The Vin pin does not have a reverse polarity protection diode like the barrel jack, never mix up GND and Vo+ from the power supply!

VO+ pin: Arduino Vin. Adjusted to 7 volts.

GND pin: Arduino GND (Ground) + Power input ground (Common ground)

In+: Positive power input (12V)

EN pin: Not connected

DC-DC Buck Converter

Input voltage: DC 4.5 to 24VOutput voltage: Adjustable DC 0.8 to 17VOutput current: Max 3A
Amazon.com 

pH sensor

A PH4502C sensor monitors the pH of the nutrient solution. Before using the sensor it needs to be calibrated using buffer solutions that alter the pH of distilled water to a predefined value. Distilled water is free of impurities and minerals that could react with the calibration solution and alter its pH. It is available in larger stores or can be homemade. Usually, it is a good idea to re-calibrate the pH probe every 2-3 months and replace the pH probe after 3 years. Never allow the electrode in the pH probe to dry out, keep it in pH neutral (pH 7) distilled water when storing it.

Specs

To pin: Not connected (Temperature correction pin)

Do pin: Not connected (Digital output for pH limit, 1 if pre-set pH limit is reached, 0 if pH is below the set limit)

Po pin: Arduino A0 (Analog input)

GND pin: Not connected

GND pin: Arduino GND (Ground)

V+ pin: Arduino 5V

Test-PHSensor sketch

After uploading the sketch follow the below calibration process:

Calibrating the offset: Disconnect the pH probe and with a piece of wire (like a male-male jumper cable or paper clip) short-circuit the BNC connector's inside and outside contacts. While monitoring the voltage reading showed by the calibration sketch adjust the Offset Potentiometer until the voltage reading is 2.5V. At this point send any character on the Serial input to proceed with the pH calibration.

pH calibration: Re-connect the pH probe  and follow the below process to gather two readings to complete the calibration.

1. Prepare 3 glasses filled with 250ml / 8.45 oz, 25°C/77°F distilled water.

2. Pour 1-1 packet of 4.01 and 6.86 pH calibration solutions into separate glasses and wait a few minutes for them to dissolve. Remember which glass contains which pH solution! Leave pure distilled water in the 3rd glass and place the pH probe in it to soak for a minute.

3, Place the pH probe in the glass with 4.01 pH solution and wait a minute for the Analog reading in the sketch to stabilize. At this point ignore the calculated pH in the sketch. Once the reading is stable send  any character on the Serial input to save the reading for pH 4.01.

4. Rinse the pH probe in distilled water then place it in the glass with 6.86 pH solution. Wait a minute for the Analog reading to stabilize then send any character on the Serial input to save the reading for pH 6.86.

5. With the two readings saved the sketch will calculate the Slope and Intercept parameters. You will need to store these in the Reservoir's Settings.h file under PHSensorSettings - Slope and Intercept variables.

6. (Optional) Update the Slope and Intercept variables in the test sketch and set OffsetCalibrationComplete and PHCalibrationComplete variables to true. After re-uploading the sketch you can now measure the pH of any solution without the need to re-calibrate the probe at every startup.

PH4502C module + probe

pH calibration powder

PH: 4.01, 6.86

Temp & Humidity sensor

Temperature and humidity are monitored using a DHT22 sensor that communicates with the Arduino over a single digital data line.

Specs

DAT pin: Arduino 3 (digital input)

VCC pin: Arduino 5V

GND pin: Arduino GND (Ground)

Test-DHTSensor sketch

Expected test result: Temperature and humidity readings are printed to the serial output every 5 seconds.

Water temp sensor

A waterproof DS18B20 sensor is used to read the water reservoir temperature. The sensor is powered by 5V and communicates with the Arduino over a single data line. A 4.7kΩ resistor is required between 5V and Data lines (Red + Yellow wire), else the sensor will not return readings.

Specs

Yellow wire: Arduino 4 (digital input)

Red wire: Arduino 5V

Black wire: Arduino GND (Ground)

Test-WaterTempSensor sketch

Expected calibration output: The temperature reading getting printed on Serial in °C and °F every 2 seconds.

DS18B20 temp sensor
Waterproof, With pluggable terminal 

Includes the 4.7kΩ resistor

Weight sensor

Weight sensors are mounted under the reservoir to measure its weight. Before using a weight sensor it needs to be calibrated using the sketch from the bottom of this section. The sketch will return two parameters that need to be written in the Reservoir module's Setting.h file under WeightSensorSettings - Scale and Offset variables.

Weight sensor

GND pin: Arduino GND (Ground)

DT pin: Arduino 5 (digital input)

SCK pin: Arduino 6 (digital output)

VCC pin: Arduino 5V


Load cell

Red wire: Weight sensor E+

Black wire: Weight sensor E-

Grey wire: Weight sensor A-

Green wire: Weight sensor A+

Test-WeightSensor_Reservoir sketch

Follow this procedure to calibrate the weight sensor:

7. (Optional) You can also update the test sketch Offset and Scale variables and change the CalibrationComplete variable to true. After uploading the sketch it will skip the calibration part and just show the current weight on the scale.

Expected calibration output: 

HX711 + 4 weight cells

4 set (4x4 cells) Rated to 50kb / 110lbs

Requires soldering!


Amazon.com, Amazon.de

Wireless transceiver

To relay data between the Main module and all other modules nRF24L01+ wireless transceivers are used. The Main module always acts as a transmitter, all other modules are receivers. When a receiver gets a package from the Main module it sends back a pre-cached Acknowledgement package to report its current status. You can find a great in-depth overview of the wireless module at lastminuteengineers.com.

Specs

GND pin: Arduino GND (Ground)

VCC pin: Arduino 3.3V

CSN pin: Arduino 9 (digital output)

CE pin: Arduino 10 (digital output)

MOSI pin: Arduino 11 (digital output)

MISO pin: Arduino 12 (digital input)

SCK pin: Arduino 13 (digital output)

Test-WirelessConnection_Nano sketch

This sketch will verify the connectivity between the Arduino and the nRF24L01+ wireless transceiver.

Expected test result: Successful update of the "Data Rate" field

Test-WirelessReceiver sketch

This sketch will verify the nRF24L01+ wireless transceiver communication between an Arduino Mega as the Transmitter, and an Arduino Nano a Receiver. Requires an Arduino Mega to be set up as a Transmitter, check out the Main module - Test-WirelessTransmitter sketch for more details on setting up the Transmitter.

Expected test result: Printing the received command from the Transmitter on the serial output and sending a response message back.

nRF24L01+ wireless transceiver

100m / 330 ft range with integrated antenna. DataSheet,

nRF24L01+ wireless transceiver

1000m / 3300 ft range external antenna. DataSheet