LNbits on Fire
Lightning ATM (en)

Lightning ATM (en)


The english version is no longer maintained here. The current version can be found on github.

Bitcoin Lightning ATM – Pocket Edition

This is a tutorial for the Bitcoin Lightning ATM – Pocket Edition. This is a do-it-yourself project consisting of a mini-computer (Raspberry Pi Zero), a coin acceptor, a display, a 3D printed case, and a Bitcoin Lightning wallet as a funding source. The machine takes over the task of the money changer. He exchanges fiat coins for valuable Bitcoin Lightning ⚡ Satoshis 丰. The user can pick up the Satoshis via QR code (LNURL-withdraw) on his mobile phone wallet. There are already good guides that I’ll refer to later, but I was missing a step-by-step guide, specifically for this Pocket Edition with connection to an LNTXBOT wallet. The connection to a BTCPayer server is also possible, but is not explained further here. You can get the components as individual parts and build the case yourself. All the necessary data can be found in the instructions, which I will refer to later. However, I made it easy for myself and ordered the kit from Fulmo.org. The shop offers payments in Bitcoin and Lightning ⚡.

The entire LightningATM project is based on FOSS (free and open source software) according to MIT-License. In the same way I publish all data, pictures and information on this website. You can copy, link and use everything as you wish. Only the guarantee and liability is excluded.

I think the project is so intermediate, for experienced beginners who already have experience with the Command Line Interface (CLI) and the Raspberry Pi. If you are not quite up to it yet, I can recommend the DIY project BTC-Ticker as a starter. The project uses similar components and commands as in this tutorial, but a little less complex and extensive.

Basics of the project

Hardware preparation

Prepare the voltage converter

  • Cut the micro USB cable. Approx. 15 cm from the Micro USB connector
  • Strip both sides and solder together in parallel (++ / –) if you have a soldering iron
  • Place both ends on the input of the voltage converter and screw tight
  • Connect the USB plug to the power pack or USB power pack
  • Connect a voltmeter on the output side
  • Using a screwdriver, turn the small rotary potentiometer (see picture) several times (probably first to the left) until the voltage shows 12.1 volts
  • Caution: The initial voltage can be very high. For me it was 35 volts. So do not connect directly to the coin validator and set the measuring device to the correct measuring range
  • Prepare cables for the output side:
  • Connect plus (12V) and GND (0V) from the voltage converter to the coin validator
  • Join a second wire from GND of the voltage converter (output) to the terminal 25 of the Raspberry Pi
  • Check you wiring with pictures and wiring diagrams

Configure validator checker (6 coins, 5 cents to 2 euros)

  • Set the switches on the coin validator to "NO" and "Medium".
  • Apply the 12V to the coin validator (without Raspberry Pi) => The coin validator will flash and show 0
  • Press and hold simultaneously the ADD and MINUS buttons until A appears in the display
  • When B appears, switch back to A by ADD or MINUS
  • Press and hold the SET button briefly, until E will appears on the display
  • This indicates: You are in them menu to set the amount of differnet coin types
  • Set to 6 (6 coins = 5 cents to 2 euros) with ADD (or MINUS) and press SET
  • Now the display shows H1 (for the first coin). The first of 6 LEDs has come on
  • Now specify how often the coin should be inserted for calibration
  • Set to 20 with ADD (or MINUS) and then press SET
  • The display now shows P1 for further settings of coin 1 and you can define the output signal
  • 5 cents = 2 pulses / 10 cents = 3 / 20 cents = 4 / 50 cents = 5 / 10 euros = 6 / 2 euros = 7
  • Set to 2 pulses (for 5 cents) with ADD (or MINUS) and then press SET
  • The last thing on the display is F1, which represents the accuracy of the coin recognition. The value 8 worked well
  • Set to 8 with ADD (or MINUS) and then press SET
  • The parameters for the first coin have now been set
  • Now the second LED is on and the display shows H2
  • Now repeat the same steps again for the second coin (e.g. 10 Cent) up to coin 6 vor (e.g. 2 Euro)
  • When all coins are set, all LEDs flash briefly to confirm and the display shows A again
  • After a short time, 0 (zero) appears again in the display

Calibrating the coin validator

  • Press the SET button twice
  • The first LED light and A1 will show in the display
  • Now insert the first coin (5 cents) 20 times
  • Use as many different coins as posible
  • Finally all LEDs flash to confirm and the display shows A2
  • Repeat for the remaining coin types
  • All LEDs flash briefly again to confirm and the display shows 0 (zero) again
  • The coin validator is now ready.

Wire the hardware

  • Wire the hardware according to the pictures, but do not yet install the ATM in the housing
  • Set the switch on the e-Paper Display HAT to A and 0
  • Be careful when plugging in the fine display ribbon cable!
  • The clamp has a small lock and must be released beforehand. See pictures!

Create SD card and write WiFi data to it

Download the image and write it to the SD card

Set up WiFi for the Raspberry Pi

Create a file named wpa_supplicant.conf with the following content:

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


  • The file contains two WiFi networks. "Home" for home use and the "Mobil" for mobility
  • "Mobil" can be you hotspot on your cell phone
  • Adjust the values ​​for SSID and PSK as you like
  • More networks can be added if needed
  • Make sure the file ends with .conf and not in .conf.txt
  • In the basic setting, Windows has the habit of hiding known file type extensions
  • See "Folder Options/View/Advanced Settings"
  • -> "Hide extensions for known file types" must be deselected!
  • Slide the newly written SD card back into the slot
  • -> The BOOT directory of the SD card is displayed
  • Copy the new file wpa_supplicant.conf into it
  • Note: After starting the Raspberry Pi for the first time, the ".conf" file disappears from the directory
  • It can then be edited later via CLI by the command:
  • $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Carry out basic software settings and updates

  • Insert the SD card into Raspberry Pi
  • Check the wiring again and then apply voltage
  • Wait for a while and then look for the assigned WiFi IP in your own WiFi router
  • Login to Raspberry Pi via CLI: ssh pi@192.168.x.x
  • Confirm The authenticity.. with yes
  • Enter raspberry in the password prompt
  • If you are logged in correctly you will now see: pi@raspberrypi:~ $

Adjust password and please remember!

	$ passwd
  • Note: $ stands for pi@raspberrypi:~ $ in CLI and does not need to be typed

Perform an update, clone the ATM Github and install necessary additional options

	$ sudo apt update && sudo apt upgrade
	$ git clone https://github.com/21isenough/LightningATM.git
	$ cd LightningATM
	$ pip3 install -r requirements.txt
  • Note: When updating, you sometimes have to confirm with y or q
  • Now disconnect the power supply and log in again via SSH with the new password

Set up and test the display

Update display software

$ cd ~
$ git clone https://github.com/waveshare/e-Paper
$ cd ~/e-Paper/RaspberryPi*/python
$ sudo python3 setup.py install

Testing the display

$ cd ~
$ cd e-Paper/RaspberryPi_JetsonNano/python/examples
$ sudo python3 ./epd_2in13_V2_test.py

If everything has been correctly connected and installed, the display will now show a demonstration and finally the screen will cleare.

Setting the config.ini and app.py file

Basic settings are made in config.ini and the program is adjusted slightly in app.py.

  • New login on Raspberry Pi again via CLI: ssh pi@192.168.x.x

Start ATM once to create the config.ini

$ cd ~/LightningATM/
$ ./app.py
  • The app.py (the ATM) was started and the config.ini file was created
  • The display should now show LightningATM
  • The process or the ATM can be interrupted/stopped with CTRL+C
  • After a short time, Manually Interrupted is displayed and you can see on the display that the ATM is turned off.

Open the config.ini file

$ nano ~/.lightningATM/config.ini
  • Don’t be surprised, the spelling is really ~/.lightningATM/config.ini with a dot and lowercase letters

Set the config.ini file

Enter display type under [atm]
	display = waveshare2in13v2

Note: Please compare the display type. Yours may require different settings.

Delay time (set from 0 to 12 seconds. 0 is only for ATM with button)
	payoutdelay = 12 
Activate wallet types
	activewallet = lntxbot
  • Note: A good guide to getting started with the LNTXBOT can be found here: coincharge.io
  • If you would like to set a BTCPayServer wallet, get further information here: BTCPayServer
Under [lntxbot] enter the data for the API to the lntxbot
# base64 encoded lntxbot api credentials
url = https://lntxbot.com
creds = abc..xyz==
  • Note: The LNTXBOT delivers url and creds with the command /lightningATM from you Telegram bot
  • The structure from the bot answer is build up like: <creds>@<url>
Set the coins to the pulses
# Pulsecount, fiat value, name
coin_types = 2,0.05,5  eur cent
             3,0.10,10 eur cent
             4,0.20,20 eur cent
             5,0.50,50 eur cent
             6,1.00,1 eur
             7,2.00,2 eur
  • To save and exit the editor: CTRL+x -> y -> ENTER
  • Note: In version 3.0.0 you still had to make the setting in app.py. I don’t know which version you get, but if the settings with the config.ini don’t work, you can set them directly in the app.py. I wrote something about that in the next paragraph. But if you are lucky, it might be enough to set it here in the config.ini. You have to test it out. With the monitoring system (tmux), explanation see below, you can see that well.

Special settings in the app.py file

Open the app.py
$ cd ~/LightningATM/
$ nano app.py
Optional setting: Skip the "Prepare for LNURL" page:
  • Search for display.update_lnurl_cancel_notice() with CTRL+W. (It exists twice)
  • There is a place where it says if activewallet == "lntxbot", please edit the two lines
Comment out the following two lines with #
	# display.update_lnurl_cancel_notice()
	# time.sleep(5)

-> This will skip the LNURL "query page" as it is not relevant for the pocket version (without push button).

Alternative setting: coin preselection if the setting in config.ini does not work:
Adjustment of the pulses for the respective coins
  • Search for if config.PULSES == 2 in app.py with CTRL+W
  • There you will find the setting options for the coins.
  • Note: If you can’t find if config.PULSES == 2 in the app.py file, then you might have a higher version then V3.0.0 and the coin settings are in the config.ini. You can skip this point.
For example:
	if config.PULSES == 2:
			config.FIAT += 0.02
			logger.info("2 cents added")

The settings are now set in the same way as the coin validator is parameterized:

For the example, two pulses = 5 cents
	if config.PULSES == 2:
			config.FIAT += 0.05
			logger.info("5 cents added")
  • Repead the change up to 2 euros = 2.00 (200 cents)
  • Note: As I said, you only have to do this if the setting in config.ini doesn’t work

Monitoring system (tmux) to control the processes

Terminal multiplexer (tmux) command overview:
CTRL + b -> % = split window
CTRL + b -> right or left arrow = change the window
CTRL + b -> CTRL + right or left arrow = move dividing line
CTRL + b -> d = back to single window

This allows the CLI window to be split vertically into two parts to observe two processes at the same time.

install tmx
$ cd ~
$ sudo apt install tmux    
Start and use tmux
$ tmux
  • Split tmux windows: CTRL+b -> %
Start the app.py process (ATM).
	$ cd ~/LightningATM
	$ ./app.py
  • Switch to the right window: CTRL+b -> right arrow
Start debug.log
	$ tail -f ~/.lightningATM/debug.log
  • If necessary, move the dividing line: CTRL+b -> CTRL + arrow right or left
  • Back to single window: CTRL+b -> d


Activate the Service:
$ cd ~/LightningATM
$ sudo cp LightningATM.service /etc/systemd/system/LightningATM.service
$ sudo systemctl enable LightningATM.service
$ sudo reboot
Other commands to control the service:
$ sudo systemctl status LightningATM.service
$ sudo systemctl stop LightningATM.service
$ sudo systemctl start LightningATM.service

Well done, that’s it!

  • I hope it worked out and everything works 🙂
  • You can get more help in the Telegram group: https://t.me/lightningatm_building
  • If you find any errors in the documentation or have any other suggestions, you can reach me by:
  • Email: axel@lnbitsonfire.xyz
  • Telegram: @AxelHamburch
  • Twitter: @AxelHamburch

A few more tips

  • When making entries in the Command Line Interface (CLI), it is best to copy and paste the commands:
  • -> To do this, copy the command to the clipboard with STRG+C and then point to the blinking cursor in the CLI window and press the right mouse button to paste the clipboard into the CLI.
  • If you get the error bash: $: command not found then you copied the dollar sign $ in front of the command. Don’t do that!
  • If you get the error bash: cd: too many arguments, you may have to go back one level with $ cd ~.
  • When logging in via SSH, make sure to use the correct user pi. If you accidentally use admin or make a typo, you will not see an error, but the password will not be accepted.
  • You can change WiFi parameters later with the command:
  • $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
  • If it asks you for a user and password when "cloning" a repository, restart the PC + Raspberry Pi once. At least it worked for me.
  • SSH login problems with Windows: Check whether OpenSSH client AND OpenSSH server are installed under Settings / Apps / Apps & Features or Optional Features.
  • If you are not quite up to speed with the CLI and the Raspberry Pi, I recommend starting with a somewhat smaller project, for example the BTC ticker.

Created with love! 🧡 block high 721536 / 722354 updated