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. | 5V | Digital Out (Trigger) Digital In (Echo) |
PIR Motion Sensor (HSR501) | Detects motion. | 5V | Digital Out |
Gas Sensor (MQ-Series) | Detects gas. | 5V | Analog Out |
Soil Moisture Sensor and Probe | Measures soil moisture. | 5V | Analog Out Digital Out |
Raindrop Detection Sensor | Detects raindrops or water accumulation. | 5V | Analog Out Digital Out |
Submersible Water Pump | Pumps water from container. | 5V | Analog Out Digital Out |
LoRa Module (SX1278-RA02) | For LoRa communication between boards. | 3.3V | SPI |
Logic converter | To connect 3.3V modules to 5V Nano | 5V/3.3V | Pin to Pin |
I2C LCD 16x2 | Used to display data | 5V | I2C |
LED Module | Used as a visual indicator | 3.3V | Digital Out |
Buzzer Module | Used as an audio indicator | 3.3V | Digital Out |
Circuit Diagram
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 | Function | Component | Pin |
---|---|---|---|---|
D2 | 2 | Digital GPIO In (Interrupt) | LoRa SX1278-RA02 | DIO0 |
D3 | 3 | Digital GPIO In (Interrupt) | PIR Motion Sensor | Digital Out |
D4 | 4 | Digital GPIO In | MQX Gas Sensor | Digital Out |
D5 | 5 | Digital GPIO Out (PWM) | RGB LED Module | Red Cathode |
D6 | 6 | Digital GPIO Out (PWM) | RGB LED Module | Green Cathode |
D7 | 7 | Digital GPIO In | - | - |
D8 | 8 | Digital GPIO Out | Buzzer | Digital In |
D9 | 9 | Digital GPIO Out (PWM) | RGB LED Module | Blue Cathode |
D10 | 10 | SPI CS | LoRa SX1278-RA02 | NSS |
D11 | 11 | SPI COPI | LoRa SX1278-RA02 | COPI |
D12 | 12 | SPI CIPO | LoRa SX1278-RA02 | CIPO |
D13 | 13 | SPI SCK | LoRa SX1278-RA02 | SCK |
A0 | A0 | Digital GPIO Out | LoRa SX1278-RA02 | RST |
A1 | A1 | Digital GPIO Out | Ultrasonic Distance Sensor | Echo |
A2 | A2 | Digital GPIO In | Ultrasonic Distance Sensor | Trigger |
A3 | A3 | Digital In | Soil Moisture Sensor | Digital Out |
A4 | A4 | I2C SDA | I2C LCD | SDA |
A5 | A5 | I2C SCL | I2C LCD | SCL |
A6 | A6 | Analog In | Soil Moisture Sensor | Analog Out |
A7 | A7 | Analog In | MQX Gas Sensor | Analog 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.