The World’s First Cloud Texting Enabled Raspberry Pi Powered Espresso Machine

Zipwhip is a cloud texting company. That means our goal is to give users a way to send and receive their texts from the cloud. Texting is a very important medium in our lives and yet it’s been stuck on our mobile phones forever. Why can’t we send a text from the web, our desktops, tablets, iPads, Kindle Fires, or even the family T.V.? We can send email from all those places so why not texts? With Zipwhip you can.

The first thing Zipwhip has to do to solve cloud texting is get your texts into the cloud. Once they’re there you can do all sorts of fancy things. By installing our background app on your Android phone your texts are synced in real-time. In addition to our mobile solution, we’ve recently launched our landline service that  allows users to send and receive texts from their existing business or residential landlines. That’s right, you can now order dinner via text from a restaurant with a Zipwhip enabled landline. It’s a powerful platform with thousands of use cases. So powerful that last year, as you may recall, we were able to create the world’s first text enabled espresso machine as a way to show off  just how cool the SMS medium really is.

We were already working on a version of Textspresso you could own yourself when we heard that the Raspberry Pi team had moved into their first office. We knew they needed one. It was meant to be a nice way to thank them for revolutionizing the computing industry with their $25 credit card sized Linux computer. This project wouldn’t have been possible without their amazing new device. We decided to document the whole process so you can make your own over a long weekend. Below you’ll find all the gory details.

Completed Circuit Board

pscircuitboard

Circuit Board Attached to Raspberry Pi

psraspi507

Part 1

Steps to Build Your Own

  1. Get yourself a Textspresso circuit board
  2. Get the parts
  3. Buy the machine
  4. Setup Raspberry Pi
  5. Create a Zipwhip account
  6. Configure your Zipwhip account to the machine (the software step)
  7. Text yourself a coffee

1.) Get Yourself a Textpsresso Circuit Board

We used to have our circuit boards available on Batch PCB but the site has closed. You can download the Eagle files below and then upload them directly to OSH park (they take the files natively). Unfortunately you’ll have to buy the boards in batches of 3 for $17.60 and upload them yourself. You can also download Eagle via the link below if you don’t already have it.

Eagle: http://www.cadsoftusa.com/

Hardware Files: http://ftp.zipwhip.com/public/textspresso/textspressohardware/schematics.zip

2.) Get the Parts

We created a list of parts from four different sites: Digi-Key, Samtec, Allied, and Amazon. The heavy lifting is done. You can click right through to the exact part you need inside the table. Although the capacitors aren’t absolutely necessary, they help smooth out the electrical currents running through the board and lessen the chance that you’ll have isues with your circuit board. The parts at the bottom of the list are for your Raspberry Pi. Instructions on how to configure your Model A are below. You’ll be soldering the circuit board yourself, so get that magnifying glass ready. Some of these parts are extremely small.

 

Supplier Quantity Part Number Item
Digi-Key 2 445-1265-1-ND Capacitor 0.1uF
Digi-Key 6 445-1237-1-ND Capacitor 15pF
Digi-Key 1 541-348LCT-ND Resistor 350OHM
Digi-Key 4 541-499LCT-ND Resistor 499OHM
Digi-Key 1 541-1.21KLCT-ND Resistor 1.2k
Digi-Key 4 541-3.57KLCT-ND Resistor 3.57k
Digi-Key 3 541-100KLCT-ND Resistor 100k
Digi-Key 1 541-4.7KJCT-ND Resistor 4.7k
Digi-Key 1 541-20KJCT-ND Resistor 20k
Digi-Key 4 568-1633-1-ND NPN Transistors
Digi-Key 1 497-1857-1-ND Shift Register
Digi-Key 3 HCPL2631SDCT-ND Optocouplers
Samtec 1 TSW-111-26-F-S Ribbon Cable
Samtec 1 SSW-113-01-F-D GPIO Port
Sametc 1 ESQ-111-24-G-S ESPR_BRD Connector
Allied 1 70266830 Raspberry Pi Model A
Allied 1 70232557 Power Supply
Allied 1 70235238  SD Card
Amazon 1 EW-7811UnR2 Wireless USB Adaptor

3.) Buy the Machine

Seattle Coffee Gear has the Delonghi Magnifica Super Automatic espresso machine available for purchase on their site. They are a great company with stellar customer service, but you’ll be hacking this machine at your own risk. Once that cover comes off there is no going back. The direct link to the machine is below.

http://www.seattlecoffeegear.com/delonghi-magnifica-esam3300-superautomatic-espresso-machine

4.) Setup Raspberry Pi

When you start this step, you’ll probably have all of your parts in a nice pile ready to go. If you already have an imaged card you can jump right to the second paragraph in this section which covers enabling WiFi. If you have a blank SD card (we recommend 8GB) copy the Raspian Wheezy OS on it. If you’re not sure how to do that, follow the link below. Just a heads-up for newbies to the code/tech/electronics hobby, the “image” you’ll see referenced isn’t a picture. It’s the operating system that will be running on your Pi and acting as the brains of the operation. All you have to do is download a free disk-imager, download and extract the latest version of Raspian Wheezy, get the image onto your card and you’re done. Below you see a screen grab of a successful “write.”

Once your SD card has the Raspian Wheezy OS on it, you can insert it and complete the initial setup of the Pi. If you’re working with a keyboard made in the U.S., remember to make that change as U.K. is the default style. Once that’s done you can setup WiFi for your Pi. How exciting! Plug in your dongle and then use sudo nano /etc/network/interfaces to access your network configuration files. Then, enter the WiFi file information below (you have to add your own network name and password). Once you’ve saved and exited out of that file, you can check to see if you are setup correctly with a ping http://www.XXXX.com command. You’ll get an error message back if something isn’t setup correctly.

WiFi network interface file:

auto wlan0
iface wlan0 inet dhcp
wpa-ssid wifi_ssid
wpa-psk wifi_password
wpa-key-mgmt WPA-PSK
wpa-pairwise TKIP CCMP
wpa-group TKIP CCMP
wpa-proto WPA RSN
wpa-ap-scan 1
wpa-scan-ssid 1

diskimagerdone

5.) Create a Zipwhip Account

In order for all of this to work, you need to have an account for either your Android smartphone, 800 number, or landline. All coffee orders sent to the number associated with the machine will be routed through our cloud and then down to the machine. Links to our registration pages are below.

To register with your Android smartphone: http://webapp.zipwhip.com/#register

To register with your landline: http://zipwhip.com/landlines

To register with your 800 number: http://zipwhip.com/text-enable-your-1-800-number

6.) Configure Your Zipwhip Account to the Machine (the software step)

On your Pi run the following commands to download and install the Zipwhip Textspresso software package:

sudo wget http://ftp.zipwhip.com/public/textspresso/install-textspresso.sh
sudo chmod 755 install-textspresso.sh
sudo ./install-textspresso.sh

Configure the software with your account info:

sudo python /opt/zipwhip/bin/cmdconfig.py –write –write-phonenum <your-zipwhip-phonenumber> –write-password <your-zipwhip-pasword> –write-getnewsessionandclientid

Start it up and watch the logs:
sudo service zwtextspressod start; tail -f /opt/zipwhip/log/zipwhip-textspresso.log

7.) Text Yourself a Coffee

You can text in 3 different orders: “coffee single” for a small coffee, “coffee double” for a bigger coffee, and “The Zipwhip” for a triple coffee . You can also text in “status” to see if the machine is on or off, and “menu” just in case you forget what your order options are.

Part 2

A Deeper Look Into the Hack

  1. The machine
  2. Hacking into the machine
  3. Ribbon cable
  4. The control panel circuit board
  5. The shift register
  6. How the push buttons work
  7. The board layout
  8. Our schematic design
  9. Octocouplers
  10. Powering the pi

1.) The Machine

Below you’ll see a shot of the front of the machine. With the custom software and hardware of this hack, you’ll be recreating the pushing of a button without actually touching the buttons. Pretty cool, right. *Hot tip: Once your machine is up and running, you can reset the machine by holding the preground button (the one with the scooper) down for 10 seconds.

image

Button                 Placement
On/Off                   Far Left
Coffee                   One Cup
Coffee Double        Two Cups
Hot Water              Faucet
Decalcify                Bottom L
Pre-Ground Beans  Bottom R

2.) Hacking Into the Machine

It just takes a few screws to open the machine. Take off the back first and then slide the side panel off. Here are the inside guts of the machine. One of the things you’ll notice is that the area where the Pi will eventually go looks like it was custom made for our hack. It fits in there perfectly.

image

After opening up the DeLonghi we noticed a PIC microcontroller at the heart of the main board. You can read more about this chip on the Microchip website (http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010296). We know this chip runs at 5 volts and thus is operating at normal TTL logic levels. That’s good because that’s easy to interface with. We figured the best place to start tapping into the machine was on the ribbon cable that ran from the main board to the front control board.

image

3.) Ribbon Cable

There is a ribbon cable on the main circuit board of the espresso machine that connects to the front control panel. This was our key area to try to interface with the machine since all of the LEDs tell us the state of the machine and it let’s us mimic button presses from a text command rather than pressing the button itself.

image

After some deep probing of the circuits here is what we determined all of the functions of the ribbon cable are for.

image

Pin Description Voltage Waveform
1 Push Button Signal for Coffee Double / Use Pre-Ground Beans 5V Square Wave to PIC Microcontroller. 1.04ms On. 1.04ms Off. Inverted for 2nd button.
2 Push Button Signal for Coffee / Decalcify 5V Square Wave to PIC Microcontroller. 1.04ms On. 1.04ms Off. Inverted for 2nd button.
3 Clock Signal Sinking to GND and rising to 5V 8-bit Pulse to Shift Register
4 Serial In to Shift Register Sinking to GND and rising to 5V 8-bit On/Off Values to Shift Register
5 Latch/Strobe to Shift Register Indicating Data Done Sinking to GND and rising to 5V 1 Pulse to Latch on Shift Register
6 Potentiometer for Coarse / Fine Beans GND to 5V depending on pot setting Varying voltage
7 Potentiometer for Amount of Water Per Cup GND to 5V depending on pot setting Varying voltage
8 GND GND Ground
9 VDD 5V Straight voltage
10 Push Button Signal for On/Off / Hot Water 5V Square Wave to PIC Microcontroller. 1.04ms On. 1.04ms Off. Inverted for 2nd button.
11 Alt GND (Don’t think this is used) -20V Alt GND

4.) The Control Panel Circuit Board

Here is a front and back picture of the control panel circuit board. We had to figure out how this whole thing worked so we could correctly reverse engineer how the signals communicated between the main board and this control panel. There are LEDs, some simple push buttons, a couple potentiometers, a shift register, and two transistors labeled “Q1” and “Q2”. Those ended up being quite important for how the shift register worked. If you look at your finished circuit board, or the one from above you’ll notice some pieces that look exactly the same (the shift register), and you’ll notice that other pieces look completely different (the resistors).

image

Here is the back of the board. It’s hard to trace where the wires go due to the epoxy that Delonghi poured onto the board to protect it from moisture.

image

5.) The Shift Register

The espresso machine sends an 8-bit shift register signal to the control board. This allows the machine to turn on and off the 8 LEDs on the front of the machine by only using 2 wires on the ribbon cable. The circuit board on the front of the machine with the shift register chip is sent a 5V TTL logic signal. On one wire is the clock signal. It sends 8 pulses at a time. The 8 pulses last 24 uS. That’s 3 uS per pulse.At the same time as the clock signal, another wire sends over which register to turn on by sending 5V, or a high state, during the clock pulse. You can see below what that looks like on the oscilloscope. The pulse being sent below occurs when the espresso machine is off. In fact, the machine sends a pulse on register 1 and then register 2 in an oscillating fashion. This generates 2 square waves on the shift register that is used for the buttons. One square wave is used by the On/Off, Coffee, and Coffee Double buttons. The other square wave, which is out of phase with the first square wave, is sent to the other 3 buttons. This way the ribbon cable only needs 3 wires to detect 6 different buttons being pushed.The pulse signal and the clock signal while the machine is off. The clock is yellow. The data is green.The second pulse signal while the machine is off.image

The clock signal comes in every 1.04mS or at 960 Hz. This is important because we need to detect this on the Raspberry Pi GPIO ports. That also means the LEDs blink every 1.04 mS or about 1,000 times each second.

image

Here we have an example of what the shift register 8-bit pulse looks like when a few LED lights are turned on.

image

Here is the shift register that DeLonghi used. Remember, this piece is already included for you in the top section of this blog post.

image

You can view its datasheet at the following URL. Below is also a diagram of the registers that are output from the Serial In data. We deduced that DeLonghi is not using any of the strobing or output enabling available on the shift register. They are simply using Q1 thru Q8 to control how the LEDs are turned on and how to generate the in phase and out of phase square wave for the round trip through the push buttons back to the main board.

http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/CD00000323.pdf

image

There are two transistors on the control panel that say “Q1” and “Q2”. That was a hint as to how they were controlling 8 LEDs and generating two square waves from only 8 registers. They essentially use up Q1 and Q2 registers to control if a transistor is on or not. That means they sort of created two planes on the panel. One plane can have Q3 thru Q8 controlling stuff. The other plane gets Q3 thru Q8 again for a brand new set of controls. That gives them 12 switches from an 8 bit register. That does mean they are blinking the LED lights on and off constantly, but humans can’t tell because the blinking is so fast, i.e. 1,000 times per second.

Here is what we determined the shift register is controlling.

Q1

Q2

Q3

Q4

Q5

Q6

Q7

Q8

Coffee LED

High

High

Coffee Double LED

 

High

 

High

Hot Water LED

 

High

 

High

Out of Water LED

High

High

 

Tray Needs Emptied LED

High

High

Warning LED

High

 

High

Decalcify LED

High

High

Use Pre-Ground Beans LED

High

High

This is great. Now that we know what the pulses mean, we can feed them into our Raspberry Pi GPIO port and write

This is great. Now that we know what the pulses mean, we can feed them into our Raspberry Pi GPIO port and write some code to interpret the pulses. That way we’ll always know what our machine is doing and can send back informational text messages to the user when things happen. For example, if you text in a coffee order we can see if the machine is out of water. We can text you back letting you know it needs water first and then vend your coffee.

6.) How the Push Buttons Work

Our hope was that we could read the clock, serial, and latch signals directly into the Raspi. That would have made our circuit way simpler. After some testing, we could never get the Raspi to trigger an interrupt on a GPIO port from a 3uS square wave. That was very disappointing. Our trick was to just use the exact same shift register that the espresso machine was using on it’s front control panel. We knew the latch was only thrown every 1.04ms. Our hope, although we didn’t know, was that this was slow enough for the GPIO ports to catch it. Fortunately, we were right.

We rigged up the shift register and then connected each of Q1 through Q8 to it’s own GPIO ports. We did get worried we would run out of GPIO ports using this approach, but fortunately we had 2 of them left unused when everything was done.

The nice part about the shift register was that we had a bit less code we’d have to write to interpret the clock and data signals. So, at least we got some benefit out of having to use more components.

7.) The Board Layout

Delonghi used a very cool technique to detect what buttons were being pressed. They let the shift register generate a nice square wave at the front control panel. Then that wave is sent back to the main board along Pin 1, 2, or 10 to represent which button was pushed. Refer to the table earlier to see which Pin represents which button.

The shape of the square wave is below. You can see that when the button is pushed the square wave is being sent. When it’s not pushed there is no voltage or waveform on the Pin. So, all we really need to do is mimic this square wave being sent into the main board and we should have our way of mimicking a button push.

One thing you may notice here is that the GND state of the espresso machine is a bit funky in the oscilloscope. It wavers a lot. If we had been able to connect the GND from our oscilloscope probe this problem would be solved, but we found the espresso machine would shut off the moment we connected GND to the probe. So we had to analyze it without connecting ground.

This inability to connect ground of the Raspberyy Pi together with the espresso machine caused us to have to design our circuit board in a way where the grounds were isolated. This required use of some optocouplers which you’ll see more on later.

image

8.) Our Schematic Design

Here is our final board layout. We’re pretty happy with it. It allowed us to connect it directly into the ribbon connector on the main board of the espresso machine, while still fitting the Raspi directly onto it and connecting the ribbon cable to the front of the machine.  We used Advanced Circuits to get a barebones PCB whipped up. We used BatchPCB to get the final boards made. We did do a lot of prototyping on our Shapeoko CNC machine with the TinyG as our controller.

schematicblack

After a lot of prototyping, here is the final design of the schematic. The general arrangement is to have two sides of the schematic. The left side is the Raspberry Pi side. This side is a 3.3v powered circuit to not blow the GPIO ports. It is electrically isolated from the espresso machine via optocouplers. The right side is for the espresso machine. That is a 5V powered circuit off the espresso machine’s power supply. There aren’t that many components being powered on that side so it should be safe to pull a few more mA from the espresso board.

 

schematic4

9.) The Optocouplers

The optocouplers were our approach to solve three issues. 1. To electrically isolate the espresso machine from the Raspberry Pi circuit to ensure we didn’t blow anything on the espresso machine. 2. It was to solve the fact that whenever we touched the GND on the espresso machine, we’d shut it off. We never quite figured out why, so we just avoided the problem. 3.  To solve the conversion of the 5V system to a 3.3V system that was compliant with the Raspberry Pi.

We found that if we used a standard cheap optocoupler that we didn’t have enough response rate to transmit the clock signal, serial data, and latch signal. So, we ended up using some pretty new speedy optocouplers from Fairchild Semiconductor. They are rated at a 44ns rise time. Most standard optocouplers have a 2uS rise time. So there’s a huge difference in the ones we’re using. The clock and data signal runs every 3uS, so you can see why standard optos would never work.

*Hot Tip: Before you solder the optocouplers to the board, it helps to pinch in the legs slightly. This ensures that all 8 of them make contact with the pads on the board.

imageimage

The really cool thing about optos is that you’re using light as part of your circuit. That’s a very cool concept. Instead of using electrons through copper, you are guiding data down a light path. It’s amazing that such an otherwise simple task of text-enabling an espresso machine would require the need to steer light around.

Initially we tried to just feed our optos on the espresso side directly from the clock signal, serial data, and latch signal. Well, that failed miserably. Those signals have no real power behind them. So, we had to drop in a transistor to each of those signals. Then the signal could just toggle on and off an NPN transistor with a tiny bit of power. This meant we had to put in place some pull-up resistors as well to feed the opto on the espresso side. The extra benefit to this approach is that it nicely and correctly inverted our signal. That was good because the optocoupler itself inverts the signal. So with the two inversions, we got the correct output on the Raspi side.

The hardest part of driving the optos was finding the correct resistor size to place just in front of the base on the transistor. You would think that all three of the signals on the espresso machine would need the same resistor size, especially if they’re all being generated from the PIC controller. However, we found that 100k was correct for the serial in and the latch, but 20k was the correct size for the clock signal. We’re still not sure why, but that gave us the best waveforms on our oscilloscope.

Here’s a link to the datasheet. http://www.fairchildsemi.com/ds/6N/6N137.pdf

On the Raspi side we had to also create some pull-up resistors because all the opto does is yank you to a ground state. We missed this in our first design because we incorrectly assumed we’d be given a logic state based on Vcc. After looking deeper at the schematic it was quite obvious that’s not the case. You can see two little NPN transistors inside that package.

10.) Powering The Pi

To power the Raspberry Pi inside your machine you can either plug it in externally, or do the stylish thing and power it through the espresso machine. To do this, you solder one of the plug-ins of the external power supply to one of the internal power supply cords, and the other plug-in to the second internal power supply cord. The order doesn’t matter. Just remember that these wires can’t touch, as that would cause a short circuit. The internal black cords are the thick black cords you see at the bottom of the image and the external power supply looks like it should be plugged into the wall.

raspiblog

If you’ve made it this far in the blog, thank you! We did our best to be as thorough as possible so that completing this hack was easier for you than it was for us. If you find yourself stumped and you need some help, please send an email to support@zipwhip.com with the word “textspresso build” in the subject line. We’ll do our best to get back to you as soon as possible.

Happy Hacking!

30 Responses to The World’s First Cloud Texting Enabled Raspberry Pi Powered Espresso Machine

  1. Simon Ritter says:

    Just a minor point, you have a typo in the link to osh park which takes you to ohspark.com, and somebody’s blog :-). Great article!

  2. Christian says:

    Awesome stuff! But you still need a robot placing a cup in machine ;)

  3. Pingback: MAKE | How-To: Text Your Coffeemaker

  4. Pingback: The World’s First Cloud Texting Enabled Raspberry Pi Powered Espresso Machine. | Wisdom Bytes:The journal of a recovering SysAdmin

  5. Pingback: Java drugačne vrste | Slo-Pi

  6. walker_stick says:

    Forget the cloud business model. Get this on an iPhone, flog it for 2 bucks on the AppStore and you’ll make a million.

  7. musicman432 says:

    Is the Zipwhip board necessary for interfacing with the machine? I would really like to set this up to receive Twitter DMs instead of texts, is that feasible?

  8. musicman432 says:

    Is the Zipwhip board necessary for interfacing with the coffee machine? I’m sorry, I’m new the the Rasp. Pi world :P what I would really like to do is essentially the same hack, but using Twitter DMs instead of texts. Is that feasible?

  9. Pingback: How-To: Text Your Coffeemaker - IT Clips

  10. Louis says:

    I think maybe the “SHUT OFF” problem was caused by “SHORT CIRCUIT”. Assumed that the probe’s GND was connect to the earth ground, but the coffee machine’s earth ground was lower then reference ground point, so when you tried to connect each other(Earth GND from the probeRef. GND from the machine), the coffee machine’s protection circuit kicks in to shutdown the machine immediately to prevent the circuit board burn out.

    And the “20k” problem I think maybe was caused by “CLOCK SPEED”, because the clock speed was too fast the NPN transistor need more current to change the state faster, so the 100k resister was not suitable.

    Sorry about my poor english. :)

  11. Spock says:

    Let me puth this way – this is great and professional hack even if “professional hack” sounds like oxymoron :)

  12. Pingback: Textspresso: Kaffe per SMS bestellen dank Raspberry Pi » t3n

  13. Pingback: แฮกเครื่องชงกาแฟให้รับคำสั่งจากการส่งข้อความได้ | Raspberry Pi Thailand

  14. Bob says:

    Very cool. How can we use your service for other Pi projects? I guess I could download the code and sift through it.

    • zipwhip says:

      Hi Bob,
      Thanks for reading and reaching out. My recommendation would be to look through our code and use it however you would like.
      Cheers,
      Kelsey

  15. TxBobS says:

    Is there any doc on how one could use your service to text to other Pi projects? While the espresso machine is very cool, I could see using this on one of my other projects.

    • zipwhip says:

      Bob,
      Feel free to dig into our API at http://zipwhip.com. That would be your best bet in terms of utilizing our software with other projects. We don’t have any documentation specifically on utilizing our software with Pi.
      -Kelsey

  16. ILAN says:

    Color me impressed!

  17. Ben says:

    Can you use any espresso maker besides the one you guys showed in your video?

  18. Dimitri says:

    This looks awesome.
    I’ve been looking for the source code and can’t find the download location, can someone link me to it.
    Thanks.

  19. Nick London says:

    Brilliant, too complicated for me but raspbertrypi.org put it on their news feed which brought me to Zipwhip. It is on my computer at work and a real boon as you dont need to fire up an app as with airdroid that I used to use.

  20. Manish Kumar says:

    Thanks for sharing this post . I’m using this coffee-machine for best results.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 25 other followers