Projects
Nano Circuit 2

Nano Circuit 2 (Sensor and Controller Circuit)

This circuit will have a collection of sensors that will capture data. The Nano will read the data and display it on the LCD, send it to the ESP32 over LoRa, and write the data to the default Serial port so that it can be read by the Node-RED flow.

The ESP32 communication circuit will publish the sensor data to the MQTT broker from where it will be read by the mobile app.

Components

Component
Function
Voltage
Pins
Ultrasonic Distance Sensor (HCSR04)Measures how close an object is.5VDigital Out (Trigger)
Digital In (Echo)
PIR Motion Sensor (HSR501)Detects motion.5VDigital Out
Gas Sensor (MQ-Series)Detects gas.5VAnalog Out
Soil Moisture Sensor and ProbeMeasures soil moisture.5VAnalog Out
Digital Out
Raindrop Detection SensorDetects raindrops or water accumulation.5VAnalog Out
Digital Out
Submersible Water PumpPumps water from container.5VAnalog Out
Digital Out
LoRa Module (SX1278-RA02)For LoRa communication between boards.3.3VSPI
Logic converterTo connect 3.3V modules to 5V Nano5V/3.3VPin to Pin
I2C LCD 16x2Used to display data5VI2C
LED ModuleUsed as a visual indicator3.3VDigital Out
Buzzer ModuleUsed as an audio indicator3.3VDigital Out

Circuit Diagram

Nano Circuit Diagram 1

Connections

Board pin numbers are those printed on the board while code pin numbers need to be used in code (generally indicated in the pinout diagram as the GPIO pin number). They may be the same or different, depending on the board.

Board Pin
Code Pin
FunctionComponentPin
D22Digital GPIO In (Interrupt)LoRa SX1278-RA02DIO0
D33Digital GPIO In (Interrupt)PIR Motion SensorDigital Out
D44Digital GPIO InMQX Gas SensorDigital Out
D55Digital GPIO Out (PWM)RGB LED ModuleRed Cathode
D66Digital GPIO Out (PWM)RGB LED ModuleGreen Cathode
D77Digital GPIO In--
D88Digital GPIO OutBuzzerDigital In
D99Digital GPIO Out (PWM)RGB LED ModuleBlue Cathode
D1010SPI CSLoRa SX1278-RA02NSS
D1111SPI COPILoRa SX1278-RA02COPI
D1212SPI CIPOLoRa SX1278-RA02CIPO
D1313SPI SCKLoRa SX1278-RA02SCK
A0A0Digital GPIO OutLoRa SX1278-RA02RST
A1A1Digital GPIO OutUltrasonic Distance SensorEcho
A2A2Digital GPIO InUltrasonic Distance SensorTrigger
A3A3Digital InSoil Moisture SensorDigital Out
A4A4I2C SDAI2C LCDSDA
A5A5I2C SCLI2C LCDSCL
A6A6Analog InSoil Moisture SensorAnalog Out
A7A7Analog InMQX Gas SensorAnalog Out

Code

The code for this circuit is distributed across multiple files, so will not be displayed here. It will be available for download for subscribers.

The code for LoRa communication will be added later. You may connect the LoRa module now or later.