How To Make Lightning Node Mobile
This is an opinion editorial by Anthony Feliciano, a Bitcoin events organizer and contributor at Bitcoin Magazine.
This article is a follow up to a previous article I wrote, talking about different types of Lightning nodes. I will be expanding on the RaspiBlitz Lightning Network node. I won’t be going into the many other options and features of what RaspiBlitz offers, but this is a unique twist.
This project started four years ago when I was sitting in my apartment, midday, and the power suddenly went out. The first thing that goes through a normal person’s mind, is “damn it, power’s out — I wonder how long is it going to take and do I need to start looking in the fridge to possibly BBQ what might defrost?”
Not me! I immediately thought, “MY LIGHTNING NODE!” Long story short, the power was only out for a couple of hours. But at that time it got me thinking, if something like this happens again, what can I do?
What manifested next was a project that followed me setting up a RaspiBlitz LN node. That project being to figure out a way to keep the LN node running when power and internet goes out.
The issues to solve for:
- Power — what can I use to keep the LN node running during the next power outage?
- Internet — how do I keep the LN node connected to the internet to keep LN sync’d ?
- Mobility — what if there was a fire or emergency and I had to leave, taking only what I can carry?
Power
If you read through the issues, you yourself are probably already also thinking about solutions. The first problem is easy to solve – obtain an uninterruptible power supply (UPS) as a backup. Makes sense right? If the power goes out, UPS kicks on and keeps the device’s power on with no issues. Only follow-up question is, how long do you need? There are many UPSs on the market providing power for any number of hours, so at that point it becomes a matter of preference and budget. I went for an approximately two-hour power supply UPS model. At the time I had nothing, so this was still new to me and had never crossed my mind. While not the longest charge or most powerful UPS out there, the UPS I selected only provides backup power to my LN node and my router; if I lose internet, I can still keep my router power going and connect via a Secure Shell (SSH) terminal to my devices on the network. First problem solved.
Internet
**Note** The following solution is based upon if you are using a WiFi setup to begin with. If you are using the Ethernet cable, you can still add the WiFi network as a backup from the steps below. Also, if you keep your router powered up by a UPS, this doesn’t always mean you lose internet in a power outage, as this will depend upon whether your provider is affected as well. This method is for a greater area power outage or emergency situation, and will contribute to solving the third problem — mobility.
Internet And Maintaining Connectivity
While everyone worries about power, and rightfully so, many forget the second most crucial part — the internet connection. How do I keep this device connected if there is a power outage? Easy — this is when I started researching; thankfully because I am using a Raspi 4 that comes with built-in WiFi, with a simple configuration of the WiFi file you can add a second WiFi network.
How To Setup A Second Network On Your Raspi:
Head over to this page for more info: Set up WiFi on Raspi
This is the line of code you are looking for:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
**NOTE** If you are not using WiFi and instead are using RJ45 (Ethernet) your wpa_supplicant.conf file might not have this code at the top; if it is missing add it:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US – **Change your country code if outside the United States**
To enter this code, exit out of your RaspiBlitz menu to the terminal screen, which should look like this:
admin@NODEIPADDRESS:~ $
Enter the code to look like this below:
admin@NODEIPADDRESS:~ $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
I won’t be showing my configuration, but you will see your setup when you open the file. I took this from the “Set up WiFi on Raspi” link above.
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
network={
ssid=”SchoolNetworkSSID”
psk=”passwordSchool”
id_str=”school”
}
network={
ssid=”HomeNetworkSSID”
psk=”passwordHome”
id_str=”home”
}
What you will see on your file is your WiFi network that you already use. What you are adding is that second network. So what is your second network? I mean how many WiFi spots can you connect to? Do you know the SSID (service set identifier) and the password to connect to them? In my instance, I used my cellphone’s hotspot. That’s right, you can use your cellphone as a hotspot to act as WiFi, so that your LN node can connect to it. So for the second network on the list, I entered my SSID and the password that is given by my cellphone hotspot feature.
Question — but what if I use my cellphone hotspot? How will I know the IP address to connect to it? Don’t worry, I’ve got you covered with that as well. On your phone (I use Android) download an app called Termius which acts like a SSH terminal from your cellphone to your LN device.
**Note** If you have a screen on your RaspiBlitz, the IP address to connect to will show up there as well, which means you entered the second WiFi network correctly and your phone and device are communicating.
**Note** If you run your device headless (no screen) like I do, then you have to get the IP address, from “connected device” information, a step that I discuss below
Termius App
Steps: Due to security policy I can’t take screenshots to show how to set up the app on your phone, but I can guide you.
- Open the app
- Click “+” – New Host
- Fill out the info – Alias (name for the connection)
- Hostname or IP Address: you will get this IP address when your node connects to your cellphone hotspot. I’ll show how to get this later.
- Make sure “SSH” box is checked.
- User name: for RaspiBlitz users the user name is “admin” but if you changed it to something else, then it is whatever you called it,.
- Password: DON’T ENTER A PASSWORD! If you enter it, it will automatically connect, which is a security flaw if someone gets into your phone. Leave it blank when you click on the alias name, it will ask you for the password of your device to connect to.
- Click the check mark at top to add the new connection.
- When you make your first SSH connection into the device it will ask you to accept the fingerprint to do so. Click “Yes.”
Below is a screenshot of what this all looks like:
As you can see, I’m on my cell phone hotspot.
My WiFi network is “Gopoundsand” along with the password provided (psk), which I entered as the second WiFi network.
network={
ssid=”Gopoundsand”
psk=”passwordHome”
id_str=”home”
}
If you see connected devices (your LN node name) that means you successfully set up the sudo nano /etc/wpa_supplicant/wpa_supplicant.conf correctly and your device is now WiFi connected to your cellphone and the internet. Congratulations on making it this far!
**Note** Make sure your first connection if you use Ethernet is unplugged, or if you use WiFi, as your main connection, that it is turned off. For when you reboot, the device will lock onto your main WiFi network and won’t look for your second connection. This will take a few minutes on reboot to establish a connection.
You can now go to mobile hotspot from settings and see connected devices or swipe down from the notification bar, like shown above to see connected devices. Now click on “details” of the connected device, and “details” again. This is where you will see the IP address given from your cellphone to the device. (Example: 192.168.200.102.) That information will now go into the Termius app: Hostname or IP Address: you will get this IP address when your node connects to your cellphone hotspot.
If you managed to do everything correctly then you should arrive to this spot in the screenshot:
This is the menu screen of the RaspiBlitz, on my Android phone with Termius app.
If you managed to get through all the steps, then you have successfully added a second WiFi network to your sudo nano /etc/wpa_supplicant/wpa_supplicant.conf, managed to get the LN node to connect to your cellphone via hotspot and were finally able to SSH into your device and get your LN node to resync over cellular and access the RaspiBlitz menu as seen in the screenshot above you. Congratulations, you are going to make it!
Tips if something fails to connect:
- Make sure the SSID and password are correct in the sudo nano /etc/wpa_supplicant/wpa_supplicant.conf file. Ctrl+x to exit, “y” to save the file if the info is correct. Or “n” if you mistyped something.
- When rebooting the LN node, to connect to your cell phone hotspot, then give it a few minutes to establish that connection. So don’t fear you did something wrong – if it takes over five minutes, then it’s probably worth troubleshooting.
- Make sure your first connection if you use Ethernet is unplugged, or if you use WiFi, as your main connection, that it is turned off. For when you reboot, the device will lock onto your main WiFi network and won’t look for your second connection.
- On SSH via terminal, make sure you have the correct IP address from your hotspot. And add that info to the new host connection. (Side note: on some devices like mine, everytime I turned off and turned on the hotspot, I got a new IP address, so I have to “edit connection alias” in the app with the new IP address, and SSH will reconnect.
Mobility
We finally come to the last step. What if there is a major emergency, a fire or say just a vacation, and you had to take only what you could and go? Could you take your LN node with you? How would you do it? If you went with a moderately-sized UPS, you can always grab that and go, as it provides a few hours needed to keep your unit going until you can get to a more stable setup. Lets say, your UPS is big and chunky, and taking it with you is just not feasible. I thought about that as well, and decided to go with a 28800mAH solar backup charger, basically what you could use to charge your cell phone. Why is this handy? Because it’s small, light, and versatile. The unit also has uses (usb-c connector) for wall charging the unit. But more importantly, the solar charger provides the power (3Amp) necessary to power up your device including the external SSD.
Tips:
- You can’t wall-charge the backup charger while trying to power up the LN device; it didn’t kill the Pi, just stopped it from working. I pulled the power, waited some time, and rebooted back up.
- You can’t use both USB ports to connect to your Raspi USB ports. That will fry your board: So yea, I killed my board. Thankfully it was just the board, which was only a $35 replacement.
To sum it up, I learn through trial and error. Hope you had a laugh about it but hopefully it helps someone avoid unnecessary stress.
This is the end result (photo taken at a state park in the Rocky Mountains):
Conclusion
This can be a weekend project for you. If you are already running a node and feel like getting a bit #reckless this is a fun way to expand your applications and skills. Even if you don’t do it this exact way, I hope this inspired you to think of a more creative way to solve the problems that I experienced.
Now go be #reckless.
This is a guest post by Anthony Feliciano. Opinions expressed are entirely their own and do not necessarily reflect those of BTC Inc or Bitcoin Magazine.