Compare commits
No commits in common. "23d4f8d2ec17791fd65b4e47c304616fb31a356d" and "8bc186102462c80aa5202dc748c94f0ff470a77c" have entirely different histories.
23d4f8d2ec
...
8bc1861024
|
|
@ -7,12 +7,5 @@
|
|||
const char *MQTT_BROKER = "192.168.178.74";
|
||||
const char *MQTT_SENSOR_TOPIC = "living/sensor2";
|
||||
const char *MQTT_CLIENT_ID = "living_mobile_sensor";
|
||||
const char *MQTT_LAST_WILL_TOPIC = "living/sensor2/status";
|
||||
const char *MQTT_LAST_WILL_MSG = "offline";
|
||||
const char *MQTT_CLIENT_USER = "NULL"; // if NULL, no username or password is used
|
||||
const char *MQTT_CLIENT_PW = "NULL"; // if NULL, no password is used
|
||||
|
||||
const int AirValue = 800; //replace the value with value when placed in air
|
||||
const int WaterValue = 345; //replace the value with value when placed in water
|
||||
|
||||
#endif
|
||||
|
|
@ -36,8 +36,9 @@ uint8_t rh_buf[RH_BUF_LEN];
|
|||
* */
|
||||
#include "config.h"
|
||||
|
||||
// const int AirValue = 800; //replace the value with value when placed in air
|
||||
// const int WaterValue = 345; //replace the value with value when placed in water
|
||||
|
||||
const int AirValue = 800; //replace the value with value when placed in air
|
||||
const int WaterValue = 345; //replace the value with value when placed in water
|
||||
|
||||
volatile boolean new_value = false;
|
||||
|
||||
|
|
@ -54,7 +55,6 @@ RH_ASK driver(RH_SPEED, RH_RX_PIN);
|
|||
#define MSG_BAT 0x20
|
||||
#define MSG_TEMPHUM 0x30
|
||||
#define MSG_ERR 0x40
|
||||
#define MSG_HUM 0x50
|
||||
|
||||
char buff[20];
|
||||
|
||||
|
|
@ -170,14 +170,6 @@ void loop()
|
|||
Serial.println(SoilHumidity);
|
||||
new_value = true;
|
||||
break;
|
||||
case MSG_HUM:
|
||||
Serial.println("Soil Humidity");
|
||||
memcpy(&soil, &rh_buf[1], 2);
|
||||
Serial.println(soil);
|
||||
SoilHumidity = (float)(map(soil, AirValue, WaterValue, 0, 100));
|
||||
Serial.println(SoilHumidity);
|
||||
new_value = true;
|
||||
break;
|
||||
case MSG_BAT:
|
||||
// battery data
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
|
@ -223,9 +215,7 @@ void reconnect()
|
|||
{
|
||||
Serial.println("INFO: Attempting MQTT connection...");
|
||||
// Attempt to connect
|
||||
|
||||
// Should work without authentication, if credentials are NULL
|
||||
if (mqttClient.connect(MQTT_CLIENT_ID, MQTT_CLIENT_USER, MQTT_CLIENT_PW))
|
||||
if (mqttClient.connect(MQTT_CLIENT_ID))
|
||||
{
|
||||
Serial.println("INFO: connected");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,4 @@
|
|||
// Sleep this many again before waging up. Sleep time in s = WATCHDOG_WAKEUP s * WATCHDOG_SLEEP_FURTHER, e.g. 8*8s = 64s
|
||||
#define WATCHDOG_SLEEP_FURTHER 8
|
||||
|
||||
// define wether to use a DHT-Sensor or not
|
||||
bool USE_DHT_SENSOR = true;
|
||||
|
||||
#endif
|
||||
|
|
@ -68,10 +68,7 @@ void setup()
|
|||
pinMode(SOIL_PIN, INPUT);
|
||||
|
||||
// init the DHT22
|
||||
if (USE_DHT_SENSOR == 1)
|
||||
{
|
||||
dht_init(&dht, DHT_PIN);
|
||||
}
|
||||
|
||||
uint8_t num_blink = 3;
|
||||
|
||||
|
|
@ -115,9 +112,7 @@ void loop()
|
|||
memcpy(&rh_buf[1], &battery, 4);
|
||||
rh_send(rh_buf,RH_BUF_LEN);
|
||||
}
|
||||
else if (USE_DHT_SENSOR == 1)
|
||||
{
|
||||
if (dht_read_data(&dht, &t, &h) == 1)
|
||||
else if (dht_read_data(&dht, &t, &h) == 1)
|
||||
{
|
||||
rh_buf[0] = MSG_TEMPHUM;
|
||||
memcpy(&rh_buf[1], &t, 4);
|
||||
|
|
@ -136,15 +131,6 @@ void loop()
|
|||
rh_buf[0] = MSG_ERR;
|
||||
rh_send(rh_buf,1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rh_buf[0] = MSG_HUM;
|
||||
soil = analogRead(SOIL_PIN);
|
||||
memcpy(&rh_buf[1], &soil, 2);
|
||||
|
||||
rh_send(rh_buf,RH_BUF_LEN);
|
||||
}
|
||||
counter++;
|
||||
|
||||
// turn off the LED and transistor:
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@
|
|||
#define MSG_BAT 0x20
|
||||
#define MSG_TEMPHUM 0x30
|
||||
#define MSG_ERR 0x40
|
||||
#define MSG_HUM 0x50 // case, sensor just reads soil-humidity
|
||||
|
||||
// for watchdog wakeup
|
||||
// https://gist.github.com/dwhacks/8055287
|
||||
|
|
|
|||
Loading…
Reference in New Issue