Skip to content

Commit

Permalink
Merge pull request #57 from konnected-io/nodemcu-firmware-2-2
Browse files Browse the repository at this point in the history
updates for NodeMCU 2.2.0 firmware
  • Loading branch information
heythisisnate authored May 7, 2018
2 parents 881cacc + 17e1ef6 commit 8c53c98
Show file tree
Hide file tree
Showing 31 changed files with 1,053 additions and 292 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* Konnected Temperature & Humidity Sensor (DHT)
*
* Copyright 2018 Konnected Inc (https://konnected.io)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
*/
metadata {
definition (name: "Konnected Temperature & Humidity Sensor (DHT)", namespace: "konnected-io", author: "konnected.io") {
capability "Temperature Measurement"
capability "Relative Humidity Measurement"
}

preferences {
input name: "pollInterval", type: "number", title: "Polling Interval (minutes)",
defaultValue: 3,
description: "Frequency of sensor updates"
}

tiles {
multiAttributeTile(name:"main", type:"thermostat", width:6, height:4) {
tileAttribute("device.temperature", key: "PRIMARY_CONTROL") {
attributeState "temperature", label:'${currentValue}°F', unit: "°F", backgroundColors: [
// Celsius Color Range
[value: 0, color: "#153591"],
[value: 7, color: "#1E9CBB"],
[value: 15, color: "#90D2A7"],
[value: 23, color: "#44B621"],
[value: 29, color: "#F1D801"],
[value: 33, color: "#D04E00"],
[value: 36, color: "#BC2323"],
// Fahrenheit Color Range
[value: 40, color: "#153591"],
[value: 44, color: "#1E9CBB"],
[value: 59, color: "#90D2A7"],
[value: 74, color: "#44B621"],
[value: 84, color: "#F1D801"],
[value: 92, color: "#D04E00"],
[value: 96, color: "#BC2323"]
]
}
tileAttribute("device.humidity", key: "SECONDARY_CONTROL") {
attributeState("humidity", label:'${currentValue}%', unit:"%", defaultState: true)
}
}
main "main"
details "main"
}
}

def updated() {
parent.updateSettingsOnDevice()
}

// Update state sent from parent app
def updateStates(states) {
def temperature = new BigDecimal(states.temp)
if (location.getTemperatureScale() == 'F') {
temperature = temperature * 9 / 5 + 32
}
sendEvent(name: "temperature", value: temperature.setScale(1, BigDecimal.ROUND_HALF_UP), unit: location.getTemperatureScale())

def humidity
if (states.humi) {
humidity = new BigDecimal(states.humi)
sendEvent(name: "humidity", value: humidity.setScale(0, BigDecimal.ROUND_HALF_UP), unit: '%')
}

log.debug "Temperature: $temperature, Humidity: $humidity"
}

def pollInterval() {
return pollInterval
}
123 changes: 123 additions & 0 deletions firmware/2.2.0/app/include/user_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#ifndef __USER_CONFIG_H__
#define __USER_CONFIG_H__

// #define FLASH_512K
// #define FLASH_1M
// #define FLASH_2M
// #define FLASH_4M
// #define FLASH_8M
// #define FLASH_16M
#define FLASH_AUTOSIZE

// This adds the asserts in LUA. It also adds some useful extras to the
// node module. This is all silent in normal operation and so can be enabled
// without any harm (except for the code size increase and slight slowdown)
//#define DEVELOPMENT_TOOLS

#ifdef DEVELOPMENT_TOOLS
extern void luaL_assertfail(const char *file, int line, const char *message);
#define lua_assert(x) ((x) ? (void) 0 : luaL_assertfail(__FILE__, __LINE__, #x))
#endif

// This enables lots of debug output and changes the serial bit rate. This
// is normally only used by hardcore developers
//#define DEVELOP_VERSION
#ifdef DEVELOP_VERSION
#define NODE_DEBUG
#define COAP_DEBUG
#endif /* DEVELOP_VERSION */

#define BIT_RATE_DEFAULT BIT_RATE_115200

// This enables automatic baud rate detection at startup
#define BIT_RATE_AUTOBAUD

#define NODE_ERROR

#ifdef NODE_DEBUG
#define NODE_DBG dbg_printf
#else
#define NODE_DBG
#endif /* NODE_DEBUG */

#ifdef NODE_ERROR
#define NODE_ERR dbg_printf
#else
#define NODE_ERR
#endif /* NODE_ERROR */

#define GPIO_INTERRUPT_ENABLE
#define GPIO_INTERRUPT_HOOK_ENABLE
// #define GPIO_SAFE_NO_INTR_ENABLE

#define ICACHE_STORE_TYPEDEF_ATTR __attribute__((aligned(4),packed))
#define ICACHE_STORE_ATTR __attribute__((aligned(4)))
#define ICACHE_RAM_ATTR __attribute__((section(".iram0.text")))
#ifdef GPIO_SAFE_NO_INTR_ENABLE
#define NO_INTR_CODE ICACHE_RAM_ATTR __attribute__ ((noinline))
#else
#define NO_INTR_CODE inline
#endif

// SSL buffer size used only for espconn-layer secure connections.
// See https://github.com/nodemcu/nodemcu-firmware/issues/1457 for conversation details.
#define SSL_BUFFER_SIZE 6178

#define CLIENT_SSL_ENABLE
//#define MD2_ENABLE
#define SHA2_ENABLE

#define BUILD_SPIFFS
#define SPIFFS_CACHE 1

//#define BUILD_FATFS

// maximum length of a filename
#define FS_OBJ_NAME_LEN 31

// maximum number of open files for SPIFFS
#define SPIFFS_MAX_OPEN_FILES 4

// Uncomment this next line for fastest startup
// It reduces the format time dramatically
// #define SPIFFS_MAX_FILESYSTEM_SIZE 32768
//
// You can force the spiffs file system to be at a fixed location
// #define SPIFFS_FIXED_LOCATION 0x100000
//
// You can force the SPIFFS file system to end on the next !M boundary
// (minus the 16k parameter space). THis is useful for certain OTA scenarios
// #define SPIFFS_SIZE_1M_BOUNDARY

// #define LUA_NUMBER_INTEGRAL

#define READLINE_INTERVAL 80
#define LUA_TASK_PRIO USER_TASK_PRIO_0
#define LUA_PROCESS_LINE_SIG 2
#define LUA_OPTIMIZE_DEBUG 2

#define ENDUSER_SETUP_AP_SSID "konnected"

/*
* A valid hostname only contains alphanumeric and hyphen(-) characters, with no hyphens at first or last char
* if WIFI_STA_HOSTNAME not defined: hostname will default to NODE-xxxxxx (xxxxxx being last 3 octets of MAC address)
* if WIFI_STA_HOSTNAME defined: hostname must only contain alphanumeric characters
* if WIFI_STA_HOSTNAME_APPEND_MAC not defined: Hostname MUST be 32 chars or less
* if WIFI_STA_HOSTNAME_APPEND_MAC defined: Hostname MUST be 26 chars or less, since last 3 octets of MAC address will be appended
* if defined hostname is invalid: hostname will default to NODE-xxxxxx (xxxxxx being last 3 octets of MAC address)
*/
#define WIFI_STA_HOSTNAME "konnected-"
#define WIFI_STA_HOSTNAME_APPEND_MAC

//#define WIFI_SMART_ENABLE

#define WIFI_SDK_EVENT_MONITOR_ENABLE
#define WIFI_EVENT_MONITOR_DISCONNECT_REASON_LIST_ENABLE

////#define ENABLE_TIMER_SUSPEND
//#define PMSLEEP_ENABLE


#define STRBUF_DEFAULT_INCREMENT 32

#endif /* __USER_CONFIG_H__ */
Loading

0 comments on commit 8c53c98

Please sign in to comment.