Sometimes i just want to build something stupid. And today i had a tought about something really stupid and pointless.
A Maneki-Neko with Wifi and Bluetooth.
Those adorable japanese cats, that constantly wave with their paw to welcome people and give them luck and happiness.
The idea i had is simply use a Pi Zero, connect a GPIO to the arm’s drive mechanism and hook it up to the net somehow.
To use the Pi that way i had to make sure the arm wouldn’t draw to much current, so i could hook it up directly to the GPIO.
But the cat is supposed to operate for weeks, even months on a single AA battery, so can’t be that much!
Confirmed: The cats draws 1.5mA max. That should work.
The next steps are totally non-cat related and focus on getting the RPi to some kind of headless operation.
My goals are:
- Headless boot
- SSH over WiFi
- Configure the WiFi via Bluetooth from an React Native app
I have an older Pi Zero without the on-board wifi, so i directly ordered the Pi Zero W that will go into the cat later on.
But for the next days a USB Wifi adapter and a USB BT dongle have to do.
I used the latest Raspian image and then (with keyboard and monitor hooked up) went through the basic setup:
- Set a hostname
- Setup the SSH server
- Manually setting up Wifi so i can work on the pi
After that i was ready to go to tackle the Bluetooth stuff
First i had to update the Bluetooth systemd file at
/lib/systemd/system/bluetooth.service and add/change the
Then i created a new service for
rfcomm. Rfcomm will listen on a bt channel on the dongle and starts a terminal. So i kept it basic:
and saved it as
/etc/systemd/system/rfcomm.service. That should wait for connections on channel 1 and will open a shell on that channel. Just like a TTY terminal.
The next step would be to write a small program that will get started instead of the
bash so we can do the wifi configuration.
Now i want to replace the normal shell session with my own program.
So i put a very basic python program together that reposnds with
MANEKINEKO and echos the input from the client:
I put that into
/home/pi/wifi-setup.py and made it executable (
chmod 755 /home/pi/wifi-setup.py). To have it run after a client connects via bluetooth i just changed the
getty command in
/etc/systemd/system/rfcomm.service and replaced the
-a pi with
-ni -l /home/pi/wifi-setup.py which directly runs the command as root. I know, i know, but eh! (at least for now :-P )
systemctl daemon-reload && service rfcomm restart i reconnected and my python script answered me!
Thats it for part 1. Part 2 will probably cover the development of a very small React Native app that will talk via Bluetooth with the Pi Zero to set it up.