Power consumption

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
Sasch600xt
Normal user
Posts: 164
Joined: 10 Sep 2018, 16:37

Power consumption

#1 Post by Sasch600xt » 08 Jul 2019, 13:28

Hello all,

i have an ESP8266 with 2x DS18b20 temp sensors running.

At the moment i get every minute new data.

Problem is, the device is running on battery and my solarpanel does not charge enough on cloudy days.
So i search for a solution to get the power consumption down.

it would be fine to get every 2 or even every 5 minutes datas from the DS18b20.
Is there a way to put the device in sleep, automaticly wake up every 5 minutes, connect to AP and send data ?

Thank you so much for help :)
have a great day
Sascha
"the flat earth society has members all around the globe"

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Power consumption

#2 Post by TD-er » 08 Jul 2019, 14:44

There is a sleep mode possible.
For this you need to connect GPIO-16 with the RST pin on the ESP to make it able to wake itself.
This also means you cannot use GPIO16 for anything else. (or else the unit will reset)

You can set the sleep period in the advanced settings.

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: Power consumption

#3 Post by dynamicdave » 08 Jul 2019, 15:01

Hi,
I'm working with one of my IoT students on a similar project.

Here's a link...
https://discourse.nodered.org/t/solar-p ... tion/12499

Do you really need to report the readings that often???

As an experiment, we've been doing it every 15-mins for over a week running off of the solar-panel.

Today we changed the frequency to every 10-mins, so it will be interesting to see if the solar-panel and the Li-Ion battery manage this time.

User avatar
Sasch600xt
Normal user
Posts: 164
Joined: 10 Sep 2018, 16:37

Re: Power consumption

#4 Post by Sasch600xt » 08 Jul 2019, 15:33

thank you, it works perfect !!!

But settings was at "Config" tab i assume.

in Advanced was another option called "CPU Eco Mode"

Would that help also additional to sleep settings ?

Sascha
"the flat earth society has members all around the globe"

User avatar
Sasch600xt
Normal user
Posts: 164
Joined: 10 Sep 2018, 16:37

Re: Power consumption

#5 Post by Sasch600xt » 08 Jul 2019, 15:37

@ dynamicdave:

yes, your right, i will match the data period to my solarpanel :)

at the moment i did settings 300s sleep and 20s awake time.

i choose 20s awake time so i have a chance to reach the cotroller every 5 minutes and do some changes to the settings :)

How do you reach the controller to change settings ?
is there another trick ?

Sascha
"the flat earth society has members all around the globe"

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: Power consumption

#6 Post by dynamicdave » 08 Jul 2019, 15:51

We used a set of rules that get triggered when the Wemos comes out of deepsleep.
Take a few readings, publish them via MQTT to Node-RED, then go back to sleep by using the sleep command set to 900 (seconds).

If you are interested, I'll be at the school tomorrow and can get the student to copy his 'rule-sets' to a text-file.

User avatar
Sasch600xt
Normal user
Posts: 164
Joined: 10 Sep 2018, 16:37

Re: Power consumption

#7 Post by Sasch600xt » 08 Jul 2019, 15:54

that would be awesome !

also nice info would be:

- size of solarmodul
- how much watts you get out of the panel
- typ of battery
- how much mAh the battery has

thank you :)
"the flat earth society has members all around the globe"

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: Power consumption

#8 Post by dynamicdave » 08 Jul 2019, 18:30

Physical size of solar panel is 95mm by 95mm.
It's a 5V, 1 watt panel that we bought from Banggood in China.

The battery is a Li-Ion rated at 3.7V, 2500mAh (again from Banggood).

Couple of things to point out about our set-up...

We configured switches on D5 and D6 and an output on D7.

D5 defines whether to publish the sensor readings to ThingSpeak or not.
If D5 = 1, publish, if D5 = 0, don't publish
The system always publishes to Node-RED via MQTT, but can optionally also publish to ThingSpeak.

D6 defines whether the Wemos or Node-RED controls the deepsleep action.
If D6 = 1, Wemos invokes deepsleep, if D6 = 0, Node-RED controls it.
This is really useful as Node-RED can send an 'event command' to the Wemos to prevent it going back into 'deepsleep' when it wakes up.
We use it to enable us to log-in to the Wemos and make adjustments, then put it back to sleep.

D7 (output) drives the base of a Bipolar Junction Transisitor which in turn operates a MosFET.
This arrangement is used to turn the power (+3v3) on/off to the auxilary devices (in our case a BME280 which reads temp, humidity and pressure).

This is Rule-Set-1

Code: Select all

// Link D0 and RST for wake-up at the end of DeepSleep
//
// D5 is used to select whether to publish to ThingSpeak or not
// D5=1 (pulled-hi) Do-not publish to ThingSpeak
// D5=0 (grounded)  Do publish to ThingSpeak
//
// D6 is used as an input to sense the operating mode
// D6=1 (pulled-hi)  Wemos invokes DeepSleep
// D6=0 (grounded) Node-RED invokes DeepSleep
//
// D7 connects to the base of a BJT
// which in turn connects to the gate of a P-channel MOSFET to power the AUX devices
//    Logic '0' turns BJT 'off'
//    Logic '1' turns BJT 'on'


on MQTT#Connected do
   TaskValueSet,1,3,0    //Set wemos#donotsleep=0
   TaskValueSet,1,2,600  //Set wemos#fixedsleeptime to 15 minutes

   gpio,13,1     //Set D7 to logic '1' to turn BJT 'on' 

   timerSet,1,6  //Delay for 6 secs to allow AUX devices to become active
                 //and take a couple of readings
endon

on Rules#Timer=1 do
   event publishReadings   //Rule Set 2
   timerSet,2,3  // Allow 3 sec for Node-RED to send 'event,doNotSleep=1'   
endon

on Rules#Timer=2 do
   if [switch_d6#sw_d6]=1 and [wemos#donotsleep]=0

      gpio,13,0  //Set D7 to logic '0' to turn BJT 'off'

      timerSet,3,1  //1 second delay then go in to DeepSleep
   endif  

endon


on Rules#Timer=3 do
   deepsleep,[wemos#fixedsleeptime]
endon

on Rules#Timer=4 do
   deepsleep,[wemos#sleeptime]
endon

on SampleThenSleep do
      
      TaskValueSet,1,1,%eventvalue1%  //Set wemos#sleeptime from %eventvalue1%

      event publishReadings  //Rule Set 2
      
      if [wemos#sleeptime]>0
         timerSet,4,3  //Delay for 1sec then go in to DeepSleep
      endif   

endon

on doNotSleep do
   TaskValueSet,1,3,%eventvalue1%  //Set wemos#donotsleep from %eventvalue1%
endon
This is Rule-Set-2

Code: Select all

on publishReadings do
  publish weatherStation/reading,{"node_type":"wemos_D1_min","ssid":"%ssid%","ip_address":"%ip%","wifi_strength":[sysinfo#strength],"solar_panel":[analog_3#a3],"lion_battery":[analog_2#a2],"supply_to_wemos":[analog_1#a1],"wemos_3v3_supply":[analog_0#a0],"temperature":[bme280#temperature],"humidity":[bme280#humidity],"pressure":[bme280#pressure]}  

   if [switch_d5#sw_d5]=1
     SendToHTTP api.thingspeak.com,80,/update?api_key=<your_API_key_goes_here>&field1=[bme280#temperature]&field2=[bme280#humidity]&field3=[bme280#pressure]
     SendToHTTP api.thingspeak.com,80,/update?api_key=<your_API_key_goes_here>&field1=[analog_3#a3]&field2=[analog_2#a2]&field3=[analog_1#a1]&field4=[analog_0#a0]
   endif
endon
Here's a screenshot of the 'Devices' tab inside the Wemos.

At the moment we are using an ADS1115 (analog switch) to monitor and report the voltage of the solar panel, the voltage of the battery and the value of the +3V3 rail/pin.

We are also using a MQTT broker on the cloud (beebotte.com) as the student and I wanted to be able to monitor the readings at the weather station from home.

'SampleThenSleep' and 'doNotSleep' are event-commands sent from Node-RED to manipulate the operational mode of the Wemos.

Hope you can 'hack' the above around to suit your needs.

Let me know if you need any further information.

Regards, David.
ScreenShot123.png
ScreenShot123.png (65.49 KiB) Viewed 30444 times
Last edited by dynamicdave on 14 Jul 2019, 20:38, edited 1 time in total.

User avatar
Sasch600xt
Normal user
Posts: 164
Joined: 10 Sep 2018, 16:37

Re: Power consumption

#9 Post by Sasch600xt » 08 Jul 2019, 20:37

WOW !!!

this is so helpful !!!

Thank you for sharing :)

is your panel maybe this one ?
https://www.amazon.de/gp/product/B072LX ... UTF8&psc=1

i was thinking about an resistor divider to messure battery voltage by using the analog input.
So i could monitor the battery aswell.


May i ask you about the different between deepsleep and "online, sending data" for power consumption in mA ?
that would be very intresting for me. So i could do a little math with my battery here.

And sorry about my "creative" way of english typing :)

Greetings from good old germany :)
Sascha
"the flat earth society has members all around the globe"

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: Power consumption

#10 Post by dynamicdave » 08 Jul 2019, 21:36

This is the one I bought from Banggood in China.

Took a couple of weeks delivery, but worth the wait.

https://www.banggood.com/5_5V-1W-180mA- ... rehouse=CN

I used a resistor divider network consisting of two 10K ohms resistors in series.
The mid-point tap goes to an input on the ADS115

Wiki
Normal user
Posts: 413
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Power consumption

#11 Post by Wiki » 09 Jul 2019, 11:30

Based on this post of ligeza I did some rough research on optimizing power consumption of a wemos D1 and posted the details of modifications and results here.

After these modifications using just one 2800 mAh Liion battery gives a battery cycle of up to 70-90 days publishing the data of a BMP280 every 300 sec.

Using a 6V 1W solar panel attached to a TP4056 and one 2800 mAh Liion battery will result in an endless runtime of the installation, I suspect at least limited only by the lifetime of the battery.

To make the battery easily changeable I have put the TP4056 together with the battery into this housing, connected with these plugs directly to the Wemos.

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Power consumption

#12 Post by TD-er » 09 Jul 2019, 14:36

Things you can do to increase battery life:
- Select "ECO mode" in the advanced settings
- Set a low enough "awake time" to prevent endless reconnect attempts in bad conditions
- Disable any existing USB-serial adapter (also mentioned in the link posted by dynamicdave)
- Use a FET with low quiescent current to switch on any sensor (does take an extra GPIO pin from the ESP to trigger the FET)
- Use a larger resistor in series with the onboard 100k resistor for measuring voltage. This will decrease resolution of the measured voltage but will lower the stand-by current.
- Use static IP address (DHCP may need 3 - 5 seconds)
- Switch to B/G network (is just a hunch, should be tested)
- Make sure controller settings do not have to wait for a confirmation
- Set the unit to go to sleep from the rules as soon as possible



Things I still need to do:
- Allow to switch on/off WiFi in rules
- Store last used WiFi channel + BSSID in RTC memory to speed up WiFi reconnect after deep sleep (can reduce connect time from 2.5 - 3 seconds now to 100 - 200 msec in optimal scenario)
- Allow to disable RF calibration at start of WiFi. (does take a huge peak current and is only needed when conditions have changed (temp/voltage))

When setting WiFi state from rules, you can also do stuff like check battery at boot and go to sleep if it is too low, to prevent destroying the battery.
It also allows to take a number of samples and send them in a single run. (storing data in the RTC memory)
This last part is part of the new features I am working on for the "cache controller". That one stores data in RTC memory and as soon as that's full it does save to flash.
The idea is that it could be sent later when there is a network connection.

User avatar
Sasch600xt
Normal user
Posts: 164
Joined: 10 Sep 2018, 16:37

Re: Power consumption

#13 Post by Sasch600xt » 09 Jul 2019, 18:15

sounds great !!!

:)

Thank you for the sneak preview :)

have a great day
Sascha
"the flat earth society has members all around the globe"

Wiki
Normal user
Posts: 413
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Power consumption

#14 Post by Wiki » 09 Jul 2019, 20:56

TD-er wrote: 09 Jul 2019, 14:36 [...]
- Disable any existing USB-serial adapter (also mentioned in the link posted by dynamicdave)
- Use a FET with low quiescent current to switch on any sensor (does take an extra GPIO pin from the ESP to trigger the FET)
[...]
Disconnecting the USB-serial adapter is one of the most effective way to save energy - lowering the quiescent current of the board from somewhat 5mA down to few µA. Tipp: just unsolder carefully the GND pin of the adapter, leave the rest untouched. So you will be able to reanimate the adapter lateron if needed.
(Btw.: the link wasn't dynamicdave but Wiki ;) )
Switching the power source of the sensors is the other effective point, in most cases a simple BC337 works perfectly. More simplicity: i.e. a single BMP280 sensor could be driven directly by using a free GPIO pin as power source - pull down resistor required.

@TD-er: I don't agree that setting the device to Eco mode will have a positive effect. If I understood right (please correct me, if I am wrong), it will take place after 10 secs. of cpu idle. If you can't lower the awake time under 10 secs in your project I assume that you need some kind of communication beside of publishing some data and in eco mode there is a theoretical risk of missing some requests/infos from the outer world....

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Power consumption

#15 Post by TD-er » 14 Jul 2019, 19:50

I agree with your last statement.
If the node is using deep sleep, it will not be the best choice to use eco mode.
If the unit is idle running for most of the time, the ECO mode may help reducing power.

garnold
Normal user
Posts: 93
Joined: 17 Jun 2019, 03:59

Re: Power consumption

#16 Post by garnold » 19 Jul 2019, 13:07

Something I'm trying to understand is, would a solar powered phone charger do the job here? I'm looking to do the same thing (create a weather logger) and thought that using one of these water proof solar powered phone chargers would be a great way to go.

Let's take this one for an example.
https://www.amazon.com/dp/B078RQH9WK/re ... mDbMN8GBBJ

It is waterproof, will recharge the battery from the sun and has 20000mAh. Wouldn't this just be a simplest and best option? That's a whole lot of power and should keep a Wemos D1 Mini going for quite some time all by itself correct? So if you toss in the solar charging feature wouldn't this be perfect?

Since I'm not to advanced in this hobby yet I'm looking for easy solutions to help make my IoT projects work. Can I please get some feedback on why this might not be a good option for both me and the original poster's needs?

Thank you very much!

happytm
Normal user
Posts: 107
Joined: 15 Aug 2016, 17:53

Re: Power consumption

#17 Post by happytm » 19 Jul 2019, 18:23

More affordable option is to build that charger device for cheap from parts like :

https://www.ebay.com/itm/6V-2W-0-35A-80 ... 2749.l2649

https://www.ebay.com/itm/10PCS-TP4056-M ... Swo4pYQR2U

Couple of Li-Ion batteries.

Thanks

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Power consumption

#18 Post by TD-er » 19 Jul 2019, 20:06

I don't know if those power bank things have proper discharge protection.
Some of these only detect "activity" above a minimal current.
Meaning it may deplete the cells via very low discharge currents.

garnold
Normal user
Posts: 93
Joined: 17 Jun 2019, 03:59

Re: Power consumption

#19 Post by garnold » 19 Jul 2019, 20:10

happytm wrote: 19 Jul 2019, 18:23 More affordable option is to build that charger device for cheap from parts like :

https://www.ebay.com/itm/6V-2W-0-35A-80 ... 2749.l2649

https://www.ebay.com/itm/10PCS-TP4056-M ... Swo4pYQR2U

Couple of Li-Ion batteries.

Thanks
I hear ya, but to keep things simple and not have to also create the waterproof case for everything I'm cool with spending the extra money and get the project done. Still, if it just won't work that is a completely different story :-(

garnold
Normal user
Posts: 93
Joined: 17 Jun 2019, 03:59

Re: Power consumption

#20 Post by garnold » 19 Jul 2019, 20:12

TD-er wrote: 19 Jul 2019, 20:06 I don't know if those power bank things have proper discharge protection.
Some of these only detect "activity" above a minimal current.
Meaning it may deplete the cells via very low discharge currents.
That is a very valid concern. I do have some chargers at home that actually will not even power the Wemos D1 Mini because when plugged in the current is so low that the charger does not detect it and will not supply power. I guess that's something else to take into consideration. :roll:

happytm
Normal user
Posts: 107
Joined: 15 Aug 2016, 17:53

Re: Power consumption

#21 Post by happytm » 19 Jul 2019, 20:18

Very informative video about the subject is linked below:

https://www.youtube.com/watch?v=joAkJ9QA2bw

Thanks

happytm
Normal user
Posts: 107
Joined: 15 Aug 2016, 17:53

Re: Power consumption

#22 Post by happytm » 19 Jul 2019, 20:33

In above video he have solution which is cheap and you need to change only 1 resistor. ESP32 lasts 30 hours without sun according to his calculation.ESP8266 would last probably the same time or little more. As he explained many battery bank do not allow charging/discharging at the same time so they are useless for solar application.

Thanks

garnold
Normal user
Posts: 93
Joined: 17 Jun 2019, 03:59

Re: Power consumption

#23 Post by garnold » 19 Jul 2019, 20:46

Thank you for that video link. I'm a big fan of his content and that video was very helpful! It might just be the best bet to go.

happytm
Normal user
Posts: 107
Joined: 15 Aug 2016, 17:53

Re: Power consumption

#24 Post by happytm » 19 Jul 2019, 20:58

This video just came out and it shows perfect device if source is supplied with solar panel:

https://www.youtube.com/watch?v=sXZJhWpGHYU

https://www.ebay.com/itm/60000lm-LED-He ... 723a9c9db7

Thanks

garnold
Normal user
Posts: 93
Joined: 17 Jun 2019, 03:59

Re: Power consumption

#25 Post by garnold » 22 Jul 2019, 00:27

Thank you

I tried the link to the details but I don't think it's working?

Wiki
Normal user
Posts: 413
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Power consumption

#26 Post by Wiki » 22 Jul 2019, 12:35

Just scroll up to my original post #11 and use the original link. Don't know what irfanaslam did to change the original link....

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

Wiki
Normal user
Posts: 413
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Power consumption

#27 Post by Wiki » 16 Jul 2020, 12:34

No problem at all. End of january I reduced the awake time from ten to five seconds. Up to now I never had to climb up to recharge the battery. Have a look at the voltage readings:
sunny.JPG
sunny.JPG (29.17 KiB) Viewed 20066 times

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Power consumption

#28 Post by TD-er » 16 Jul 2020, 12:48

@wiki
What size and power has your solar module?
Apart from the less hours of sunlight in winter, there is also a temperature issue that will lower the battery voltage.
Voltage car battery during day/night
Voltage car battery during day/night
Car_battery_day_night.png (109.69 KiB) Viewed 20063 times
This is the voltage of my car battery during the day and night and the temperature difference is clearly attributing to the measured voltage.
On the 13th the recorded min and max. temp differ 15 degree C.

N.B. the spikes is something I'm also working on and is related to the effect of WiFi on the ADC of the ESP.

Wiki
Normal user
Posts: 413
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Power consumption

#29 Post by Wiki » 17 Jul 2020, 15:28

Details: Click

7-days of my weather stations battery voltage:
Akku.JPG
Akku.JPG (36.57 KiB) Viewed 20003 times

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

User avatar
LisaHamiltonEu
New user
Posts: 2
Joined: 14 Jul 2020, 11:58

Re: Power consumption

#30 Post by LisaHamiltonEu » 20 Jul 2020, 14:07

Great thread, thank you for sharing useful ideas!

Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests