Skip to content

9658-Camber-Robotics/batteries

Repository files navigation

Camber Robotics' Battery Management System

NextJS Redis TypeScript Tailwind CSS shadcn/ui

A modern web application for FRC robotics teams to track, manage, and maintain their robot batteries. This system helps teams ensure they always have charged batteries ready for matches and practice sessions.

Battery Management UI

Table of Contents

Features

  • Real-time battery status tracking (Charged, Charging, Needs Charging)
  • Battery voltage monitoring
  • Simple, intuitive UI for quick status updates
  • Automatic data refreshing (every 10 seconds)
  • Responsive design for use on various devices in the pit area

Technology Stack

  • Frontend: Next.js with React
  • Backend: Next.js API Routes
  • Database: Redis (via Upstash)
  • UI Components: Custom components with Tailwind CSS
  • Form Management: React Hook Form with Zod validation

Getting Started

Prerequisites

  • Node.js 16+ and npm/yarn
  • Upstash Redis account (or any Redis instance)

Installation

  1. Clone the repository
git clone https://github.com/your-team/frc-battery-manager.git
cd frc-battery-manager
  1. Install dependencies
npm install
# or
yarn install
  1. Create a .env.local file with your Redis credentials
UPSTASH_REDIS_REST_URL=your-redis-url
UPSTASH_REDIS_REST_TOKEN=your-redis-token
  1. Run the development server
npm run dev
# or
yarn dev
  1. Open http://localhost:3000 in your browser

Customization Guide

Adding More Batteries

Edit the app/api/batteries/route.ts file to change the number of default batteries:

// Change the number in the Array.from to adjust battery count
const defaultBatteries = Array.from({ length: 10 }, (_, i) => ({
  id: i + 1,
  status: "needs-charging",
  voltage: 0,
}));

Modifying Battery Statuses

To add or modify battery statuses, update the batteryStatusSchema in lib/schema.ts:

export const batteryStatusSchema = z.enum([
  "charging",
  "needs-charging",
  "charged",
  "in-use", // Added new status here
  "damaged", // Added new status here
]);

Then update the UI in components/battery-form.tsx to include the new statuses in the radio group.

Adding Additional Battery Data

To track additional information for each battery:

  1. Update the batterySchema in lib/schema.ts:
export const batterySchema = z.object({
  id: z.number(),
  status: batteryStatusSchema,
  voltage: z.number().min(0).max(50),
  cycleCount: z.number().optional(), // Add new field
  lastTestedDate: z.string().optional(), // Add new field
});
  1. Update API handlers and UI components to use the new fields.

Deployment

The application can be deployed to various platforms:

  • Vercel (recommended for Next.js)
  • Netlify
  • Any platform supporting Node.js applications

Make sure to set the environment variables for your Redis instance on your hosting platform.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Developed with ❤️ for FRC teams. Feel free to submit issues or pull requests to help improve this tool!

Releases

No releases published

Packages

No packages published