|
Altium DesignerAltium Designer
|
|
|
arduino IDEArduino
|
|
|
Visual Studio Code |
Crop Manager
The Crop Manager
The project is developed for monitoring water level of soil, air temperature and humidity of air. It is noted that many soil moisture sensors are cloud based but required some monthly charges and also cost is very high in India.
- This device do not require any monthly charges for account because this is based on google firebase project. this firebase access is free of cost.
- the web site is also hosted on firebase which is also free and allow hosting the application like web.
- user only need to have access for internet in order to upload data to firebase real-time data management system.
#include <DHT.h>
#include <Arduino.h>
#if defined(ESP32)
#include <WiFi.h>
#elif defined(ESP8266)
#include <ESP8266WiFi.h>
#endif
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
#include <time.h>
WiFiManager wifiManager;
// Set web server port number to 80
WiFiServer server(80);
// Variable to store the HTTP request
String header;
#include <Firebase_ESP_Client.h>
//Provide the token generation process info.
#include "addons/TokenHelper.h"
//Provide the RTDB payload printing info and other helper functions.
#include "addons/RTDBHelper.h"
// Insert Firebase project API Key
#define API_KEY "your firebase app api"
// Insert Authorized Email and Corresponding Password
#define USER_EMAIL "Your registered Email on firebase"
#define USER_PASSWORD "your Password"
// Insert RTDB URLefine the RTDB URL */
#define DATABASE_URL "Your database URL"
//Define Firebase Data object
FirebaseData fbdo;
FirebaseAuth auth;
FirebaseConfig config;
//----------------------------------------------------
// Variable to save USER UID
String uid;
// Database main path (to be updated in setup with the user UID)
String databasePath;
// Database child nodes
String tempPath = "/temperature";
String humPath = "/humidity";
String soilPath = "/soil_moisture";
String timePath = "/timestamp";
// Parent Node (to be updated in every loop)
String parentPath;
FirebaseJson json;
// Define NTP Client to get time
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org");
int timestamp;
//---------------------------------------------------------------
unsigned long sendDataPrevMillis = 0;
int count = 0;
bool signupOK = false;
#define DHTPIN D7
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
const int sensor_pin = A0;
const int dry = 570;//1024-454; // value for dry sensor
const int wet = 620;//1024-404; // 395 value for wet sensor
// Function that gets current epoch time
unsigned long getTime() {
timeClient.update();
unsigned long now = timeClient.getEpochTime();
return now;
}
void setup() {
Serial.begin(115200); delay(5000);
if (WiFi.status() != WL_CONNECTED)
{
Serial.println("Creating Soft AP");
wifiManager.autoConnect("Crop Manager");
// or use this for auto generated name ESP + ChipID
//wifiManager.autoConnect();
// if you get here you have connected to the WiFi
}
Serial.println("Connected.");
//---------------------------------------------------------------
timeClient.begin();
/* Assign the api key (required) */
config.api_key = API_KEY;
// Assign the user sign in credentials
auth.user.email = USER_EMAIL;
auth.user.password = USER_PASSWORD;
/* Assign the callback function for the long running token generation task */
config.token_status_callback = tokenStatusCallback; //see addons/TokenHelper.h
// Assign the maximum retry of token generation
config.max_token_generation_retry = 5;
// Initialize the library with the Firebase authen and config
Firebase.begin(&config, &auth);
signupOK = true;
// /* Sign up */
// if (Firebase.signUp(&config, &auth,USER_EMAIL,USER_PASSWORD)){
// Serial.println("ok");
//
//
// }
// else{
// Serial.printf("%s\n", config.signer.signupError.message.c_str());
// }
uid = auth.token.uid.c_str();
Serial.print("User UID: ");
Serial.println(uid);
//---------------------------------------------------------------
// Update database path
databasePath = "/UsersData/" + uid + "/readings";
}
float h,t;
int s=0, wx;
int sensor_analog=0;
void loop(){
//WiFiClient client = server.available(); // Listen for incoming clients
// If a new client connects,
if (Firebase.ready() && signupOK && (millis() - sendDataPrevMillis > 60000 || sendDataPrevMillis == 0)){
sendDataPrevMillis = millis();
// Read DHT Sensor
h = dht.readHumidity();
t = dht.readTemperature(); // Reading temperature as Celsius (the default)
for (wx=0; wx<20;wx++)
{
sensor_analog+=analogRead(sensor_pin); delay(10);
}
sensor_analog=sensor_analog/20; Serial.print("ADC= "); Serial.println(sensor_analog);
sensor_analog=1024-sensor_analog;
s = (map(sensor_analog, dry, wet, 0, 100)); Serial.print("Mapped Value= "); Serial.println(s);
s= constrain(s,0,100);
sensor_analog=0;
Serial.print("Humidity: ");
Serial.print(h);
Serial.print("% Temperature: ");
Serial.print(t);
Serial.println("°C ");
Serial.println("Soil Moisture: ");
Serial.print(s);
Serial.println("%");
//Get current timestamp
timestamp = getTime();
Serial.print ("time: ");
Serial.println (timestamp);
parentPath= databasePath + "/" + String(timestamp);
json.set(tempPath.c_str(), String(t));
json.set(humPath.c_str(), String(h));
json.set(soilPath.c_str(), String(s));
json.set(timePath, String(timestamp));
Serial.printf("Set json... %s\n", Firebase.RTDB.setJSON(&fbdo, parentPath.c_str(), &json) ? "ok" : fbdo.errorReason().c_str());
}
}
Crop Manager
Project images are for reference only. Actual production is based on the manufacturing files on the project page.
Please review the designer's notes (e.g., PCB thickness) and select the appropriate options.
PCBWay is not responsible
for issues caused by unsuitable parameter selections.
For more important ordering information, please refer to
Read More
Raspberry Pi 5 7 Inch Touch Screen IPS 1024x600 HD LCD HDMI-compatible Display for RPI 4B 3B+ OPI 5 AIDA64 PC Secondary Screen(Without Speaker)
BUY NOW- Comments(0)
- Likes(2)
- 2 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
-
5design
-
9usability
-
7creativity
-
8content
-
10design
-
10usability
-
10creativity
-
10content
More by Engineer
-
Programmable Mist Maker - XIAO / QT PY Extension
1182 2 1 -
RadioHAT - Raspberry Pi radio development platform
986 0 2 -
QWIIC-VL53L4CD Time-of-Flight Distance Sensor Module
1200 0 1 -
-
-
-
ARPS-2 – Arduino-Compatible Robot Project Shield for Arduino UNO
3402 0 6 -
-
A Compact Charging Breakout Board For Waveshare ESP32-C3
4025 3 8 -
AI-driven LoRa & LLM-enabled Kiosk & Food Delivery System
4419 2 2







