Showing posts with label Battery. Show all posts
Showing posts with label Battery. Show all posts

2024-05-05

Is it spring yet?

This is more like it, but is only one day!

Most of our import (and today it is likely all of our import) was 2am to 5am at 14.71p.

Most export was during the day at 15.08p.

A lot of export, around 15kWh (54MJ) was 4pm to 7pm (actually 5:30pm to 7pm so we save some for evening) at 24.93p

Doing the sums I think...

  • Import 34.1kWh (122.8MJ), assume 14.71p, £5.02
  • Export sunshine, 26.7kWh (96.1MJ) at 15.08p, £4.02
  • Export battery, 15kWh (54MJ) at 24.93p, £3.74

Total electricity bill (excluding standing charge) -£2.74, and that left some in the battery still.

Without solar and battery? House used 31.4kWh (113MJ) and would have been mostly 24.51p, so £7.70.

If only every day was like this.

2023-11-01

LiPo batteries

I have done a lot of small circuit boards, but one of the challenges with any board is battery working.

I used the Watchy as a good example of this, understanding how to put the ESP32 in to deep sleep and so on. This worked very well. What I had not done until now was actually make a battery based board myself.

The first attempt, which was a massive long shot, was to test if I could run an ESP32 (ESP32-S3-MINI-1) off a button cell. The answer is no. This was not a big surprise.

So the next attempt was this :-

This has a small LiPo battery, an LDO regulator, and a charger circuit. This is basically copied the choice of components for these from the Watchy design.

There are a few things you need for battery working though - for a start, I have a FET to control power to the LED chain. The LEDs, when idle, do use very little power, but for battery working I want it to be zero power. So I have a GPIO that actually switches the power for the LED chain on and off (this is the small WS2812B compatible 3.3V RGB LEDs I have been using lately).

Another small trick is to also use a FET to switch the battery voltage to an ADC. The ADC on the ESP32 needs a lower voltage, so has a potential divider. The problem is a potential divider uses a small amount of current all the time - so again, this is switched on using a FET. I don't know if that is really necessary, but every uA helps. This should, hopefully, allow me to confirm battery levels whenever I need.

One small issue, which I have yet to quite get to the bottom of, is waking from deep sleep. The ESP32 IDF seems to suggest it is possible to make any RTC GPIO cause a wake on a state change. This is ideal for any buttons (I have two on that board design). However, that did not seem to work. I'll experiment more. There is, however, a separate way to do this, which is you can have a set of RTC GPIOs and wake on "any high" or "all low". For more than one button (I added two for the hell of it), this only really works if you have the idle state of the button low, not high. I had, as is common, had these buttons switched to GND with a pull up. I had to change the design not be reversed to allow wake on either button being pressed (at least until I get the "change of state" logic working).

I had fun finding a suitable upright USB-C connector, and I have juggled the various connector positions a bit since this original design.

Now to find what the battery life is when idle, and how many times you can use it before it goes flat. But it does work - yay!

2022-10-04

Free electricity

I got solar about 6 months ago. At that time I did not have a battery or an export tariff. In fact it took about 5 months to get any sort of export arrangement because of delays in paperwork.

So back then... (June)


This meant I was getting free electricity. When the sun was shining I could decide to use something, like the hot tub, or tumble dryer, and use that sunshine, and the marginal cost of doing so was zero. I neither gained, nor lost, any money by doing so.

Of course there are caveats, if I was to use too many things or use them on a cloudy day when there was not the solar, I would be paying for the extra usage. So only free electricity up to a point. But still, it was guilt free using the hot tub, etc.

Payback time (August)

Finally I got an export tariff, albeit only 7½p/unit, which has yet to actually pay due to So Energy dragging their heels. But in principle, at that point, my excess solar was paying me 7½p/unit. This meant I no longer had free electricity. If I used the hot tub, even when sunny, it was costing me 7½p/unit. But that is really cheap so almost guilt free.

Battery time (September)

Finally I got the battery install, and that changes things a lot.

Because the battery can charge up on the excess solar and then be used to power the house, whist the battery is not full, and whilst we are not making excess solar more than 5kW, the battery takes the power.

In the morning, if there is enough sun to fill the battery as above, all of that extra sunshine can be used any time during the day and it will just delay the point the battery is full. So costs me the export (5p) that I am reducing. But once passed that, at the point the battery does not get full, any usage will simple mean the battery runs out faster and so will mean power from the grid, so cost me normal rate (currently 24p).

Of course, whether the usage in the morning is nearly free electricity (5p) or not (24p) depends on how much sunshine happens later in the day. It is Schrödinger's free electricity - you have to wait to open the box.

Some symmetry (October)

I am now on a new tariff with Octopus, the idea is they control the battery now, and use it to charge and feed in to the grid as needed. As they control it, they have taken the sensible approach of making the electricity a symmetric pricing, I pay 24p/unit but I get 24p/unit for export, so end up paying for my net usage at 24p/unit.

This means no more free electricity. Any usage at any time will cost me 24p/unit for that usage. Similarly any sunshine (up to my 6kW export limit after any battery charging) is 24p/unit benefit.

This is, at least, simple, and does not depend on how sunny the afternoon is - the cost is known, but does mean no more free electricity. All usage costs.

Battery feeding the grid in evening

Battery charging at night

Next step (when hell freezes over)

The next step gets fun. I am getting a second battery (which are like hen's teeth). When I get it I will be able to change to a night time EV tariff, charging it (and heating hot tub) in the night at something daft like 7½p/unit. Then I use battery and solar to run the house during the day.

This means all my electricity will be cheap, 7½p/unit, well, up to a limit. If I use too much, and then if there is not enough sunshine, I end up using during the day as the battery will run out. At that point I am paying more like 40p/unit.

So, once again Schrödinger's free electricity - I won't know what extra usage will cost until end of the day depending on how sunny it was, but as the battery plus cloudy solar should cover most of our normal usage, it should always be the 7½p rate. The only caveat is I may want to shut down hot tub until next day if no sunshine, and I may want to discourage tumble dryer on cloudy days.

Every little helps

Even though some of these options mean no free electricity, all of these steps reduce my overall bill, a lot. The solar now means I am paid for electricity I make at a sane rate, which is excellent. Indeed, some options could mean exporting extra battery storage at the end of the day to get paid more than it cost to get the charge in the morning. It could make some days negative total price.

Nothing is free

Don't forget, it is only free if you also forget the huge installation cost. Start here.

2022-09-18

Weird science

LED panel (when switched on)
I have LED lighting panels in my bedroom, two of them. Nothing complicated.

They each have a power supply behind them in the ceiling, and connect to the power with just live and neutral (no earth).

The live goes via a switch, obviously. It's a Shelly, so a clean relay contact.

So, when they are off, they should be off. Simple. They only have the neutral connected at that point.

The weird bit

However, during the night, I can see that they are not quite off. They have a faint glow some of the time. It can only be seen in the pitch black of night, and when your eyes have adapted to the dark. So if I wake up in the night I can see it.

At first I did wonder if I was imagining it, it was so faint, but no, I have seen them glow turn on and off, not fading in/out but sudden on/off. So very real. They are not glowing all the time, and not at the same time necessarily - sometimes one or the other. But most of the time as far a I can see, i.e. if I wake up in the night they are glowing. And frankly they are annoying me.

But with only neutral connected I don't see how this can happen at all!

The weirder bit

This only started happening the day my battery was installed. I have had these over 18 months and never seen then glow before, but they do now, every night I see them.

How can my battery install have triggered this?

The even weirder bit

The point the battery stopped powering the house
As I say, I now see this every night, well, except for last night. Last night I turned off the hot tub and allowed the house to run on battery all night for the first time. To be fair, I kept checking the battery charge in the night. Sad, I know. But yes, the battery lasted not only until sunrise, but until enough solar to run things and start charging it again. That means I have not used any power from the grid for over 24 hours, and in fact exported 9½kWh, even using the hot tub in the day yesterday. Amazing.

But, guess what, the lights did not glow last night, not once did I catch them doing so.

So they only glow, once the battery was installed, but only when it is in standby, not powering the house.

I repeat, there is no earth on these lights. And the extra earth rod for the battery install was done 6 months ago anyway. So all that changed when the battery was installed was, err, the battery and gateway box.

I may play with switching the neutral as well, but wow, why would I need to do that.

Explanations welcome!

Update

Usually the switch for a light like this would be L/N to the ceiling, the L going all the way down to a light switch, and all the way back, in the same wire/sleeve, to the ceiling, and then in to the light with N. This long wire acts as a capacitor allowing small amounts of AC current to flow.

But sorry. My lights are L/N to a shelly, L via the relay in shelly, and the L(switched)/N on to the light. No cable to act as a capacitor. Nice try twitter.

Further: We are planning to take up floor boards tomorrow (Friday) to confirm wiring is as I remember it, and try some things - I'll post more details here when I know. Thank you all for the ideas on this.

Final answer

Firstly, there is no switch lead, so capacitive pick up L to Switched-L was not the cause.

One person sort of got it right, a lively neutral. But not quite what you may think. In fact it was L/N tails to CU reverse, so all neutrals were very live and unprotected. The cable to the light therefor had a live (on neutral wire), and an earth (not used at light, but obviously connected to earth), and next to the earth was the neutral (on the switched live wire), which capacitively picked up from earth and power the lights.

Yes, there was a big flash and a bang in discovering this. No, I am not going to point fingers (was not me, obviously).

2022-09-07

Battery, part 3

Slightly misleading as battery is charging!
I have just been going over the final handover and testing with Green Park for the Tesla Battery.

Part of it was making a power cut. This was interesting.

So a few facts that are useful to know.

  • A real power cut means a couple of seconds of no power. It is not seamless.
  • A deliberate "off grid" (done on the app) does not, so if it is a planned power cut then you can seamlessly go off grid if needed. Good.
  • Going back on grid is seamless, a few seconds while it sorts phase match and back on. Good.
  • It will take solar during a power cut, and charge the battery if needed. Good.
  • If the solar exceeds its 5kW charging capacity it will shut down the solar (done using frequency change, apparently).

The last point is a pain as the solar can do 10kW. More importantly the solar can control what it makes by de-optimising the panels, so it if knew it was a problem it could reduce power. There seems no way to link these intelligently, sadly. But once I have a second battery we will be fine at it will match the battery, at least until the battery is full. What I don't know is if there is any way it tries to turn the solar back on in such cases, maybe trying it for a few seconds every now and then? Must find out.

And as for the first point, a power cut causing a blip - I need a very small UPS for my comms rack to last a few seconds, that is the easy part.

Second battery

One battery can handle 5kW in/out, and charge to 14kWh. This is fine for most cases for balancing the solar and usage and reducing export. It is also perfect for getting on the Octopus tariff for this where they manage the battery and I pay for net usage.

However, one battery does limit my options. It does not have capability to run the house for 24 hours, meaning that I cannot make use of "cheap charge at night and run of battery for the day". If I could, I would save even more, but without that I could be using more expensive electricity later in the day, especially in winter when less sun.

One battery is also likely to have the same issue if I went on an agile tariff, in that trying to match charge at low price and usage when high would be hard if I do not have a whole day's capacity.

So for these various reasons, a second battery is on order. For now, I am trying to sort the Octopus tariff, which is fun.

Off backup

The other work still planned is an additional small consumer unit that has a few circuits which will not be on backup. The Tesla can only do 5kW, so if I have the tumble drier on, or the car charger, it won't work. There are about 4 circuits to move to that. All good fun.

2022-08-21

Battery, part 1

This post is literally just a teaser.

The solar install was to include a battery, but it has taken months to arrive. Finally it is fixed to the wall - that is it for part 1, bolted to the wall.

It is Tesla Powerwall with 13½kWh usable storage, with 5kW charge/discharge rate.

Later this week Some time next week, it will be wired up, including a "gateway" to allow me to run off grid during power cuts.

Should be fun, watch this space.

But yes, planning to explain what it is, how much, what it does, how the wiring works, how it works with the solar panels, the app, the API, the tariff I end up, etc...

2022-04-14

Solar install, part 1

I finally have a solar install, and a battery on order. So this blog is the first one on this - I don't have a lot of data yet as it just went in, and I don't have a battery yet as they are like hen's teeth, so more on both of those later.

Solar panels waiting to be installed

The basics on a solar install

Firstly, it is not a simple/quick "free electricity" solution for the current price rises. There is more to it in terms of whether it is worthwhile, and over what period, and so on. I hope I can explain some of the factors here. There are several factors.

When the sun actually came out yesterday

How much power do we use anyway?

In my case we use a lot of power. Over the winter, since I have started monitoring in more detail, we have been using around 60kWh a day. One kWh (kilowatt hour) is one "unit" of electricity, and currently that is costing me over 28p - but tariffs are a key factor here. 60kWh is a lot, and a typical household is more likely to be 10kWh/day. Bear in mind that will depend on the time of year and the type of heating and so on.

One of the first things I did was install some monitoring. This is way more useful that simply having a smart meter as it tells me much more accurately where the power usage is happening. This meant some Shelly EM modules with tasmota and current clamps - not that expensive, but did mean messing with current clamps on lots of circuits. It means I can graph usage per circuit.

It immediately highlights the key uses of power here are the hot tub (yeh, it came with the house), and the heated kitchen floor (also came with the house). Other users like tumble drier come in when used, obviously, and now we have air-con that too is a noticeable factor. Some adjustments to temperature made a noticeable difference, and I really want to find something nicer for the kitchen floor (it is also a living room). The rest of the house is gas central heating. I would say that summer is expected to be lower, but the air-con will make a difference.

So yes, we are a very high user. This is, however, a factor in terms of solar - if you make more than you need you are "selling" it as export - but getting a good tariff for that is not so simple. You make/save most with solar if you are using it yourself, as that will save you money at that huge 28p/unit rate. Exporting it may only get you 5p/unit. Oddly you can have a different company for "exported" power payment than for your "imported" power - crazy, but apparently the best deals on export are when both are the same.

The other issue here is that our usage is in bursts - we have a base of around 1kW a lot of the day, but hot tub uses an extra 3kW in short bursts, and the kitchen floor is even more, but again in short bursts and often in the morning before the sun rise in winter. So we have these high bursts of usage that will often not be covered by solar. This is where the battery comes in - being able to store the extra solar when only using 1kW and power things when they burst. (more on power monitoring)

Hot tub

The good news is the air-con is not quite so bursty the way I have it set up now, and this can more easily be covered by the solar before I even have a battery.

Air-con

So why solar anyway?

One obvious factor is saving money - but this is where there is a catch - if I simply put the money in a savings account and used it to reduce my electricity bill every month, that would probably be better for the next decade - well, maybe, but certainly for a few years.

This is all a bit of a "Vimes's boots" scenario - i.e. the poor have to keep buying cheap boots, but the rich can afford to spend a fortune on boots once and they last so much longer than they end up spending way less overall. The same is true here - if you can afford a solar install you can have decades of spending way less on electricity - something from which that those who cannot afford the install would greatly benefit.

So what other factors are there?

Well, one factor for me is the stability of this (or perhaps "energy security" is a better phrase) - electricity prices are silly now and could get extra silly soon (next rise is October). If I can produce a noticeable chunk of my electricity, and have a means to reduce a lot of the rest (shut down the hot tub, etc), I can protect myself from those silly prices. It is, of course, hard to pin a figure on what this means in advance, especially if trying to plan for the next decade.

Another factor comes in with the (expensive) battery (Tesla power wall). It is able to power the house, so a short power cut (of which we have only had one so far) can be covered. Again, there are risks - the way the country is being run, and factors like Russian oil/gas, etc, could mean power cuts - who knows? This is a small risk, but it would be very nice to manage small power cuts - whether deliberate ones, or simply storm related (as last time).

Finally, it is investment in the house. We expect to be here some time - maybe "forever" from our point of view, but the solar install should improve the house value. This may be useful if ever we do want to sell, or if we raise funds on the house, or even when it comes to our kids selling it. The installation is not just throwing money away - it increases the house value some (yes, this itself is complicated as some older solar "roof rental" deals are more of a burden and can reduce value).

Of course it is also an environmental aspect - it helps reduce the burning of fossil fuels. Indeed, I seem to have earned a gold star already!

Solar and/or battery?

There are two distinct aspects - solar panels and battery. These are distinct but do help each other, so you may want solar, battery, or both, depending on your circumstances.

Solar

The Solar aspect is pretty simple - the panels make power - more in summer than winter - only during the day - more when the sun is shining than in cloud. The installer can predict how much in the year. That will allow you to work out the cost vs payback. The installer should do proper forecasts.

For us, based on 22p/unit starting point, we are looking at a little over 10 years to cover the cost of the solar system install. Over the following 10 years we are looking to save a further twice the cost of the install. This assumes some inflation on electricity prices as well as some degradation on performance.

On this basis you can see solar cost per unit over 20 years is good, better than you would get from any electricity supplier even now. On a long term plan it makes sense. It may even make sense for some people on a "loan to install" basis, but that is a risk over future interest rates.

Battery

This is where the options and costs get even more complex. It seems there are some battery systems which basically help "level out" the solar some (those 3kW spikes for hot tub, etc), and are not a lot of good as a "backup" for a power cut. These are probably a no brainer in terms of managing the solar supply from any install as the usage and the solar can vary during the day - something even a small battery can level out nicely.

There are, however, some that can back up the house, and the tesla power wall is one of those. Such systems cost a lot.

For a start, the battery helps make the most of the solar. It means you are not exporting. Without this, any time in the day we are making more than we use, we are sending that electricity to the grid. It you are lucky, and have sorted the paperwork (I have not yet, just installed), you may get 5p/unit for that. It is much better for that to go in to a battery and then get used later saving you 28p/unit.

For example, right now, on a very cloudy April morning, I am making over 2kW but only using 1.43kW. As I don't yet have all the paperwork to be on any "export tariff", I am just wasting that 0.61kW going to the grid.

A cloudy morning

In an ideal world with solar and battery, when you have enough solar in a day to cover a day's usage, you want a battery that can store enough to cover the night time, and hence never import any electricity on those days (typically in the summer). If you have usage figures then that can be quite easy to work out. Even so, you may also be able to move usage around - especially if anything (e.g. a car) needs charging as well.

But a battery has other advantages - apart from the possibility of covering a short power cut, it can also work with agile tariffs - charging from the power grid when electricity is very cheap in the middle of the night, etc. You then use that power during the day.

Indeed, just having a battery, and no solar, can end up making your electricity very cheap. We may even want a second battery at some point for this very reason.

In this case you want a battery that can charge in the short periods of cheap power (middle of the night), at the same time as perhaps charging your car, and hold enough (allowing for any solar contribution) to power your house for the rest of the day until the next cheap charging point. Again, not too hard to work out, and to decide if you want to cover winter (less solar) and summer (less battery needed).

So for some people a battery is an option - but a good battery system like the tesla power wall can end up costing a lot more than the solar install.

There are some power companies (Octopus, for example) with special tariffs where you give them control of your battery (if a Tesla battery) allowing them to feed in power when they need, and they end up charging you only for net power usage at a much lower rate. Such a tariff is extra "simple" as you don't have to do anything - it just works and you have power at a low rate. They even keep some in reserve for power cuts.

Both

In my case, I have gone for both - though that does make it harder to work out what each separately may be saving me. It also means I need to sort some suitable tariffs. That special tariff that need control of the battery also only works if you also have a solar install and a tesla battery. Even then, there are some limits per battery on solar capacity and daytime usage, with which I may have a challenge on only one battery. This could be fun, and I am sure another blog post eventually.

Payback

The forecast payback, as I said, was a round a decade, for the solar alone, based on 22p/unit starting point.

That said, if I was to take a simple calculation of 60kWh/day usage at 28p/unit, that is £6132 a year. If I make an average of only 25kWh/day from solar, and get on a 10p/unit "they control the battery" tariff, that gets to £1277/year, saving around £4855k/year. That makes a payback of a £22k solar and battery system under 5 years. If I can make use of the battery to charge at 5p/unit middle of the night, top up with solar, and use battery for my usage, then payback would be 4 years. There is even a saving on standing charge to add to that. Now allow for inflation, or maybe an October rise to 35p/unit, and well, things get very interesting - there is a very real prospect of the whole system payback in only a few years - even Vimes would be impressed.

Of course, it could be we get a sane government, and sensible power pricing, and the payback is way longer - but I am, none the less, buying stability.

More specifics...

The supplier I have used is Green Park Power, based in Abergavenny (a short walking distance from my house). They have been very professional. I'm impressed.

The system is 31 panels, each 390W, so 12.09kW total. It is using solar edge - with per panel optimisers and an inverter in the loft. The per panel optimisers are DC/DC convertors allowing the mix of panels that have high and low light levels to all work together, even allowing for some in shade. Traditionally panels in shade can bring down the overall performance, but not so in this system.

It also allows monitoring of power per panel, and whilst there system is cloud based (which I dislike), it is very good. (I thought solar panels did not like "clouds"). I may set up some MODBUS stuff to provide some local monitoring in the long run, obviously. The inverter does connect to WiFi or, as in my case, Ethernet.

The figures in my case are roughly £12k for solar and £10 for battery, but it will very much depend on circumstances.

It really is simple

It is just working, the solar power cancels a chunk of the usage and creates some export. I mean, yes, once I have a battery, I may want to fine tune to make the best of some tariff, but in general I don't have to actually "do" anything - it just works. For now (before I get a battery) I have tweaked the settings on my hot tub, as one of the main power uses in the house, to be when the sun is shining.

But ultimately if someone bought the house they would not have to "do" anything, it would just lower their bills!

More to follow...

The solar edge monitoring if very comprehensive, and in a few days I should have some more useful data to share. Later this year I'll also have a battery to play with.

The first day, yesterday, was very gloomy, wet, and cloudy, but in the afternoon we were seeing a consistent 5kW, and at one point in the morning when the sun came out, well over 8kW. In our case, even though the system is rated to 12kW, it is 12 panels facing west and 19 facing east, so not expected to have full capacity, making 8kW rather impressive. I am going to love seeing a proper sunny day on this. But only starting stats some time yesterday, I don't even have a full (cloudy) day's stats yet.

A quick update: First whole day (all cloudy) 18kWh, second day (more sun) 43kWh so far (4:30pm). Remember the forecast was only 25kWh/day over the year, and at this rate I'll exceed that just in the summer.

Part 2

2021-05-28

Battery powered

My latest project is to make something battery powered, based on an ESP32 processor. The ESP32 data sheet claims it can go down to under 1uA in a deep sleep mode. It also has an Ultra Low Power processor that can do things in deep sleep at only a few uA. It is not very clear in the datasheet for the ESP32-WROOM-32 module how low it can go - after all that has extra bits including an external flash. So it was a bit of an unknown. However, I have made something, and it works... (on GitHub)

The first board was a cock up - wrong footprint completely on a key device - kicking myself. The second version was more what I would expect - some minor errors I could work around, allowing me to prove it all works and confirm power usage. The 3rd version was great except one of the chips again had wrong footprint - but this time close enough for the device to fit without problem. I have managed to keep the device tiny - not much bigger than the ESP32-WROOM-32 itself.

The first application is actually to work with a VL53L0X ranger in the top of an oil tank, running on battery and reporting over WiFi. The next trick may be LoRa for such things.

Battery / power supply?

The first real question was whether to try and run directly from a battery, or to use a power supply?

Directly from a battery means finding a battery that is within spec to produce 3.3V. The voltage from a battery is often slightly more (when new) than stated, and depends on the battery technology. The processor will cope with voltages a bit out of range as well (3.0V to 3.6V). So a 3V battery should work. But the voltage drops as the battery runs down, and we are starting on the edge of acceptable voltages, so this could cause problems. The advantage of running directly from a battery, apart from fewer components, is the really low power modes of the ESP32 should allow a really long battery life.

With a power supply you have the advantage of using a wide range of battery, e.g. 4.5V, 9V, 12V, etc, but the big disadvantage of wasting power on the regulator itself.

I ended up using the LMR16006 from TI which is designed for battery devices, and has an idle current of 28uA when not driving much load (e.g. an ESP32 in deep sleep). It also has a shutdown mode drawing less than 1uA (see more on that later).

However, testing showed that it draws 34uA when not even connected to a load. This pretty much is explained by the 460kΩ potential divide built in to the fixed 3.3V module to drive its feedback pin. I could go for external potential divide but 460kΩ is on the top range recommended in the data sheet.

However, even 34uA is good, and can allow a battery to last years.

USB as well?

Do I need USB as well? Well, no, not really, I could have a generic programming header, but I like the USB-C connectors. They are good as a power supply when not running off battery, and make programming and debug easy. So yes, I'd like to keep the USB.

The issue is power. The USB chip (FT231X) can be powered from USB, and even work its own 3.3V I/O from that. So it can be totally off when no USB. Good.

But it is used to control EN/GPIO0 to reset and put the ESP32 in boot mode. If USB is off, the ESP32 stays in reset. Thankfully the USB chip can be configured to invert RTS and DTR if you want, so I put them through a simple transistor inverter so that when the USB is off the ESP32 is not in reset or boot mode. The result then works as expected with the debug and flashing tools in the ESP IDF.

The Tx pin to the USB when powered down was a concern, but it seems to cause no problem, and the code can turn it off immediately on start up, and in deep sleep it is not connected.

The USB chip can also feed in some useful GPIO pins, reporting when it is on (a fixed "1" on a CBUS pin), and even if it is connected to a charger not a USB device. This means the software can tell if running from battery or not, and stay awake when being used for USB debug.

How low does the ESP32-WROOM-32 go?

Well, the good news is that the ESP32-WROOM-32 does indeed use bugger all (aka 1uA) in deep sleep. This is impressive, so we are looking at under 35uA idle current for the whole board from a 9V supply when idle.

Obviously we need to wake up occasionally, but we can wake up, boot, connect to WiFi, connect to MQTT, report status, and shut down in under a second with fixed IP. Indeed, the WiFi can be in use for under half a second, which is impressive. We need to do some long term tests to confirm battery life.

Measuring the voltage?

Of course, one thing we want to measure is the battery voltage. That allows us to see if we have a low battery. It is essential for any battery based device to tell you the battery is low. The answer is a simple potential divide feeding an ADC input to the ESP32. Except that draws current! Even 1MΩ divide is 9uA at 9V, 100% of the time.

The answer is a FET, well, two FETs. I am not an electrical engineer so this needed a bit of research. One FET or transistor would not work as it had to be at the "top" of the divider. If it was at the bottom of the divider it would mean 9V going in to the ADC pin when the FET was off. But when at the top of the divider you don't have GND as a reference to drive the FET.

The answer is an N-channel FET driving a P-channel FET, all in one package. Thanks to twitter for help on this. It works! I can turn on the divider, take a reading, and turn off again. I have some resistors to ensure than when GPIOs are isolated the FET stays off anyway. Sorted.

How low can you go?

Can I do better than 35uA? Well, yes, probably. The ESP32-WROOM-32 itself goes down to 1uA or so. The regulator in shutdown goes to 1uA but as that annoying potential divider still. If I was able to shutdown and disconnect the power from the ESP32-WROOM-32, it could run off a capacitor for many seconds at 1uA.

So basically I'd need a way for the processor to turn off its own power most of the time!

The trick is ensuring that if you sleep too long, the power will come back on anyway, and indeed when first powered up.

I think I can do this with another FET, pulling the shutdown pin to GND, driven from a GPIO pin. When no power the GPIO will go to ground, pulled by parasitic diodes if nothing else, and cause the FET to go off. Of course you still have the issue of making the shutdown pin then go high when the FET is off, with the only power being the battery, so you still need that one pull up resistor. I wonder how big we can make it? If we can make it 10MΩ we waste only 1uA on that.

The same signal driving the shutdown pin could also drive a FET switching the feedback potential divider, so we turn that off too. It may need some careful design, e.g. FET at bottom of that divide, to ensure we don't fool the regulator in to supplying too much power because its feedback is not get connected, but that should not be rocket science.

For now, I'll test using the current design, idling at 35uA, and see how it goes. But I may yet make a new version that tries to turn itself off most of the time :-)

P.S. I am such a fan of solder paste now, I can't see me ordering boards without getting a stencil as well. It is so quick and so reliable, it is quite amazing really...

2021-05-15

NFC reader works, what next

It has been a month since I came up with this crazy idea, but the NFC reader board is working really well now. To be fair, every version I have made has worked, just some better than others. The most noticeable impact on how well it works is the inductors. Using small inductors (i.e. 0603) means it is crap - needs fob flat on then antenna to do anything. Now it works around 2cm. I have changed layout a lot, changed the antenna shape, changed component size. Lots.

I have, however, learned a lot about ESD protection, layout for RF, choosing components for RF, using KiCad, and solder paste. The solder paste has perhaps been to be the biggest change as I am no longer afraid of adding passives, which previously would have been far too annoying to hand solder and take too much space. Lots of 0603s are no issue now.

So I have a nice NFC card design, thanks a lot to John for his help. I also have a nice door control module which is tiny, and only 7mm thick. Easy to fit in a back box with other stuff.

If any hack space want to have a play with one of these NFC boards, let me know. I'd be interested in feedback. Main advantages over Elechouse are red/amber/green LEDs, tamper button, door bell input, and more ESD protection.

The boards, and 3D cases, are all on GitHub.

So what next?

Well - battery power - that's what. I have made up a new regulator for my boards rather than using the Pololu boards (they really are very good!). It has an automatic ECO mode dropping to 27uA.

Planning to work on Ultra Low Power mode on the ESP32, see how low I can get it, and run from a battery.

So now I need a board that can be low power. This means the USB chip needs to be turned off when not using USB, which is fun as it means I do not want to power its I/O pins for Tx either - and the ESP32 blurts lots of debug on Tx at start up. So a small FET is in order. Also quite fun as the FT231X USB chip works the RST and GPIO0 pins, so need them to work properly when no USB power.

P.S. Why USB?

Someone asked why do I have USB at all? I used to have boards with USB-C for power, and a header for programming, but it was actually less space and easier to just fit an FT231 to the board instead of the header, so using the USB for power and serial load/debug. The battery board is perhaps an exception as it needs a couple of extra components to let me disconnect the USB, but even so, on a board this small an extra programming header would be tricky, so I decided to stick with USB serial.

Shipping to EU from UK

We are selling some stuff to EU, and all over the world now (see shop.revk.uk ). This is all a bit new to us, as we have traditionally only ...