- Create account on https://connect.raspberrypi.com/
apt install rpi-connect
rpi-connect on
# Only remote shell access
apt install rpi-connect-lite
rpi-connect on
rpi-connect signin
Only for Raspberry Pi OS Bookworm

apt install rpi-connect
rpi-connect on
# Only remote shell access
apt install rpi-connect-lite
rpi-connect on
rpi-connect signin
Only for Raspberry Pi OS Bookworm

The 5V Relay switch require that i have require around 52mA current to work properly.
So Now i can use Arduino as a switch on/off. Also I needed this switching to be based on some external events. So I used Aurdino Pin 2 as INPUT pin and added one 2.7K ohm resistor to from pin2 to Ground.
int status = 0;
void setup() {
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(2, INPUT);
}
void loop() {
status = digitalRead(2);
if (status == HIGH) {
digitalWrite(13, HIGH);
digitalWrite(12, HIGH);
digitalWrite(8, HIGH);
}
else {
digitalWrite(13, LOW);
digitalWrite(12, L0W);
digitalWrite(8, LOW);
}
}
Switch ON = 7PM
Switch OFF = 12AM
0 19 * * * /usr/bin/python3.8 /opt/led.py on
0 0 * * * /usr/bin/python3.8 /opt/led.py on
led.py
import RPi.GPIO as GPIO
from time import sleep
import sys
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(21, GPIO.OUT, initial=GPIO.LOW)
if sys.argv[1] == "on":
GPIO.output(21, GPIO.HIGH)
#print("on")
exit()
elif sys.argv[1] == "off":
GPIO.output(21, GPIO.LOW)
#print("off")
exit()

Note: withdrawing more current(~15mA) from GPIO can affect the Rpi
https://raspberrypi.stackexchange.com/questions/9298/what-is-the-maximum-current-the-gpio-pins-can-output
import RPi.GPIO as GPIO
from time import sleep
import sys
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(21, GPIO.OUT, initial=GPIO.HIGH)
if sys.argv[1] == "on":
GPIO.output(21, GPIO.LOW)
#print("on")
exit()


pip3 install adafruit-circuitpython-dht
apt-get install libgpiod2
temp.py
import Adafruit_DHT
import time
DHT_SENSOR = Adafruit_DHT.DHT11
DHT_PIN = 4
#while loop is there because sometime it does not get the temp.
while True:
humidity, temperature = Adafruit_DHT.read(DHT_SENSOR, DHT_PIN)
if humidity is not None and temperature is not None:
print("Temp={0:0.1f}C Humidity={1:0.1f}%".format(temperature, humidity))
else:
print("Sensor failure. Check wiring.");
time.sleep(1);
run:
python3 temp.py

For DHT22 sensor:
temp-dht22.py
import Adafruit_DHT
import time
DHT_SENSOR = Adafruit_DHT.DHT22
DHT_PIN = 4
humidity, temperature = Adafruit_DHT.read(DHT_SENSOR, DHT_PIN)
if humidity is not None and temperature is not None:
#print("Temp={0:0.1f}C Humidity={1:0.1f}%".format(temperature, humidity))
print("{0},{1}".format(temperature, humidity))
root@lp-arm-1:~# cat /opt/cron/get_temp_dht22.sh
#!/bin/bash
t_and_h=$(python3 /opt/cron/get_temp_dht22.py)
temprerature=$(echo $t_and_h | awk -F ',' '{print $1}')
humidity=$(echo $t_and_h | awk -F ',' '{print $2}')
echo "room_temp $temprerature" | curl --data-binary @- http://192.168.0.183:30008/metrics/job/room_temp/instance/lp-arm-1
echo "room_humidity $humidity" | curl --data-binary @- http://192.168.0.183:30008/metrics/job/room_humidity/instance/lp-arm-1
lshw
ls /sys/class/net
it was wlan0 in my case
network:
ethernets:
eth0:
dhcp4: true
optional: true
version: 2
wifis:
wlan0:
optional: true
access-points:
"SSID-NAME":
password: "your_password"
dhcp4: yes

netplan try
netplan --debug try
This command will make the above changes for 120seconds if anything wrong it will be reverted back. OR you can hit Enter to make the changes.
netplan generate
netplan apply
#enable wifi module
modprobe brcmfmac
#disable
modprobe -rv brcmfmac
nano /etc/modprobe.d/raspi-blacklist.conf
blacklist brcmfmac
blacklist brcmutil
#disable
rfkill block wifi
#enable
rfkill unblock wifi
nmcli d
nmcli d wifi list
nmcli d wifi connect my_wifi password <password>
#### with BSSID
root@lp-arm-3:~# nmcli device wifi list
IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY
xx:06:C3:CD:57:xx TP-Link_123 Infra 153 270 Mbit/s 100 ▂▄▆█ WPA2
* xx:06:C3:CD:57:xx TP-Link_123 Infra 2 130 Mbit/s 93 ▂▄▆█ WPA2
====================
nmcli d wifi connect xx:06:C3:CD:57:xx password PASSWORD
https://ubuntu.com/core/docs/networkmanager/configure-wifi-connections