Connect NodeMCU to power supply(battery)

Hello everyone, how to connect ESP8266(NodeMCU) to power supply(battery)? I'm using BATT -BT3 for the battery


What is that? Please post its technical data.

It looks like a box for 3x AA or AAA.

Normally it would be ok to connect this to the Vin pin of NodeMCU. However, I think I see a gas sensor of some kind in the photo and these can consume a lot of current. If the circuit draws a lot of current at 5V from the NodeMCU, there is a danger of the on-board regulator overheating.

Also, many gas sensors run at 5V, so your battery box may not provide sufficient voltage. The NodeMCU is a 3.3V device, so signals from the sensor must be reduced from 5V to 3.3V to avoid damaging the ESP pins.

I would recommend using a 4x AA box for this. If you use only NiMH cells, the voltage will be close enough to 5V that you won't need a regulator for the gas sensor (you will still need to use Vin pin of the NodeMCU).

Please post a schematic and links to the specs of all components. You should always do this when asking a question on the forum.

Really sorry about that.

I’m doing my ioT project, which is a gas leak detector that uses the ESP8266 microcontroller(nodeMCU) and the Blynk IoT platform to notify the user of potential gas leaks.

I chose to base my final IoT project on this gas leakage monitoring system from (https://srituhobby.com/iot-based-gas-leakage-monitoring-system/ )

I used breadboard, nodeMCU, Mq2 sensor, active buzzer, led(green, red), 180-ohm resistor, jumper wires and BATT -BT3 for the battery




This is the code:

#define BLYNK_TEMPLATE_ID "xxxxxxxxxxxx"
#define BLYNK_DEVICE_NAME "xxxxxxxxxxxx"
#define BLYNK_AUTH_TOKEN "xxxxxxxxxxxx"

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char ssid[] = "xxxxxxxxxxxx";
char pass[] = "xxxxxxxxxxxx";

BlynkTimer timer;
int pinValue = 0;

#define Buzzer D5
#define Green D6
#define Red D7
#define Sensor A0

int sensor_threshold = 50;
bool alert_sent = false;

void setup() {
  Serial.begin(9600);
  pinMode(Green, OUTPUT);
  pinMode(Red, OUTPUT);
  pinMode(Buzzer, OUTPUT);
  pinMode(Sensor, INPUT);
  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
  timer.setInterval(1000L, notification);
  }

BLYNK_WRITE(V0) {
  pinValue = param.asInt();
}

void notification() {
  int sensor = analogRead(Sensor);
  Serial.print("Temperature    = ");
  Serial.println(sensor);
  Serial.println();

  Blynk.virtualWrite(V1, sensor);
  
  if (sensor > sensor_threshold && alert_sent == false) {
    digitalWrite(Green, HIGH);
    digitalWrite(Red, LOW);
    digitalWrite(Buzzer, LOW);
    Blynk.logEvent("gas_leak_detected",  String("The temperature is ") + Sensor);
    Serial.println("High temperature alert!");
    Serial.println("Blynk Alert Notification sent!");
    Serial.println();
    alert_sent = true;
    
    } else if (sensor <= sensor_threshold && alert_sent == true) {
      Serial.println("Temperature back to normal");
      Serial.println();
      alert_sent = false;
    }
  }
  
  void loop() {
    Blynk.run();
    timer.run();
  }

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.