summaryrefslogtreecommitdiff
path: root/cricket.ino
diff options
context:
space:
mode:
Diffstat (limited to 'cricket.ino')
-rw-r--r--cricket.ino12
1 files changed, 8 insertions, 4 deletions
diff --git a/cricket.ino b/cricket.ino
index 7979c61..46430f0 100644
--- a/cricket.ino
+++ b/cricket.ino
@@ -8,12 +8,15 @@
#define WIFI_PASS "PASS"
WiFiClient wifiClient;
-#define MQTT_ID "cricket0"
+#define MQTT_ID "ID"
#define MQTT_BROKER "BROKER"
PubSubClient mqttClient(wifiClient);
#define DHTPIN 5 //Pin D1
#define DHTTYPE DHT22 //Temp and Humidity Sensor
+#define ANALOG_PIN 17
+
+
DHT dht(DHTPIN, DHTTYPE);
void setup() {
@@ -21,6 +24,7 @@ void setup() {
Serial.println("Initialised...");
connectWifi();
delay(1000);
+ pinMode(ANALOG_PIN,INPUT);
dht.begin();
}
@@ -60,7 +64,7 @@ void connectMqtt() {
void loop() {
delay(1500);
- float h = dht.readHumidity();
+ float h = analogRead(ANALOG_PIN);
float t = dht.readTemperature();
char t_msg[20];
@@ -70,7 +74,7 @@ void loop() {
Serial.println("Failed to read from DHT sensor!");
return;
}
- Serial.print("Humidity: ");
+ Serial.print("Moisture: ");
Serial.print(h);
Serial.print(" Temperature: ");
Serial.println(t);
@@ -81,5 +85,5 @@ void loop() {
dtostrf(t, 1, 2, t_msg);
mqttClient.publish("temperature", t_msg);
dtostrf(h, 1, 2, h_msg);
- mqttClient.publish("humidity", h_msg);
+ mqttClient.publish("moisture", h_msg);
}