A comprehensive Python-based monitoring system for ocean environmental sensors using Teensy 4.1 microcontroller. Features real-time data visualization, SD card logging, remote data download, and interactive graphing capabilities.
- Features
- System Architecture
- Hardware Requirements
- Software Requirements
- Installation
- Usage
- Data Protocol
- Screenshots
- File Structure
- Troubleshooting
- Contributing
- License
- pH Sensor - Water acidity/alkalinity measurement
- Dissolved Oxygen (DO) - Oxygen concentration in mg/L
- Temperature - Water temperature in Β°C
- Pressure - Atmospheric/water pressure in mbar
- β° 30-minute interval readings - Optimized for long-term deployment
- πΎ Dual storage system - SD card (Teensy) + CSV file (GUI)
- π₯ Remote SD card download - Retrieve all data via serial connection
- π Continuous monitoring - Real-time display updates even during sleep cycles
- π ~4,320 readings over 90-day deployment
- π¨ Modern dark-themed interface with color-coded sensor displays
- π Live heartbeat monitoring - Continuous display updates
- π Real-time graphing - 4-panel matplotlib visualization
- π Historical data analysis - Load and plot SD card data
- πΎ Export capabilities - PNG, PDF, and CSV formats
- π Status notifications - Visual feedback for all operations
- π Auto-detection - Automatic Teensy port detection
- π§΅ Multi-threaded - Non-blocking serial communication
- π Thread-safe - Proper GUI update synchronization
- β‘ High-speed serial - 115200 baud communication
- π‘οΈ Error handling - Robust exception management
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β TEENSY 4.1 HARDWARE β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β pH β β DO β β Temp β β Pressure β β
β β Sensor β β Sensor β β Sensor β β Sensor β β
β ββββββ¬ββββββ ββββββ¬ββββββ ββββββ¬ββββββ ββββββ¬ββββββ β
β β β β β β
β βββββββββββββββ΄βββββββββββββββ΄ββββββββββββββ β
β β β
β ββββββΌβββββ β
β β Teensy β β
β β 4.1 β β
β ββββββ¬βββββ β
β β β
β ββββββΌβββββ β
β β SD Card β (30-min intervals) β
β βββββββββββ β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
β
USB Serial
115200 baud
β
ββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββ
β PYTHON GUI APPLICATION β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Real-time Display β CSV Logging β Graphs β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Serial Thread (Background) β β
β β - Continuous reading β β
β β - Protocol parsing β β
β β - Thread-safe updates β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββ΄βββββββββ
β β
ββββββΌβββββ ββββββΌβββββ
β CSV β β Graphs β
β Export β β Export β
βββββββββββ βββββββββββ
- Teensy 4.1 microcontroller
- SD Card (for onboard logging)
- Sensors:
- pH sensor (analog output)
- Dissolved Oxygen sensor (analog output)
- Temperature sensor (digital/analog)
- Pressure sensor (I2C/analog)
- USB Cable (for serial communication)
- Power Supply (appropriate for deployment environment)
Python >= 3.7
tkinter (usually included with Python)
pyserial >= 3.5
Pillow >= 8.0
matplotlib >= 3.3.0- Clone the repository:
git clone https://github.com/yourusername/teensy-ocean-sensor-dashboard.git
cd teensy-ocean-sensor-dashboard- Install required packages:
pip install pyserial pillow matplotlib- Run the application:
python ocean_sensor_dashboard.py-
Connect Hardware:
- Connect Teensy 4.1 to your computer via USB
- Ensure SD card is inserted in Teensy
- Verify all sensors are connected
-
Launch Application:
python ocean_sensor_dashboard.py
-
Connect to Teensy:
- Click "π Connect to Teensy"
- Port auto-detection will attempt to find Teensy
- Manual port entry available if auto-detection fails
-
Monitor Data:
- Live sensor values update continuously
- Scheduled readings (every 30 min) saved to SD + CSV
- Console displays all system messages
1. Click "π₯ Download SD Card"
2. Select save location
3. Wait for download completion
4. Data saved as text file with all readings
1. Click "π Live Graph"
2. 4-panel graph window opens
3. Auto-refreshes every 10 seconds
4. Export as PNG/PDF/CSV available
1. Click "π₯ SD Graph"
2. Select downloaded SD card file
3. Visualize historical data
4. Export graphs and data
1. Click "πΎ Download CSV"
2. Choose save location
3. All GUI readings exported
Primary Format:
$Params,<pH*100>,<DO*10>,<Temp*50>,<Pressure*1000>,<FLAG>
Example:
$Params,742,85,1120,1013000,SAVED
Decoding:
- pH = 742 / 100 = 7.42
- DO = 85 / 10 = 8.5 mg/L
- Temp = 1120 / 50 = 22.4Β°C
- Pressure = 1013000 / 1000 = 1013.0 mbar
- FLAG = SAVED (indicates 30-min scheduled reading)
Request:
DOWNLOAD_SD\n
Response:
SD_DOWNLOAD_START
<data lines...>
SD_DOWNLOAD_PROGRESS: X lines sent
<more data...>
SD_DOWNLOAD_END
Error Handling:
SD_DOWNLOAD_ERROR: <error message>
Real-time sensor monitoring with color-coded displays
4-panel real-time data visualization
Remote SD card data retrieval interface
teensy-ocean-sensor-dashboard/
β
βββ ocean_sensor_dashboard.py # Main Python application
βββ teensy_firmware/ # Teensy 4.1 firmware (if included)
β βββ sensor_logger.ino
β
βββ flowchart/ # Engineering documentation
β βββ teensy_flowchart.html # Interactive system flowchart
β
βββ screenshots/ # Application screenshots
β βββ dashboard.png
β βββ live_graphs.png
β βββ sd_download.png
β
βββ data/ # Sample data (optional)
β βββ sample_readings.csv
β βββ sample_sd_data.txt
β
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ LICENSE # License information
BAUD = 115200 # Serial baud rate
SERIAL_TIMEOUT = 1.0 # Serial timeout in secondsMAX_BUFFER_SIZE = 10000 # Maximum readings in memory
READING_INTERVAL = 30 # Minutes between readings (Teensy)- Continuous CSV: Auto-created on connection
- Format:
teensy_30min_readings_YYYYMMDD_HHMMSS.csv - Fields: timestamp, pH, DO, Temperature, Pressure
Problem: Cannot find Teensy port
Solution:
1. Check USB cable connection
2. Verify Teensy is powered on
3. Try manual port entry (COM3, /dev/ttyACM0, etc.)
4. Install Teensy USB drivers if needed
Problem: Serial connection drops
Solution:
1. Check USB cable quality
2. Verify stable power supply
3. Reduce serial timeout if needed
4. Check for electromagnetic interference
Problem: No data appearing
Solution:
1. Verify Teensy firmware is running
2. Check sensor connections
3. Monitor serial console for errors
4. Verify $Params protocol format
Problem: SD download fails
Solution:
1. Ensure SD card is properly inserted
2. Check SD card has data
3. Verify sufficient disk space for download
4. Try downloading to different location
Problem: Graphs not displaying
Solution:
1. Verify matplotlib is installed: pip install matplotlib
2. Check that sensor_data_list has entries
3. Ensure valid timestamp format
4. Update matplotlib: pip install --upgrade matplotlib
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- π Additional sensor support
- π New visualization options
- π Web-based dashboard
- π± Mobile app integration
- π Alert/notification system
- ποΈ Database integration
- π§ͺ Unit tests
- β Core functionality complete
- β Real-time monitoring
- β SD card download
- β Graph visualization
- β CSV export
- β Web dashboard (planned)
- β Database integration (planned)
MIT License
Copyright (c) 2025 [Santosh Ambule]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
- Santosh Ambule - Initial work - https://github.com/Santosh1526
- Teensy 4.1 by PJRC
- Python Serial library by pySerial
- Matplotlib for visualization
- Ocean sensor research community
Project Link: - https://github.com/Santosh1526/-Teensy-4.1-Ocean-Sensor-Dashboard/tree/main
Email: santoshambule15@gmail.com
If you find this project useful, please consider giving it a β!
Total Readings Expected: ~4,320
Reading Interval: 30 minutes
Storage Required: ~2-5 MB (SD card)
Power Consumption: ~500mW average
Battery Life: ~90 days (with 5000mAh battery)
- π Aquaculture monitoring
- π¬ Marine research
- π Pool/water quality monitoring
- π‘οΈ Environmental studies
- π Long-term data collection
**Made with β€οΈ for ocean environmental monitoring