A hackathon MVP for predicting period start dates more accurately for people with irregular cycles by detecting ovulation using basal body temperature (BBT), not calendar averages.
This is NOT a calendar-based period tracker.
Luna is physiology-first: all predictions are derived from daily BBT readings. The app does not rely on cycle length or last period start date. Instead, it focuses on:
- Ovulation detection → Period prediction (~12–14 days after ovulation)
- Real body signals, not averages
- Designed for irregular cycles by default
- Confidence-based predictions (predicted windows, not single dates)
- Hardware: ESP32-based device with DS18B20 temperature sensor, capacitive touch button, and NeoPixel LED ring
- Backend: Node.js + Express API with physiology-based ovulation detection and period prediction
- Frontend: React dashboard with BBT graphs, ovulation markers, and body literacy insights
- Mobile-Responsive: Works beautifully on phones, tablets, and desktops
Luna/
├── esp32/ # Arduino code for ESP32
│ └── luna_esp32.ino
├── backend/ # Node.js + Express API
│ ├── server.js
│ └── package.json
├── frontend/ # React dashboard
│ ├── src/
│ │ ├── App.js
│ │ └── components/
│ │ ├── BBTChart.js
│ │ ├── TodayCard.js
│ │ └── WidgetSimulation.js
│ └── package.json
├── WIRING.md # Hardware wiring instructions
├── SETUP.md # Complete setup guide
└── README.md # This file
cd backend
npm install
npm startServer runs on http://localhost:3000
cd frontend
npm install
npm startApp opens at http://localhost:3000
- Install Arduino IDE and ESP32 board support
- Install required libraries (OneWire, DallasTemperature, Adafruit_NeoPixel)
- Update WiFi credentials and server URL in
esp32/luna_esp32.ino - Upload to ESP32
- Wire components (see WIRING.md)
POST /temperature- Receive BBT reading from ESP32GET /data?days=14- Get historical BBT dataGET /today- Get today's summary (temperature, phase, tip)GET /phase- Get current cycle phase informationGET /tips- Get phase-specific wellness tipsGET /health- Health check
Luna can use Google Gemini AI to generate personalized, contextual tips based on your cycle phase and BBT readings. This feature is optional - the app works perfectly with static tips if you don't configure Gemini.
- Get a free API key from Google AI Studio
- Set it as an environment variable:
Or create a
export GEMINI_API_KEY="your-api-key-here"
.envfile in thebackenddirectory:GEMINI_API_KEY=your-api-key-here - Restart the backend server
Without the API key, Luna will use curated static tips that are still helpful and informative.
The backend uses BBT patterns to detect phases, not calendar dates:
- Ovulation Detection: Uses the "3-over-6" rule - 3 consecutive days at least 0.3°C above the previous 6 days' average
- Period Prediction: Predicts period start 12-14 days after detected ovulation (with confidence windows)
- Phase Detection: Determines current phase based on:
- Pre-ovulation: Lower BBT range
- Ovulation: Detected temperature rise
- Luteal: Sustained elevated BBT post-ovulation
- Pre-menstrual: Approaching period window
The system works for irregular cycles because it doesn't assume cycle length - it detects actual physiological events.
- ESP32 DevKit
- DS18B20 Temperature Sensor
- 4.7kΩ Resistor (for DS18B20 pull-up)
- Capacitive Touch Button
- NeoPixel LED Ring (WS2812B, 12 LEDs)
- USB Cable or Battery Pack
See WIRING.md for detailed wiring instructions.
- SETUP.md - Complete setup guide for all components
- WIRING.md - Hardware wiring diagram and instructions
- Sample data pre-loaded for immediate demo
- Real-time updates when ESP32 sends readings
- Color-coded phase indicators
- Mobile-responsive design
- Widget simulation card
cd backend
npm run dev # Auto-reload with nodemoncd frontend
npm start # Auto-reload on file changes- Open Serial Monitor (115200 baud)
- Monitor WiFi connection and sensor readings
- Test touch button and LED feedback
- Check if port 3000 is available
- Verify Node.js version (v16+)
- Run
npm installin backend directory
- Verify WiFi credentials in code
- Ensure 2.4GHz WiFi (ESP32 doesn't support 5GHz)
- Check server IP address matches your computer
- Verify backend is running
- Check
REACT_APP_API_URLin.envfile - Ensure CORS is enabled in backend
See SETUP.md for detailed troubleshooting.
This is a minimal viable product for demonstration:
- In-memory data storage (replace with database for production)
- Simplified cycle phase calculation (28-day assumption)
- Manual button press for readings
- Sample data included for live demo
- Database persistence (PostgreSQL/MongoDB)
- User authentication
- Multiple cycle tracking
- Advanced ovulation prediction algorithms
- Mobile app (React Native)
- OTA updates for ESP32
- Battery optimization with deep sleep
- Cloud deployment
MIT
Built for hackathon demonstration. Components:
- ESP32 Arduino Core
- React + Recharts
- Express.js
- NeoPixel (WS2812B)
Happy Tracking! 🌙