"Robonomics coffee" - is a smart coffee machine integrated in Robonomics Network. This project aims to show Robonomics potential in the IoT sphere by a real-world example.
How to make coffee?
In order to have a cup of delicious coffee, a customer should send some funds (1 Statemine's token ACT, id=3077) to the address of a coffee machine in Statemine parachain. After that the pouring process is started and action log is published in the Robonomics parachain via Datalog function.
NOTE!You may use any token on Statemine, more on that here
How it works?
There is a single-board computer attached to the body of the coffee machine. This computer is the center of the entire system, where all the processes are happening. The single-board (Raspberry Pi 4) is connected to the control panel of the coffee machine via jumper breadboard wires and GPIO interface. RPI is also the one interacting with Robonomics and Statemine parachains. Sample flowchart of the workflow is presented below.
- Coffee machine
The very important criteria for a coffee machine was the ability to solder some wires to the control panel since GPIO was selected as a communication interface being the easiest one to implement. Several options were considered (Saeco PicoBaristo HD 8925, De'Longhi ESAM3200.S). As may be seen, no touchscreen and no bells and whistles, just buttons and espresso. Finally, De’Longhi Magnifica ECAM 22.110 was chosen as it is cheap and has an easy-removed front panel.
- Single-board Raspberry Pi 4B (2 GB) with Ubuntu server installed via RPi Imager.
- 5V adapter and USB A to USB type C cable (this and this are examples)
- A set of F-M, M-M, F-F jumper wires, a breadboard (again, this is just an example).
- Transistor and a resistor(optionally). More on that later.
- A set of screwdrivers.
- Soldering iron with some solder and resin.
1. Disassembly the coffee machine.
There is a sample tutorial on YouTube. Your goal is to remove the front panel (it won't be used anymore, so this is a thing to improve to hide all the wires) and detach the control PCB.
2. Solder two wires to the button you need.
Solder them to the isolated contacts (in our case - two bottom contacts). You can use any wires, but keep im mind that in the end there should be an M-wire to put it into the breadboard.
3. Assemble the entire coffee machine back leaving the front panel removed.
Overall circuit is presented below, this is a very simple transistor switch, we used R1=1kΩ, a npn transistor Q1 (hfe=40, Uce>5V, Ic>0.015A, sample here, but almost any general transistor suites, since this is a switch) and a small 3.3V diode D in base circuit found in the storage of our lab:) One can use a MOSFET transistor as well.
5. Connect coffee machine and RPI
Connect wires marked as RPI GND and RPI GPIO Pin to pins GND and 21 respectively. RPI GPIO scheme is presented below. Wires marked as Button+ and Button- should be connected to the left button contact and right button contact respectively.
Time to turn the Raspberry Pi into blockchain-powered coffee maker!
- Prepare the RPI for Substrate libs (source):
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh rustup default nightly
- Install gpiozero library (source) and reboot:
sudo apt update sudo apt install python3-gpiozero sudo pip3 install gpiozero sudo reboot
- Clone the repository
git clone https://github.com/Multi-Agent-io/robonomics-coffee-maker
- Install project requirements
pip3 install -r requirements.txt
On your PC install Polkadot Extension and register a coffee machine account there. Save mnemonic seed phrase as it is going to be used later.
Logging actions in Robonomics is optional, you will need XRT on parachain.robonomics.network for coffee machine account (it is the same across networks) for this. If not, there will simply be an error message "Balance too low."
Run Robonomics coffee
Run this in repo folder:
python3 main.py <previously saved seed in quotes>
You should see the program waiting for ACT incomes:
You can send tokens from another account created the same way via
As soon as there is an income (positive change in
assets:accountstorage function for address
derived from seed and for token id
3077) the RPI triggers GPIO pin 18 and coffee machine starts making coffee and
records a datalog!
Things to point out
- This is a POC of a blockchain-driven IoT device, it has things to improve, wires to hide and functionality to implement.
- Token ID, the one, coffee machine is waiting to receive, is set
here, so you can use your own token,
existing one or newly created. To create one, go to
Statemine Kusama parachain page,
Network -> Assets -> Create. Set an ID there, complete the procedure and paste ID in the code.