Custom Node-RED nodes for the Waveshare DA-AD HAT with working drivers
npm install node-red-contrib-waveshare-da-ad-hatCustom Node-RED nodes for the Waveshare DA-AD HAT with working drivers. This package provides reliable control of the Digital-to-Analog Converter (DAC) and Analog-to-Digital Converter (ADC) functionality through proven Python drivers.
bash
Install system packages
sudo apt-get update
sudo apt-get install python3-pip python3-devInstall Python packages
pip3 install spidev RPi.GPIO
`$3
`bash
Navigate to your Node-RED user directory
cd ~/.node-redInstall the package
npm install node-red-contrib-waveshare-da-ad-hat
`$3
After installation, restart Node-RED to load the new nodes.Hardware Setup
$3
1. Power: Connect the HAT to your Raspberry Pi
2. SPI Interface: Ensure SPI is enabled in raspi-config
3. GPIO Pins: The HAT uses specific GPIO pins for CS, RST, and DRDY$3
`bash
Enable SPI interface
sudo raspi-configNavigate to: Interface Options > SPI > Enable
Reboot after enabling
sudo rebootVerify SPI is enabled
ls /dev/spidev*
`Usage
$3
#### Basic Setup
1. Drag the "Waveshare DA" node to your flow
2. Configure the DAC port (0 or 1)
3. Set the default output value (0-65535)
4. Optionally enable auto-update with custom interval
#### Message Input
`json
{
"payload": {
"port": 0,
"value": 32768
}
}
`#### Output
`json
{
"payload": {
"port": 0,
"value": 32768,
"success": true,
"timestamp": 1703123456789
}
}
`$3
#### Basic Setup
1. Drag the "Waveshare AD" node to your flow
2. Select the ADC channel (0-7)
3. Configure gain, buffering, and data rate
4. Optionally enable auto-read with custom interval
#### Message Input
`json
{
"payload": {
"channel": 2,
"gain": 16,
"buffered": true,
"dataRate": 500
}
}
`Data Rate Options:
- 2.5-30 SPS: Slow, high precision measurements
- 50-500 SPS: Medium speed, general purpose
- 1000-30000 SPS: Fast, real-time monitoring
#### Output
`json
{
"payload": {
"channel": 2,
"gain": 16,
"buffered": true,
"dataRate": 500,
"reading": 12345,
"rawOutput": "AIN2 reading: 12345",
"success": true,
"timestamp": 1703123456789
}
}
`Pool Management System Integration
This package is specifically designed for pool management applications:
$3
- Port 0: Control variable power supply voltage
- Port 1: Control current limiting or secondary power rail
- Auto-update: Maintain consistent power levels$3
- Current Sensing: Hall effect sensors for power monitoring
- Voltage Monitoring: Resistor divider bridges for voltage measurement
- pH Sensing: Interface with pH sensors for water quality
- Temperature: Monitor water and equipment temperature
- Auto-read: Continuous monitoring with configurable intervalsDevelopment
$3
`
├── src/ # TypeScript source files
│ ├── nodes/ # Node implementations
│ └── index.ts # Main entry point
├── nodes/ # HTML editor files
├── python/ # Python driver scripts
├── types/ # TypeScript type definitions
├── lib/ # Compiled JavaScript (generated)
└── package.json # Package configuration
`$3
`bash
Install dependencies
npm installBuild the project
npm run buildWatch mode for development
npm run devClean build artifacts
npm run clean
`$3
The project uses TypeScript with strict type checking:
- Full type safety for Node-RED interfaces
- Proper error handling and validation
- Modern ES2020 features
- Source maps for debuggingTroubleshooting
$3
#### SPI Permission Denied
`bash
Add user to spi group
sudo usermod -a -G spi $USER
Log out and back in, or reboot
`#### Python Script Not Found
- Ensure Python scripts are in the
python/ directory
- Check file permissions: chmod +x python/*.py
- Verify Python 3 is available: python3 --version#### GPIO Access Denied
`bash
Add user to gpio group
sudo usermod -a -G gpio $USER
Log out and back in, or reboot
`$3
Enable Node-RED debug mode to see detailed error messages:
`bash
Start Node-RED with debug logging
node-red --verbose
`Contributing
1. Fork the repository
2. Create a feature branch:
git checkout -b feature-name`MIT License - see LICENSE file for details.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Waveshare for the DA-AD HAT hardware
- Node-RED community for the excellent framework
- Python community for the reliable hardware interface libraries
---
Note: This package includes working Python drivers that have been tested and proven reliable. The Node-RED nodes provide a user-friendly interface while maintaining the performance and reliability of the underlying hardware drivers.