xidameng / Picoclick-C3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Picoclick-C3

This page is a work in progress!

The Picoclick C3 as well as its little brother (the C3T, T = tiny) are the successors of the well known Picoclick. The name is related to its new processor: the ESP32-C3 single core RISC-V 160MHz CPU.

The Picoclick is a tiny WiFi and BLE IoT button for several applications. Originally designed for smart home things, the Picoclick can also be used as an actuator for IFTTT automations or as an MQTT device. It is based on the single core ESP32-C3 RISC-V processor and therefore comes with tons of useful features. With dimensions of only 10.5mm by 18mm, the C3T is not only the smallest one in the family of the Picoclicks, it is also the smallest device I have created so far.

The Youtube video of the C3T shows the assembly and soldering process, the optimization of the boot up time, the power measurements as well as some useful applications of the Picoclick.

As the C3 is in development at the moment, most of the files are related to the C3T so far.

Here are some specs of the Picoclick C3T:

  • Dimensions are only 10.5x18mm
  • Ultra low standby current due to latching circuit (no sleep mode needed)
  • Single button & LED interface (WS2812 RGB LED)
  • USB Type-C for charging the battery and flashing the ESP32-C3

I sell on Tindie

Update 14.07.2022: The Picoclick C3 is alive!

It's a pleasure for me to announce that the Picoclick C3 (the big brother of the C3T) is finally here! It comes with the most advanced features of my latest projects which occupies the following points:

  • Optimized idle current: we're below 200nA (!!) current consumption (without battery protection) in idle state! (compared to 3µA for the C3T)
  • Optimized antenna design, which will lead to a better performance and longer range.
  • Optimized power latching circuit, which makes the firmware development easier. (especially with the Arduino IDE)
  • Optimized battery charging circuit with separated status LED.
  • Added second RTC crystal for BLE applications.
  • Added FPC connector for connecting external hardware.
  • Added embedded battery protection.
  • Added boot emergency jumper.
  • Same dimensions as the standard Picoclick.
  • Added a nice "golden" logo ;)

GPIOs

Function GPIO C3T GPIO C3 Mode
LED GPIO6 GPIO6 (CLK) + GPIO7 (SDI) Output
Latch* GPIO3 ** Output
Button GPIO5 GPIO5 Input
Charge Stat. GPIO1 ext. LED Input
Bat Voltage GPIO4 GPIO4 Input
Bat Voltage EN -- GPIO3 Output

*Enabling the LDO can be done by pressing the button of the device or turning the latch high. In most use cases, the latch GPIO should be turned on as the first task of the Picoclick. Once the task is completed the device can be powered off by turning the latch off (e.g. pulling it low).

**The Picoclick C3 doesn't need a latching GPIO because it uses the embedded flash's power supply pin as a reference. It can be depowered with putting the ESP32 in deepsleep. To reduce the power consumption of the ESP32 this function will disable the power of the embedded flash (VDD_SPI) which in result will depower the Picoclick itself. The deepsleep calling function is only necessary to pulling the VDD_SPI line low, not to use the deepsleep mode of the ESP32.

Extension port of the Picoclick C3

The C3 has an FPC extension connector which can be used to power the Picoclick via the +VBAT pin, actuate the button press and use two pulled-up GPIOs (for I2C for example). Furthermore it leads out +3V3 and GND signal. The +3V3 signal is only active if the device is on.

In order to use the connections of the extension port, I designed a simple breadboard friendly breakout board. The pinout of the breakout board is shown below with both the connector of the breakout board and the Picoclick facing in the same direction. The FPC connectors are double-sided (contacts both facing up and down), so it will work in the other direction as well, but then the pinout is switched.

Using I2C

Both external GPIOs are strapping pins of the ESP32C3 and thus are pulled up on the Picoclick itself (they don't need external I2C pull-ups). If you wanna hook up an I2C device which should be turned off during the idle period you can simply use the +3V3 as a power source. In the other case the +VBAT signal can be used with an external voltage regulator. Latter can be useful if you have an I2C device which activates the Picoclick by firing an interrupt.

Function GPIO C3
SDA GPIO2
SCL GPIO8

External button actuator

The button pin can be used for external switches, door sensors, reed sensors and motion sensors. The button signal has to be tied to +VBAT to actuate a button press of the Picoclick.

I'm using the Picoclick as an IOT-doorbell, but here an external optocoupler is needed, because my doorbell is running on AC. (Tutorial coming soon)

Extension boards

The extension boards can be connected to the Picoclick with one of the FPC connection cables. To ensure that the pinout is correct make sure that both connecters (of the extension board and the Picoclick) are facing in the same direction.

Motion sensor (PIR)

Extension board with the Panasonic EKMB1107112 PIR motion sensor. It's output pin can be used to activate the Picoclick. I've chosen this sensor because it is an ultra low power device - it consumes only 1µA in standby, which is great for battery powered devices like the Picoclick.

Accelerometer sensor

Extension board with the LIS3DH accelerometer sensor. It's interrupt pin can be used to activate the Picoclick. The interrupt pin can be configured to be fired on any motion, a single tap or a double tap. The LIS3DH is an ultra low power sensor - it only consumes around 2µA in standby.

Light sensor

Extension board with the LTR303ALS ambient light sensor. It's interrupt pin can be used to activate the Picoclick. The thresholds can be configured via I2C. Power consumption coming soon.

Proximity sensor

Extension board with the VCNL4040 proximity and light sensor. It's interrupt pin can be used to activate the Picoclick. The thresholds can be configured via I2C. As the interrupt pin is active low there is a mosfet on the board which inverts the int state. Power consumption coming soon.

Battery voltage monitoring of the C3

The Picoclick-C3 comes with an optimized battery monitoring feature which won't consume any power while not in use. The C3T needs about 3µA of current even if not in active state.

To read the voltage of the battery you have to pull the ADC_ENABLE_PIN low after which the voltage can be read for a few milliseconds. After reading the battery voltage it is useful to go back to a high state of that pin in order to read the voltage again afterwards.

The function below reads the analog pin where the ADC is connected to and returns the filtered (sum of 100 divided by 100) battery voltage in volts. In the last row of code the raw analog value will be converted to a voltage value by using a multiplier and a constant linear offset.

float get_battery_voltage(){
  digitalWrite(ADC_ENABLE_PIN, LOW);
  delayMicroseconds(10);
  int sum = 0;
  for(int i=0; i<100; i++){
    sum = sum + analogRead(ADC_PIN);
  }
  float result = sum/100.0;
  digitalWrite(ADC_ENABLE_PIN, HIGH);
  return float(result) * (1.42) - 50;
}

Reducing power consumption

In order to reduce the power consumption of the Picoclick the following points can be done:

  • Disable WiFi while not in use (e.g. if using LED animations only): WiFi.mode(WIFI_OFF);
  • Reducing CPU frequency after WiFi stuff is completed (crystal is 40MHz): setCpuFrequencyMhz(10); //reduce to 10MHz
  • Reducing brightness of the LEDs (can be done right after FastLED init): FastLED.setBrightness(150);

Board overview (Battery connections)

C3T

C3

component description following.

Flashing firmware to the ESP32

C3T

- Press and hold the button during the complete flashing process! Otherwise the ESP32 will be loose power and the upload process will crash!

- A battery or a power supply has to be applied to the battery pads (3.5v - 5.5v) in order to flash the device!

Except the above, the Picoclick behaves like a normal development board. No need to get the ESP32 into download mode or pressing any reset button.

C3

As the C3 comes with an optimized power latching circuit, the button doesn't have to be pressed the whole flashing time. But to be recognized from the PC it has to be on while hitting the upload button, else the serial console is not active. Furthermore the C3 doesn't need a connected battery. If you wanna use the Picoclick over USB only, you can short the jumper marked jumper (TODO). Don't connect a battery or an external power supply to the pads if this jumper is shorted, else you would destroy your power source or the Picoclick itself.

Furthermore, as the +VBAT pin is available on the FPC connector, the Picoclick C3 can be powered over the extension cable. With the FPC breakout board, the device can thus simply be powered from a breadboard.

Speed up boot process

Following instructions are only needed for the C3T, not for the C3 as it doesn't use a separate latching GPIO.

Due to the latching circuit, the button press has to be longer than the boot up time of the processor, because the first task should have been executed once the button is released. For most of the use cases of the Picoclick the first task is to toggle the latch GPIO high in order to enable power hold feature of the Picoclick. If this task haven't been executed before the button is released, the Picoclick is going to standby mode without finishing its main task. Standard boot up time of the ESP32-C3 is almost 300ms. So the first task will be executed after these 300ms. This is far too long because a standard button press (especially with the metal buttons on the C3T) is around 100ms-200ms or even slightly below. Almost every task of the Picoclick would have been interrupted in this case (unless you press and hold the button...). To speed up the boot process I got familiar with the menuconfig of the ESP-IDF. Actually the reason why I've switched from the Arduino framework to ESP-IDF was that I get access to all the configs of the ESP32-C3.

Things I have done so far:

  • Set Flash SPI mode from DIO to QIO (in Serial flasher config)
  • Set Log output from Info to Warning (in component config)
  • Set Bootloader log verbosity from Info to Warning (in Bootloader config)
  • Enable Skip image validation from power on (in Bootloader config)

These points result in a boot up time of around 68ms which is almost quite fantastic. The test I've done so far were quite sufficient. If it is possible to make it even faster or if you have other ideas which could lead into the right direction then please let me know!

Power consumption

C3T

These power measurements are done with the Otii Arc power analyzer and its dedicated software. The average and peak current can be seen in the top right corner and is based on the selected frame in the current graph. The Picoclick C3T is used as an ESP-NOW slave in this case, which is probably the fastest solution of any wireless connection.

A complete Picoclick task will look like this, whereby the LED part in the end is the longest part. The whole task took about 1,7 seconds, but the transmission itself is completed after around 200ms. The other part is with disabled WiFi and only used to do some visualizations with the LED. Overall average current is below 28mA.

The ESP-NOW package is sent in the first 200ms. Average current is 73mA here.

As already said, the rest is just visualization stuff which will use 22mA of current in average.

Probably the most interesting part is the standby current, because it's the most used state of the Picoclick. As the device doesn't use any sleep mode, we're getting as low as 3µA in this state. This is only related to the battery monitoring feature. As the voltage divider between Vbat and GND is 1MOhm + 250kOhm = 1.25MOhm the current flow through it is about 3µA.

C3

coming soon.

Battery for the Picoclick

C3T

The optimal battery, which is shown in the picture below, is a 301012 LiPo battery (3.0mm thick, 10mm width, 12mm length). Nevertheless you can use whatever single cell LiPo battery you want. Charging current is set to 20mA, to be used with those 20-30mAh batteries. For larger capacity batteries the battery charging time will - of course - increase. For 20-30mAh charging time is about 1h - 1,5h.

Below are some links for those tiny batteries (no sponsor, no affiliate, just for info):

Aliexpress 301012

Aliexpress 401012

eBay 301012

C3

As the Picoclick C3 comes with an embedded battery protection, the protection of the LiPo battery itself is redundant. Therefore you can use these tiny cells which are used by BT headsets. They come in a 401010 or 301010 package.

Aliexpress 401010

Flashing adapter with pogopins

C3T

In order to flash boards without soldering wires or batteries to the Picoclick, I decided to print a simple flashing adapter which uses 1mm pogopins to make contact to the battery pads on the board. Just plug in the USB cable, shift the device in, press it down to the pogopins and hit the upload button. Simple overview is given below.

C3

Needless because the Picoclick C3 can be powered over the extension cable.

Cases

Case 2 (round) for the C3T

Round design. Combined with two M2x8mm screws.

Cases C3

coming soon.

FAQ

My Picoclick C3T is not shown on the device list when I plug it in the computer - what can I do?

  • Your Picoclick is well tested before shipping, so it is probably not broken. Make sure you have connected a decent power supply to the battery connections (3.5v - 5.5v). Battery polarity is shown above. The USB-C jack is only for charging the battery and to flash the ESP32 - not for powering the device.

Media

Hackster.io article by James Lewis: Picoclick C3T Is the World's Smallest IoT Button and It Has a RISC-V Processor

Electronics-lab.com article by Abhishek Jadhav: Picoclick C3T IOT button built around ESP32-C3 RISC-V processor – supports WIFI and BLE

About

License:MIT License


Languages

Language:C 61.5%Language:C++ 31.9%Language:Dockerfile 2.9%Language:CMake 1.7%Language:Python 1.0%Language:Makefile 1.0%