Smart Cities - Tiny House at Home (Alternate way)
Tiny House: Smart Temperature Monitoring System
Tiny House is a weather and temperature monitoring system for small homes, using a Raspberry Pi Pico W, multiple sensors, and MQTT for remote data access. This wiki provides setup, usage, troubleshooting, and API documentation.
Contents
- Introduction
- Hardware Setup
- Software Setup
- Configuration
- File Structure
- Usage
- Local Graphing
- Web Dashboard
- Testing Without Sensors
- Troubleshooting
- API Documentation
- License
Introduction
Tiny House monitors temperatures in multiple locations using high-accuracy sensors. Data is sent to an MQTT broker for real-time viewing via graphs or a web dashboard. The system is robust, supports offline data storage, and is easy to set up.
Hardware Setup
Required Components
- Raspberry Pi Pico W
- PiicoDev TMP117 sensor
- 3x DS18X20 temperature sensors
- PiicoDev RTC module
- Relay, motor, and wiring
- WiFi access
Pin Connections
| Component | Pin on Pico W | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Motor DIR | GP21 | Motor PWM | GP26 | Relay | GP15 | UART | GPIO 0 (pin 1 pair) | Temp Sensors | GPIOs 0 / 2 / 3 | Reset Button | GP22 | I2C (TMP117 + RTC) | SDA = GP4, SCL = GP5 |
- Daisy-chain TMP117 and RTC using PiicoDev connectors.
- Connect temp sensors to the appropriate GPIO pins.
- Power on your Pico W.
Software Setup
- Install MicroPython on your Pico W.
- Install Thonny IDE (or another MicroPython IDE).
- Upload all project files to the Pico W.
- Edit
env.pywith your WiFi and MQTT details. - Run
main.pyusing Thonny.
Configuration
Edit env.py to set:
WLANSSID: WiFi network nameWLANPASSWD: WiFi passwordMQTT_CLIENT_ID: Unique MQTT client IDMQTT_SERVER: MQTT broker addressMQTT_USER: MQTT usernameMQTT_PASSWORD: MQTT passwordMQTT_TOPIC_DATA: Topic for temperature dataMQTT_TOPIC_STATUS: Topic for system status
File Structure
MicroPico/ ├── main.py # Main logic ├── env.py # WiFi & MQTT config ├── lib/ │ ├── PiicoDev_TMP117.py │ ├── PiicoDev_Unified.py │ ├── PiicoDev_RV3028.py │ └── umqtt/simple.py weatherGraph.py # Local graphing dummy_data_publisher.py # Simulated test data Graph-Site-Docker/ ├── flaskSite.py ├── Docker_Build-and-Run.sh
Usage
- Flash the MicroPico files to your Raspberry Pi Pico W.
- Ensure
env.pyis configured with your WiFi and MQTT credentials. - Set up an MQTT broker (e.g., Mosquitto, HiveMQ, or Adafruit IO).
- Power up the Pico W to start collecting and publishing temperature data.
Pump and Relay Control
- The system can control a pump (forward/backward/stop) and a relay for automation.
- See
main.pyfor example usage.
Local Graphing
- Install Python 3 and required packages:
pip install -r requirements.txt - Run
python weatherGraph.pyto display real-time temperature graphs.
Web Dashboard
- Navigate to
Graph-Site-Dockerdirectory. - Create a
.envfile with your API keys and MQTT settings. - Run
./Docker_Build-and-Run.sh false true 1.0.0to launch the web server. - Access the dashboard at http://localhost:5000
Manual Docker Build/Run
docker buildx build --platform linux/amd64,linux/arm64 \ -t jezzcomputers/pyapp-image:latest \ --push . docker run -d --restart unless-stopped --name pyapp-container --env-file <path-to-your-env-file> -p 5000:5000 jezzcomputers/pyapp-image:latest
Testing Without Sensors
Run python dummy_data_publisher.py to simulate temperature data for testing the dashboard and graphing tools.
Troubleshooting
| Problem | Solution | ||||||
|---|---|---|---|---|---|---|---|
| Pico not connecting | Check env.py WiFi settings, ensure network is available.
|
MQTT issues | Ensure broker is running, test with simulator, check credentials. | Sensor errors | Recheck wiring or use dummy_data_publisher.py.
|
Docker site not working | Verify Docker is installed and .env is valid.
|
Additional Tips
- Check the status LED on the Pico W (solid means connected).
- Use
docker logs pyapp-containerfor Docker troubleshooting. - For sensor problems, try running the dummy data publisher.
API Documentation
MQTT Topics
JezzComputers/feeds/data: Publishes temperature data.JezzComputers/feeds/status: Publishes system status.
Data Format Example
{
"timestamp": {
"year": 2023,
"month": 6,
"day": 15,
"hour": 14,
"minute": 30,
"second": 45
},
"outdoor_temp": 25.5,
"in_house_temp": 22.3,
"thermal_mass_temp": 20.8,
"cont_box_temp": 24.1,
"error": null
}
Status Format Example
{
"context": "System Status",
"doClearLogs": "false",
"year": 2023,
"month": 6,
"day": 15,
"hour": 14,
"ampm": "PM",
"minute": 30,
"second": 45
}
License
This project is licensed under the MIT License. You are free to use, modify, and distribute this code as long as you include the original copyright.
For questions, improvements, or to contribute, visit the project repository or use the discussion page.