Browser examples demonstrating the pasco-ble library for PASCO wireless BLE sensors.
Note: These examples use the
pasco-blenpm package. For library documentation and API reference, see the pasco-ble repository.
git clone https://github.com/OpenPhysics/pasco-BLE-examples.git
cd pasco-BLE-examples
npm install # Required before running any npm scripts
npm run servenpm install # If not already done
npm run check # Run linting and formatting checks
npm run check:fix # Auto-fix issues- Open
http://localhost:3000/examples/in Chrome or Edge. - Click "Connect" to scan for PASCO devices
- Select your sensor from the browser's Bluetooth dialog
No build step required - examples load the library from CDN via ES modules.
| Example | Description | Hardware |
|---|---|---|
| basic-usage.html | Connect and read all measurements | Any PASCO sensor |
| force-sensor.html | Large force display with all measurements | Wireless Force Acceleration |
| motion-sensor.html | Position tracking | Wireless Motion Sensor |
| code-node.html | LED matrix, RGB LED, speaker control | Code.Node |
| control-node.html | Stepper motors, servos, speaker | Control.Node |
| sensor-xy-graph.html | Parametric X-Y plotting with Chart.js | Any PASCO sensor |
| multi-sensor-graph.html | Multiple sensors on one graph | Multiple sensors |
| smart-cart.html | 3D position-velocity-time plot with Plotly | Wireless Smart Cart |
- Browser: Chrome or Edge (Web Bluetooth API required)
- Connection: HTTPS or localhost
- Hardware: PASCO Wireless BLE sensor(s)
- Sensors: Must be powered on with blinking red light (ready to connect)
pasco-BLE-examples/
├── examples/
│ ├── index.html # Main navigation page
│ ├── common.css # Shared styles for all examples
│ ├── common.js # Shared utility functions
│ ├── components.js # Reusable Web Components
│ ├── basic-usage.html # Entry-level example
│ ├── force-sensor.html # Force sensor demo
│ ├── motion-sensor.html # Motion sensor demo
│ ├── code-node.html # Code.Node controller
│ ├── control-node.html # Control.Node controller
│ ├── sensor-xy-graph.html # X-Y parametric plotting
│ ├── multi-sensor-graph.html # Multi-device graphing
│ └── smart-cart.html # 3D visualization
├── package.json
├── README.md
└── documentation.md # Detailed examples guide
Examples use ES module imports via importmap:
<script type="importmap">
{
"imports": {
"pasco-ble": "https://esm.sh/pasco-ble@0.3.70"
}
}
</script>
<script type="module">
import { PASCOBLEDevice } from 'pasco-ble';
// ... your code
</script>Unified styling with:
- Responsive layouts (mobile, tablet, desktop)
- Card-based UI components
- Status indicators and buttons
- Chart and graph containers
- Accessibility features (skip links, focus indicators)
Utility functions:
setStatus()- Update connection status indicatorshowError()- Display error messages with auto-dismisscreateLogger()- Console-style logging to DOMformatNumber()- Format numbers with fixed decimalscalculateStats()- Compute min/max/mean statisticssetupDisconnectOnUnload()- Clean disconnect on page unloadhexToRgb()- Color conversion for LED controldebounce()/throttle()- Function rate limitingexportToCSV()- Export data to CSV filescreateAutoReconnect()- Auto-reconnect on disconnectcreateDataPlayback()- Data playback controlscreateKeyboardShortcuts()/createShortcutsHelp()- Keyboard shortcut manager and help overlaycreateSampleRateTracker()/createConnectionQualityIndicator()- Sample rate monitoringcreateThrottledChartUpdater()- Rate-limited chart redrawscreatePreferences()- Persisted user preferencesconnectDevice()/disconnectDevice()- Connection helpersescapeHtml(),clamp(),delay()- Small general-purpose helpers
Reusable Web Components for consistent UI:
<pasco-connection-panel>- Connect/disconnect with status<pasco-console-log>- Console-style log output<pasco-error-display>- Error messages with auto-dismiss<pasco-browser-warning>- Browser support check<pasco-measurements-list>- Display sensor measurements<pasco-primary-reading>- Large single-value display<pasco-page-footer>- About section with slots
Some examples use additional charting libraries loaded from CDN:
- Chart.js - Time series and scatter plots
- Plotly.js - 3D scatter plots
- expr-eval - Safe equation evaluation
- Red Light Blinking: Device should have a red blinking light (ready to connect)
- Green Light: If solid green, device is already connected elsewhere
- Reset Device: Hold power button to turn off, then press to turn on again
- Distance: Move closer to the device
- Browser Tab: Keep the browser tab active (browsers throttle background tabs)
- pasco-ble npm: npmjs.com/package/pasco-ble
- pasco-ble source: github.com/OpenPhysics/pascoTS
- CDN: esm.sh/pasco-ble@0.3.70
See LICENSE for details.