Power board just long enough to send a signal

Hi
I have this project of creating a copy of my ceiling fan remote control.

I want to note that, contrary to most IOT project, my ceiling fan is controlled by a 433.92MHz remote and it's very good that way. I do not want to involve any bluetooth, wi-fi, or phone. Just a good old copy of my current remote. Because why not.

What I have for the moment: I bought an ESP32 and a CC1101 emitter. I can emit the "light on" signal with a code like this:

#include <SmartRC_CC1101.h>
#include <RCSwitch.h>

int pinTx = 4;

RCSwitch mySwitch = RCSwitch();
SmartRC_CC1101 myRadio;

int repetitions = 15;
unsigned int protocol = 1;
unsigned int rdelay = 256;
unsigned long encodedSignal = 3481482895;
unsigned int bitlength = 32;

void setup() {
  Serial.begin(115200);

  myRadio.Init();
  myRadio.setMHZ(433.92);
  
  mySwitch.enableTransmit(pinTx);
  myRadio.SetTx();
  Serial.println("Transmit");

  mySwitch.setRepeatTransmit(repetitions);
  mySwitch.setProtocol(protocol);
  mySwitch.setPulseLength(rdelay);
  mySwitch.send(encodedSignal, bitlength);
}

void loop() {}

I learned the "encodedSignal" thanks to the RCSwitch library example, and so I know all the codes I need (fan on, off, speed up, down, etc...)

What I want to do now is to turn this into a true remote control, and my main problem will probably be power management. For now, I'm connected via usb, but in the end I will want to be battery powered and that it last as years, if possible. (On a traditional remote, you can keep the same batery for years...)

Reading about consumption in deep sleep (~10µA? I'm not sure), I calculated: 100mAh battery vs 10µA deep spleep consumption, that is 10000h or a little more that a year. It doesn't seems a lot.

But then I though, I don't need deep spleep. I could be fully disconnected, and pressing the button will both power the board and select wich signal to send.

I have the ESP32 + Li battery (3.7V) + Step-Up Power Module 3.7->5V + 4 tactile buttons. The question is, how to wire all of that so that pressing the button will power the board for long enough to send the signal, and signal the board which button was pressed.

I'm also open to any other idea to achieve the same result. I might not have chosen the best approach.

Thanks

But you have jumped way to the end of the line! Begin by recording how much time is taken to ready the microcontroller to be ready to determine what you have programmed it to do.

Just write a program to turn a LED on when you push the power switch. When you know that you can begin to design the rest of the project. You will have to count the seconds as you cannot program to do this timing.

You mean a program that turn the light on but not off, and count how long the led last? I'll try that as soon as I get home

Yes. The actual time taken by the electronics between switch pressing and the LED turning on. That will be the same time needed for your actual project to begin executing.

I mean just what I wrote, nothing more. Do not add your own narrative to the test. Just the time from when you push the power button until you see the LED light. That is a rather simple test!

Why? The esp32 is a 3.3VDC device, why do you need 5VDC?

I'm not familiar with the ESP32 so can't verify the 10µA.

You might have chosen the wrong board; a 328P processor can go far below that (100 nA according to Gammon Forum : Electronics : Microprocessors : Power saving techniques for microprocessors).


Is your board an Arduino Nano ESP32 or a more generic ESP32?

Where will this show up if the USB cable is disconnected and you are on battery?

Exactly what chemistry, and what physical size. I mainly use LiFePO4 which are in fact a nominal 3.2V and LiOn which are 3.7V but both those are 18650 physical size (18mm D and 65mm L) BTW that 65 is not really true, it depends on protection status and end cap, flat vs nipple.

You need to provide ALL the information.

You mean you bought a development board based on ESP32. Let's hope you chose wisely, not all are designed with long battery life in mind. If you must use an ESP32 I would recommend Seeed Studio ESP32C3 mini. From experience, those will deep sleep at around 35uA with a li-po pack connected to the BAT+/- pads on the underside of the board.

But, as mentioned, why not use something AVR based, like a 3.3V Pro Mini or Micro? They will sleep at currents even lower than ESP32.

I would look at using an ATtiny for the processor with the internal oscillator. Then both the processor and the CC1101 could operate over the range of the lithium battery without any voltage conversion.

@sterretje I didn't know about the 328P, it seems indeed much better, I don't need any of the wireless capabilities of the esp32. Is programming as easy on this chip (usb+arduino ide, and using rcswitch.h?)?

@sonofcy the println is not the final project of course, I also need to rework to take multiple input

For now, I have a Lithium polymère 3,7V battery (because this is what I had available) but I will buy the smallest battery that can make this work in the end. If LiFePO4 is better that is fine for me.

Regarding the physical size, I have not yet figure how I will encase this. My ideal would be to have it behind something that looks like a wall switch (
maybe like this ?)

, but honestly I have no idea how to do it.

@PaulRB I bought this exactly : Amazon.fr

I must not use an ESP32, I'm 100% open to switch to a controller with less feature. I took an esp32 because I read it was easy and I've never done anything like that yet.

I agree with the others. I don't see any need for 5V. That step-up module will probably consume more current than the AVR or ESP32 when in sleep mode. Stepping up to 5V then down to 3.3V again is inefficient, wasting more battery energy.

For a device that spends almost all it's time in deep sleep, a low drop-out linear regulator will be more efficient than a step-up/down module.

That is not an Arduino Nano ESP32 and therefore your topic has been moved to a more suitable category of the forum.

TBH I don't see the need for a esp32 at all, since I just need to send fixed code. I originally though the CC1101 alone could do it, but I have no idea how to use it alone.

I'll look into the other microcontroller mentionned

It's best to ask the forum for advice before purchasing. The module you purchased uses an AMS1117 regulator :frowning:. You cannot power it from a 3.7V battery without inefficiently boosting the voltage up to 5V and then inefficiently regulating the 5V down to 3.3V again.

Other ESP32 modules have more efficient regulators and will accept the 3.7V without needing a boost module.

@PaulRB Yeah I didn't even knew the forum when I started this, unfortunatly

From what I understand, an Arduino Micro could be good for this kind of project? Or rather a Pro Mini ?

The 328P is the processor in the Arduino Uno and Nano. It is also used in the Pro Mini mentioned by @PaulRB in post #9.
So yes, it will be just as easy.

The Pro Mini has barely any power consuming additional electronics so that is your first saving. Remove the power LED to save additional power; and if I'm not mistaken some people even remove the voltage regulator to save even more power.

@sayanel01 It's possible to program the ESP32 in either C/C++ or Micro-Python. With the AVR processors, only C/C++ is possible. So if you are comfortable and familiar with Python, you may prefer ESP32. But C/C++ is faster and so more efficient, extending battery life to some degree I guess.

I built an IR remote that runs on an 18650 lithium cell, or three alkaline AAs. The power goes directly to a 3.3V 8MHz Pro Mini with its power indicator LED and voltage regulator removed. It stays in deep sleep until a key is pressed, and has no trouble waking up. The deep sleep current is something less than 1 microamp, so it's really not worth the trouble to switch off the power completely.

But we need to consider the CC1101 emitter. What power does it need? Is it possible to shut it down completely when the power is still on? If not, you may need to control its power with a mosfet.

Edit: Can you provide more information on your CC1101 module? Perhaps a link to where you bought it, or a good picture of it.