Chapter 20:
PAGING SYSTEM
Implementing a Raspberry Pi-Based Paging System
Introduction
This guide details how to set up a Wi-Fi paging system using a Raspberry Pi. It enables patients to notify nursing staff with a simple button press on a web page. The press activates a Raspberry Pi pin, signaling via an LED or buzzer.
System Setup
Software Installation:
Begin by installing necessary software:
sudo apt install git
sudo apt install apache2 -y
sudo apt-get install php libapache2-mod-php -y
Install WiringPi for GPIO control:
sudo clone git://git.dragon.net/wiringPi # Or sudo apt install wiringpi
Web Server Configuration:
Remove the default Apache index page:
sudo rm index.html
Create a new PHP file for the web interface:
sudo nano index.php
Add HTML and PHP code to control GPIO pins. (See original instructions for detailed code).
Verifying WiringPi Installation:
Check WiringPi:
gpio -v gpio readall
Test GPIO control:
gpio -g write 17 1
Setting Permissions:
Add PHP user to GPIO group:
sudo usermod -a -G gpio www-data
Modify sudo permissions:
sudo visudo
Add www-data ALL=NOPASSWD: ALL in the file.
Notifying via Lobby Station:
Automate office visit notifications using a Raspberry Pi in the lobby. When a button is pressed, it signals the office Raspberry Pi, activating a buzzer.
Enable remote GPIO in raspi-config.
Implement a Python script using RPi.GPIO and gpiozero libraries. (Refer to the original guide for the script).
Final Steps
Ensure all components are correctly installed and configured.
Test the system in a controlled environment before implementing in a patient care setting.
Note: This guide is intended for those familiar with basic Raspberry Pi setup and programming. The paging system can be a valuable tool in a healthcare setting, improving communication between patients and staff.
Guide: Setting Up Raspberry Pi Pico Ws for MQTT-Based Communication
This guide will help you set up two Raspberry Pi Pico Ws to communicate with each other over a Wi-Fi network using the MQTT protocol. Additionally, it includes steps for communication between a Raspberry Pi Pico W and a Raspberry Pi 4B.
Part 1: Setting Up Pico Ws for MQTT Communication
Requirements:
Two Raspberry Pi Pico W boards
USB mic and audio jack for Pi Pico W
Access to a Wi-Fi network
An MQTT broker (e.g., Mosquitto running on a Raspberry Pi 4B or another device)
Setup for Each Pico W:
Configure GPIO Pins:
On Pico 1, configure a push button on GPIO 0.
On Pico 2, set up an LED and buzzer on the desired GPIO pins.
Install Required Libraries:
Use MicroPython to install libraries for network, urequests, and umqtt.simple.
Configure Wi-Fi and MQTT:
Set the Wi-Fi SSID and password to connect both Picos to the same network.
Set up MQTT broker details (IP, port, username, password) in the script.
Assign a unique MQTT topic for communication, e.g., pico/led.
Pico W Code:
For Pico 1, write a script to send an MQTT message when the button is pressed.
For Pico 2, write a script to listen for MQTT messages and activate the LED and buzzer accordingly.
Part 2: Setting Up Raspberry Pi 4B as MQTT Broker
Install Mosquitto MQTT Broker:
sudo apt install mosquitto
sudo apt install mosquitto-client
sudo systemctl start mosquitto
sudo systemctl enable mosquitto
Configure MQTT Broker:
Set up the Pi 4B with a static IP for consistent access.
Optionally, create MQTT user credentials for secure communication.
Pi 4B Script:
Write a Python script using paho.mqtt.client to control an LED based on MQTT messages.
Testing MQTT Communication:
Use the mosquitto_sub command to subscribe to the MQTT topic and test communication:
mosquitto_sub -h <your_pi4_ip> -u <your_mqtt_user> -P <your_mqtt_password> -t pico/led
Part 3: Final Integration and Testing
Deploy Scripts on Pico Ws and Pi 4B:
Transfer and run the respective scripts on each device.
Test the System:
Press the button on Pico 1 and observe if Pico 2 responds with LED and buzzer activation.
Monitor the MQTT messages on the Pi 4B for debugging and verification.
Troubleshooting:
Ensure all devices are on the same Wi-Fi network.
Check MQTT broker settings and network configurations.
Verify the GPIO connections on the Picos.
Notes:
This setup allows for scalable IoT applications using Raspberry Pi Picos and MQTT.
Ensure network security, especially when communicating over MQTT.
The MQTT protocol enables efficient and reliable communication between IoT devices.