WiFi Outlet X2 Raspberry Pi

by ScottieDigital in Circuits > Raspberry Pi

203 Views, 5 Favorites, 0 Comments

WiFi Outlet X2 Raspberry Pi

PXL_20240216_191006504.jpg
WiFi Outlet X2 Raspberry Pi

This is ongoing project You can find my other previous projects here

https://www.instructables.com/Wifi-Outlet-X4-Raspberry-Pi/

https://www.instructables.com/WiFi-Outlet-Raspberry-Pi/

https://www.instructables.com/Raspberry-Pi-IoT/

With this project you can control any outlet via internet from anywhere in the world! I have several and use them for security deterrent, my bedroom control laziness from my bed. There is also the ability to upgrade to have multiple sensors! This is my mini version and cheapest. BTW this not NOT AI associated and FASTER THAN!!!! By the time you can say "Hey google" I could have turned it on/off by hand 100 x's! Build yourself a better smart home than Bill Gates!

i love this project it's my favorite one!!!!

*Note for future.

So far currently if you did want sensors you'd have to drill a hole. If I get better luck working with them and finish up the software I'll make another version of this. using a rj-11 connector to I2C.

*History

The original idea started in 2016 with a friend no longer here. As you can see I did it backwards. I started with the full IOT project and worked my way down to now this version the mini. I just haven't went bigger yet. It's been many years I've wanted this to be done. THIS IS TRUELY THE FUTURE IN YOUR HANDS! Come to think about it it might also be Nikola Tesla dream?! If you think about it, the picture of it by itself. If you seen it as his eyes and then popped back in his time. By all definition he would think it's a wireless electricity box. Just something to THINK ABOUT!

Supplies

PXL_20240212_074718953.jpg
PXL_20240212_081224120.jpg

Raspberry Zero W (I prefer 1.1 because 2.0 is not needed no difference)

32GB GB micro SD card 100/MBS

U.FL IPX RF SMD female

U.FL /IPX to RP-SMA female antenna wire

SMA female 11cm wifi antenna dual-band (can be upgraded if needed more distance go bigger size)

upgrade heatsink if can

1A USB power adapter wall charger

AC power IEC standard C-14 Inlet connector snap-in

(2) AC outlet NEMA S-15R 3 wire 15A snap-in

(2) General purpose relay DC 5V 20A

(2) NPN transistor 3904

(4) 1K 1/4W ressistor

(2) doide 1N4001

(2) LED red 5mm

Mis wire

hardware

Other- hot glue, liquid tape, solder, UV super glue, super glue

3D parts


Total cost $51.60

Raspberry Pi Command Line

Download and burn image to micro sd card

Go through settings and enable Remote GPIO

sudo raspi-config

Personal settings

sudo nano /boot/config.txt

add to bottom

avoid_warnings=1

Save and Exit. Next we change settings at startup

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

add these lines

@xset s off

@xset s noblank

@xset -dpms

(comment out screensaver with # like # @xscreensaver)

Save and Exit. Next we can set static IP

sudo nano /etc/dhcpcd.conf

Goto Bottom and add

interface wlan0

static ip_address=192.168.2.190/24

static routers=192.168.2.1

static domain_name_servers=192.168.2.1

save and exit. Next Wifi Settings

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

update_config=1

country=us


network={

    ssid=""

    psk=""

    key_mgmt=WPA-PSK

}

Save and Exit. Now we'll Reboot for settings to take efect.

sudo reboot

sudo apt-get update

sudo apt-get full-upgrade

sudo apt-get -y dist-upgrade

Now Install Python

sudo apt install python

sudo apt install python3 idle3

To get sensor working.

git clone https://github.com/adafruit/Adafruit_Python_DHT.git

cd Adafruit_Python_DHT

sudo apt-get install build-essential python-dev

sudo python setup.py install

Next we'll do Apache webserver

sudo apt install apache2 -y

Next we need permission for ftp to transfer files

cd /

cd /var/www

sudo chown pi: html

Next we change the port # of the pi

cd html

sudo nano /etc/apache2/ports.conf

change "Listen 80" to Listen 8030 Save and Exit

Now install PhP

sudo apt install php

Set permissions on ppi for browser access

sudo visudo

add the following lines at the bottom

www-data ALL=(ALL)NOPASSWD:ALL

www-data ALL=/sbin/reboot

www-data ALL=NOPASSWD:/sbin/reboot

www-data ALL=/sbin/shutdown

www-data ALL=NOPASSWD:/sbin/shutdown

www-data ALL=/sbin/sysctl

www-data ALL=NOPASSWD:/sbinsysctl

Save and Exit. 

cd ..

In the "www" folder run command

sudo chwon -R www-data:www-data /var/www

Next WE NEED Wiring Pi ABSOLUTE MUST!

cd ~

In "home/pi" folder

sudo git clone https://github.com/WiringPi/WiringPi

cd WiringPi

sudo ./build

Now you can read GPIO pins

gpio readall

Now you should be all setup that you can put the ip address and port that we had assigned in your web browser in view what we have!. Currently there should be some sort of basic index.html page there. Finally here is the link you NEED to download and unzip to replace in the "html" folder. I used filezilla to ftp to the pi and transfer the files. [/var/www/html/] If doesn't work change file permissions. There are many ways you can do this but I just do this in FTP and do all the files in folder to 777. Click link for code package

https://github.com/ScottieD369/Raspberry-Pi-IoT/raw/main/Pi%20Server%202%20Mini.zip

I can say there is a "hidden feature" in IE browser! via pc. Then you can use any browser on ANY device to view! These lovely buttons love to change color! Just like anything else if you want to access this outside your network port forward on router! Yes tested and WORKS! ***PLEASE NOTE***(Your IP and port may differ? Just change in the files.)

http://IPADDRESS:PORT/index.html

Then if you have port forward that port the IP becomes the IP of your location NOT the pi!!!

3D Printing

Files can be found

HERE

or

HERE

Files were designed in:

Autodesk Fusion 360

Soldering

PXL_20240212_101758822.jpg
PXL_20240214_073212402.jpg
PXL_20240214_095203808.jpg
PXL_20240214_101256136.jpg
PXL_20240214_094757901.jpg
PXL_20240214_114957006.jpg
R-Pi-Zero-Pinout.jpg
download (2) (1).jpeg
download1.png

It's best to setup the micro SD card before doing ANYTHING That was when your done it's ready for TESTING!

Now first step and MUST be first is air solder the U.FL connector (EXTREAMLY HARD!!!)

If you need help or idea I found this on youtube

https://www.youtube.com/watch?v=Y648CjIiEv8

Now as you can see I popped in the outlets.

It's nice to pre-solder everything

I use a cut-off wheel to remove power supply from USB

You can plug up the power cable to soldering the Inlet to make sure the pins are aligned! For just in case purpose. Soldering to them pins can get HOT and cause the plastic to slightly melt and cause misalignment.

Relay 1 = GPIO 5

Relay 2 = GPIO 6

Sensors are optional

Glue Mounts

PXL_20240214_143627327.jpg
PXL_20240215_105529966.jpg
PXL_20240216_142818989.jpg
PXL_20240219_071426803.jpg

Use plain super glue for mounts

Now you can also UV super glue the outlets IF you like? I prefer extra safety

I show picture of removal of washer so you a NICE fit on antenna! It is slightly short.

Troubleshooting

PXL_20240214_131426845.jpg
PXL_20240215_054339587.jpg
PXL_20240215_055633222.jpg

Give yourself plenty of wire length for troubleshooting and or replaceing


Mounting

PXL_20240216_085844240.jpg
PXL_20240216_095237748.jpg
PXL_20240216_091207311.jpg

place screws in place to measure distance. and determine how far.

Next pilot hole and screw in place.

Then POP and SLIDE in place!

Transfer/Move Location

If you are moving to a different location or gifting to a friend or family. These are the things you need to check and change. Everything you need to connect to network

SSID PASSWRORD IP ADDRESS RANGE

sudo nano /etc/dhcpcd.conf

interface wlan0

static ip_address=192.168.2.190/24

static routers=192.168.2.1

static domain_name_servers=192.168.2.1

save and exit. Next Wifi Settings

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

update_config=1

country=us


network={

    ssid=""

    psk=""

    key_mgmt=WPA-PSK

}

Save and Exit. Now we'll Reboot for settings to take efect.

sudo reboot

That is all the changes you need to make.

ENJOY!

Final

PXL_20240216_150749903.jpg
PXL_20240216_150646587.jpg
PXL_20240216_150601865.jpg
PXL_20240214_140407888.jpg
PXL_20240214_140315726.jpg

Can be placed ANYWHERE!

LOOKS AMAZING!