News:

The Latest electronic and computer Tips that work!

Main Menu

Recent posts

#1
General Discussion / Switch Mode Power Supply Expla...
Last post by branx86 - July 23, 2024, 07:14:19 AM
#2
General Discussion / 1 ingredient doughnuts
Last post by branx86 - July 18, 2024, 07:26:46 AM
#3
General Discussion / Sandwich Bread two ingredients...
Last post by branx86 - July 18, 2024, 07:20:20 AM
#4
Arduino / HVAC Monitor with a Shelly
Last post by branx86 - July 18, 2024, 07:15:24 AM
#5
Raspberry Pi / Wireless USB using Raspberry P...
Last post by branx86 - July 01, 2024, 10:36:59 PM
https://magpi.raspberrypi.com/articles/pi-zero-w-smart-usb-flash-drive


Built-in wireless on the Pi Zero W opens up a huge number of possibilities for the various USB gadget modes. The Pi Zero W can be configured to spoof different USB device types, such as a keyboard, a webcam, or a smart USB flash drive.

At home, many people use a USB flash drive to transfer files to a TV, but it takes time to move the drive to and from the source computer. How about a remotely accessible USB flash drive, permanently located in the TV, where you could transfer files using the wireless connection? Drag and drop, job done!

STEP-01: The Pi Zero W USB flash drive
On Raspbian Jessie, wireless connections can be made via the networking icon on the right-hand end of the desktop menu bar. Left-clicking the icon will bring up a list of available networks. If you see the scanning message, wait for a moment and it should find your network.

Click the network that you want to join. If the network is secured, you will see a dialogue box. Enter the password, click OK, and wait for a few seconds. Finally, write down the IP address the Pi has acquired. Hover the mouse over the signal strength icon and the IP address will appear in a tooltip. If you prefer, you can complete this process on another Pi, and move the SD card over to the Pi Zero W when you reach Step 03.

STEP-02: Disable desktop and enable SSH
From this point we don't need the desktop, because the Pi Zero is going to have one job: to be a file server for the TV. To save CPU cycles, we should disable the automatic boot to desktop. Go to Menu (Raspberry icon at the top-left corner of the screen) Preferences Raspberry Pi Configuration.

On the System tab, find the Boot option. Select 'To CLI' (command line interface), and disable the 'Login as user pi' checkbox.
On the Interfaces tab, make sure that SSH is enabled. Click OK and choose Yes to reboot. After the reboot, you should see a text login prompt with a flashing cursor.

STEP-03: Switch to remote access
We recommend using SSH (Secure Shell), because we'll be doing everything using the command line. SSH allows us to see the Raspberry Pi command prompt in a window on another PC, Mac, smartphone, or tablet.

Go to magpi.cc/2sLqBmM and follow the instructions for the platform you're using. You'll need the IP address you wrote down earlier, and the login. The default login for Raspbian is pi, with the password raspberry.

When the SSH link is working, you can disconnect any keyboard and screen.

STEP-04: Free up some disk space
When you've logged in over SSH, you can free up disk space by removing some programs that we're not going to need for this project.
The command df -h shows your disk space usage. Look at the Avail column for /dev/root to see how much free space you have. We can claw back about 1GB if we remove LibreOffice and Wolfram.

Enter the commands below into your SSH client:

sudo apt-get remove --purge libreoffice* -y

You can safely ignore any errors you see here. They happen because the command will try to remove some parts of LibreOffice that aren't actually installed.

sudo apt-get purge wolfram-engine -y
sudo apt-get clean
sudo apt-get autoremove -y

Now run df -h again and check the Avail column.

STEP-05: Enable the USB driver
Next, we need to enable the USB driver which provides the gadget modes, by editing two configuration files.

sudo nano /boot/config.txt

Scroll to the bottom and append the line below:

dtoverlay=dwc2

Press CTRL+O followed by Enter to save, and then CTRL+X to quit.

sudo nano /etc/modules

Append the line below, just after the i2c-dev line:

dwc2

Press CTRL+O followed by Enter to save, and then CTRL+X to quit.
Now shut down the Pi Zero W with the command:

sudo halt

STEP-06: Switch to TV power
On the Pi Zero W, you'll see two micro USB ports. One is marked 'USB' and the other 'PWR IN'. You can supply power through either port, but the USB port is for data as well. There are two options.

You could plug the TV into the Pi Zero W USB port, not the PWR IN port, using a standard micro USB cable. The cable will both supply power from the TV and make the USB data connection. The disadvantage is that the TV must be switched on to supply power to the Pi. When someone turns the TV off with the remote, the Pi will also lose power, which can corrupt your SD card.

Alternatively, you can connect a separate, always-on power supply to the PWR IN port, and use a slightly modified micro USB cable to connect the TV to the USB port. The modification is to cut the red wire inside the micro USB cable. This protects the Pi from damage that could be caused by drawing power from two different power sources. The advantage of this method is that the Pi is powered independently from the TV. It will be available on the network even if the TV is off, and there is a reduced risk of sudden power loss and SD card corruption.

You might want to test the system with the first option, and then move onto the second when you want a more permanent setup. Don't forget to cut the red wire if you use the second option.

Connect the Pi Zero W USB port to the TV using your chosen method, power everything up, and log back in over SSH.

STEP-07: Create a container file
To enable mass storage device mode, we need to create a large file to act as the storage medium on the SD card. This file will emulate the USB flash drive that the TV sees.

The command below will create an empty 2GB binary file (change the count=2048 parameter if you want a different size). Please note that this will be limited by the available free space on your SD card (check the Avail column in df -h), and it may take a few minutes to complete the setup:

sudo dd bs=1M if=/dev/zero of=/piusb.bin count=2048

We now need to format the file as a FAT32 file system so that the TV can understand it. Enter the command below:

sudo mkdosfs /piusb.bin -F 32 -I

STEP-08: Mount the container file
Now let's mount the container file locally so we can download some test files. First, create a folder on which we can mount the file system:

sudo mkdir /mnt/usb_share

Now let's add this to fstab, the configuration file that records our available disk partitions:

sudo nano /etc/fstab

Append the line below to the end of the file:

/piusb.bin /mnt/usb_share vfat users,umask=000 0 2

Press CTRL+O followed by Enter to save, and then CTRL+X to quit.
The line we added to fstab allows the USB file system to be error-checked and mounted automatically at boot time. Instead of rebooting, we can manually reload fstab with the command below:

sudo mount -a

STEP-09: Download a test file
Now let's download a 300MB test file to view on the TV. Big Buck Bunny is a short open-source film, made by the Blender Foundation (www.blender.org), and released under the Creative Commons Attribution License 3.0:

cd /mnt/usb_share
wget

You'll see a progress bar move from left to right. When the download is complete, run a command to flush any cached data to the disk:

sync

STEP-10: Test mass storage device mode
Now comes the moment of truth. Let's see whether the TV is going to be friends with the Pi Zero W. The command below will enable USB mass storage device mode, and the TV should pop up a dialogue box. If it doesn't, you may need to use the Input or Source button on the TV remote to select the USB device.

sudo modprobe g_mass_storage file=/piusb.bin stall=0 ro=1

The TV should provide a file browsing interface. Locate the Big Buck Bunny file and hit Play.

Once you're satisfied that all is well, try a dismount:

sudo modprobe -r g_mass_storage

The correct behaviour here is for the film or browsing interface to disappear from the screen. You may see a message saying that the USB device was disconnected.

STEP-11: Install and configure Samba
The next step is to provide network access to the /mnt/usb_share folder that we created earlier.

sudo apt-get update
sudo apt-get install samba winbind -y

When the installation is complete, we need to configure a Samba network share. For simplicity, this will not require a user name or password, as it is already protected by your wireless network security. If you want more security, see wiki.samba.org.

sudo nano /etc/samba/smb.conf

Scroll down to the end of the file and append the lines below:

[usb]
browseable = yes
path = /mnt/usb_share
guest ok = yes
read only = no
create mask = 777

Press CTRL+O followed by Enter to save, and then CTRL+X to quit.
Now restart the Samba service for the changes to take effect:

sudo systemctl restart smbd.service

STEP-12: Access the share from another computer
Now we can try to access the share from a Windows PC or a Mac. You'll need the host name the Raspberry Pi is using. To check this, enter the command below:

cat /etc/hostname

By default this will be raspberrypi.

In Windows, you can bring up Explorer (Windows key + E) and type \raspberrypi into the address bar at the top. The Run dialogue also works (Windows key + R).
On macOS, the Raspberry Pi will show up in the Finder sidebar. Alternatively, from the Finder menu, select Go Connect to server (Apple key + K) and type smb://raspberrypi as the server address.

Pi Zero W USB Flash Drive
Pi Zero W USB Flash Drive

Depending on your network settings, you may still see a login dialogue. Any user name, including a guest or anonymous login, will work. Once you're in, you'll see a share named usb. Open this and test that you have write access, either by creating a new folder or by copying over a file.

You can enable mass storage device mode to check that the TV can see your changes, but don't forget to run the sync command first.

If you want to change the host name, edit the name in /etc/hostname. Make the same change in /etc/hosts, and finally use sudo reboot to apply the changes.

STEP-13: Automate USB device reconnect
In order for the TV to detect any changes we've made over the network (for example, file or folder creations and deletions), it needs to be tricked into thinking that the USB device has been removed and reinserted.

We can use a Python library called watchdog (magpi.cc/2sLL1fi), which is designed for monitoring file system events and responding to them. Install this with the command below:

sudo pip3 install watchdog

We then need some code to start a timer whenever something changes in the shared folder. The timer is reset to zero every time a new change occurs, and the USB reconnect is only triggered if we see 30 seconds of inactivity after a change. This avoids spamming the TV while we're copying over multiple files.

We've written a program to do this. To download it, type:

cd /usr/local/share
sudo wget http://rpf.io/usbzw -O usb_share.py
sudo chmod +x usb_share.py

USB Flash Drive
USB Flash Drive

STEP-14: Background service
We need to make this program into a background service, so that it starts automatically at boot time. We can do that by making it into a systemd unit. Enter the commands below:

cd /etc/systemd/system
sudo nano usbshare.service

This will start a new blank file. In the new file, enter:

[Unit]
Description=USB Share Watchdog

[Service]
Type=simple
ExecStart=/usr/local/share/usb_share.py
Restart=always

[Install]
WantedBy=multi-user.target

Press CTRL+O followed by Enter to save, and then CTRL+X to quit.
Now we need to register the service, enable it, and set it running:

sudo systemctl daemon-reload
sudo systemctl enable usbshare.service
sudo systemctl start usbshare.service

Whenever you copy files over to the network share, the USB device should automatically reconnect to the TV after 30 seconds of inactivity.
#6
Raspberry Pi / Airprint With Raspberry Pi
Last post by branx86 - July 01, 2024, 09:57:43 PM
#7
General Discussion / Low power UPS 5v, 9V, 12v
Last post by branx86 - July 01, 2024, 08:12:07 PM
Low power ups
#8
General Discussion / Mini A/C from 9volts /Scale up...
Last post by branx86 - July 01, 2024, 08:06:27 PM




00:01 -  Demonstration of the effective operation of a homemade cooler for beverages. This Freezing AC cooler transforms copper pipes into ice pipes!
00:25 - Use a 4.7mm diameter copper tube!
00:45 -  Wind the copper tube around a full aluminum Coca-Cola can.
01:21 - A 25mm diameter stainless steel sleeve serves as a second base for making the condenser.
02:19 -  A thin copper tube with a diameter of 1.2 millimeters will serve as the capillary tube.
04:56 - Solder the capillary tube to the condenser and evaporator using special solder and flux.
05:26  - Solder a connector for a 9-volt battery to the pump and fan.
07:00  - The first stage of testing is conducted in an open area to ensure the efficient passage of liquid gas through the pipes and capillary system of the conditioner.
#9
General Discussion / APC Linux Monitor
Last post by branx86 - July 01, 2024, 01:14:43 PM
https://srbu.se/articles/linux-et-al/configure-apcupsd-for-use-with-centos-6-and-apc-back-ups-es-700

Getting the source and installing (compiling) it
Go here; https://sourceforge.net/projects/apcupsd/?source=directory and download the latest version.

Go to your Downloads folder and untar the archive, then start compiling the source for your system.

cd ~/Downloads
tar -xvf apcupsd-3.14.14.tar.gz
cd apcupsd-3.14.14
./configure --enable-usb
If the above configure step fails, you may want to check that your system has the needed dev tools installed.

yum groupinstall "Development Tools"
When installed, rerun the configure.

./configure --enable-usb
make
make install


Configure the daemon
The config file is in /etc/apcupsd/apcupsd.conf. Edit it with eg nano.

nano /etc/apcupsd/apcupsd.conf
Change the following lines to your specification.

UPSNAME ups1
UPSCABLE usb
UPSTYPE usb
DEVICE <blank>
Please note, the DEVICE line must not be commented. It must be there but the device should be blanked.

The below lines can be left with their default settings, or changed to suit your situation.

ONBATTERYDELAY 6
BATTERYLEVEL 5
MINUTES 3
TIMEOUT 0
NETSERVER on
The NETSERVER must be on in order to check the UPS status with apcaccess. Check any of the sources below to find out what the settings do!

Testing the UPS
Stop the apcupsd(aemon) if started.

service apcupsd stop
apctest

Enable the daemon
chkconfig --list | grep apc
apcupsd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
chkconfig apcupsd on
chkconfig --list | grep apc
apcupsd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
 

Control apcupsd
service apcupsd start
service apcupsd stop
service apcupsd restart
apcaccess status


Enable CGI
Earlier we just used the --enable usb parameter to tell the installer we had a USB-type UPS. If we want to also enable CGI, we need to run the below.

It doesn't matter if you already have a working apcupsd install, you can run this without breaking anything.

./configure --enable-usb --enable-cgi --with-cgi-bin=/var/www/cgi-bin/apcupsd-cgi

What the above does is

Enable USB, because we have a USB-type UPS.
Enable the CGI bits.
Tells the installer where to save the cgi-scripts. The default is /etc/apcupsd, which may not be optimal.
 

If you get this error after running ./configure..., you need to install libgd.

configure:
error: Your system lacks the GD library which is needed for compiling the apcupsd CGI programs.
Please install libgd and re-run the ./configure script. Alternatively you can disable the CGI support.
 

For CentOS 6 it couldn't be found in the usual repos, but a Google search later revealed where to find it; https://centos.pkgs.org/6/centos-x86_64/gd-devel-2.0.35-11.el6.x86_64.rpm.html.

Therefore;

yum install http://mirror.centos.org/centos/6/os/x86_64/Packages/gd-devel-2.0.35-11.el6.x86_64.rpm
 

Install it and re-run the ./configure as above.

On a successful run, you should now see the below

Configuration complete: Run 'make' to build apcuspd.
 

Run make and make install as earlier.

When done, you should see new contents in /var/www/cgi-bin/apcupsd-cgi.

root@cyndane2:/var/www/cgi-bin/apcupsd-cgi # ll
total 384
drwxr-xr-x 2 root root 4096 Nov 30 15:53 .
drwxr-xr-x. 3 root root 4096 Nov 30 15:39 ..
-rwxr-xr-x 1 root root 99256 Nov 30 15:53 multimon.cgi
-rwxr-xr-x 1 root root 83746 Nov 30 15:53 upsfstats.cgi
-rwxr-xr-x 1 root root 96980 Nov 30 15:53 upsimage.cgi
-rwxr-xr-x 1 root root 94399 Nov 30 15:53 upsstats.cgi
#10
Windows Fixes / Change Password Hint on login ...
Last post by branx86 - June 27, 2024, 07:14:15 PM
 

Step 1- On the search bar, type "Settings" then locate and click on "Accounts".

Step 2- On the left navigation pane, locate and click on "Sign- In Options", then click on "Password" Click Change.

Step 3- Type your current password/new password and the hint that you want to provide under "Password Hint".