Lithium Coin Cell Charger for Rechargeable Coin Batteries

This versatile charger has been designed to charge Lithium Coin Cell Rechargeable CR2016/CR2025/CR2032 Coin Batteries. Just insert the battery to the holder, and plug in to any USB port to recharge, D3 Power LED, D1 LED indicates the charge cycle. The board has been designed to use dual chips, either BQ21040 IC from Texas instruments or MCP73831 from Microchip however the board is tested with BQ21040 IC.

Programmable Charge Current using External Resistor up to 800 mA (default set to 50mA), follow formula bellow to set the desired current.

An external resistor R2 is used to Program the Output Current (50 to 800 mA) and can be used as a current monitor.

Lithium Coin Cell Charger for Rechargeable CR2016 CR2025 CR2032 Coin Batteries – [Link]

Lithium Coin Cell Charger for Rechargeable Coin Batteries

This versatile charger has been designed to charge Lithium Coin Cell Rechargeable CR2016/CR2025/CR2032 Coin Batteries. Just insert the battery to the holder, and plug in to any USB port to recharge, D3 Power LED, D1 LED indicates the charge cycle. The board has been designed to use dual chips, either BQ21040 IC from Texas instruments or MCP73831 from Microchip however the board is tested with BQ21040 IC.

Programmable Charge Current using External Resistor up to 800 mA (default set to 50mA), follow the formula bellow to set the desired current.

An external resistor R2 is used to Program the Output Current (50 to 800 mA) and can be used as a current monitor.

RISET = KISET / IOUT

Where

  • IOUT is the desired fast charge current;
  • KISET is a gain factor found in the electrical specification (1)

For greater accuracy at lower currents, part of the sense FET is disabled to give better resolution. Figure 1 shows the transition from low current to higher current. Going from higher currents to low currents, there is hysteresis and the transition occurs around 0.15 A. 

For host monitoring, a pull-up resistor is used between the STATUS terminal and the VCC of the host and for a visual indication a resistor in series with an LED is connected between the STATUS terminal and a power source. First charge after Input supply applied LED will be ON and LED will be OFF when OVP/SLEEP condition.

BQ21040 – Single-Input, Single Cell Li-Ion and Li-Pol Battery Charger

The bq21040 device is a highly integrated Li-Ion and Li-Pol linear battery charger device targeted at space limited portable applications. The device operates from either a USB port or AC adapter. The high input voltage range with input overvoltage protection supports low-cost unregulated adapters. The bq21040 has a single power output that charges the battery. A system load can be placed in parallel with the battery as long as the average system load does not keep the battery from charging fully during the 10 hour safety timer. The battery is charged in three phases: conditioning, constant current and constant voltage. In all charge phases, an internal control loop monitors the IC junction temperature and reduces the charge current if an internal temperature threshold is exceeded. The charger power stage and charge current sense functions are fully integrated. The charger function has high accuracy current and voltage regulation loops, charge status display, and charge termination.

The pre-charge current and termination current threshold are fixed to 20% and 10%, respectively. The fast charge current value is programmable through an external resistor.

Note: The board provides dual option for the charging IC, refer to datasheet of MCP73831 and use appropriate components as per data sheet.

Features (BQ21040)

  • Supply Input 5V USB Port
  • 1% Charge Voltage Accuracy
  • 10% Charge Current Accuracy
  • Low Battery Leakage Current (1 μA)
  • Output Current Approx. 50mA
  • 2-V Li-Ion and Li-Pol Coin Battery CR2016/CR2025/CR2032
  • Over temperature Sensing Protection Through NTC
  • Fixed 10-Hour Safety Timer
  • Status Indication – Charging/Done
  • OUT Short-Circuit Protection and ISET Short Detection
  • 125°C Thermal Regulation; 150°C Thermal
  • Shutdown Protection

Schematic

Parts List

Photos

 

Video

BQ21040 Datasheet

New Wio Lite RISC – V WiFi Board with ESP8266 Module for WiFi connectivity Launches for $6.9

Recently, there was a lot of buzz as the 32bit general purpose GigaDevice GD32V which is based on RISC-V open architecture as well as the Longan Nano development board with LCD display were launched into the board market. Compared to the formerly released GD32 Arm Cortex-M3 microcontroller, the GD32V RISC-V MCU is expected to deliver 15% performance improvement in Coremark and 25 – 50% lower power consumption. However, since many applications require network connectivity, there is still a strong need for wireless SoCs for RISC-V MCUs and while the founding members of the RISC-V foundation are seemingly not doing anything about it, Seeed Studio is taking a bold step and has launched the new Wio Lite RISC – V board with the ESP8266 WiFi module to bring Wi-Fi connectivity to GD32V MCU.

programming enviroment

The Wio Lite has a feather form factor that allows for feathering add-on board compatibility. It also has a similar development environment as the Longan Nano board and a support for LieOS and RT-Thread operating systems, as well as tools like the Arduino IDE, OpenOCD, PlatformIO IDE and GCC. Some of Wio Lite specifications include:

  • Wireless Module –  ESP8266 Wi-Fi Wio Core with 802.116 / g / n / WiFi 4 connectivity
  • Microcontrolling Unit – Gigadevice GD32VF103CBT6 RISC-V at 108MHz with 32KB SRAM and 128KB Flash .
  • USB – One USB Type-C port for power and programming
  • MISC – Charging and power LEDS, boot switch and reset button
  • Storage – Micro SD card slot for storage
  • Debugging – Unpopulated 6-pin JTAG header
  • Power Supply – 5V via USB Type-C port and JST2.0 Lipo battery header .
  • Power Consumption – RISC-V core power consumption.
  • I / O header for Wio Core ESP8266 module and I / O headers for GD32 MCU
RISC-V-WiFi-Board

The board works with the Grove Shield for Wio Lite, so any Grove sensor or module can be used with it, just like in the Arm-based Wio Lite W600 which sells for $9.95. It is particularly ideal for battery operated devices and interesting to those that would want to work around with the RISC-V.

The Wio Lite RISC – V board is currently up for pre-order for $6.90 and shipping is expected to commence by the end of November. However, since the RISC-V board consumes less TBC than its counterparts and has an included battery support, there is a more likelihood that maybe by next year, RISC-V WiFi and Bluetooth boards would start selling for $2 or less.

For now, there is no documentation on it as such, but you can visit Github for some images, the PCB layout and the PDF schematics. More documentation would eventually be made available at Seeed Studio’s Wiki.

NXP Launches The Gigahertz Microcontroller Era

NXP Semiconductors has announced the industry’s first crossover MCU, i.MX RT1170 28nm fully-depleted silicon-on-insulator (FD-SOI) microcontroller unit (MCU), which is a power-efficient design with real-time functionality, and MCU usability at an affordable price. It clocks its primary Arm Cortex-M7 processing core at up to 1GHz while packing a secondary Cortex-M4 core running at 400MHz. Geoff Lees, senior vice president and general manager for microcontrollers at NXP says:

“NXP saw the potential early on to create high-performance crossover MCUs, utilising the latest applications processor architecture and design philosophies. Now, with the i.MX RT1170 breaking the gigahertz barrier, we have opened up edge computing to all these technology possibilities.”

In addition to its Cortex-M7 and Cortex-M4 cores, the i.MX RT1170 features a 2D vector graphics core, NXP‘s in-house Pixel Processing Pipeline (PxP) 2D graphics accelerator, and its EdgeLock 400A embedded security platform. The new crossover MCU incorporates up to 2MB of on-chip SRAM, including 512KB that can be configured as TCM with Error Code Correction (ECC) for Cortex-M7 use, and 256KB of TCM with ECC for Cortex-M4 use.

The i.MX RT1170 dual-core system infuses a high-performance core and a power-efficient core with independent power domains of operation, enabling developers to run applications in parallel or reduce power consumption by switching off individual cores as necessary. To illustrate, the energy-efficient Cortex-M4 core can be dedicated to time-critical control applications, such as sensor hub and motor control, while the main core runs more complex applications. Additionally, its dual-core system can run ML applications in parallel, such as face recognition with natural language processing to create human-like user interactivity.

i.MX RT1170 Crossover MCU Block Diagram

As we move towards a world of a trillion connected devices, businesses are looking for real-time data insights, driving an increased requirement for on-device intelligence,”

says Dipti Vachani, senior vice president and general manager for automotive and Internet of Things (IoT) at core IP provider Arm. He continues :

“The i.MX RT1170 family efficiently combines enhanced on-device processing with low-latency performance, significantly lowering the bill of materials (BOM) cost, while pushing the boundaries of what’s possible for embedded and IoT applications.”

For edge compute applications, the GHz Cortex-M7 core enhances performance for ML, edge inference for voice, vision and gesture recognition, natural language understanding, data analytics, and digital signal processing (DSP) functions. The combination of GHz performance and high density of on-chip memory speeds up face recognition inference time by up to 5x, in comparison to today’s fastest MCUs available in the market, in addition to having processing bandwidth to improve accuracy and immunity against spoofing. The GHz core is also highly efficient in executing computationally demanding voice recognition, including audio pre-processing (echo cancellation, noise suppression, beamforming, and barge-in) for improved cognition. The GHz core also offers 720p displays at 60fps refresh and 1080p HD screens at 30fps to create immersive visual experiences. The combination of a GPU and high-performance core can be useful for smart home, industrial, and automotive cockpit applications.

NXP has confirmed it will be demonstrating the i.MX RT1170 at Arm TechCon 2019, showcasing a new record CoreMark benchmark run of 6,468 at Booth #731 on October 8th-10th 2019. More information on the part itself can be found on the NXP website.

Temperature Controlled FAN using ATtiny10

The electrons movement in electronic components lead to the generation of heat which when beyond certain thresholds, prevents some components from functioning properly and in others could lead to a catastrophic breakdown. For this reason, the topics of ventilation, overheating, and cooling are important discussions in the design of any device. Several cooling solutions, including popular ones like; the use of aluminum heat sinks, and fans/heat extractor can be adopted for a project but the ultimate choice usually depends on the amount of heat produced and the maximum level the components can withstand. Heat extractors/fans are used in devices like Laptop computers and similar in which the amount of heat being generated could get really high. To save power and reduce noise levels, the fans are deployed in a feedback-based system such that the they only come on when certain heat threshold is attained and goes back off when heat levels are back to normal. For today’s tutorial, we will examine how a DIY version of this temperature-controlled fan can be built and deployed in your electronics project.

While there are several solutions for this issue on the internet, this project will chronicle the efforts of Zak Kemble during the construction of his bench power supply due to the compact and standalone module-like nature of his build.

At the end of the tutorial, you will be able to build a microcontroller based FAN controller to be used in your electronic devices.

Required Components

The following components are required to build this project;

  1. ATtiny10
  2. Delta EFB0412VHD or equivalent fan
  3. Push-button
  4. Ceramic Capacitor 1uf x 2
  5. 1N4148WT diode
  6. Resistors (10k, 100 ohms, 10k)
  7. DMG6968U-7 MOSFET
  8. 10k NTC thermistor
  9. USBasp programmer

A more comprehensive BOM generated from the schematics is provided in the table below. Since the project is expected to be deployed in a device, the decision was made to use mostly SMD-type components as it will help reduce space occupied by the device.

Part Value Device Package Description
C1 1u CAP_CERAMIC_0603MP _0603MP Ceramic Capacitors
C2 1u CAP_CERAMIC_0603MP _0603MP Ceramic Capacitors
C3 1n CAP_CERAMIC0402_SMALL 0402_SMALL
D1 1N4148WT DIODESOD-523 SOD-523 Diode in 0805 package
JP1 PINHD-1X3 1X03 PIN HEADER
JP4 2WAY 2WAY
Q1 DMG6968U-7 MOSFET-NWAVE SOT23-W N-Channel Mosfet
R1 10k RESISTOR0402_SMALL 0402_SMALL
R2 100R RESISTOR0402_SMALL 0402_SMALL
R3 10k RESISTOR0402_SMALL 0402_SMALL
SW1 SPST_TACTG75_3X4 TACT_SMD5
U1 ATTINY10 ATTINY10SM_PAD SOT23-6_SM_PAD
U2 MCP1703T-5002E/CB MCP1700T-2502E/TTWIDE_PAD SOT-23 Low Quiescent Current LDO
X1 22-23-2031 22-23-2031 22-23-2031 0.1

All of these components can be bought from electronics component suppliers like digikey.

Schematics

As mentioned above, most of the components used are SMD type which means the project is best implemented on a PCB. As such the schematic was designed using Autodesk Eagle CAD. The components are connected as shown in the image below:

 

To make it easy to connect the Delta EFB0412VHD fan to the PCB, a 1 x 3 header pin was used.

After the schematics design has been done, we then switch to the Eagle Board Layout where the PCB is created. The PCB after routing looks like the image below;

Viewing in 3D to get insight into how things will look after manufacturing:

The schematics and PCB files are provided in a zip file under the download section to make it easy to generate the Gerber files or make any modification you desire on the project.

Preparing the Arduino IDE

While the code for today’s project could have been developed using platforms like Atmel Studio, we will use the Arduino IDE due to it’s popularity and the fact that using it could also teach you a new hack.

Programming the ATtiny10 with the Arduino IDE is a bit different from how the IDE works for other microcontrollers because unlike the SPI protocol used in programming larger AVR chips like the Atmega328p on the Arduino Uno, the ATtiny10 uses a programming protocol called TPI (Tiny Programming Interface) which needs only five wires. As such, it requires modifications in the software and hardware involved.

For software modification, we will need to add the Attiny10 core to the Arduino IDE. While there are a few ATtiny10 cores out there, for this project, we will use the Core developed by Johnson Davies. The core is essentially a boards.txt file that adds options for ATtiny10/9/5/4 to the Arduino IDE’s Board menu so they can be programmed using the Arduino IDE. However, this core doesn’t include the Arduino support core, as a result, it does not support the popular Arduino functions like pinMode(), millis(), etc., so the code must be developed in pure C programming language.  To install the ATtiny10 Core, download the core from it’s GitHub page. Extract the zip file, and copy its content to the hardware folder inside the Arduino folder (the same folder where your sketches and Library folder is located) in your Documents folder. If there is no hardware folder, create it before doing any other thing. According to the Github page, the ATtiny10Core should work with all versions of the official Arduino IDE (from arduino.cc) from version 1.6.3 onwards but versions from 1.8.3 and up are recommended.

 

USBasp Programmer

On the hardware side, the popular usb-serial converters cannot be used in programming the ATtiny10 due to the TPI interface requirement but fortunately for us, Thomas Fischl created an excellent USBasp programmer which supports this protocol so you can build your own using his guide or just order one with a 10pin or 6pin adapter for ISP from his website or others like eBay and Banggood.

With all of these in place, we are now ready to write the code for the project.

Code

As mentioned above, the ATtiny10 core being used does not support the Arduino functions so we need to develop the code in pure C/C++. To do this effectively, one needs to understand how the Arduino functions translate in core C/C++ and how ports work. You can check out these explanations to better understand it.

As usual I will do a quick breakdown of the code to explain how each of the parts work.

We start the code by including libraries that allow us use standard AVR register definitions and standard C++ routines.

#include <stdint.h>
#include <avr/io.h>
#include <avr/power.h>
#include <avr/wdt.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <util/delay.h>

Next, we create variables to hold the state of the fan, intervals at which the temperature is measured, and temperature threshold at which it is declared HOT or COLD.

#define FAN_OVERRIDE_NONE	0
#define FAN_OVERRIDE_ON		1
#define FAN_OVERRIDE_OFF	2

#define FAN_COOL_TIME		125 // 125 * 64ms = 8s // Keep fan on for this much longer after COOL_VAL has been reached
#define TEMP_MEASURE_INTERVAL	32 // 32 * 64ms = 2s // How often to measure temperature

#define HOT_VAL				23 // Sense: 4k @ ??C
#define COOL_VAL			27

Next, we declare that the state of each of the pin should be and the value  that should be associated with that state.

#define FAN_ON() (PORTB |= _BV(PORTB0))
#define FAN_OFF() (PORTB &= ~_BV(PORTB0))
#define BTN_ISPRESSED() (!(PINB & _BV(PINB1)))

Next, we create the main function. The main function is similar to the void loop() as it contains the code snippets we hope to run perpetually but unlike the Arduino void loop function, it also contains code snippets similar to what we would have written for the void setup() function. The convention used in the Arduino version can however be retained but for this tutorial we will write the standard C version of the main() function.

We start the main() function by setting the clock and declaring the pin mode of the pin on the port that we will be using as 0 (Indicating the PinMode as input). After this we activate the internal pull up resistors using a separate pullup register, PUEB, power off analog comparators, setup the ADC and power off everything else to save power.

int main(void)
{
  clock_prescale_set(CPU_DIV);

  DDRB |= _BV(DDB0);
  PUEB |= _BV(PUEB1);

  ACSR = _BV(ACD); // Power off analogue comparator

  // Setup ADC
  ADMUX = _BV(MUX1);
  ADCSRA = _BV(ADIE)|_BV(ADPS2)|_BV(ADPS0);
  DIDR0 = _BV(ADC2D);

  power_all_disable(); // Power off everything else

Next we initialize variables that will be used to; hold the last temperature to determine if a change has occurred, check if the button is pressed or not, and start the fan in an override mode. With that done, we set the global interrupt flag by calling sei().

      uint8_t now = 0;
uint8_t lastMeasureTemp = 0;
uint8_t lastHotTime = (0 - FAN_COOL_TIME) + 31; // Turn fan on for 2 seconds at power on
uint8_t hot = 0;
uint8_t btnIsPressed = 0;
uint8_t fanOverride = FAN_OVERRIDE_NONE;

sei();

Next we handle Watchdog resets and finally write the code that compares the temperature level and turns the fan “ON” or “OFF” depending on it while also checking the pushbuttons in every 64ms to see if the mode of use has changed. Depending on the Mode, the Fan can either be activated or not. If the pushbutton is pressed, the system checks the last state of the fan and switches to an opposite state and continues to run in that opposite state until the push button is pressed again. However, if the button is not pressed the fan runs its on and off duty based on the temperature and time.

  sei();

  // Was reset by the watchdog (mainly for debugging)
  if(rstflr_mirror & _BV(WDRF))
  {
    while(1)
    {
      // _delay_ms() is giving some asm error (avr-libc bug? GCC 8.3.0)
      for(uint16_t i=0;i<20000;i++)
      {
        WDT_INT_RESET();
        _delay_us(100);
      }
      //_delay_ms(2000);
    
      FAN_ON();

      // _delay_ms() is giving some asm error (avr-libc bug? GCC 8.3.0)
      for(uint16_t i=0;i<5000;i++)
      {
        WDT_INT_RESET();
        _delay_us(100);
      }
      //_delay_ms(500);
    
      FAN_OFF();
    }
  }

  WDT_INT_RESET();

  while(1)
  {
    // Timer stuff, increments every 64ms from the WDT
    // Also turns the WDT back on
    if(WDT_TIMEDOUT())
    {
      WDT_INT_RESET();
      now++;
    }

    if((uint8_t)(now - lastMeasureTemp) >= TEMP_MEASURE_INTERVAL)
    {
      // Pullup enable
      PUEB |= _BV(PUEB2);

      lastMeasureTemp = now;

      // Wait for a bit for voltage to stabilize
      // _delay_ms() is giving some asm error (avr-libc bug? GCC 8.3.0)
      for(uint8_t i=0;i<10;i++)
        _delay_us(100);
      //_delay_ms(1);

      // Do an ADC convertion
      power_adc_enable();
      ADCSRA |= _BV(ADEN)|_BV(ADSC);
      set_sleep_mode(SLEEP_MODE_ADC);
      sleep_mode();
      loop_until_bit_is_clear(ADCSRA, ADSC); // In case we wakeup from another interrupt before the convertion completes
      uint8_t val = ADCL;
      ADCSRA &= ~_BV(ADEN);
      power_adc_disable();

      // Pullup disable
      PUEB &= ~_BV(PUEB2);

      if(val > COOL_VAL)
        hot = 0;
      else if(val < HOT_VAL)
        hot = 1;
      // else we're between the hot and cool values (hysteresis)

      if(hot)
        lastHotTime = now;
    }

    // Don't need to bother with switch debouncing here since we only loop every ~64ms from the WDT
    if(BTN_ISPRESSED() && !btnIsPressed)
    {
      btnIsPressed = 1;

      if(fanOverride == FAN_OVERRIDE_NONE)
      {
        fanOverride = FAN_OVERRIDE_ON;
        FAN_ON();
      }
      else if(fanOverride == FAN_OVERRIDE_ON)
      {
        fanOverride = FAN_OVERRIDE_OFF;
        FAN_OFF();
      }
      else
      {
        fanOverride = FAN_OVERRIDE_NONE;
        if(!hot)
          lastHotTime = now - FAN_COOL_TIME;
      }
    }
    else if(!BTN_ISPRESSED() && btnIsPressed)
      btnIsPressed = 0;

    if(fanOverride == FAN_OVERRIDE_NONE)
    {
      if(hot || (uint8_t)(now - lastHotTime) < FAN_COOL_TIME)
        FAN_ON();
      else
      {
        FAN_OFF();
        lastHotTime = now - FAN_COOL_TIME;
      }
    }

    // Sleep if nothing to do
    cli();
    if(!WDT_TIMEDOUT())
    {
      set_sleep_mode(SLEEP_MODE_PWR_DOWN);
      sleep_enable();
      //sleep_bod_disable();
      sei();
      sleep_cpu();
      sleep_disable();
    }
    sei();
  }
}

EMPTY_INTERRUPT(WDT_vect);
EMPTY_INTERRUPT(ADC_vect);

The complete code for the project is provided below and attached in the zip file under the download section.

#include <stdint.h>
#include <avr/io.h>
#include <avr/power.h>
#include <avr/wdt.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <util/delay.h>

#define FAN_OVERRIDE_NONE	0
#define FAN_OVERRIDE_ON		1
#define FAN_OVERRIDE_OFF	2

#define FAN_COOL_TIME		125 // 125 * 64ms = 8s // Keep fan on for this much longer after COOL_VAL has been reached
#define TEMP_MEASURE_INTERVAL	32 // 32 * 64ms = 2s // How often to measure temperature

// Temperature sensor resistance is 10k @ 22C
// Sensor resistance goes down as temperature goes up
// Pullup resistance is around 40k
// Lower value = hotter
#define HOT_VAL				23 // Sense: 4k @ ??C
#define COOL_VAL			27

#define WDT_INT_RESET()		(WDTCSR |= _BV(WDIE)|_BV(WDE)) // NOTE: Setting WDIE also enables global interrupts
#define WDT_TIMEDOUT() (!(WDTCSR & _BV(WDIE)))

#define FAN_ON() (PORTB |= _BV(PORTB0))
#define FAN_OFF() (PORTB &= ~_BV(PORTB0))
#define BTN_ISPRESSED() (!(PINB & _BV(PINB1)))

// PB0 = Fan out
// PB1 = Switch in
// PB2 = Temp sense ADC

static uint8_t rstflr_mirror __attribute__((section(".noinit,\"aw\",@nobits;"))); // BUG: https://github.com/qmk/qmk_firmware/issues/3657

void get_rstflr(void) __attribute__((naked, used, section(".init3")));
void get_rstflr()
{
  rstflr_mirror = RSTFLR;
  RSTFLR = 0;

  //wdt_disable(); 
  wdt_enable(WDTO_60MS);
}

int main(void)
{
  clock_prescale_set(CPU_DIV);

  DDRB |= _BV(DDB0);
  PUEB |= _BV(PUEB1);

  ACSR = _BV(ACD); // Power off analogue comparator

  // Setup ADC
  ADMUX = _BV(MUX1);
  ADCSRA = _BV(ADIE)|_BV(ADPS2)|_BV(ADPS0);
  DIDR0 = _BV(ADC2D);

  power_all_disable(); // Power off everything else

  uint8_t now = 0;
  uint8_t lastMeasureTemp = 0;
  uint8_t lastHotTime = (0 - FAN_COOL_TIME) + 31; // Turn fan on for 2 seconds at power on
  uint8_t hot = 0;
  uint8_t btnIsPressed = 0;
  uint8_t fanOverride = FAN_OVERRIDE_NONE;
  
  sei();

  // Was reset by the watchdog (mainly for debugging)
  if(rstflr_mirror & _BV(WDRF))
  {
    while(1)
    {
      // _delay_ms() is giving some asm error (avr-libc bug? GCC 8.3.0)
      for(uint16_t i=0;i<20000;i++)
      {
        WDT_INT_RESET();
        _delay_us(100);
      }
      //_delay_ms(2000);
    
      FAN_ON();

      // _delay_ms() is giving some asm error (avr-libc bug? GCC 8.3.0)
      for(uint16_t i=0;i<5000;i++)
      {
        WDT_INT_RESET();
        _delay_us(100);
      }
      //_delay_ms(500);
    
      FAN_OFF();
    }
  }

  WDT_INT_RESET();

  while(1)
  {
    // Timer stuff, increments every 64ms from the WDT
    // Also turns the WDT back on
    if(WDT_TIMEDOUT())
    {
      WDT_INT_RESET();
      now++;
    }

    if((uint8_t)(now - lastMeasureTemp) >= TEMP_MEASURE_INTERVAL)
    {
      // Pullup enable
      PUEB |= _BV(PUEB2);

      lastMeasureTemp = now;

      // Wait for a bit for voltage to stabilize
      // _delay_ms() is giving some asm error (avr-libc bug? GCC 8.3.0)
      for(uint8_t i=0;i<10;i++)
        _delay_us(100);
      //_delay_ms(1);

      // Do an ADC convertion
      power_adc_enable();
      ADCSRA |= _BV(ADEN)|_BV(ADSC);
      set_sleep_mode(SLEEP_MODE_ADC);
      sleep_mode();
      loop_until_bit_is_clear(ADCSRA, ADSC); // In case we wakeup from another interrupt before the convertion completes
      uint8_t val = ADCL;
      ADCSRA &= ~_BV(ADEN);
      power_adc_disable();

      // Pullup disable
      PUEB &= ~_BV(PUEB2);

      if(val > COOL_VAL)
        hot = 0;
      else if(val < HOT_VAL)
        hot = 1;
      // else we're between the hot and cool values (hysteresis)

      if(hot)
        lastHotTime = now;
    }

    // Don't need to bother with switch debouncing here since we only loop every ~64ms from the WDT
    if(BTN_ISPRESSED() && !btnIsPressed)
    {
      btnIsPressed = 1;

      if(fanOverride == FAN_OVERRIDE_NONE)
      {
        fanOverride = FAN_OVERRIDE_ON;
        FAN_ON();
      }
      else if(fanOverride == FAN_OVERRIDE_ON)
      {
        fanOverride = FAN_OVERRIDE_OFF;
        FAN_OFF();
      }
      else
      {
        fanOverride = FAN_OVERRIDE_NONE;
        if(!hot)
          lastHotTime = now - FAN_COOL_TIME;
      }
    }
    else if(!BTN_ISPRESSED() && btnIsPressed)
      btnIsPressed = 0;

    if(fanOverride == FAN_OVERRIDE_NONE)
    {
      if(hot || (uint8_t)(now - lastHotTime) < FAN_COOL_TIME)
        FAN_ON();
      else
      {
        FAN_OFF();
        lastHotTime = now - FAN_COOL_TIME;
      }
    }

    // Sleep if nothing to do
    cli();
    if(!WDT_TIMEDOUT())
    {
      set_sleep_mode(SLEEP_MODE_PWR_DOWN);
      sleep_enable();
      //sleep_bod_disable();
      sei();
      sleep_cpu();
      sleep_disable();
    }
    sei();
  }
}

EMPTY_INTERRUPT(WDT_vect);
EMPTY_INTERRUPT(ADC_vect);

Uploading the Code

With the code verified, PCB soldered, and every other thing in place, follow the steps below to upload the code to the Attiny10.

Connect USBasp Programmer to ATtiny10
  1. Connect the USBasp to the ATtiny10 as shown in the diagram above.
  2. Select the board type from the options under the ATtiny10 core board options under the tool menu.  Tools->Board -> ATtiny10 
  3. Under the programmer option, select USBasp as the programmer. Tools -> Programmer-> USBasp
  4. Hit the upload button

Do note that the code could also be developed using platforms like Atmel Studio and the procedure would have been only a little bit different.

Demo

With the code uploaded, connect/mount the smart fan on one of your projects/devices. As the device gets hot or cold, you should see the fan come on and go off.

To test the project, it was connected it to a Bench Power supply and the overall performance was definitely better than when an ordinary heat sink was used. A picture of Zak’s setup is shown in the image below.

That’s it. The idea of the project was to provide you with a module like unit that can be used to maintain acceptable temperature levels in your project. Feel free to reach out to me via the comment section if you have any issue replicating this.

References:

World’s smallest and most affordable 65W GaN Adapter for Laptops and Mobile Devices

Though the sizes of laptops and mobile phones have become smaller and lighter over the years, that of power adapters have pretty much remained the same. They are still the same device we have always known them to be; bulky, messy and hard-to-carry-around. But the new GaNtechnology seeks to bring a revolution in the world of power electronics.

The new series of SlimQ power adapters made of GaN technology is a new set of smaller and lighter adapters that works for all modern models of laptops and phones that use USB Type-C power supply up to 65W.

The SlimQ 65W power adapter is the world’s first and smallest most-affordable power adapter. It is safe, more powerful and more efficient with a high-quality built to give protection against input and output over current protection, over-voltage, short current, leakage, and electric surge,anti-electromagnetic and anti-ripple effect. The 65W adapter is about 6ft/1.8m in size, elastic, durable, supports Type-C to Type-C and has a current capacity of 3.5A. It also works great with major laptop brands that use non-Type-C for the power supply but comes with a converter cable as a part of the accessories.

The SlimQ 65W power adapter is sold at a retail price of $16 and its hardware and accessories come with a limited one year warranty. Apart from the countries that have been flagged by courier services, the adapters can be shipped to anywhere in the world but come with more cost if you wish to ship to any of those countries. To order the adapter, simply visit the Indiegogo site to select the particular “perk” you’d want to buy. There are quite a number of perks there, so you’d have to swipe right and left to find the particular one you want. Click on payment and proceed to select add-on perks that you will find the cables compatible with your laptop.

The SlimQ is travels-friendly as it comes with a travel bag in which it can be stowed away. It has a default US-style plug but there is a free converter that comes with it for you to use if you are out of the United States. For instance, a UK style converter is included for those in places like UK, Singapore, Hong-Kong and likewise an AU style converter for New Zealand, Australia and an EU converter for those in Italy, France, Germany, Swiss. There are also applicable VAT/GST charges that depend on your country’s regulations. Shipping fees vary among different countries and it is through post service but a different shipping method can be arranged if ordered.

u-blox’s latest meter-level positioning technology offers enhanced GNSS performance

u-blox, a global provider of leading positioning and wireless communication technologies, has announced its new ultra-robust meter-level M9 global positioning technology platform, designed for demanding automotive, telematics, and UAV applications.

Thanks to its high performance GNSS chip, UBX-M9140, the M9 technology platform and the NEO-M9N, the first module based on the platform, can receive signals from up to four GNSS constellations (GPS, Glonass, Beidou, and Galileo) concurrently, in order to achieve high positional accuracy even in difficult conditions such as deep urban canyons. The u-blox M9 offers a position update rate of up to 25 Hz, enabling dynamic applications like UAVs to receive position information with low latency.

The u-blox M9 also features a special filtering against RF interference and jamming, spoofing detection, and advanced detection algorithms that enable it to report fraudulent attacks quickly so that users’ systems can react to them in a timely fashion. A SAW (surface acoustic wave) filter combined with an LNA (low noise amplifier) in the RF path is integrated in the NEO-M9N module. This setup guarantees normal operations even under strong RF interferences, for example when a cellular modem is co-located with the NEO-M9N.

“We’ve developed the u-blox M9 as a follow-on from our very successful u-blox M8 GNSS platform, offering even more robust meter-level positioning technology and security features to protect the integrity of applications in the automotive, telematics, and UAV markets,” says Bernd Heidtmann, Product Manager, Product Strategy GNSS, Product Center Positioning, at u-blox.

Users of the u-blox M9 will therefore benefit from it being part of the wider u-blox product family, which means that developers will be able to design a single PCB and then migrate to a different positioning technology, such as dead reckoning augmenting GNSS technology, with very little change to the board design.

https://www.u-blox.com/en

Mini Speaker Attached Audio Amplifier using TS4871

This Mini Audio Power Amplifier is capable of delivering 1W of continuous RMS Output Power into 8 ohms load @ 5V. The Amplifier is built using TS4871 IC from ST.  This Audio Amplifier is exhibiting 0.1% distortion level (THD) from a 5V supply for a Pout = 250mW RMS. An external standby mode control reduces the supply current to less than 10nA. An internal thermal shutdown protection is also provided. The amplifier has been designed for high quality audio applications such as mobile phones, media players and portable device. The gain is set to 6dB but unity-gain stable amplifier can be configured by external gain setting resistor R4. 28mm ID hole provided for easy mounted of PCB directly on speaker.

Mini Speaker Attached Audio Amplifier using TS4871 – [Link]

RAKWireless RAK4260 is a Tiny LoRAWAN Module based on Microchip SAMR34 LoRa SiP

Rakwireless has just announced a new module part of their LPWAN family:  RAK4260 LoRaWAN module based on Microchip ATSAMR34J18B LoRa SiP and at just 15x15x1.2 mm, one of the smallest LoRaWAN modules in the market.

The new module is cheaper than the company’s earlier RAK811 module and consumes less power at just 790 nA in sleep mode. The company also provides a RAK4260 evaluation board with easy access to GPIOs and serial interfaces.

Key Specifications:

  • High quality Low power LoRa® device (Microchip ATSAMR34J18 SiP)
  • Fully supported 862 to 1020 MHz frequency coverage (all LoRaWAN bands)
  • High level of accuracy and stability (32MHz TXCO)
  • Max Tx Power: 20dBm; Max Sensitivity: -148dBm; Rx Current: 17mA (typical)
  • Rich selection of interfaces: I2C, SPI, ADC, UART, GPIOs
  • Small form factor: 6×6 mm compact BGA package

Specifications:

  • SiP – Microchip ATSAMR34J18 SiP with SAM L21 Arm Cortex M0+ MCU @ 48 MHz, up to 40 KB RAM, up to 256 KB Flash
  • LoRa Connectivity
    • Frequency Range – 862 to 1020 MHz
    • High level of accuracy and stability (32MHz TXCO)
    • Max Tx Power: 20dBm; Max Sensitivity: -148dBm; Rx Current: 17mA (typical)
    • Compliant with LoRaWan 1.0.2
  • Expansion – Castellated holes with I2C, SPI, ADC, UART, GPIOs
  • Power Consumption
    • Low RX current of 13.6mA
    • 790 nA in sleep mode
  • Dimensions – 15×15 mm

RAK4260 Evaluation Board

The evaluation board is based on RAK5005 carrier board and RAK4261 intermediate board which has RAK4260 soldered to it.

There aren’t any details about the board by we can see three power options with micro USB port, 2-pin battery header, and 2-pin solar panel header. There are various expansion headers as well as and connectors for Wisblock add-on modules.

Documentation and Software

Documentation is still work in progress, but you’ll find a getting started guide on the documentation page explaining how to flash the firmware, and configure the board with The Things Network (TTN). The demo firmware is based on Microchip SDK, and you’ll find the source code on Github.

Availability and Pricing

Both the module and evaluation board are available on Aliexpress, with a pack of 50 modules selling for $440 (or $8.80 per unit), and the EVB4260 EVB going for $25 plus shipping.

More information may eventually be available on the product page.

via www.cnx-software.com

Mini Speaker Attached Audio Amplifier using TS4871

This Mini Audio Power Amplifier is capable of delivering 1W of continuous RMS Output Power into 8 ohms load @ 5V. The Amplifier is built using TS4871 IC from ST.  This Audio Amplifier is exhibiting 0.1% distortion level (THD) from a 5V supply for a Pout = 250mW RMS. An external standby mode control reduces the supply current to less than 10nA. An internal thermal shutdown protection is also provided. The amplifier has been designed for high quality audio applications such as mobile phones, media players and portable device. The gain is set to 6dB but unity-gain stable amplifier can be configured by external gain setting resistor R4. 28mm ID hole provided for easy mounted of PCB directly on speaker.

Connections: D1 Power LED, CN1 Power input, LS1 Speaker, CN2 Audio Signal Input.

Note : Default Gain 6dB, Change R4 to 110K to set the Gain to 20dB.

Specifications

  • SUPPLY 5V
  • 1W RAIL TO RAIL OUTPUT POWER
  • Vcc=5V, THD=1%, f=1kHz, with 8W LOAD
  • ULTRA LOW CONSUMPTION IN STANDBY MODE (10nA)
  • 75dB PSRR @ 217Hz from 5V to 2.6V
  • Gain 6dB
  • ULTRA LOW POP & CLICK
  • ULTRA LOW DISTORTION (0.1%)
  • UNITY GAIN STABLE
  • PCB Dimensions 42.42mm OD & 28mm ID

Schematic

Parts List

Connections

Photos

 

Video


TS4871 Datasheet

TOP PCB Companies