💬 Battery Powered Sensors
-
VCC pin is directly connected to the MCU.
The RAW or IN pin is connected to the regulator input. Th eregulator output is connected to VCC pin and thus to the MCU power input pin.
On a 3V3 promini you can give between 3V3 and 12V (on most promini's, some can handle up to 16V) on the RAW or IN pin. The regulator on the promini will bring that down to 3V3 (which you will be able to measure on the VCC pin).
By giving 3V3 on the VCC pin, some power is lost via the output pin of the regulator (through the regulator) towards the GND pin of the regulator. This should be minimal, but on bad regulators it can be enough to drain a battery in weeks. So yes, I would cut the regulator output line when giving power via VCC.
Cutting the line of the powerLED (on either side of it, doesn't matter) will make sure that the LED does not drain the battery either. This LED can pull between 5 -15mA depending on the protection resistor that sits in series with it.
So VCC pin and RAW pin are NOT the same.
@GertSanders Thanks for you explanation. I thought vvc on the short end next to rx was going through the voltage regulator just as RAW. Anyhow I have already de-soldered the LED's and are powering through vcc next to A3. Apparently my voltage regulators are bad so I'll cut the lines and give it a try and hope power consumption stays low.
-
I'll answer myself - no, the Vcc lib is not realiable :) I had a sensor that died yesterday and it reported 100% battery until the end...
@maghac The Vcc library is reliable. It uses the internal 1.1 v reference of the MCU to measure the voltage on the Vcc pin. If your sensor keeps reporting 100% I guess you either power the arduino through a regulator (or the raw pin) or missed something in the Vcc initialisation/ calibration.
-
Do you think that the use of a piezo electric switch is possible ?
I found one that deliver 24v and 0,2A... The goal would be to create wireless switch...@aclertant Interesting idea... Energy harvesting with piezo-electric components is certainly possible. From MySensors point of view the energy (very very little) has to be stored and boosted to power the radio and mcu for message processing. There are a few examples of "harvesting" remotes (i.e. Philips HUE) but I am not sure if these use a piezo element.
-
I removed the both the LED and the Voltage Regulator of an Arduino pro min 3.3v . The simple sketch on it's own works fine. However when I connect an NRF24L01 it does not communicate back to the gateway.. :(
-
Do you think that the use of a piezo electric switch is possible ?
I found one that deliver 24v and 0,2A... The goal would be to create wireless switch... -
Like all commercial products they cost because they have been developed, tested and produced. So it's up to you if you want to spend time tinkering or go with an already working solution :-)
-
You see, enocean protocol has been developed from the start to be used with devices that use energy harvesting, so you can't think to use general purpose HW (like esp8266, FRF24, Arduino boards) that is not optimized very low power consumption (look at all the mods required to make a mini pro last months on battery with a reed switch and a nrf24 module); with piezo-electric components the amount of energy is really really tiny so you need super optimized HW to work with that.
The link you posted is about something that works on a ESP8266 but that works over wifi, that is for sure not the best energy efficient system. -
There is a much more efficient way (and cost-less) to measure VBATT :
https://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/
It doesn't need any external resistor, so there will be no current flowing even when the Atmega is asleep. -
There is a much more efficient way (and cost-less) to measure VBATT :
https://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/
It doesn't need any external resistor, so there will be no current flowing even when the Atmega is asleep. -
@AWI Ahh Sorry ! Didn't seen the comment !
I thought it was never mentioned since the how-to still refers to resistor divider method (which is, IMO a bad method since it will draw current...)
I'll have a look at Yveaux's lib. -
I have used resistor ( 470K+1M ) to measure the voltage on a 5 minute interval. The Soil sensor is out in the garden where the container housing the arduino pro min gets exposed to sun. The voltage reading is high during 1 PM to 4 PM, when its under the sun. I am not sure if this is because of the heat.

The code is given below. Please note I multiply my actual voltage with calibration variable. however during the high voltage time the calibration variable does not seem to work.
- Battery powers the soil sensor.
- The voltage regulator has been removed.
- MCU powered using vcc pin.
//#define MY_DEBUG #define MY_RF24_PA_LEVEL RF24_PA_LOW #define MY_BAUD_RATE 38400 #define MY_RADIO_NRF24 #define VIEW_READING #include <MySensors.h> #include <SPI.h> #include <math.h> #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) #define N_ELEMENTS(array) (sizeof(array)/sizeof((array)[0])) #define NUM_READS 10 #define CHILD_ID_MOISTURE 0 #define CHILD_ID_BATTERY 1 #define SLEEP_TIME 300000//10000 // Sleep time between reads (in milliseconds), was 10000 #define STABILIZATION_TIME 500 // Let the sensor stabilize before reading default BOD settings #define VOLTAGE_PIN A0 int index; long buffer[NUM_READS]; const long Known_Resistor = 4700; /// @brief Structure to be used in percentage and resistance values matrix to be filtered (have to be in pairs) typedef struct { int moisture; //!< Moisture long resistance; //!< Resistance } values; MyMessage soil_msg(CHILD_ID_MOISTURE, V_LEVEL); MyMessage voltage_msg(CHILD_ID_BATTERY, V_VOLTAGE); void presentation() { sendSketchInfo("Soil Moisture", "2.0"); present(CHILD_ID_MOISTURE, S_MOISTURE); present(CHILD_ID_BATTERY, S_MULTIMETER); } void setup() { pinMode(6, OUTPUT); pinMode(7, OUTPUT); digitalWrite(6, LOW); digitalWrite(7, LOW); } void loop() { //float dryLevel = readNoMoisture(); long moistureLevel = readAggSoilMoisture(); //float coeff = 100.00 / float(dryLevel); float voltage = readVoltage() * 1.57368; float batteryPcnt = voltage / 3.3 * 100; #ifdef VIEW_READING Serial.print("--Voltage:"); Serial.println(voltage); Serial.print("--Battery %:"); Serial.println(batteryPcnt); Serial.print("--Soil Sensor value:"); Serial.println(moistureLevel ); #endif send(soil_msg.set(moistureLevel, 1)); sendBatteryLevel(batteryPcnt); send(voltage_msg.set(voltage, 3), 1); sleep(SLEEP_TIME); } float readVoltage() { analogReference(INTERNAL); fakeRead(VOLTAGE_PIN); int sensorValue = analogRead(VOLTAGE_PIN); float voltage = sensorValue * 0.003363075; analogReference(DEFAULT); fakeRead(VOLTAGE_PIN); return voltage; } void fakeRead(int pin) { for (int counter = 0; counter < 5; counter++) { analogRead(pin); delay(STABILIZATION_TIME); } } // Averaging algorithm void addReading(long resistance) { buffer[index] = resistance; index++; if (index >= NUM_READS) { index = 0; } } long average() { long sum = 0; for (int i = 0; i < NUM_READS; i++) { sum += buffer[i]; } return (long)(sum / NUM_READS); } int readAggSoilMoisture() { measureRawSoilMoisture(6, 7, A1); long read1 = average(); measureRawSoilMoisture(7, 6, A2); long read2 = average(); long sensor1 = (read1 + read2) / 2; return int( ((sensor1 / (float)Known_Resistor) * 100.00)); } void measureRawSoilMoisture (int phase_b, int phase_a, int analog_input) { // read sensor, filter, and calculate resistance value // Noise filter: median filter for (int i = 0; i < NUM_READS; i++) { // Read 1 pair of voltage values digitalWrite(phase_a, HIGH); // set the voltage supply on delayMicroseconds(25); int supplyVoltage = analogRead(analog_input); // read the supply voltage delayMicroseconds(25); digitalWrite(phase_a, LOW); // set the voltage supply off delay(1); digitalWrite(phase_b, HIGH); // set the voltage supply on delayMicroseconds(25); int sensorVoltage = analogRead(analog_input); // read the sensor voltage delayMicroseconds(25); digitalWrite(phase_b, LOW); // set the voltage supply off // Calculate resistance // the 0.5 add-term is used to round to the nearest integer // Tip: no need to transform 0-1023 voltage value to 0-5 range, due to following fraction long resistance = abs(Known_Resistor * (supplyVoltage - sensorVoltage ) / sensorVoltage) ; delay(1); delay(STABILIZATION_TIME); addReading(resistance); } } -
Using voltage divider still might be necessary if you don't have battery directly connected to the MCU VCC, for example using step-up/down regulator to power the MCU. In this case you still can use a voltage divider and have a P+N Mosfet to control the current going through the voltage divider, so no leak to ground.
In practical terms you basically use another GPIO to enable or disable it the Mosfet when needed. I saw that on the Whisper Node board I'm using and seems to be effective (reference: https://bitbucket.org/talk2/whisper-node-avr#markdown-header-voltage-monitor)... In any case using high value resistors (over 100K) will reduce any current draw. Finally a small capacitor can be used to stabilize the voltage.
-
I have a DHT11 + NRF24L01 + Pro Mini 3.3v 8Mhz
All is working fine when on usb cable.. but it fails when connected to 2x 1.5 AA batteries..
what could be wrong ?