Skip to content

igungor06/Teensy-4.1-Pin-Configuration-Web-Interface

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Teensy 4.1 Pin Configuration Web Interface

A comprehensive web-based pin configuration tool for the Teensy 4.1 microcontroller with EEPROM persistence and real-time control.

Teensy 4.1 Configuration Interface

Features

🎯 Core Functionality

  • Web-Based Interface: Modern, responsive web UI accessible via Ethernet
  • Real-Time Pin Control: Configure and monitor all 42 GPIO pins in real-time
  • EEPROM Persistence: Pin configurations automatically saved and restored on power-up
  • Multiple Pin Modes: Support for INPUT, OUTPUT, PWM, ANALOG_IN, and protocol modes
  • Live Pin Monitoring: Real-time display of pin states and analog values

🔧 Supported Pin Modes

  • Digital I/O: INPUT, OUTPUT, INPUT_PULLUP, INPUT_PULLDOWN
  • Analog: ANALOG_IN (ADC), PWM output (0-255)
  • Serial/UART: RX1-RX8, TX1-TX8 (8 hardware serial ports)
  • I2C: SDA0-SDA2, SCL0-SCL2 (3 I2C buses)
  • SPI: MOSI, MISO, SCK, CS (2 SPI buses)
  • CAN: CTX1-CTX3, CRX1-CRX3 (3 CAN buses)

🎨 User Interface

  • Visual Pin Layout: Interactive board representation matching physical pinout
  • Glassmorphism Design: Modern, premium UI with smooth animations
  • Auto-Refresh: Optional 10-second auto-refresh for live monitoring
  • Scroll Position Memory: Maintains scroll position across page refreshes
  • Arduino Code Export: Generate setup code from current configuration

📊 System Information Display

  • Network: IP address, MAC address, link status
  • Hardware: Board type, processor, CPU speed, temperature
  • Memory: Flash, RAM, EEPROM specifications
  • Uptime: System runtime tracking
  • Peripheral Status: SD Card, QSPI Memory, Ethernet, USB Host/Device

Hardware Requirements

  • Teensy 4.1 microcontroller
  • Ethernet connection (built-in Ethernet PHY)
  • Power supply (USB or external 5V)

Pin Capabilities

The interface automatically detects and displays available modes for each pin based on Teensy 4.1 specifications:

Pin Range Capabilities
0-1 Serial1 (RX1/TX1), CAN2, Touch
2-9 Digital I/O, PWM, Serial2
10-13 SPI (MOSI, MISO, SCK, CS), PWM
14-23 Analog (A0-A9), Serial3-5, I2C, PWM
24-27 Analog (A10-A13), Serial6, I2C2, SPI1
28-32 Serial7, PWM, CAN3
33-37 Digital I/O, PWM, SD Card
38-41 Analog (A14-A17), SPI1

Installation

1. Arduino IDE Setup

# Install Teensyduino add-on from:
# https://www.pjrc.com/teensy/td_download.html

2. Required Libraries

  • NativeEthernet (included with Teensyduino)
  • SPI (Arduino built-in)
  • EEPROM (Arduino built-in)

3. Upload

  1. Open teensy41-PinConfiguration.ino in Arduino IDE
  2. Select Tools > Board > Teensy 4.1
  3. Select Tools > USB Type > Serial
  4. Click Upload

Usage

Initial Setup

  1. Connect Ethernet: Plug Ethernet cable into Teensy 4.1
  2. Power On: Connect USB or external power
  3. Find IP Address: Check Serial Monitor (115200 baud) for assigned DHCP IP
  4. Access Web Interface: Open browser and navigate to the IP address

Web Interface Controls

Pin Configuration

  1. Select Mode: Click mode buttons (IN, OUT, PWM, AIN, etc.)
  2. Set Output Value:
    • Digital: Click "SET HIGH" or "SET LOW"
    • PWM: Drag slider (0-255, displays as percentage)
  3. Monitor Input: View real-time values for INPUT and ANALOG_IN modes

Special Features

  • Auto-Refresh Toggle: Enable/disable automatic page refresh
  • Arduino Code Export: Copy generated setup code for standalone use
  • Scroll Memory: Page remembers scroll position during navigation

EEPROM Persistence

Pin configurations are automatically saved to EEPROM when changed and restored on power-up:

// Magic number verification: 0xAA55
// Storage: 4 bytes per pin (mode + value_high + value_low + reserved)
// Total: 2 bytes (magic) + 168 bytes (42 pins × 4)

Network Configuration

Default Settings

  • DHCP: Enabled by default
  • MAC Address: DE:AD:BE:EF:FE:ED
  • HTTP Port: 80

Static IP Configuration

To use a static IP, modify the setup() function:

// Replace:
Ethernet.begin(mac);

// With:
IPAddress ip(192, 168, 1, 100);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
Ethernet.begin(mac, ip, gateway, subnet);

API Reference

URL Endpoints

GET /

Returns the main web interface

GET /config?pin=X&mode=MODE&value=VALUE

Configure a pin

  • pin: Pin number (0-41)
  • mode: Pin mode (INPUT, OUTPUT, PWM, ANALOG_IN, etc.)
  • value: Pin value (HIGH/LOW for digital, 0-255 for PWM)

Example:

/config?pin=13&mode=OUTPUT&value=HIGH
/config?pin=3&mode=PWM&value=128

GET /toggleRefresh

Toggle auto-refresh on/off

Technical Details

Memory Usage

  • EEPROM: 170 bytes (2 magic + 168 pin data)
  • Flash: ~60KB (code + HTML)
  • RAM: ~15KB (runtime)

Performance

  • Web Response Time: <100ms typical
  • Client Timeout: 500ms (prevents blocking)
  • Update Rate: 2-second stats refresh
  • Auto-Refresh: 10 seconds (when enabled)

Pin Mode Encoding

0  = INPUT
1  = INPUT_PULLUP
2  = INPUT_PULLDOWN
3  = OUTPUT
4  = PWM
5  = ANALOG_IN
6  = SERIAL_RX
7  = SERIAL_TX
8  = I2C_SDA
9  = I2C_SCL
10 = SPI_MOSI
11 = SPI_MISO
12 = SPI_SCK
13 = SPI_CS
14 = CAN_TX
15 = CAN_RX

Troubleshooting

Cannot Access Web Interface

  1. Check Ethernet cable connection
  2. Verify DHCP server is available
  3. Check Serial Monitor for IP address
  4. Try ping to verify network connectivity

Pin Not Responding

  1. Verify pin supports requested mode
  2. Check for hardware conflicts (e.g., SPI pins if using SD card)
  3. Ensure pin is not used by system (Ethernet uses pins internally)

Configuration Not Persisting

  1. Check Serial Monitor for EEPROM write confirmations
  2. Verify magic number is written (0xAA55)
  3. Try manual save: modify any pin to trigger EEPROM write

Page Not Refreshing

  1. Check Auto-Refresh toggle status
  2. Clear browser cache
  3. Verify network stability

Advanced Usage

Exporting Configuration

  1. Scroll to "Arduino Code Export" section
  2. Click textarea to select all code
  3. Copy (Ctrl+C) and paste into your sketch
  4. Call applyPinConfiguration() in setup()

Integration with Other Code

The web server runs in loop() and uses non-blocking code. Safe to integrate with:

  • Sensor reading
  • Motor control
  • Communication protocols
  • Real-time tasks

Important: Keep loop() code fast (<10ms) to maintain web responsiveness.

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues for:

  • Bug fixes
  • Feature enhancements
  • Documentation improvements
  • UI/UX refinements

License

This project is open source and available under the MIT License.

Credits

  • Hardware: PJRC Teensy 4.1
  • Libraries: NativeEthernet, Arduino Core
  • UI Design: Modern glassmorphism with gradient backgrounds

Version History

v1.0 (Current)

  • Initial release
  • Full pin configuration support
  • EEPROM persistence
  • Modern web interface
  • Real-time monitoring
  • Arduino code export

Support

For issues, questions, or suggestions:


Made with ❤️ for the Teensy community

About

Teensy 4.1 Pin Configuration Web Interface

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages