Added TTGO-T-Beam board + option to send ADC values in volt (#863)
* Added Voltage measure option * Added TTGO Beam with Battery voltage measure
This commit is contained in:
1 parent
67823d22af
commit
14fedfdf53
2 files changed
+53
No files matched your search
@@ -54,10 +54,32 @@ void MeasureADC() {
|
|||||||
} else {
|
} else {
|
||||||
if (val >= persistedadc + ThresholdReadingADC || val <= persistedadc - ThresholdReadingADC) {
|
if (val >= persistedadc + ThresholdReadingADC || val <= persistedadc - ThresholdReadingADC) {
|
||||||
Log.trace(F("Creating ADC buffer" CR));
|
Log.trace(F("Creating ADC buffer" CR));
|
||||||
|
# if defined(ADC_DIVIDER)
|
||||||
|
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(2);
|
||||||
|
# else
|
||||||
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(1);
|
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(1);
|
||||||
|
# endif
|
||||||
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
|
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
|
||||||
JsonObject& ADCdata = jsonBuffer.createObject();
|
JsonObject& ADCdata = jsonBuffer.createObject();
|
||||||
ADCdata.set("adc", (int)val);
|
ADCdata.set("adc", (int)val);
|
||||||
|
# if defined(ADC_DIVIDER)
|
||||||
|
float volt = 0;
|
||||||
|
# if defined(ESP32)
|
||||||
|
// Convert the analog reading (which goes from 0 - 4095) to a voltage (0 - 3.3V):
|
||||||
|
volt = val * (3.3 / 4096.0);
|
||||||
|
# elif defined(ESP8266)
|
||||||
|
// Convert the analog reading (which goes from 0 - 1024) to a voltage (0 - 3.3V):
|
||||||
|
volt = val * (3.3 / 1024.0);
|
||||||
|
# else
|
||||||
|
// Asume 5V and 10bits ADC
|
||||||
|
volt = val * (5.0 / 1024.0);
|
||||||
|
# endif
|
||||||
|
volt *= ADC_DIVIDER;
|
||||||
|
// let's give 2 decimal point
|
||||||
|
val = (volt * 100);
|
||||||
|
volt = (float)val / 100.0;
|
||||||
|
ADCdata.set("volt", (float)volt);
|
||||||
|
# endif
|
||||||
pub(ADCTOPIC, ADCdata);
|
pub(ADCTOPIC, ADCdata);
|
||||||
persistedadc = val;
|
persistedadc = val;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ extra_configs =
|
|||||||
;default_envs = esp32-m5stick-cp-ble
|
;default_envs = esp32-m5stick-cp-ble
|
||||||
;default_envs = esp32-m5atom
|
;default_envs = esp32-m5atom
|
||||||
;default_envs = ttgo-lora32-v1
|
;default_envs = ttgo-lora32-v1
|
||||||
|
;default_envs = ttgo-t-beam
|
||||||
;default_envs = nodemcuv2-rf
|
;default_envs = nodemcuv2-rf
|
||||||
;default_envs = nodemcuv2-rf-cc1101
|
;default_envs = nodemcuv2-rf-cc1101
|
||||||
;default_envs = nodemcuv2-somfy-cc1101
|
;default_envs = nodemcuv2-somfy-cc1101
|
||||||
@@ -497,6 +498,36 @@ build_flags =
|
|||||||
'-DZgatewayLORA="LORA"'
|
'-DZgatewayLORA="LORA"'
|
||||||
'-DGateway_Name="OpenMQTTGateway_ESP32_LORA"'
|
'-DGateway_Name="OpenMQTTGateway_ESP32_LORA"'
|
||||||
|
|
||||||
|
[env:ttgo-t-beam]
|
||||||
|
# See version pinout differences here
|
||||||
|
# https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436
|
||||||
|
platform = ${com.esp32_platform}
|
||||||
|
board = ttgo-t-beam
|
||||||
|
lib_deps =
|
||||||
|
${com-esp.lib_deps}
|
||||||
|
${libraries.ble}
|
||||||
|
${libraries.lora}
|
||||||
|
build_flags =
|
||||||
|
${com-esp.build_flags}
|
||||||
|
'-DZgatewayLORA="LORA"'
|
||||||
|
'-DZgatewayBT="BT"'
|
||||||
|
'-DGateway_Name="OpenMQTTGateway_ESP32_BLE_LORA"'
|
||||||
|
|
||||||
|
'-DLED_RECEIVE=21' # T-BEAM board V0.5
|
||||||
|
# '-DLED_RECEIVE=14' # T-BEAM board V0.7
|
||||||
|
# '-DLED_RECEIVE=4' # T-BEAM board V1.0+
|
||||||
|
'-DTimeLedON=0.05'
|
||||||
|
'-DLED_RECEIVE_ON=1' # Set 0 for board V1.0+
|
||||||
|
|
||||||
|
# for V0.5 and V0.7 ONLY (V1.0+ as onboard AXP202 dedicated chip, need driver)
|
||||||
|
# it's a 100K/100K divider (so 2 divider) and connected to GPIO35
|
||||||
|
'-DZsensorADC="ADC"'
|
||||||
|
'-DADC_GPIO=35'
|
||||||
|
'-DADC_DIVIDER=2'
|
||||||
|
# Reading battery level every minutes should be more than enought
|
||||||
|
'-DTimeBetweenReadingADC=60000'
|
||||||
|
|
||||||
|
|
||||||
[env:nodemcuv2-all-test]
|
[env:nodemcuv2-all-test]
|
||||||
platform = ${com.esp8266_platform}
|
platform = ${com.esp8266_platform}
|
||||||
board = nodemcuv2
|
board = nodemcuv2
|
||||||
|
|||||||
Reference in new issue
Block a user