diff --git a/esp32/.vscode/extensions.json b/esp32/.vscode/extensions.json index 0f0d740..080e70d 100644 --- a/esp32/.vscode/extensions.json +++ b/esp32/.vscode/extensions.json @@ -1,7 +1,10 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ] -} +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/esp32test/Esp32DeepSleepTest/.vscode/extensions.json b/esp32test/Esp32DeepSleepTest/.vscode/extensions.json index 0f0d740..080e70d 100644 --- a/esp32test/Esp32DeepSleepTest/.vscode/extensions.json +++ b/esp32test/Esp32DeepSleepTest/.vscode/extensions.json @@ -1,7 +1,10 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ] -} +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/esp32test/Esp32DeepSleepTest/platformio.ini b/esp32test/Esp32DeepSleepTest/platformio.ini index 46c5a12..c910f3b 100644 --- a/esp32test/Esp32DeepSleepTest/platformio.ini +++ b/esp32test/Esp32DeepSleepTest/platformio.ini @@ -14,4 +14,5 @@ board = esp32doit-devkit-v1 framework = arduino build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY lib_deps = OneWire - DallasTemperature \ No newline at end of file + DallasTemperature + \ No newline at end of file diff --git a/esp32test/Esp32DeepSleepTest/src/main.cpp b/esp32test/Esp32DeepSleepTest/src/main.cpp index a04df45..9d7d074 100644 --- a/esp32test/Esp32DeepSleepTest/src/main.cpp +++ b/esp32test/Esp32DeepSleepTest/src/main.cpp @@ -1,25 +1,33 @@ #include #include "driver/pcnt.h" -#define OUTPUT_SENSOR 14 /**< GPIO 16 - Enable Sensors */ -#define SENSOR_PLANT5 39 /**< SENSOR vn */ -#define SENSOR_PLANT6 36 /**< SENSOR VP */ +#define PWM_FREQ 50000 +#define PWM_BITS 8 + +#define OUTPUT_SENSOR 14 +#define SENSOR_PLANT 17 int16_t pulses = 0; int16_t pulses2 = 0; +int plantId = 0; + void setup() { Serial.begin(115200); pinMode(OUTPUT_SENSOR, OUTPUT); - pinMode(SENSOR_PLANT5, INPUT); + + ledcSetup(plantId, PWM_FREQ, PWM_BITS); + ledcAttachPin(SENSOR_PLANT, plantId); + ledcWrite(plantId, plantId); + pinMode(SENSOR_PLANT, INPUT); pcnt_config_t pcnt_config = { }; // Instancia PCNT config - - pcnt_config.pulse_gpio_num = SENSOR_PLANT5; // Configura GPIO para entrada dos pulsos + pcnt_unit_t unit = (pcnt_unit_t)(PCNT_UNIT_0 + plantId); + pcnt_config.pulse_gpio_num = SENSOR_PLANT; // Configura GPIO para entrada dos pulsos pcnt_config.ctrl_gpio_num = PCNT_PIN_NOT_USED; // Configura GPIO para controle da contagem - pcnt_config.unit = PCNT_UNIT_0; // Unidade de contagem PCNT - 0 + pcnt_config.unit = unit; // Unidade de contagem PCNT - 0 pcnt_config.channel = PCNT_CHANNEL_0; // Canal de contagem PCNT - 0 pcnt_config.counter_h_lim = INT16_MAX; // Limite maximo de contagem - 20000 pcnt_config.pos_mode = PCNT_COUNT_INC; // Incrementa contagem na subida do pulso @@ -34,11 +42,10 @@ void setup() { digitalWrite(OUTPUT_SENSOR, HIGH); - Serial.println("Start done"); + Serial.println("Nodemcu ESP32 Start done"); } void loop() { - pulses2 = pulseIn(SENSOR_PLANT5,HIGH); pcnt_counter_resume(PCNT_UNIT_0); delay(500); @@ -47,6 +54,5 @@ void loop() { pcnt_get_counter_value(PCNT_UNIT_0, &pulses); pcnt_counter_clear(PCNT_UNIT_0); - Serial.println(pulses2*2); Serial.println(pulses*2); } \ No newline at end of file