# Switch off devices attached to board to save energy

**URL:** <https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450>\
**Category:** End Devices (Nodes)\
**Created:** [October 3, 2019, 9:25am UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450 "2019-10-03T09:25:24Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Verkehrsrot](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/verkehrsrot/32/46588_2.png) [@Verkehrsrot](https://www.thethingsnetwork.org/forum/u/Verkehrsrot)\
**Post date:** [October 4, 2019, 6:09pm UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450/21 "2019-10-04T18:09:54Z")

</div>

That’s why i use the OLED powersave mode in the paxcounter software, not shutdown. Otherwise i2c bus will crash ☹

---

<div class="post-metadata">

**Author:** ![Sandgroper](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/sandgroper/32/46619_2.png) [@Sandgroper](https://www.thethingsnetwork.org/forum/u/Sandgroper)\
**Post date:** [October 7, 2019, 4:07pm UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450/22 "2019-10-07T16:07:08Z")

</div>

> [@TonySmith](#):
>
> Thanks @cslorabox I need to review my power management circuits as I may be wasting energy.
> 
> I just realised I forgot to mention I do power down the I2C pull-up resistors as well.

When you “power down” your pull-up resistors, are you isolating each resistor from the other such that they are not loading the I2C via the two resistors effectively being connected in series across the I2C bus?

---

<div class="post-metadata">

**Author:** ![TonySmith](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/tonysmith/32/46334_2.png) [@TonySmith](https://www.thethingsnetwork.org/forum/u/TonySmith)\
**Post date:** [October 7, 2019, 8:28pm UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450/23 "2019-10-07T20:28:22Z")

</div>

Good point.  
No my resistors are still tied together and still connected to Vcc of the sensor. I power down all the sensors and pull-up resistors by open circuiting power supply line with a high side mosfet. Leaving Vdd and SDA and SCL still connected to the processor.

---

<div class="post-metadata">

**Author:** ![cslorabox](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/cslorabox/32/35697_2.png) [@cslorabox](https://www.thethingsnetwork.org/forum/u/cslorabox)\
**Post date:** [October 8, 2019, 6:20am UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450/24 "2019-10-08T06:20:39Z")

</div>

> [@TonySmith](#):
>
> No my resistors are still tied together and still connected to Vcc of the sensor.

There’s nothing wrong with that, if you take both SDA and SCL low at the MCU. There would only be a problem if you kept them high, or too _only one_ of them low. A resistor without a voltage difference across it doesn’t turn electricity into heat.

---

<div class="post-metadata">

**Author:** ![tornadijo](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/tornadijo/32/35697_2.png) [@tornadijo](https://www.thethingsnetwork.org/forum/u/tornadijo)\
**Post date:** [October 8, 2019, 6:21am UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450/25 "2019-10-08T06:21:39Z")

</div>

Thanks, I’m still trying to manage AXP, but i still can’t initialize it, while, i have a doubt, if i disconnect ground pin of 5V device (such a accelerometer) instead VBUS pin, is more dangerous for board? Disconnecting VBUS, device still maintains power led on, but low intentisty, and device not work, perhaps is getting power from SCL and SDA pin and i think it is dangerous. But if i disconnect GND pin, device switchs off completely.

---

<div class="post-metadata">

**Author:** ![tornadijo](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/tornadijo/32/35697_2.png) [@tornadijo](https://www.thethingsnetwork.org/forum/u/tornadijo)\
**Post date:** [October 8, 2019, 7:25am UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450/26 "2019-10-08T07:25:17Z")

</div>

Thanks, i’ll buy a step-up voltage converter, to raise voltage to 5v.

> **[MT3608 Modulo elevador de tension ajustable Step Up Boost 2A DC-DC - Arduino...](https://www.ebay.es/itm/MT3608-Modulo-elevador-de-tension-ajustable-Step-Up-Boost-2A-DC-DC-Arduino-Ele/223030739051?hash=item33edab006b%3Ag%3A38QAAOSwc~NbOey4)**
>
> Las mejores ofertas para MT3608 Modulo elevador de tension ajustable Step Up Boost 2A DC-DC - Arduino Ele están en eBay ✓ Compara precios y características de productos nuevos y usados ✓ Muchos artículos con envío gratis!

  
I’m still trying to work with AXP but still not initialize, i’m using a axp20.h library of m5stack, i can’t found it in your github PaxCounter, seems no longer uses that library, but it used in past. How can i get it? Thanks again!!!

---

<div class="post-metadata">

**Author:** ![Verkehrsrot](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/verkehrsrot/32/46588_2.png) [@Verkehrsrot](https://www.thethingsnetwork.org/forum/u/Verkehrsrot)\
**Post date:** [October 8, 2019, 12:51pm UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450/27 "2019-10-08T12:51:38Z")

</div>

If you are using the Arduino IDE, you need to install the AXP202x library by hand.  
If you are using Platformio IDE (like paxcounter), the IDE will grab and install it for you.

Does it sure make sense to have a voltage conversion 5V to 5V like this?

5V USB -\> VBUS -\> DCDC (AXP192) -\> 3V3 -\> DCDC(MT3608) -\> 5V

---

<div class="post-metadata">

**Author:** ![tornadijo](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/tornadijo/32/35697_2.png) [@tornadijo](https://www.thethingsnetwork.org/forum/u/tornadijo)\
**Post date:** [October 8, 2019, 2:08pm UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450/28 "2019-10-08T14:08:46Z")

</div>

🙂 Well, working with battery, board will work about 3.5 - 4.2v, so internally board would have a step-up converter too, to supply VBUS isn’t it?  
But you are right, to save energy i need to find a accelerometer and a pulsometer that works with 3.3v… 🙂 really this devices will work only along 20 seconds each 2 minutes, (i will catch values and go to sleep board 2 minutes).  
btw, it’s for a sheep or a cow (Smart Farming)  
🙂

---

<div class="post-metadata">

**Author:** ![tornadijo](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/tornadijo/32/35697_2.png) [@tornadijo](https://www.thethingsnetwork.org/forum/u/tornadijo)\
**Post date:** [October 9, 2019, 5:39am UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450/29 "2019-10-09T05:39:00Z")

</div>

Updated! I switched to platformio as suggested, project works. I’ll continue in platformio, but AX192 still fails initalizing in this line  
if (pmu.begin(Wire, (0x34)))

I have build flags;  
build\_flags = -DCORE\_DEBUG\_LEVEL=5  
but still show nothing about errors in terminal or debug console…  
any idea how log i2c errors in platformio?  
Many thanks!

---

<div class="post-metadata">

**Author:** ![Verkehrsrot](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/verkehrsrot/32/46588_2.png) [@Verkehrsrot](https://www.thethingsnetwork.org/forum/u/Verkehrsrot)\
**Post date:** [October 9, 2019, 7:32am UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450/30 "2019-10-09T07:32:56Z")

</div>

If you have debug level 5 and don’t see i2c errors from esp32-arduino core, there won’t be any i2c errors. The i2c hal by stickbreaker in esp32-arduino normally talks a lot when the bus has errors. Check your hardware (i.g. i2c pullup resistors and voltage level) and i2c settings in your software (e.g. SCL/SDA lines/wiring).

---

<div class="post-metadata">

**Author:** ![tornadijo](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/tornadijo/32/35697_2.png) [@tornadijo](https://www.thethingsnetwork.org/forum/u/tornadijo)\
**Post date:** [October 10, 2019, 11:36pm UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450/31 "2019-10-10T23:36:55Z")

</div>

Done!  
Only replacing this line  
if (pmu.begin(Wire, AXP192\_PRIMARY\_ADDRESS)) {  
by those 2 lines:  
Wire.begin(21, 22);  
if (pmu.begin(Wire, AXP192\_SLAVE\_ADDRESS))

And AXP intialized and ¡3.5v on 3V3 pin!!!

On the other hand i damaged the board because a bad multimeter, board blue led (charge battery led) is always blinking like charging, but without battery. if i try to put on a battery, components around blue led going very hot fast… but never mind, it was worth it, this board still works under usb and still is valid to make tests and works connected to external usb battery, i have 2 more boards like that and i can now go ahead with my mad project. Thanks a lot!!!

---

<div class="post-metadata">

**Author:** ![Verkehrsrot](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/verkehrsrot/32/46588_2.png) [@Verkehrsrot](https://www.thethingsnetwork.org/forum/u/Verkehrsrot)\
**Post date:** [October 11, 2019, 10:07am UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450/32 "2019-10-11T10:07:40Z")

</div>

The blue led is directly controlled by AXP192 pmu chip, it’s behaviour can be configured by software. Blinking, even without battery, can be normal, depending on software settings.

`AXP192_PRIMARY_ADDRESS` and `AXP192_SLAVE_ADDRESS` both are aliases for 0x34, but obviously pasted from different libraries (paxcounter / axp202x)  
-\> you should sanitize your code and know what you’re doing!

---

<div class="post-metadata">

**Author:** ![tornadijo](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/tornadijo/32/35697_2.png) [@tornadijo](https://www.thethingsnetwork.org/forum/u/tornadijo)\
**Post date:** [October 11, 2019, 1:02pm UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450/33 "2019-10-11T13:02:06Z")

</div>

Yes, after all tests, my code is madness.  
Finally problem was only this missing line  
Wire.begin(21, 22);

---

<div class="post-metadata">

**Author:** ![Verkehrsrot](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/verkehrsrot/32/46588_2.png) [@Verkehrsrot](https://www.thethingsnetwork.org/forum/u/Verkehrsrot)\
**Post date:** [October 14, 2019, 7:51pm UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450/34 "2019-10-14T19:51:59Z")

</div>

@borroz …and now i ran into the problem. What’s a straight forward way to reset the i2c bus on ESP32 with arduino-esp32 core after waking up from deep sleep? I don’t need to restore it’s state, will do a full re-init, but coming from warmstart after deepsleep. Thus don’t have hardware reset of GPIOs.

---

<div class="post-metadata">

**Author:** ![BoRRoZ](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/borroz/32/44234_2.png) [@BoRRoZ](https://www.thethingsnetwork.org/forum/u/BoRRoZ)\
**Post date:** [October 14, 2019, 8:08pm UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450/35 "2019-10-14T20:08:18Z")

</div>

on ESP32 I’m not sure… arduino is just re init the sensor

---

<div class="post-metadata">

**Author:** ![Verkehrsrot](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/verkehrsrot/32/46588_2.png) [@Verkehrsrot](https://www.thethingsnetwork.org/forum/u/Verkehrsrot)\
**Post date:** [October 14, 2019, 8:18pm UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450/36 "2019-10-14T20:18:17Z")

</div>

Re-init i2c devices is of course mandatory. But for this i need a working i2c bus. After waking up from deep sleep i get

```
[W][esp32-hal-i2c.c:1411] i2cCheckLineState(): invalid state sda(21)=0, scl(22)=0
[E][esp32-hal-i2c.c:1426] i2cCheckLineState(): Bus Invalid State, TwoWire() Can't init sda=0, scl=0

```

I tried a `Wire.~TwoWire()` before to reset the i2c bus driver - but no success. Maybe the GPIOs need a certain treatment after waking up from deep sleep?

---

<div class="post-metadata">

**Author:** ![BoRRoZ](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/borroz/32/44234_2.png) [@BoRRoZ](https://www.thethingsnetwork.org/forum/u/BoRRoZ)\
**Post date:** [October 14, 2019, 8:29pm UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450/37 "2019-10-14T20:29:34Z")

</div>

I read something about reconfiguring SDA line upon recover from deep sleep ?

---

<div class="post-metadata">

**Author:** ![Verkehrsrot](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/verkehrsrot/32/46588_2.png) [@Verkehrsrot](https://www.thethingsnetwork.org/forum/u/Verkehrsrot)\
**Post date:** [October 14, 2019, 8:32pm UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450/38 "2019-10-14T20:32:47Z")

</div>

How to ❓

---

<div class="post-metadata">

**Author:** ![cslorabox](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/cslorabox/32/35697_2.png) [@cslorabox](https://www.thethingsnetwork.org/forum/u/cslorabox)\
**Post date:** [October 14, 2019, 9:08pm UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450/39 "2019-10-14T21:08:36Z")

</div>

> [@Verkehrsrot](#):
>
> invalid state sda(21)=0, scl(22)=0

That makes it sound like your pins are stuck low. Might be the ESP, might be something else holding them down.

One debugging trick can be to insert small series resistors in the bus. Then, by seeing (ordinarily with a scope, in this case even with a meter) the direction of voltage drop across them, you can see if it is the processor or peripherals holding the lines down.

---

<div class="post-metadata">

**Author:** ![BoRRoZ](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/borroz/32/44234_2.png) [@BoRRoZ](https://www.thethingsnetwork.org/forum/u/BoRRoZ)\
**Post date:** [October 14, 2019, 9:33pm UTC](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450/40 "2019-10-14T21:33:36Z")

</div>

sorry… I googled ’ esp32 after deep sleep i2c ’ and forgot the link

seems to be a problem … _hope I find the work around again 🙃_

think it was this one

’ I need to reconfigure the SDA line upon recover from deep sleep:

Code: [Select all](https://www.esp32.com/viewtopic.php?t=6578#)

```auto
rtc_gpio_deinit(SU_HARDWARE_I2CSDA)

```

[Previous page](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450.md?page=1)

[Next page](https://www.thethingsnetwork.org/forum/t/switch-off-devices-attached-to-board-to-save-energy/30450.md?page=3)
