-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.ino
175 lines (130 loc) · 4.61 KB
/
main.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
//salman-faris
#include <WiFiSSLClient.h>
#include<ArduinoJson.h>
#include <WiFi101.h>
#include <SPI.h>
#include <TelegramBot.h>
#include <DHT.h>;
// Initialize Wifi connection to the router
char ssid[] = "salfar"; // your network SSID (name)
char pass[] = "salfarhome4"; // your network key
#define DHTPIN A1 // what pin we're connected to
#define DHTTYPE DHT11 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
// Initialize Telegram BOT
const char* BotToken = "token"; // your Bot Teken
const char* BotName = "Agribot"; // your Bot Name
const char* BotUsername = "bot user name"; // your Bot User Name
int chk;
String hum; //Stores humidity value
String temp; //Stores temperature value
WiFiSSLClient client;
TelegramBot bot(BotToken, BotName, BotUsername, client);
int motor = 6; //connect to motor
int wifi = 7; // wifi indicator
void setup()
{
Serial.begin(9600);
dht.begin();
pinMode(wifi, OUTPUT);
pinMode(motor, OUTPUT);
delay(3000);
// attempt to connect to Wifi network:
Serial.print("Connecting Wifi: ");
Serial.println(ssid);
while (WiFi.begin(ssid, pass) != WL_CONNECTED)
{
Serial.print(".");
delay(500);
}
Serial.println("");
Serial.println("WiFi connected");
digitalWrite(wifi,HIGH);
bot.begin();
digitalWrite(wifi,HIGH);
}
void loop()
{
message m = bot.getUpdates(); // Read new messages
if (m.text.equals("Hi"))
{
bot.sendMessage(m.chat_id, " Hi! I'm AgriBot!. I'm your agriculture assistant to know more about my commands, type 'Help'.");
}
else if (m.text.equals("Help"))
{
bot.sendMessage(m.chat_id, " ==>>FarmTemp :- To know the temperature of your farm .");
bot.sendMessage(m.chat_id, " ==>>FarmMoisture :- To know the Moisture level of your farm.");
bot.sendMessage(m.chat_id, "==>>FarmHumidity :- To Know the Humidity level of your farm.");
bot.sendMessage(m.chat_id, "Motor on :- To turn on Your Motor");
bot.sendMessage(m.chat_id, "Motor off :- To turn off Your Motor");;
bot.sendMessage(m.chat_id, "for Dialy Tips 'ACT TIPS'");
bot.sendMessage(m.chat_id, "Live :- for watch your farm live");
bot.sendMessage(m.chat_id, "News");
bot.sendMessage(m.chat_id, "More Details");
}
else if(m.text.equals("FarmTemp"))
{
temp= dht.readTemperature();
bot.sendMessage(m.chat_id, "Temperature = ");
bot.sendMessage(m.chat_id, temp);
bot.sendMessage(m.chat_id, "Celsius");
}
else if (m.text.equals("FarmHumidity"))
{
hum= dht.readHumidity();
bot.sendMessage(m.chat_id, "Humidity = ");
bot.sendMessage(m.chat_id, hum);
bot.sendMessage(m.chat_id, "%");
}
else if(m.text.equals("FarmMoisture"))
{
temp= dht.readTemperature();
bot.sendMessage(m.chat_id, "FarmMoisture level = 75% ");
}
else if(m.text.equals("More Details"))
{
bot.sendMessage(m.chat_id, "1. Karshika Kerala");
bot.sendMessage(m.chat_id, "2. Farmers Portel");
bot.sendMessage(m.chat_id, "3. m kisan Portal");
message m = bot.getUpdates();
if (m.text.equals("1"))
{
bot.sendMessage(m.chat_id, "Click to open Karshika Kerala :- http://keralaagriculture.gov.in/");
}
else if (m.text.equals("2"))
{
bot.sendMessage(m.chat_id, "Click to open Farmers Portal :- http://www.farmer.gov.in/");
}
else if (m.text.equals("3"))
{
bot.sendMessage(m.chat_id, "Click to open m kisan Portal :- http://www.mkisan.gov.in/");
}
}
else if (m.text.equals("News"))
{
bot.sendMessage(m.chat_id, "http://www.mathrubhumi.com/agriculture");
bot.sendMessage(m.chat_id, "http://www.keralaeverything.com/kerala-agriculture.html");
bot.sendMessage(m.chat_id, "http://www.ndtv.com/topic/kerala-agriculture");
}
else if (m.text.equals("Motor on"))
{
bot.sendMessage(m.chat_id, "Motor is now On ");
digitalWrite(motor,HIGH);
}
else if (m.text.equals("Motor off"))
{
bot.sendMessage(m.chat_id, "Motor is now Off ");
digitalWrite(motor,LOW);
}
else if (m.text.equals("ACT TIPS"))
{
bot.sendMessage(m.chat_id, "Thankyou For Activating our Daily Tips ");
bot.sendMessage(m.chat_id , "Today tip's");
bot.sendMessage(m.chat_id ," ==>> Use joint venture and shared machinery to intensify production.");
}
else if (m.text.equals("Live"))
{
bot.sendMessage(m.chat_id, "http://foxlabfarm.azurewebsites.net");
}
}