Other distributions often do not work.
- Download the image from the Raspberry Pi website.
 - Alternatively, use the Raspberry Pi Imager.
 
- If using 'Raspberry Pi OS Lite', connect a keyboard and monitor for the first boot.
 - Create an empty 
sshfile inside the/bootdirectory to enable SSH access. - Alternatively, configure SSH and user credentials using the Raspberry Pi Imager before flashing.
 
modprobe 8021q
echo 8021 >> /etc/modules
Restart the networking services to apply the changes:
sudo systemctl restart dhcpcd
sudo systemctl restart networking
interface eth0.204
static ip_address=10.1.6.XXX/24
static routers=10.1.6.1
static domain_name_servers=8.8.8.8
auto eth0.204
iface eth0.204 inet manual
vlan-raw-device eth0
- On the desktop version, open a terminal window.
 - On the headless version, connect via SSH with your configured user and password.
 
Run the raspi-config tool:
sudo raspi-config
- 
Disable login shell over serial:
- Navigate to 
Interface Options > Serial Port. - Select 
Nowhen asked if you want the login shell accessible over serial. 
- Select 
Yesto enable the serial port hardware. 
- Confirm and return to the main menu.
 
 - Navigate to 
 - 
Exit and select No when prompted to reboot.
 
Edit the /boot/config.txt file:
sudo nano /boot/config.txt
Add the following line at the end:
dtoverlay=disable-bt
For Raspberry Pi 5, also add:
dtoverlay=uart0
Save and exit. (Note: If Bluetooth is required, skip this step and use ttyS0 instead of ttyAMA0.)
sudo systemctl disable hciuart
Reboot the system:
sudo reboot
Reconnect via SSH once the system is up.
- 
Install
python3-serial:sudo apt-get install python3-serial - 
Download and install the RPICT package:
wget lechacal.com/RPICT/tools/lcl-rpict-package_latest.deb sudo dpkg -i lcl-rpict-package_latest.deb - 
Install Prometheus-client for later
 
 pip install prometheus-client
DO NOT SKIP THIS TEST.
- Insert the RPICT board.
 - Configure and read from the serial port:
stty -echo -F /dev/ttyAMA0 raw speed 38400 cat /dev/ttyAMA0 - Alternatively, use:
Example output will display on the terminal.
lcl-run 
- Start the web server:
lcl-server.sh - Access the interface at: http://raspberrypi:8000
 - Load, modify, and send configurations as needed.
 
- Click on the button with the 'upload' icon, which has a hover tip saying "Load from Device." This action will load all the current configurations from the device to the web interface.
 
- Modify Configurations:
 
- Adjust the necessary configurations, such as changing the "number of slaves" or "output fields."
 
- Send Configuration to the Device:
 
- Click on the button with the 'download' icon, which has a hover tip saying "Send to Device." This action will push all the updated configurations from the web interface to your device.
 
- Start Collecting Metrics:
 
- Click the "Start" button to begin collecting metrics based on the new configurations.
 
- Check the current firmware version:
lcl-show-header.py - Download the latest Arduino sketch:
wget lechacal.com/RPICT/sketch/RPICT_MCP3208_v4.2.0.ino.hex - Install 
avrdude:sudo apt-get -y install avrdude - Upload the sketch:
Last two lines of the output should look like this.
lcl-upload-sketch.sh RPICT_MCP3208_v4.2.0.ino.hex 
avrdude done. Thank you. strace: |autoreset: Tubería rota
- Verify the installation:
lcl-show-header.py 
To clone this repository into /home/cttc/Documentos/, run:
cd /home/cttc/Documentos/
git clone https://gitlab.cttc.es/pons/energy-monitor
Add a new .service file on the /system/ folder with:
sudo nano /etc/systemd/system/EMON-client.service
Remember to also include the correct path to the .py code in ExecStart= and the WorkingDirectory= (where the json file is alocated) otherwise it won't load the directory and kill the process if JSON not load.
[Unit]
Description=Python Boot Script to start brodcasting EMON metrics to the server
After=network.target
[Service]
ExecStart=/usr/bin/python3 /home/cttc/Documentos/SensorResourceExporter/pythonCode.py
WorkingDirectory=/home/cttc/Documentos/SensorResourceExporter/
StandardOutput=journal
StandardError=journal
Restart=always
User=cttc
Environment="PYTHONUNBUFFERED=1"
[Install]
WantedBy=multi-user.target
enable commit and check the service
sudo systemctl daemon-reload
sudo systemctl start EMON-client.service
sudo systemctl enable EMON-client.service
sudo systemctl status EMON-client.service
to restart the service
sudo systemctl restart EMON-client.service
- Edit the network interface:
enable configure terminal interface ce1 ip address 192.168.10.1 255.255.255.0 description "add information here" no shutdown write memory commit exit - Verify the static route:
show ip route 
- 
Download and configure the SNMP exporter:
wget https://github.com/prometheus/snmp_exporter/releases/latest sudo mkdir /etc/snmp_exporter sudo cp <downloaded_files> /etc/snmp_exporter/ - 
Create the
snmp-exporter.servicefile:[Unit] Description=SNMP Exporter Wants=network-online.target After=network-online.target [Service] ExecStart=/etc/snmp_exporter/snmp_exporter --config.file=/etc/snmp_exporter/snmp.yml Restart=always [Install] WantedBy=multi-user.target - 
Start the service:
sudo systemctl start snmp-exporter.service sudo systemctl status snmp-exporter.service - 
Configure Prometheus to collect metrics:
- job_name: '<job_name>' static_configs: - targets: - 10.1.1.86 - 10.1.1.87 metrics_path: /snmp params: module: [if_mib] relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: 10.1.1.88:9116 - 
Restart Prometheus:
sudo systemctl restart prometheus.service 


