Recently, there is a new, worldwide demand for one drink: boba milk tea.
What isn’t new is how these drinks are made. Boba shops have been using the same techniques for pour-scoop-seal process for making their drinks since the first shops opened in the 1980s. Without innovation, shops are unable to satisfy customer demand, enticing either more copycat boba tea shops to open or long waits for drinks.
Now, like a majority of other college students, I enjoy drinking boba so I can escape the harsh realities of my debilitating student loan debt. But with the massive ongoing boba trend, drinks around me usually start at $4 and can reach up to $10 for more exotic flavors.
These prices are insane. To produce one cup of boba, the shop spends far less than what the drink is sold for.
Precisely how much? Half a dollar — even less if the shop purchases its ingredients in bulk.
And yet, it’s virtually impossible to find a drink close to this price despite lots of competition (up to 16 per block in some places!). Furthermore, boba shops don’t make nearly as much profit per cup as the numbers above might make it seem.
Much of their revenue is allocated into two areas: labor and rent. Most stores still use the same inefficient practices created 40 years ago, the only difference being the number of people employed. To eliminate long lines, they simply add more employees; five or more might be needed to handle the after school rush, for example. Increasing the number of employees increases labor costs multiplicatively, eating away at a large part of the shop’s profit. Rent is also a major issue. To accommodate the additional expenses of hiring workers, colloquially (and somewhat affectionately) dubbed “bobaristas,” shops are forced to open up in high traffic locations — the San Francisco Bay Area, Hong Kong, and Sydney, to name a few — which have sky-high rental prices. This cost dramatically cuts into store profit, despite the inflated prices on the menu.
Once the boba craze dies down, these new shops will have two options: to lower their prices or to innovate on how boba is made. The former will cause many to succumb to the two major costs of labor and rent and cause many to close their doors. Though it’s hard to break decades-old business practices, the latter will allow those that are open now to stay open, all the while giving more affordable options to customers.
And that’s where LEGO Boba Fetch comes in. Alexa is the employee; LEGO, the store.
Planning and ResearchWhile designing our project, we discovered a bunch of prior solutions. We highlighted a few of them below.
Traditional Way
The traditional way (can you call something that’s 40 years old traditional?) to make boba milk tea is to cook the boba, brew tea, and make a syrup. To assemble the drink, a person must grab a cup, spoon boba into the cup, and pour tea into the cup, hand seal the drink, and shake it up. This method will be used as a benchmark for the other existing solutions.
Enhanced Way
This is the way most boba tea shops follow now. It is basically the same as the traditional way with two differences: a machine sealer is used rather than hand sealing the drink, and an electric-powered shaker is used rather than shaking the drink by hand. This saves workers’ energy and reduces the amount of work required for each drink.
However, the machines used to seal and shake drinks are incredibly expensive and can cost up to $1000 each. Not only that, but the majority of existing boba tea shops require multiple as the machines can only handle one drink at a time.
Berkeley Students Boba Robot
There was an earlier design at UC Berkeley that a couple of students built for their final mechanical engineering design project. I can’t seem to find the YouTube video for it so I’ll just describe it.
Like our device, it uses a pump to move liquid from a container into the cups. However, unlike our device, it uses an Archimedean screw to move boba slowly from a funnel into the cup. This process is slow; if the screw is spun too quickly, the boba will fly out of the machine or jam the machine — an even worse outcome.
Lambda Tea
Lambda Tea is a recent startup that was launched by a couple of MIT students.
“The machine itself is a refrigerator which has a Samsung Galaxy tablet mounted on the front. The tablet itself is connected by USB to an Arduino, and the interface is run on an Amazon Web Services server. Customers buy boba through an app, which allows you to Venmo money to Lambda Tea’s account”
The problem with this design is its size. The entire machine is gigantic; it’s housed in a used refrigerator. There is also very little documentation, video or otherwise, on how the device works. The machine also seems to only be able to mix one type of boba drink. This design should be easily miniaturized.
Taiwanese Robot Arm Boba Shop
“The robot can make eight types of drinks with about 40 variations based on customer preferences for different amounts of ice and sugar – each taking about 90 seconds, Koubei said.”
This robot is great and fulfills the majority of my boba robot dreams. However, the price point is not as attractive. Clearly, this robot is meant purely for businesses as a giant robotic arm must cost a lot.
There is also a problem of safety. What would happen if a person were to accidentally stumble upon the machine while it is operating?
Project ProposalWe propose LEGO Boba Fetch, an automated boba barista machine powered with Alexa and the Alexa Gadget Toolkit to make boba more affordable while increasing production.
With our designs, we wanted to stress:
Affordability
- A low fixed cost will allow business owners to quickly recoup their investment
- A low priced machine will allow regular consumers to enjoy a cup of boba whenever they like for a low variable cost
- Targeting less than $200 cost
Speed
- A typical boba shop can assemble about a cup of boba every one minute on average (from my timing of 10 boba shops in the San Francisco Bay Area)
- A typical person can cook a cup of boba in about half an hour
- Targeting less than a minute assembly time
Compact
- A business owner should be able to fit multiple machines on a table for maximum throughput
- A typical consumer should have enough space in their living quarters to house a single unit comfortably
- Ease of Use
- Any person should be able to use this machine without major difficulty
- Alexa voice interactions make the machine intuitive to use
Last summer, we briefly produced an unsuccessful prototype in a couple of weeks using an Arduino, a pump, and several stepper motors. The machine would dispense boba and then tea to prevent splashing. To dispense boba, I created a CAD model of a disk that would spin and release some boba through gravity. This worked perfectly with uncooked boba.
The challenge we faced was dispensing cooked boba. When freshly cooked, boba is easy to dispense using the rotating disk and gravity. However, as boba becomes stale and cold, the tapioca starch in boba causes each pearl to become sticky in a process known as starch gelatinization. This meant the disk had to spin repeatedly to agitate the boba to cause it to fall from the sides of the container.
However, the project was put on the back burner as the stepper motors lost grip on 3D printed parts. The axle was too smooth and I had already spent over $300 on parts.
Over the next few months, we brainstormed ideas on how to produce a working prototype.
Cal Hacks 6.0 PrototypeIn October, we decided to try to make the project again — this time at a hackathon. Rather than having one hole to deliver both boba and tea, we used a delivery robot in conjunction with an assembly robot. These bots communicated with and followed a finite state machine design. The state machine was updated and stored through a PostgreSQL database, which the two robots would constantly ping for updates.
The delivery robot acted as a sort of conveyor belt. The assembly robot would dispense boba into the delivery robot and then the delivery robot would move up to the next state which would trigger the assembly robot to dispense tea. In an optimistic real-world scenario, we would have liked this robot to also deliver the drink to people using a mobile app like that of UberEats or DoorDash.
This design also added a new feature: cup dispensing. This part was quite tricky to get right because the cup dispensing largely relied on gravity even though it was controlled by a servo motor. About half the time, the cup dispensing would work but the other half, the cup would fall at an awkward angle and miss the delivery robot. We also had to make it with whatever materials we had on hand at the hackathon, so the cardboard structure housing this part of the boba assembly process would need to be adjusted and cleaned constantly as more drinks are created.
LEGO Boba FetchOne of the biggest problems with the summer prototype and the Cal Hacks design was their size. These two were both gigantic and required a lot of space to carry boba, tea, and cups. This is why we transitioned into using LEGOs for our next version. LEGOs are the perfect tool for prototyping. Compared to traditional prototyping methods (like with tape and cardboard), building with LEGO is faster while also being more structurally sound.
The goal of LEGO Boba Fetch was to create an automated boba barista machine with only LEGOs. By developing a minimum viable product using LEGOs, we could quickly and easily test our fundamental design. The LEGO block functionality allows for quick structural prototyping and easy sensor placement. During testing, this was especially useful for changing the touch sensor position to best detect cup placement as well as placing the dispensing motor to ensure minimal leakage.
In our prior designs, we incorporated ideas like an order queue and state machine by using a PostgreSQL database hosted on an Amazon EC2 cloud server. This made it easy to display to users about the machine’s current state through a React Native mobile application on both iOS and Android. However, in the Alexa design, we figured it would be best to remove the PostgreSQL database connection. Instead, we used the easier-to-use Alexa persistent attributes database as our queue tracker. Since we only had one controller this time rather than the two at Cal Hacks, we only had to store the state machine directly on the machine.
At Cal Hacks, we lacked a personal and business mode. To expand functionality, a personal mode could learn the user’s voice through Alexa’s Voice Profiles and alert the user by name when their drink is finished. However, this did not work entirely as intended as Alexa does not allow the use of Alexa Voice Profiles in events. Instead, we greet the user with their name after they finish queuing an order to give Boba Fetch an extra bit of friendliness.
To toggle the business mode on, a user simply has to open the skill and say “Turn payments on.” This will set Boba Fetch into business mode. Every drink ordered when Alexa is in business mode requires a payment which the user can set through voice command. As with all voice payment skills, you must turn on voice purchasing in your Alexa app before it will work. Once a user purchases a drink, the user will receive an email receipt of purchase.
From prior testing in the Bay Area, a typical boba tea shop can spend up to three minutes preparing a cup of boba. Normally, they average around one to two minutes a drink. In high traffic situations, people can be in line for over half an hour! This is why we made speed a priority in our design. With the LEGO Boba Fetch, a cup of boba can be prepared in just under half a minute. If a boba tea shop were to adopt multiple of these machines, they could use their space to its full potential and achieve maximum throughput during these high traffic scenarios.
TestingYou can check out a set of test videos on my YouTube playlist. Here are a few highlights:
LEGO Pump Motor
Unfortunately, LEGO doesn’t offer any liquid pump motors for their LEGO Mindstorms or LEGO Technic product lines. Since a pump was vital for this project, I disassembled a LEGO LargeMotor and replaced the motor leads with a basic submersible pump’s leads.
Server Test
Prior to discovering the Alexa Gadgets Toolkit, we used the Alexa Skills Kit and a Node.js Express.js server and MongoDB instance hosted on the free tier AWS EC2 server to demonstrate the project.
Alexa Voice Profiles
Alexa Voice Profiles makes it easy to use Alexa’s powerful AI tools to perform speaker detection. We use this to acknowledge a user and greet them.
Alexa Voice Purchasing
For businesses, building a payment system can be a huge hassle. Alexa’s got that covered too. Alexa Voice Purchasing made it quick and simple to add fully functional payments to LEGO Boba Fetch.
ExplanationsThe following sections up to the tutorial section are reserved for design and code explanations. There is also a YouTube video explanation linked directly above.
CADTo make the CAD models and LEGO instructions linked at the bottom of the document, we used Bricksmith and LPub 3D. We knew that the project needed to be small in size, stable, simple to build, and inexpensive to reproduce.
That is why the entire project uses only 72 bricks to hold a cup, dispense boba, and keep a tube in place.
All the Bricksmith files are attached with the extension .ldr under the CAD section at the bottom of the document. You can play around with them and change the design as you feel fit.
Boba Fetch uses two LargeMotors and a single touch sensor from the LEGO Mindstorms set.
Unfortunately, LEGO does not provide any pumps that can be used with the LEGO Mindstorms. To use a pump, I bought a cheap $10 pump on Amazon and added it onto the Mindstorm by disassembling a LargeMotor and replacing the motor with our pump using a soldering iron.
The other LargeMotor is used to swivel our boba dispensing mechanism back and forth to drop boba into a cup.
Finally, the touch sensor is used to determine if there is a cup present at the base so that our pump and boba dispenser is not activated prematurely which could ruin our electronics and get our LEGOs dirty.
Because of the EV3’s port design, wiring is incredibly simple and straightforward. With the ethernet-like port cables, connect one end to the touch sensor and the other end into Port 1. I recommend using a long cable for the touch sensor.
With the LargeMotor for dispensing boba, use a cable to connect one end to the LargeMotor and the other to Port A.
With the LargeMotor connected to the pump, use a cable to connect on end to the LargeMotor circuit board and the other to Port B.
Gadget Code
The most important section of the code controlling the hardware is the thread that handles the queue. Put simply, it checks if there has been a new order in the queue and if there is, it makes a drink.
def _handle_queue(self):
while 1:
if self.queue.empty(): continue
order = self.queue.get()
self._make(
name=order['name'],
tea=order['tea'],
sugar=order['sugar'],
ice=order['ice'])
Another important section would be the custom Mindstorms gadget control function. This function allows our Alexa skill to send order information to the gadget. It also allows for manual controls.
def on_custom_mindstorms_gadget_control(self, directive):
print("control")
try:
payload = json.loads(directive.payload.decode("utf-8"))
print("Control payload: {}".format(payload), file=sys.stderr)
control_type = payload["type"]
# regular voice commands
if control_type == "automatic":
self._affirm_receive()
order = {
"name": payload["name"] or "Anonymous",
"tea": payload["tea"] or "Jasmine Milk Tea",
"sugar": payload["sugar"] or 100,
"ice": payload["ice"] or 100,
}
self.queue.put(order)
# series of voice commands
elif control_type == "manual": # Expected params: [command]
control_command = payload["command"]
if control_command == "dispense":
self._affirm_receive()
if payload['num']:
self._dispense(payload['num'])
else:
self._dispense()
elif control_command == "pour":
self._affirm_receive()
if payload['num']:
self._pour(payload['num'])
else:
self._pour()
except KeyError:
print("Missing expected parameters: {}".format(directive), file=sys.stderr)
The make function simply dispenses the boba for a, n even number of cycles, and pumps liquid for a, n number of seconds.
def _make(self, name=None, tea="Jasmine Milk Tea", sugar=100, ice=100):
if not self.touch_sensor.is_pressed:
# cup is not in place
self._send_event('CUP', None)
self.touch_sensor.wait_for_pressed()
sleep(3) # cup enter delay
process = self.sound.play_file('mega.wav', 100, Sound.PLAY_NO_WAIT_FOR_COMPLETE)
# dispense boba
self._dispense()
# dispense liquid
self._pour(tea=tea)
# notify alexa that drink is finished
payload = {
"name": name,
"tea": tea,
"sugar": sugar,
"ice": ice,
}
self._send_event("DONE", payload)
process.kill() # kill song
self.sound.play_song((('C4', 'q'),('C4', 'q'),('C4', 'q')), delay=0.1)
self.touch_sensor.wait_for_released()
The dispense function iterates from i=0 to n such that when i is even, the motor turns 45 degrees and when i is odd, the motor turns -45 degrees. This is why n must be even. If n is odd, then the motor will not contain the boba when the function ends. I wrote a check in there so that n will always be even.
def _dispense(self, cycles=10):
try:
cycles = int(cycles)
except Exception:
cycles = 10
# send event to alexa
payload = {
"cycles": cycles
}
self._send_event("DISPENSE", payload)
# ensure the dispenser resets to the correct position every time
if cycles % 2:
cycles += 1
# agitate the boba to make it fall
for i in range(cycles):
deg = 45 if i % 2 else -45
self.dispense_motor.on_for_degrees(SpeedPercent(75), deg)
sleep(0.5)
Alexa
In our previous iterations of a boba maker, we used a tablet to control the hardware portion of the machine. This usually relied on a fiddly Android-to-serial connection through a UI layer, like React Native. It wasn’t always reliable and often felt as if we were reinventing the wheel in terms of communication protocols.
Fortunately, Alexa’s handy voice interface takes care of all the interaction between user and machine for us.
By defining a slew of utterances through the developer portal, processing user input is a breeze. We didn’t even have to parse through text; the predefined slots have a pretty wide range of what is accepted. In addition to processing slot values, Alexa’s dialog delegation feature makes handling missing values simple. For example, what if a user forgets to specify how much sugar they want in their drinks? Well, the answer is clear: just let Alexa take care of it for us! We don’t have to specify additional dialog options. Instead, we only need to provide a reprompt question and Alexa will guide a user through the dialog flow.
Handling user input is just one side of what Alexa is capable of. It also helps us communicate with the Mindstorm hardware. We no longer had to manually build and debug the serial connection with the device. Instead, the Gadgets Toolkit connection lets us send commands over Bluetooth in the form of directives. These directives are convenient in that they can send (for our purposes) an arbitrary amount of JSON data. This format is quite familiar to us working with Node.js, whereas something like the Arduino serial would require us to decompose our messages into multiple packets manually.
Furthermore, the Gadgets Toolkit has event handlers responding to a custom set of events fired from the Mindstorm as each drink is created. Since Alexa essentially acts as the “brains” of the operation by connecting user and machine, it is vital that it knows what’s going on with the entire machine. Responding to events like how much liquid is being dispensed lets us monitor what’s happening with the Mindstorm in a convenient format (i.e. speech) and even lets users know when their drink is done in a very excited SSML voice!
One thing that we sought out in Alexa was its ability to use Amazon Pay. In previous prototypes, we looked at potential payment platforms, like Square or Venmo. We found most of these to be either too restrictive or too expensive compared to existing payment solutions. However, Amazon’s ubiquity as an e-commerce platform almost guarantees that any particular user would have an account. Therefore, we turned to In-skill Purchasing to easily buy drinks through voice. It also has the added benefit of handling the annoying yet necessary security hurdles more traditional purchasing platforms have in their APIs.
Because many people have Amazon accounts with Alexa set up already, we can take advantage of personalization without the need for additional user accounts. As with Dialog Delegation, we hope to more closely emulate the traditional drink-ordering experience and possibly entice more customers to return. We take advantage of Alexa’s Voice Profile feature to greet a user when they successfully order a drink. The original plan was to have Alexa call out a user’s name when their drink was done (similar to how it’s done at Starbucks), but Alexa, unfortunately, does not yet allow personalized speech output in response to events.
Behind personalization, we also store some user data in the form of JSON objects in Alexa’s persistent attributes database. This lets us keep certain user settings (whether purchasing is on or off), user habits (drinks ordered), and a queue (in case the machine is already busy making a drink). Again, this is another convenient feature from Alexa. We don’t need to mess with SQL, ORMs, or even AWS’s DynamoDB. Instead, we can create a normal JSON object and persist it in the database for later use.
TutorialThe rest of the document is devoted to helping you build your own LEGO Boba Fetch. The tutorial assumes you installed Visual Studio Code as well as the ev3dev plugin for Visual Studio Code.
LEGO PumpWarning: This step may damage a LEGO LargeMotor. Proceed at your own risk.
LEGO has not created a part that can be used as a liquid pump. With another quick search, there are also no third-party engineers who have developed such a part. A liquid pump is vital for our boba milk tea barista robot. However, this does not mean we are completely out of luck. With a soldering iron and a LEGO LargeMotor, not only can you power a pump, but you can power any electronics!
Originally, I thought the process to connect the pump would be simple. My thinking was that the cabling should have some sort of ground, power, and output connection. This was correct but I was also unaware that the LEGO EV3 brick needed to read a specific voltage level in order to determine what part was connected. For example, a LargeMotor would need lower resistance to be recognized as a LargeMotor and a MediumMotor would need higher resistance to be recognized as a MediumMotor. To build such a circuit, you would need a specific resistor for each part in order to trick the EV3 into believing it was connected to a LargeMotor. However, I did not have such a variety of resistors.
Luckily, we already have an item that is reading as a LargeMotor - the LargeMotor itself. What we could do is simply open up the motor and desolder the leads connecting to the motor itself. After desoldering the leads, we can connect our own leads to connect to the pump.
For some reason, I think the LEGO motor is wired red as negative and black as positive (or I connected my leads incorrectly). Regardless, to run my motor, I plugged the leads in the opposite way (red to black and vice versa) to my pump.
To test the motor, I used the normal EV3 OS to drive my pump. Originally, I thought I would have needed to use a MOSFET and an external power supply to power my pump. However, I was delighted to see that the pump ran without this setup since the EV3 is capable of outputting the appropriate power to my motor.
LEGO AssemblyOn the bottom of the article, there will be a list of instructions as PDF files. You can download these files and follow them step by step to create an exact copy of the structure we built for this project.
Once you’ve successfully followed all the instructions, you can assemble the pieces together. Take your two sticks and plug it into your dispensing LargeMotor.
These two sticks will hold up the motor as well as the boba holder model. Connect the sticks to the base model. Each leg should be placed on a brown block like so:
Looking great! The only thing left for you to do is to connect the boba holder model to the dispensing LargeMotor. This is a little tricky. Take a look at the boba holder model. The long red brick at the bottom has holes on the bottom. There should be pins sticking out of the dispensing LargeMotor at this point. Take your boba holder model and insert it into the dispensing LargeMotor such that the pins connect to the bottom holes.
The LEGO structure is now finished! The next step is to wire your electronics. Luckily, the EV3 port system makes this incredibly intuitive and straightforward. With the ethernet like port cables, connect one end to the touch sensor and the other end into Port 1. I recommend using a long cable for the touch sensor.
With the LargeMotor for dispensing boba, use a cable to connect one end to the LargeMotor and the other to Port A.
With the LargeMotor connected to the pump, use a cable to connect on end to the LargeMotor circuit board and the other to Port B.
ev3dev is an alternative OS based on Debian for the LEGO Mindstorms EV3 brick. This platform is great because it allows us to program our EV3 brick with Python rather than with the default block based programming.
ev3dev has a great setup tutorial already but I’ll reiterate it here for your reference.
- Download the latest ev3dev image file for LEGO Mindstorms.
- Using Etcher, select the image file from step one as your image
- Select the SD card you wish to flash the image onto.
This will permanently delete everything that was previously on the SD card. Be sure to make a backup beforehand.
- Flash the image.
- When the image is finished flashing, take out the SD card and insert the SD card into the LEGO Mindstorms EV3 brick. Turn your brick on and in a few minutes, the OS should finish loading.
Congrats! You just installed the necessary OS to run the gadget code.
Want to revert? Turn the EV3 brick off and take the SD card out. Turn the EV3 brick back on and the old OS will be running instead of ev3dev.
ev3dev SetupFor this project, we will only need a Bluetooth connection with Alexa. Just go into Wireless and Networks and ensure that Bluetooth is powered on.
There is a weird bug that might prevent your Bluetooth from being powered. My EV3 reported that Bluetooth was unavailable even though it worked an hour ago. If this happens to you, try turning your device off and on again and check if you can now access the Bluetooth menu.
If this doesn’t resolve the issue, your device may be either soft blocked or hard blocked from accessing Bluetooth. This happened to me which is why I wanted to go over it in this tutorial. The most common blocking is the soft block. This is when the software blocks your Bluetooth access. For me, to unsoft block my device, I had to install the rfkill command to ev3dev.
This step requires an Internet connection for the EV3. Follow the instructions on the official ev3dev site to connect your brick to the Internet.
Open Visual Studio Code and connect to the EV3. After it finishes connecting, right-click the device on the panel and click Open SSH in Terminal. This will connect us to the ev3dev through SSH. Once that launches, we can install rfkill.
$ sudo apt install rfkill -y
This command may take a while. I found that installing anything on the ev3dev can take anywhere from 5 minutes to half an hour. After installing the rfkill command, run these commands.
$ /usr/bin/hciattach -t 30 /dev/ttyS2 any 2000000 flow nosleep
$ sudo rfkill list all
The second command will show if the device has been soft or hard blocked. If your device is soft blocked, run this command to unsoft block your device.
If the second command outputs that rfkill is not installed, the system may have installed the command under the wrong executable path. I believe you can find rfkill under /usr/local/bin. If you move the executable (with sudo) to /usr/bin, you should be able to execute it ($ sudo mv /usr/local/bin/rfkill /usr/bin
). Or, you could execute the command with the path prepended ($ sudo /usr/local/bin/rfkill list all
)
$ sudo rfkill unblock 1
After you unblock the Bluetooth, turn your brick off and on again. You could also try executing this command instead to try to force the Bluetooth service to start again but I haven’t tried it.
$ sudo systemctl start ev3-bluetooth.service
After the brick restarts, you should now be able to access the Bluetooth panel under Wireless and Networks.
Alexa Skill DeploymentDeploying the Alexa skill is done like any other Alexa skill; however, I highly recommend using Alexa’s command-line interface (ASK) rather than the online editor. ASK greatly simplifies the process of cloning code and deploying it, and you don’t have to worry about missing/misplaced files. As a result, this step will use the command line. There is a small setup process for it, but the documentation under their quick start guide is pretty clear. We’ll also assume that you have Node.js and Git already installed (otherwise ASK would not have been able to install properly).
First, you’ll need to create a new skill for Alexa. Visit the Alexa Developer Portal and click the Create Skill button. It doesn’t matter what you name your skill and what template you use (these will be overwritten later in the deployment process), but make sure you select an Alexa-hosted skill. This option ensures that we don’t have to deal with setting up an AWS Lambda function on its own. Instead, we’ll rely on Alexa to handle some of the work of setting it up, so the setup process will be easier down the road. Do this by scrolling down and selecting the option for it.
When you’re done, click Continue. If all goes well, Amazon will take about a minute to create your skill. Once it’s done, head back to the developer console and you should see your new skill. Congratulations, you have successfully set up an Alexa skill!
Here, we named our new skill Anything you want. Click the View Skill ID text underneath the skill name and a popup should appear with the skill ID. Copy and paste the ID in its entirety. You’ll need it to work on your skill locally.
Now, open up a terminal and type
$ ask clone -s [YOUR SKILL ID]
replacing the [YOUR SKILL ID] with the ID you copied from the console. This will download the files for the skill you just created, along with a special folder for ASK.
Next, you’ll need to clone the code from our Alexa skill down. Do this by visiting the GitHub repository. Feel free to clone the repository with Git or download it through the browser.
Move the .ask
folder of your new skill over to the cloned code. This folder includes special instructions for ASK on how to deploy your code. However, you still need to set up a few more things before deployment.
Open up your skill’s skill.json
file in the root of the directory. As a JSON object, there should be a key named endpoint with a single property: uri. Copy and paste the value for this key into the cloned code’s skill.json. Be sure to replace the text saying YOUR-URI-HERE with what you just copied.
Save and close this file. It won’t be modified anymore.
Next, you’ll have to set up purchasing. Because In-Skill Products have unique data associated with each skill, you’ll need to create a new one with
$ ask add isp
At the root of your directory. Select Consumable and Consumable_Template when prompted, because drinks in our skill are not recurring purchases. Although you can name it anything you want, we’ll call it Boba. Adding the product successfully will create a new file under the /isps/
folder: Boba.json.
You can manually fill in the required fields for the product in its JSON file, but we’ve taken the liberty of creating one for you. Simply copy and paste the code from our example.json
into your new file.
Now, use Node to run helper.js
at the root of your directory. This script changes the Git repository remote URL to the one defined in the .ask
folder that you moved over from your skill. Simply put, it tells Alexa where to send your code for deployment. You can finally deploy!
Save and commit your changes to let ASK handle skill deployment. Execute these commands at the root of your directory.
$ git add .
$ git commit -m “Skill code finished!”
$ ask deploy -f
Finally, head over to the Alexa Voice Service products’ page to add a new gadget. Click on the Create Product button in the top right. Again, feel free to enter whatever you want in the required fields, but make sure to select “Alexa Gadget” as your product type
This is so that the Mindstorm EV3 brick can use Bluetooth to pair with Amazon Echo devices. If you’ve filled it out properly, you should see a new product appear under your Alexa Voice Service Portal. Click on it, and you should see an ID and an Alexa Gadget Secret at the top of the page
Copy these two values and keep it in a safe place — you’ll need it for the steps below.
Congrats! Your Alexa skill is now ready to use (but finish the rest of the set-up process for the Mindstorms below).
Gadget FileYou’re going to want to connect your EV3 Brick to your computer. With the provided USB A to USB mini-B cable, plug the mini-B side into your EV3 Brick and the USB A side into your computer.
Now, the best way to download the gadget code is to download it onto your host computer and then move the files to the EV3 Brick. The code is all available at the bottom of the documentation or through GitHub.
Without Git, you can click the clone or download button to download the code as a zip file. You’ll have to expand the zip file after this.
With Git, you can run this command
$ git clone https://github.com/DevinMui/mindstorms-boba
To download the project into your current directory.
Using Visual Studio Code, open the project files. Before you move anything to the device, you’ll have to set up an auth.ini file like so:
[GadgetSettings]
amazonId = [amazon id]
alexaGadgetSecret = [alexa gadget secret]
[GadgetCapabilities]
Custom.Mindstorms.Gadget = 1.0
With the [amazon id] and [alexa gadget secret] filled out with your credentials from the Alexa skill dashboard. Save the file at the root of the directory.
Using the ev3dev plugin, connect to your ev3dev environment. There should be a button on the ev3dev plugin panel to upload the code. Click that button to transfer the files. This will take a short amount of time to transfer.
Execute ProgramOnce the files have been transferred, LEGO Boba Fetch is ready to rock and roll. Using the file browser on ev3dev, select hardware/ > main.py
. This will execute the main.py file.
When the program runs, you’ll hear a distinct initiation sound. When you have heard this sound, you’ll want to pair your new Alexa Gadget to Alexa. This process is different depending on your device but I will detail the instructions for the Amazon Echo Dot here.
In the app, click on your device and click Pair Alexa Gadget. On the LEGO EV3 display, there should be a gadget name on display. Find the device that matches that name and click the item. This will pair the device to the Amazon Echo Dot. When it successfully connects to the Dot’s Bluetooth, the EV3 will make another distinct connection musical cue.
Just insert a cup with a hole onto the boba holder model and fill it with tapioca. With that, your setup is complete! Now you can request Alexa to make you boba. Here is a list of sample commands:
Alexa, open Boba Maker
Jasmine milk tea with 0% sugar and 50% ice.
Alexa, open Boba Maker
Turn payments on
Alexa, open Boba Maker
Manual
Dispense for 10 seconds
Pour for 5 seconds
Alexa, open Boba Maker
HelpNext Steps
Alexa Skill
There is a myriad of different things we could improve with the voice interface. The voice recognition feature was meant to also recommend commonly ordered items. For example, Aaron might order Classic Milk Tea with 50% sugar and 50% ice regularly. Instead of ordering that drink again, Aaron could simply ask for the regular and Alexa could confirm the order.
Originally, I wanted to also implement a video skill using the Facebook Portal. However, the Portal does not yet support Alexa Gadgets. The idea behind the video skill was to show a real-time order queue graphic rather than needing to repeatedly ask Alexa for the current order queue status. This would further integrate Alexa into our project and increase the intuitiveness of our device.
Build
Right now, our build is not exactly the prettiest looking thing in the world. It is also not the most stable thing in the world either. That is because our situation as college students prevents us from affording more bricks to build more structurally sound and pretty LEGO machines. In the coming months, we’re hoping to scrape together many more LEGOs to build a proper enclosure that could better support the swiveling motion from the LargeMotor dispenser.
The slot for the pump tubing on the boba holder model could also be improved with greater time and funds. We actually ran out of large LEGO blocks (4x2’s and above) when building this section. This is why we used tape to hold the tubing down to aim it into the cup. If we had more bricks and a larger variety of bricks, we would build a sort of ramp and glue the LEGOs together such that it would create a liquid seal and guide the liquid into the cup.
For the base model, I wanted to add in a grid-like those of a soda dispenser at typical fast-food restaurants. This would allow the device to capture streams or drips that miss the cup and provide a cleaner surface and area.
Lastly, I was going to add in a conveyor belt to allow the EV3 to dispense multiple drinks, toppings, and ice. However, I only had three motors at my disposal (2 LargeMotors and 1 MediumMotor). Given more funding, I would have made the robot larger and use two EV3 bricks in conjunction to control a conveyor belt, three pumps and three dispensers along with a touch sensor and an ultrasonic sensor to determine and verify conveyor belt position.
Gadget Code
I feel like the gadget code did not fully take advantage of the EV3 platform. If I were to improve my code, I would add in a local mode such that the EV3 can show you a menu without having to interact with Alexa. This could have been done using the EV3 buttons. I would also want to create a graphic that could show the entire queue on the machine’s screen.
Just for fun, I wanted to also add in LEDs to the machine so that I could create a light show on order completion.
ConclusionWe hope you enjoyed your first look into LEGO Boba Fetch. We hope to continue improving our design with future iterations and if you’d like to support us or subscribe to future project updates, feel free to like this project, follow us on Hackster, and subscribe to my YouTube channel.
Thank you so much for taking the time to learn more about LEGO Boba Fetch!
Works CitedBubble Tea Market: Global Size, Growth Factors, Top Leaders, Opportunities, Emerging Technologies and Regional Forecast to 2026. (2019, October 21). Retrieved December 26, 2019, from https://www.marketwatch.com/press-release/bubble-tea-market-global-size-growth-factors-top-leaders-opportunities-emerging-technologies-and-regional-forecast-to-2026-2019-10-21.
Chou, C. (2019, March 20). Taiwanese Boba Tea Shop Sweet on Koubei Smart Tech. Retrieved December 26, 2019, from https://www.alizila.com/taiwanese-boba-tea-shop-sweet-on-koubei-smart-tech/.
D., N. (2017, December 4). Lambda Tea. Retrieved December 26, 2019, from https://mitadmissions.org/blogs/entry/lambda-tea/.
Comments