Updated build

This commit is contained in:
mercdev 2018-02-20 00:44:16 -07:00
parent 53208b5ad7
commit c94a073239
21 changed files with 640 additions and 633 deletions

View File

@ -1,2 +1,2 @@
Connecting to https://mongoose.cloud, user test Connecting to https://mongoose.cloud, user test
Uploading sources (2437 bytes) Uploading sources (2968 bytes)

File diff suppressed because one or more lines are too long

View File

@ -107,9 +107,8 @@
"deviceId": "", "deviceId": "",
"temperature": 0.0, "temperature": 0.0,
"humidity": 0.0, "humidity": 0.0,
"light": 0, "statuslight": 0,
"moisture": 0, "moisture": 0,
"connected": false, "connected": false
"battery_calibration": 2360
} }
} }

View File

@ -10,32 +10,32 @@ load('api_dht.js');
load('api_adc.js'); load('api_adc.js');
load('api_rpc.js'); load('api_rpc.js');
//Pins // Pins
let ResetPin = 0; let resetPin = 0;
let LedPin = 16; let statusLightPin = 16;
let DHTpin = 22; let dhtPin = 22;
let SOILpin = 32; let moisturePin = 32;
let LIGHTpin = 34; let lightPin = 34;
// Turn on status led // Turn on status led
GPIO.set_mode(LedPin, GPIO.MODE_OUTPUT); GPIO.set_mode(statusLightPin, GPIO.MODE_OUTPUT);
GPIO.write(LedPin, 0); GPIO.write(statusLightPin, 0);
//Reset Handler // Reset Handler
GPIO.set_mode(ResetPin, GPIO.MODE_INPUT); GPIO.set_mode(resetPin, GPIO.MODE_INPUT);
GPIO.set_int_handler(ResetPin, GPIO.INT_EDGE_NEG, function(ResetPin) { GPIO.set_int_handler(resetPin, GPIO.INT_EDGE_NEG, function(resetPin) {
print('Pin', ResetPin, 'got interrupt'); print('Pin', resetPin, 'got interrupt');
GPIO.toggle(LedPin); GPIO.toggle(statusLightPin);
Sys.usleep(200000); Sys.usleep(200000);
GPIO.toggle(LedPin); GPIO.toggle(statusLightPin);
Sys.usleep(200000); Sys.usleep(200000);
GPIO.toggle(LedPin); GPIO.toggle(statusLightPin);
Sys.usleep(200000); Sys.usleep(200000);
GPIO.toggle(LedPin); GPIO.toggle(statusLightPin);
Sys.usleep(200000); Sys.usleep(200000);
GPIO.toggle(LedPin); GPIO.toggle(statusLightPin);
Sys.usleep(200000); Sys.usleep(200000);
GPIO.write(LedPin, 0); GPIO.write(statusLightPin, 0);
Cfg.set({bt:{enable:true}}); Cfg.set({bt:{enable:true}});
Cfg.set({wifi:{sta:{enable:false}}}); Cfg.set({wifi:{sta:{enable:false}}});
@ -44,37 +44,81 @@ GPIO.set_int_handler(ResetPin, GPIO.INT_EDGE_NEG, function(ResetPin) {
Sys.reboot(1000); Sys.reboot(1000);
}, null); }, null);
GPIO.enable_int(ResetPin); GPIO.enable_int(resetPin);
ADC.enable(SOILpin); ADC.enable(moisturePin);
let dht = DHT.create(DHTpin, DHT.DHT11);
let deviceId = Cfg.get("higrow.deviceId");
if (deviceId === "")
{
deviceId = Cfg.get("device.id");
Cfg.set("higrow.devideId", deviceId);
}
let dht = DHT.create(dhtPin, DHT.DHT11);
let deviceId = Cfg.get("device.id");
let connected = false; let connected = false;
let readSensors = Timer.set(15000, Timer.REPEAT, function() { let readSensors = Timer.set(5000, Timer.REPEAT, function() {
let t = dht.getTemp(); let t = dht.getTemp();
let h = dht.getHumidity(); let h = dht.getHumidity();
let m = ADC.read(SOILpin); let m = ADC.read(moisturePin);
let l = ADC.read(LIGHTpin); let l = ADC.read(lightPin);
print("DeviceId:", deviceId,"Temperature:",t,"Humidity:",h,"Moisture:",m,"Light:",l); print("DeviceId:",deviceId,"Temperature:",t,"Humidity:",h,"Moisture:",m,"Light:",l);
if (deviceId !== "" && connected)
{
GPIO.write(statusLightPin, 1);
let jsonData = {'DeviceId': deviceId, 'Temperature': t, 'Humidity': h, 'Moisture': m, 'Light': l};
HTTP.query({
headers: {'Content-Type' : 'application/json'},
url: 'http://httpbin.org/post', // replace with your own endpoint
data: jsonData,
success: function(body, full_http_msg)
{
//print(body);
// sleep for 15 seconds, then (re)boot up and do it all over again
//ESP32.deepSleep(15000000); // 15 seconds
},
error: function(err)
{
print(err);
//ESP32.deepSleep(30000000); // 30 seconds
},
});
//Timer.del(readSensors); //Timer.del(readSensors);
}
//ESP32.deepSleep(3600000000); //3600 seconds / 60 minutes
/*
Cfg.set({higrow:{temperature:jsonData.Temperature}});
Cfg.set({higrow:{moisture:jsonData.Water}});
Cfg.set({higrow:{humidity:jsonData.Humidity}});
Cfg.set({higrow:{light:jsonData.Light}});
*/
}, null); }, null);
// RPC Handlers
RPC.addHandler('HG.Temp.Read', function(args){
return { value: dht.getTemp() };
});
RPC.addHandler('HG.Humidity.Read', function(args){
return { value: dht.getHumidity() };
});
RPC.addHandler('HG.Light.Read', function(args){
return { value: ADC.read(lightPin) };
});
RPC.addHandler('HG.Moisture.Read', function(args){
return { value: ADC.read(moisturePin) };
});
RPC.addHandler('HG.StatusLED.On', function(args){
GPIO.write(statusLightPin, 0);
print("LED On");
if (GPIO.read(statusLightPin) !== 0)
{
return false;
}
return true;
});
RPC.addHandler('HG.StatusLED.Off', function(args){
GPIO.write(statusLightPin, 1);
if (GPIO.read(statusLightPin) !== 1)
{
return false;
}
return true;
});
// Monitor network connectivity. // Monitor network connectivity.
Event.addGroupHandler(Net.EVENT_GRP, function(ev, evdata, arg) { Event.addGroupHandler(Net.EVENT_GRP, function(ev, evdata, arg) {
let status = true && connected; let status = true && connected;

Binary file not shown.

View File

@ -1,4 +1,4 @@
/* Auto-generated, do not edit. */ /* Auto-generated, do not edit. */
const char *build_id = "20180218-011554/???"; const char *build_id = "20180218-182818/???";
const char *build_timestamp = "2018-02-18T01:15:54Z"; const char *build_timestamp = "2018-02-18T18:28:18Z";
const char *build_version = "1.0"; const char *build_version = "1.0";

View File

@ -1,5 +1,5 @@
{ {
"build_id": "20180218-011554/???", "build_id": "20180218-182818/???",
"build_timestamp": "2018-02-18T01:15:54Z", "build_timestamp": "2018-02-18T18:28:18Z",
"build_version": "1.0" "build_version": "1.0"
} }

View File

@ -2,5 +2,5 @@
"arch": "esp32", "arch": "esp32",
"platform": "esp32", "platform": "esp32",
"app_name": "LilyGo-HiGrow-ESP32-Mongoose-OS-Firmware", "app_name": "LilyGo-HiGrow-ESP32-Mongoose-OS-Firmware",
"build_time_ms": 31259 "build_time_ms": 26383
} }

View File

@ -107,9 +107,8 @@
"deviceId": "", "deviceId": "",
"temperature": 0.0, "temperature": 0.0,
"humidity": 0.0, "humidity": 0.0,
"light": 0, "statuslight": 0,
"moisture": 0, "moisture": 0,
"connected": false, "connected": false
"battery_calibration": 2360
} }
} }

View File

@ -1,4 +1,4 @@
/* Auto-generated, do not edit. */ /* Auto-generated, do not edit. */
const char *mg_build_id = "20180218-011551/???"; const char *mg_build_id = "20180218-182818/???";
const char *mg_build_timestamp = "2018-02-18T01:15:51Z"; const char *mg_build_timestamp = "2018-02-18T18:28:18Z";
const char *mg_build_version = "2018021801"; const char *mg_build_version = "2018021818";

View File

@ -3,8 +3,8 @@
#include <stddef.h> #include <stddef.h>
#include "mgos_config.h" #include "mgos_config.h"
const struct mgos_conf_entry mgos_config_schema_[100] = { const struct mgos_conf_entry mgos_config_schema_[99] = {
{.type = CONF_TYPE_OBJECT, .key = "", .num_desc = 99}, {.type = CONF_TYPE_OBJECT, .key = "", .num_desc = 98},
{.type = CONF_TYPE_OBJECT, .key = "device", .num_desc = 2}, {.type = CONF_TYPE_OBJECT, .key = "device", .num_desc = 2},
{.type = CONF_TYPE_STRING, .key = "id", .offset = offsetof(struct mgos_config, device.id)}, {.type = CONF_TYPE_STRING, .key = "id", .offset = offsetof(struct mgos_config, device.id)},
{.type = CONF_TYPE_STRING, .key = "password", .offset = offsetof(struct mgos_config, device.password)}, {.type = CONF_TYPE_STRING, .key = "password", .offset = offsetof(struct mgos_config, device.password)},
@ -96,14 +96,13 @@ const struct mgos_conf_entry mgos_config_schema_[100] = {
{.type = CONF_TYPE_INT, .key = "disable_after", .offset = offsetof(struct mgos_config, wifi.ap.disable_after)}, {.type = CONF_TYPE_INT, .key = "disable_after", .offset = offsetof(struct mgos_config, wifi.ap.disable_after)},
{.type = CONF_TYPE_STRING, .key = "hostname", .offset = offsetof(struct mgos_config, wifi.ap.hostname)}, {.type = CONF_TYPE_STRING, .key = "hostname", .offset = offsetof(struct mgos_config, wifi.ap.hostname)},
{.type = CONF_TYPE_BOOL, .key = "keep_enabled", .offset = offsetof(struct mgos_config, wifi.ap.keep_enabled)}, {.type = CONF_TYPE_BOOL, .key = "keep_enabled", .offset = offsetof(struct mgos_config, wifi.ap.keep_enabled)},
{.type = CONF_TYPE_OBJECT, .key = "higrow", .num_desc = 7}, {.type = CONF_TYPE_OBJECT, .key = "higrow", .num_desc = 6},
{.type = CONF_TYPE_STRING, .key = "deviceId", .offset = offsetof(struct mgos_config, higrow.deviceId)}, {.type = CONF_TYPE_STRING, .key = "deviceId", .offset = offsetof(struct mgos_config, higrow.deviceId)},
{.type = CONF_TYPE_DOUBLE, .key = "temperature", .offset = offsetof(struct mgos_config, higrow.temperature)}, {.type = CONF_TYPE_DOUBLE, .key = "temperature", .offset = offsetof(struct mgos_config, higrow.temperature)},
{.type = CONF_TYPE_DOUBLE, .key = "humidity", .offset = offsetof(struct mgos_config, higrow.humidity)}, {.type = CONF_TYPE_DOUBLE, .key = "humidity", .offset = offsetof(struct mgos_config, higrow.humidity)},
{.type = CONF_TYPE_INT, .key = "light", .offset = offsetof(struct mgos_config, higrow.light)}, {.type = CONF_TYPE_INT, .key = "statuslight", .offset = offsetof(struct mgos_config, higrow.statuslight)},
{.type = CONF_TYPE_INT, .key = "moisture", .offset = offsetof(struct mgos_config, higrow.moisture)}, {.type = CONF_TYPE_INT, .key = "moisture", .offset = offsetof(struct mgos_config, higrow.moisture)},
{.type = CONF_TYPE_BOOL, .key = "connected", .offset = offsetof(struct mgos_config, higrow.connected)}, {.type = CONF_TYPE_BOOL, .key = "connected", .offset = offsetof(struct mgos_config, higrow.connected)},
{.type = CONF_TYPE_INT, .key = "battery_calibration", .offset = offsetof(struct mgos_config, higrow.battery_calibration)},
}; };
const struct mgos_conf_entry *mgos_config_schema() { const struct mgos_conf_entry *mgos_config_schema() {
@ -399,8 +398,8 @@ double mgos_config_get_higrow_temperature(struct mgos_config *cfg) {
double mgos_config_get_higrow_humidity(struct mgos_config *cfg) { double mgos_config_get_higrow_humidity(struct mgos_config *cfg) {
return cfg->higrow.humidity; return cfg->higrow.humidity;
} }
int mgos_config_get_higrow_light(struct mgos_config *cfg) { int mgos_config_get_higrow_statuslight(struct mgos_config *cfg) {
return cfg->higrow.light; return cfg->higrow.statuslight;
} }
int mgos_config_get_higrow_moisture(struct mgos_config *cfg) { int mgos_config_get_higrow_moisture(struct mgos_config *cfg) {
return cfg->higrow.moisture; return cfg->higrow.moisture;
@ -408,9 +407,6 @@ int mgos_config_get_higrow_moisture(struct mgos_config *cfg) {
int mgos_config_get_higrow_connected(struct mgos_config *cfg) { int mgos_config_get_higrow_connected(struct mgos_config *cfg) {
return cfg->higrow.connected; return cfg->higrow.connected;
} }
int mgos_config_get_higrow_battery_calibration(struct mgos_config *cfg) {
return cfg->higrow.battery_calibration;
}
/* }}} */ /* }}} */
/* Setters {{{ */ /* Setters {{{ */
@ -657,8 +653,8 @@ void mgos_config_set_higrow_temperature(struct mgos_config *cfg, double val
void mgos_config_set_higrow_humidity(struct mgos_config *cfg, double val) { void mgos_config_set_higrow_humidity(struct mgos_config *cfg, double val) {
cfg->higrow.humidity = val; cfg->higrow.humidity = val;
} }
void mgos_config_set_higrow_light(struct mgos_config *cfg, int val) { void mgos_config_set_higrow_statuslight(struct mgos_config *cfg, int val) {
cfg->higrow.light = val; cfg->higrow.statuslight = val;
} }
void mgos_config_set_higrow_moisture(struct mgos_config *cfg, int val) { void mgos_config_set_higrow_moisture(struct mgos_config *cfg, int val) {
cfg->higrow.moisture = val; cfg->higrow.moisture = val;
@ -666,7 +662,4 @@ void mgos_config_set_higrow_moisture(struct mgos_config *cfg, int val) {
void mgos_config_set_higrow_connected(struct mgos_config *cfg, int val) { void mgos_config_set_higrow_connected(struct mgos_config *cfg, int val) {
cfg->higrow.connected = val; cfg->higrow.connected = val;
} }
void mgos_config_set_higrow_battery_calibration(struct mgos_config *cfg, int val) {
cfg->higrow.battery_calibration = val;
}
/* }}} */ /* }}} */

View File

@ -138,10 +138,9 @@ struct mgos_config_higrow {
char *deviceId; char *deviceId;
double temperature; double temperature;
double humidity; double humidity;
int light; int statuslight;
int moisture; int moisture;
int connected; int connected;
int battery_calibration;
}; };
struct mgos_config { struct mgos_config {
@ -252,10 +251,9 @@ const struct mgos_config_higrow *mgos_config_get_higrow(struct mgos_config *cfg)
const char *mgos_config_get_higrow_deviceId(struct mgos_config *cfg); const char *mgos_config_get_higrow_deviceId(struct mgos_config *cfg);
double mgos_config_get_higrow_temperature(struct mgos_config *cfg); double mgos_config_get_higrow_temperature(struct mgos_config *cfg);
double mgos_config_get_higrow_humidity(struct mgos_config *cfg); double mgos_config_get_higrow_humidity(struct mgos_config *cfg);
int mgos_config_get_higrow_light(struct mgos_config *cfg); int mgos_config_get_higrow_statuslight(struct mgos_config *cfg);
int mgos_config_get_higrow_moisture(struct mgos_config *cfg); int mgos_config_get_higrow_moisture(struct mgos_config *cfg);
int mgos_config_get_higrow_connected(struct mgos_config *cfg); int mgos_config_get_higrow_connected(struct mgos_config *cfg);
int mgos_config_get_higrow_battery_calibration(struct mgos_config *cfg);
void mgos_config_set_device_id(struct mgos_config *cfg, const char *val); void mgos_config_set_device_id(struct mgos_config *cfg, const char *val);
void mgos_config_set_device_password(struct mgos_config *cfg, const char *val); void mgos_config_set_device_password(struct mgos_config *cfg, const char *val);
@ -338,10 +336,9 @@ void mgos_config_set_wifi_ap_keep_enabled(struct mgos_config *cfg, int v
void mgos_config_set_higrow_deviceId(struct mgos_config *cfg, const char *val); void mgos_config_set_higrow_deviceId(struct mgos_config *cfg, const char *val);
void mgos_config_set_higrow_temperature(struct mgos_config *cfg, double val); void mgos_config_set_higrow_temperature(struct mgos_config *cfg, double val);
void mgos_config_set_higrow_humidity(struct mgos_config *cfg, double val); void mgos_config_set_higrow_humidity(struct mgos_config *cfg, double val);
void mgos_config_set_higrow_light(struct mgos_config *cfg, int val); void mgos_config_set_higrow_statuslight(struct mgos_config *cfg, int val);
void mgos_config_set_higrow_moisture(struct mgos_config *cfg, int val); void mgos_config_set_higrow_moisture(struct mgos_config *cfg, int val);
void mgos_config_set_higrow_connected(struct mgos_config *cfg, int val); void mgos_config_set_higrow_connected(struct mgos_config *cfg, int val);
void mgos_config_set_higrow_battery_calibration(struct mgos_config *cfg, int val);
/* }}} */ /* }}} */
extern struct mgos_config mgos_sys_config; extern struct mgos_config mgos_sys_config;
@ -441,10 +438,9 @@ static inline const struct mgos_config_higrow *mgos_sys_config_get_higrow(void)
static inline const char *mgos_sys_config_get_higrow_deviceId(void) { return mgos_config_get_higrow_deviceId(&mgos_sys_config); } static inline const char *mgos_sys_config_get_higrow_deviceId(void) { return mgos_config_get_higrow_deviceId(&mgos_sys_config); }
static inline double mgos_sys_config_get_higrow_temperature(void) { return mgos_config_get_higrow_temperature(&mgos_sys_config); } static inline double mgos_sys_config_get_higrow_temperature(void) { return mgos_config_get_higrow_temperature(&mgos_sys_config); }
static inline double mgos_sys_config_get_higrow_humidity(void) { return mgos_config_get_higrow_humidity(&mgos_sys_config); } static inline double mgos_sys_config_get_higrow_humidity(void) { return mgos_config_get_higrow_humidity(&mgos_sys_config); }
static inline int mgos_sys_config_get_higrow_light(void) { return mgos_config_get_higrow_light(&mgos_sys_config); } static inline int mgos_sys_config_get_higrow_statuslight(void) { return mgos_config_get_higrow_statuslight(&mgos_sys_config); }
static inline int mgos_sys_config_get_higrow_moisture(void) { return mgos_config_get_higrow_moisture(&mgos_sys_config); } static inline int mgos_sys_config_get_higrow_moisture(void) { return mgos_config_get_higrow_moisture(&mgos_sys_config); }
static inline int mgos_sys_config_get_higrow_connected(void) { return mgos_config_get_higrow_connected(&mgos_sys_config); } static inline int mgos_sys_config_get_higrow_connected(void) { return mgos_config_get_higrow_connected(&mgos_sys_config); }
static inline int mgos_sys_config_get_higrow_battery_calibration(void) { return mgos_config_get_higrow_battery_calibration(&mgos_sys_config); }
static inline void mgos_sys_config_set_device_id(const char *val) { mgos_config_set_device_id(&mgos_sys_config, val); } static inline void mgos_sys_config_set_device_id(const char *val) { mgos_config_set_device_id(&mgos_sys_config, val); }
static inline void mgos_sys_config_set_device_password(const char *val) { mgos_config_set_device_password(&mgos_sys_config, val); } static inline void mgos_sys_config_set_device_password(const char *val) { mgos_config_set_device_password(&mgos_sys_config, val); }
@ -527,10 +523,9 @@ static inline void mgos_sys_config_set_wifi_ap_keep_enabled(int val) { m
static inline void mgos_sys_config_set_higrow_deviceId(const char *val) { mgos_config_set_higrow_deviceId(&mgos_sys_config, val); } static inline void mgos_sys_config_set_higrow_deviceId(const char *val) { mgos_config_set_higrow_deviceId(&mgos_sys_config, val); }
static inline void mgos_sys_config_set_higrow_temperature(double val) { mgos_config_set_higrow_temperature(&mgos_sys_config, val); } static inline void mgos_sys_config_set_higrow_temperature(double val) { mgos_config_set_higrow_temperature(&mgos_sys_config, val); }
static inline void mgos_sys_config_set_higrow_humidity(double val) { mgos_config_set_higrow_humidity(&mgos_sys_config, val); } static inline void mgos_sys_config_set_higrow_humidity(double val) { mgos_config_set_higrow_humidity(&mgos_sys_config, val); }
static inline void mgos_sys_config_set_higrow_light(int val) { mgos_config_set_higrow_light(&mgos_sys_config, val); } static inline void mgos_sys_config_set_higrow_statuslight(int val) { mgos_config_set_higrow_statuslight(&mgos_sys_config, val); }
static inline void mgos_sys_config_set_higrow_moisture(int val) { mgos_config_set_higrow_moisture(&mgos_sys_config, val); } static inline void mgos_sys_config_set_higrow_moisture(int val) { mgos_config_set_higrow_moisture(&mgos_sys_config, val); }
static inline void mgos_sys_config_set_higrow_connected(int val) { mgos_config_set_higrow_connected(&mgos_sys_config, val); } static inline void mgos_sys_config_set_higrow_connected(int val) { mgos_config_set_higrow_connected(&mgos_sys_config, val); }
static inline void mgos_sys_config_set_higrow_battery_calibration(int val) { mgos_config_set_higrow_battery_calibration(&mgos_sys_config, val); }
const struct mgos_conf_entry *mgos_config_schema(); const struct mgos_conf_entry *mgos_config_schema();

Binary file not shown.

View File

@ -107,9 +107,8 @@
"deviceId": "", "deviceId": "",
"temperature": 0.0, "temperature": 0.0,
"humidity": 0.0, "humidity": 0.0,
"light": 0, "statuslight": 0,
"moisture": 0, "moisture": 0,
"connected": false, "connected": false
"battery_calibration": 2360
} }
} }

View File

@ -90,12 +90,11 @@
["wifi.ap.disable_after", "i", {"title": "If > 0, will disable itself after the specified number of seconds"}], ["wifi.ap.disable_after", "i", {"title": "If > 0, will disable itself after the specified number of seconds"}],
["wifi.ap.hostname", "s", {"title": "If not empty, DNS server will resolve given host name to the IP address of AP"}], ["wifi.ap.hostname", "s", {"title": "If not empty, DNS server will resolve given host name to the IP address of AP"}],
["wifi.ap.keep_enabled", "b", {"title": "Keep AP enabled when station is on"}], ["wifi.ap.keep_enabled", "b", {"title": "Keep AP enabled when station is on"}],
["higrow", "o", {"title": "LilyGo HiGrow ESP32 Plant Sensor App Settings"}], ["higrow", "o", {"title": "LilyGo HiGrow ESP32 Plant Sensor v1 App Settings"}],
["higrow.deviceId", "s", {"title": "DeviceId"}], ["higrow.deviceId", "s", {"title": "DeviceId"}],
["higrow.temperature", "d", {"title": "Temperature"}], ["higrow.temperature", "d", {"title": "Temperature"}],
["higrow.humidity", "d", {"title": "Humidity"}], ["higrow.humidity", "d", {"title": "Humidity"}],
["higrow.light", "i", {"title": "Light"}], ["higrow.statuslight", "i", {"title": "Light"}],
["higrow.moisture", "i", {"title": "Moisture"}], ["higrow.moisture", "i", {"title": "Moisture"}],
["higrow.connected", "b", {"title": "Connected"}], ["higrow.connected", "b", {"title": "Connected"}]
["higrow.battery_calibration", "i", {"title": "Battery ADC value at 4000mV"}]
] ]

View File

@ -247,7 +247,7 @@
- title: Keep AP enabled when station is on - title: Keep AP enabled when station is on
- - higrow - - higrow
- o - o
- title: LilyGo HiGrow ESP32 Plant Sensor App Settings - title: LilyGo HiGrow ESP32 Plant Sensor v1 App Settings
- - higrow.deviceId - - higrow.deviceId
- s - s
- "" - ""
@ -260,7 +260,7 @@
- d - d
- 0 - 0
- title: Humidity - title: Humidity
- - higrow.light - - higrow.statuslight
- i - i
- 0 - 0
- title: Light - title: Light
@ -272,10 +272,6 @@
- b - b
- false - false
- title: Connected - title: Connected
- - higrow.battery_calibration
- i
- 2360
- title: Battery ADC value at 4000mV
- - wifi.sta.enable - - wifi.sta.enable
- false - false
- - wifi.sta.ssid - - wifi.sta.ssid

View File

@ -5,7 +5,7 @@ platform: esp32
platforms: platforms:
- esp32 - esp32
author: Jason Harrell <info@latitude17.io> author: Jason Harrell <info@latitude17.io>
description: LilyGo HiGrow ESP32 Plant Sensor description: LilyGo HiGrow ESP32 Plant Sensor v1
sources: sources:
- /fwbuild-volumes/latest/apps/LilyGo-HiGrow-ESP32-Mongoose-OS-Firmware/esp32/build_contexts/build_ctx_913791226/build/gen/deps_init.c - /fwbuild-volumes/latest/apps/LilyGo-HiGrow-ESP32-Mongoose-OS-Firmware/esp32/build_contexts/build_ctx_913791226/build/gen/deps_init.c
- /fwbuild-volumes/latest/apps/LilyGo-HiGrow-ESP32-Mongoose-OS-Firmware/esp32/build_contexts/build_ctx_913791226/libs/adc/esp32/src/esp32_adc.c - /fwbuild-volumes/latest/apps/LilyGo-HiGrow-ESP32-Mongoose-OS-Firmware/esp32/build_contexts/build_ctx_913791226/libs/adc/esp32/src/esp32_adc.c
@ -324,7 +324,7 @@ config_schema:
- title: Keep AP enabled when station is on - title: Keep AP enabled when station is on
- - higrow - - higrow
- o - o
- title: LilyGo HiGrow ESP32 Plant Sensor App Settings - title: LilyGo HiGrow ESP32 Plant Sensor v1 App Settings
- - higrow.deviceId - - higrow.deviceId
- s - s
- "" - ""
@ -337,7 +337,7 @@ config_schema:
- d - d
- 0 - 0
- title: Humidity - title: Humidity
- - higrow.light - - higrow.statuslight
- i - i
- 0 - 0
- title: Light - title: Light
@ -349,10 +349,6 @@ config_schema:
- b - b
- false - false
- title: Connected - title: Connected
- - higrow.battery_calibration
- i
- 2360
- title: Battery ADC value at 4000mV
- - wifi.sta.enable - - wifi.sta.enable
- false - false
- - wifi.sta.ssid - - wifi.sta.ssid

Binary file not shown.

View File

@ -10,32 +10,32 @@ load('api_dht.js');
load('api_adc.js'); load('api_adc.js');
load('api_rpc.js'); load('api_rpc.js');
//Pins // Pins
let resetPin = 0; let resetPin = 0;
let ledPin = 16; let statusLightPin = 16;
let dhtPin = 22; let dhtPin = 22;
let moisturePin = 32; let moisturePin = 32;
let statusLightPin = 34; let lightPin = 34;
// Turn on status led // Turn on status led
GPIO.set_mode(ledPin, GPIO.MODE_OUTPUT); GPIO.set_mode(statusLightPin, GPIO.MODE_OUTPUT);
GPIO.write(ledPin, 0); GPIO.write(statusLightPin, 0);
//Reset Handler // Reset Handler
GPIO.set_mode(resetPin, GPIO.MODE_INPUT); GPIO.set_mode(resetPin, GPIO.MODE_INPUT);
GPIO.set_int_handler(resetPin, GPIO.INT_EDGE_NEG, function(resetPin) { GPIO.set_int_handler(resetPin, GPIO.INT_EDGE_NEG, function(resetPin) {
print('Pin', resetPin, 'got interrupt'); print('Pin', resetPin, 'got interrupt');
GPIO.toggle(ledPin); GPIO.toggle(statusLightPin);
Sys.usleep(200000); Sys.usleep(200000);
GPIO.toggle(ledPin); GPIO.toggle(statusLightPin);
Sys.usleep(200000); Sys.usleep(200000);
GPIO.toggle(ledPin); GPIO.toggle(statusLightPin);
Sys.usleep(200000); Sys.usleep(200000);
GPIO.toggle(ledPin); GPIO.toggle(statusLightPin);
Sys.usleep(200000); Sys.usleep(200000);
GPIO.toggle(ledPin); GPIO.toggle(statusLightPin);
Sys.usleep(200000); Sys.usleep(200000);
GPIO.write(ledPin, 0); GPIO.write(statusLightPin, 0);
Cfg.set({bt:{enable:true}}); Cfg.set({bt:{enable:true}});
Cfg.set({wifi:{sta:{enable:false}}}); Cfg.set({wifi:{sta:{enable:false}}});
@ -55,21 +55,21 @@ let readSensors = Timer.set(5000, Timer.REPEAT, function() {
let t = dht.getTemp(); let t = dht.getTemp();
let h = dht.getHumidity(); let h = dht.getHumidity();
let m = ADC.read(moisturePin); let m = ADC.read(moisturePin);
let l = ADC.read(statusLightPin); let l = ADC.read(lightPin);
print("DeviceId:",deviceId,"Temperature:",t,"Humidity:",h,"Moisture:",m,"StatusLight:",l); print("DeviceId:",deviceId,"Temperature:",t,"Humidity:",h,"Moisture:",m,"Light:",l);
if (deviceId !== "" && connected) if (deviceId !== "" && connected)
{ {
GPIO.write(ledPin, 1); GPIO.write(statusLightPin, 1);
let jsonData = {DeviceId: deviceId, Temperature: t, Humidity: h, Moisture: m, StatusLight: l}; let jsonData = {'DeviceId': deviceId, 'Temperature': t, 'Humidity': h, 'Moisture': m, 'Light': l};
HTTP.query({ HTTP.query({
headers: {'Content-Type' : 'application/json'}, headers: {'Content-Type' : 'application/json'},
url: 'http://httpbin.org/post', // replace with your own endpoint url: 'http://httpbin.org/post', // replace with your own endpoint
data: jsonData, data: jsonData,
success: function(body, full_http_msg) success: function(body, full_http_msg)
{ {
print(body); //print(body);
// sleep for 15 seconds, then (re)boot up and do it all over again // sleep for 15 seconds, then (re)boot up and do it all over again
//ESP32.deepSleep(15000000); // 15 seconds //ESP32.deepSleep(15000000); // 15 seconds
}, },
@ -93,15 +93,15 @@ RPC.addHandler('HG.Humidity.Read', function(args){
return { value: dht.getHumidity() }; return { value: dht.getHumidity() };
}); });
RPC.addHandler('HG.Light.Read', function(args){ RPC.addHandler('HG.Light.Read', function(args){
return { value: ADC.read(statusLightPin) }; return { value: ADC.read(lightPin) };
}); });
RPC.addHandler('HG.Moisture.Read', function(args){ RPC.addHandler('HG.Moisture.Read', function(args){
return { value: ADC.read(moisturePin) }; return { value: ADC.read(moisturePin) };
}); });
RPC.addHandler('HG.StatusLED.On', function(args){ RPC.addHandler('HG.StatusLED.On', function(args){
GPIO.write(ledPin, 0); GPIO.write(statusLightPin, 0);
print("LED On"); print("LED On");
if (GPIO.read(ledPin) !== 0) if (GPIO.read(statusLightPin) !== 0)
{ {
return false; return false;
} }
@ -109,8 +109,8 @@ RPC.addHandler('HG.StatusLED.On', function(args){
return true; return true;
}); });
RPC.addHandler('HG.StatusLED.Off', function(args){ RPC.addHandler('HG.StatusLED.Off', function(args){
GPIO.write(ledPin, 1); GPIO.write(statusLightPin, 1);
if (GPIO.read(ledPin) !== 1) if (GPIO.read(statusLightPin) !== 1)
{ {
return false; return false;
} }