🛠 Intégration produit : alimentation VIN/VUSB, régulateur 250 mA, RTC à quartz et EEPROM
Objectives
Move the Teensy 3.2 from the breadboard bench to an integrated product: power via VIN without backfeeding into USB, do not exceed the 250 mA limit of the onboard regulator, enable the RTC (which requires a crystal to be soldered by the user), and save data in the emulated EEPROM and RTC RAM. Each point corresponds to a pitfall documented by PJRC and its forum.
Equipment
- 1 Teensy 3.2 + external 5 V power supply (or external 3.3 V for low-voltage use)
- 1 3 V coin cell battery (CR2032) for VBAT
- 1 32.768 kHz crystal to solder onto the RTC pads (not included, not soldered at the factory)
- Dremel/blade for cutting the VIN/VUSB pads — to be done with extreme caution
1) VIN and VUSB are connected: the backfeeding pitfall
On the Teensy 3.2, VUSB and VIN are connected underneath the board. Applying 5 V to VIN while the USB cable is plugged in sends current back into the computer — a risk for the USB port on both sides. To power via VIN while keeping USB connected (a "powered production, USB for debug" configuration), you must cut the link between the pads underneath the board — but be careful: cutting too deep severs the VIN trace in the internal layers of the board (repair thread on the PJRC forum). You can also power directly with external 3.3 V on the 3.3 V pin, respecting the constraint: the onboard regulator accepts a maximum of 250 mA of external load on the 3.3 V pin — a screen, LEDs, or an ESP8266 on this pin will cause a voltage drop. Indeed, the historical purpose of the reinforced regulator on the 3.2 (vs 3.1) is to be able to directly power an ESP8266 Wi-Fi module or a WIZ820io Ethernet module.
2) RTC: the crystal must be soldered
The PJRC technical specifications table is clear: the RTC requires a 32.768 kHz crystal soldered by the user onto the two dedicated pads — without it, the real-time clock simply does nothing. Once the crystal is installed:
// Le RTC garde l'heure grâce à la pile sur VBAT (3 V, type CR2032).
// 32 octets de RTC RAM (28 utilisables) sont également conservés par VBAT.
#include <TimeLib.h> // bibliothèque Time livrée avec Teensyduino
void setup {
Serial.begin(9600);
setSyncProvider(teensy3Get); // lit le RTC du MK20
if (timeStatus != timeSet) Serial.println(F("RTC pas initialise"));
}
void loop {
Serial.printf("%02d:%02d:%02d\n", hour, minute, second);
delay(1000);
}
3) Non-volatile memory
- Emulated EEPROM: 2048 bytes in the FlexNVM —
EEPROM.get/put— perfect for configurations, but handle with care (limited write cycles: write on change, not in a loop). - RTC RAM: 32 bytes (28 usable) preserved by the battery — ideal for critical state without wearing out the flash.
4) Ground wiring
The board has 3 GND pins + 1 AGND: connect the power supply and the Teensy with a clean common ground (star topology), especially when using LED strips or an audio stage.
Expected Verification
With the battery + crystal in place: the time survives a total power cut of several minutes. Removing the battery: the clock resets to zero — proof that VBAT is working. When measuring: a multimeter in current mode between the power supply and the VIN pin shows the consumption of your assembly; keep the 3.3 V part under 250 mA. >
Common Errors
- 5 V on VIN + USB plugged in without cutting the pads: current backfeeding into the PC — the symptom may be the computer's USB port tripping.
- Too aggressive cutting of the pads: the internal VIN trace is severed, the board no longer powers via VIN (delicate repair documented on the forum).
- Relying on the RTC without soldering the crystal: no clock, no time saving — this is not a bug, it is the original design.
- Writing to the EEPROM on every loop iteration: wear of the FlexNVM — compare before writing.
- Overloading the 3.3 V pin (screen + sensors + radio): random brown-outs — power peripherals with 5 V or an external regulator.
- Forgetting to connect grounds between the power supply and logic: ghost behaviors in PWM/LEDs.
Other tutorials for this board
- Premiers pas sur la Teensy 3.2 : Teensyduino, HalfKay et premier Blink
- Broches, ADC 13 bits, DAC 12 bits et PWM : dompter les E/S de la Teensy 3.2
- Un instrument MIDI USB en 10 minutes : Bounce, boutons et règle d'or du drain
- Audio Shield SGTL5000 : boucle stéréo 44,1 kHz et outil de conception graphique
- OctoWS2811 : piloter 8 rubans WS2812 en parallèle par DMA (presque zéro CPU)
- Timers matériels, interruptions imbriquées et FASTRUN : la vitesse Cortex-M4
Code examples for this board
clignotante.inoArduinotouche-capacitive.inoArduinoanalogique-12-bits.inoArduinomidi-piano.inoArduinopwm-respiration.inoArduinoservo-angle.inoArduino