-
-
Notifications
You must be signed in to change notification settings - Fork 504
Using Only a Stock Raspberry Pi ZeroW and USB Cable
A Raspberry Pi Serial Gadget makes it so when you plug in the Raspberry Pi Zero to your computer, it will pop up as a Serial Port. You can use the Raspberry Pi with any computer and operating system and it doesn't require special drivers or configuration.
The setup process for the Serial Gadget only has to be done once. The Tuya-Convert
software can be updated independently of this setup.
-
Download and flash the latest Raspbian Lite on a microSD card After burning the SD card, the SD flasher may automatically eject it from your computer. If so, remove the SD card and reinsert it to mount it again.
-
Edit config.txt & cmdline.txt
- Find the partition labeled boot and open that folder
- Use a text editor to open config.txt
- Go to the bottom and add 'dtoverlay=dwc2' (no quotation marks) as the last line in the file
- Save the file as plain text
- Use a text editor to open cmdline.txt
- After 'rootwait', add a space and then 'modules-load=dwc2,g_serial' (no quotation marks)
- Save the file as plain text
-
Create a new text file on the SD card named
wpa_supplicant.conf
- Add the following lines:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 country=US network={ id_str="HOTSPOT NAME" ssid="SSID" psk="PASSWORD" key_mgmt=WPA-PSK }
- Add the following lines:
-
if your wifi ssid is hidden then add
scan_ssid=1
to network section inwpa_supplicant.conf
-
Enable SSH
-
Create a new file on the SD card named
ssh
The contents of the ssh file don’t matter. When the Raspberry Pi first boots, it looks for this file. If it finds it, it will enable SSH and then delete the file.Windows:
C:\> <d>:
(where 'd' is the drive letter of the SD card)
<d>:\> copy nul ssh
Linux/MacOS:
$ cd /Volumes/boot
$ touch ssh
-
-
Log into your Raspberry Pi
- Eject the SD card from the computer
- Insert it in the Raspberry Pi
- Power up the Raspberry Pi using the microUSB connector labeled
PWR
. Once it boots, it should be connected to your Wi-Fi network - Find its IP address in the router and connect to the Raspberry Pi via SSH
- Log in with user ID
pi
; passwordraspberry
- Encode the Wi-Fi free text password
wpa_passphrase "SSID" "PASSWORD" | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null
- Then remove the free text password from
wpa_supplicant.conf
- Run
sudo dmesg
to verify that it bound theg_serial
driver
-
Set up the Raspberry Pi Zero Serial Gadget to accept logins
-
Enable the tty service
$ sudo systemctl enable [email protected]
Created symlink /etc/systemd/system/getty.target.wants/[email protected] → /lib/systemd/system/[email protected].
$ sudo reboot
-
After the Raspberry Pi reboots, connect via SSH and verify that the service is running:
$ sudo systemctl is-active [email protected]
active
-
-
Shut down the Raspberry Pi.
$ sudo shutdown now
-
Log into the Raspberry Pi using a Serial Terminal application Ensure that your USB cable is data cable and not just a USB power cable. Plug in the USB cable from your computer to the Raspberry Pi microUSB connector labeled
USB
, not thePWR
connector.-
On your computer you'll see a new Serial port is created
Windows:
COMN
(where N can be any number)Linux/MacOS:
/dev/tty.usbmodemNNNN
(where NNNN can be any number) -
Connect to it at
115200
baud,8N1
(8-bit No-parity 1-stop)
You may have to hit return a few times to get it to come up with the login prompt. -
I had success using following command on my mac (the number after usbmodem might vary so check your /dev folder for actual name) - screen -L /dev/cu.usbmodem14101 115200 –L You're now connected to your Raspberry Pi Zero via the USB cable and the Raspberry Pi ZeroW Wi-Fi interface (
wlan0
) is available forTuya-Convert
to flash your Tuya smart devices.
-
- Update Raspbian packages
$ sudo apt-get update && sudo apt-get -y upgrade
- Install git to clone the GitHub repository
$ sudo apt-get install git
- Install and configure
Tuya-Convert
$ git clone https://github.com/ct-Open-Source/tuya-convert $ cd tuya-convert $ ./install_prereq.sh
After flashing your Tuya devices, be sure to shut down the Raspberry Pi properly ($ sudo shutdown now
).
- Remove your Wi-Fi network configuration by deleting or renaming
/etc/wpa_supplicant/wpa_supplicant.conf
The Wi-Fi interface will be used byTuya-Convert
. You will connect to the Raspberry Pi with the wired USB Serial Gadget and will no longer want it to connect to your Wi-Fi network automatically. - Disable SSH
$ sudo service ssh stop $ sudo systemctl disable sshd.service (Buster) $ sudo systemctl disable ssh.service (Stretch)
Thank you to @SourPickel
(Discord) for bringing this to the community's attention.