اليكسا طابعة | upcycled استلام الطابعة
by:Xprinter
2019-11-13
I am a fan of recycling old technology and making it useful again.
I bought an old, cheap hot receipt printer a while ago and I wanted to re-print it in a useful waypurpose it.
Then, during the holidays, I got an Amazon Echo Point and one of my most commonly used features was to add groceries to my shopping list.
So I think it would be cool to combine the two and use the receipt printer as an internet of things printer for Alexa (
Or Google Home or Siri, etc).
Let\'s see what needs to be done to achieve this idea.
Here are the sections I use in this project: the other things I use in this project are: the first step is to print the old receipt printer again.
I chose Raspberry Pi Zero W as the controller because it is cheap and small in size.
It is actually small enough to fit inside the receipt printer housing so there is no external connection!
The Pi Zero W also has Wifi built in, so basically everything is integrated into its small size.
To get the Pi up and running, we need to download the Raspbian OS and burn it to a microSD card using programs like Etcher.
Plug it into the Pi with the HDMI cable, keyboard, mouse, and then power on.
When the Pi is up and you are in the desktop interface, you can connect to the wireless by clicking on the wireless icon in the upper right corner and selecting the name of the wireless connection.
Then, if you right-click the same wireless icon, you can go to the network settings and set the static IP address so that we can easily connect to it over the network.
Finally, to click on the main menu, select Raspbian configuration editor and under the interface tab, make sure SSH is enabled.
Then save it and restart the Pi.
After restarting the Raspbery Pi, it should connect to your wireless network via static IP and enabling SSH.
So now we should be able to connect to it remotely from any other computer.
You need an SSH client to do this.
Putty is a good customer for Windows.
You can connect to it using the Pi static IP address we set earlier.
You can then log in using \"pi\" as your username and \"raspberry\" as your password.
After the login is successful, we should now be in the terminal interface of Pi.
Here we can enter the command that will be executed on the Raspberry Pi.
For example, one of the first things we have to do is make sure that the software on the Pi is up to date.
So in the terminal, we can type: this command will update the software library on the Pi.
Next, we can install ESC-
POS printer software and library required.
After that, we can now connect the printer to the Micro-of the Pi-USB port (
Use adapter)and turn it on.
Then, in our terminal, we can create a small python script in which we can add this python code to exit it (CTRL-X), save it (CTRL-Y)
Run it to test it, what is the benefit of the printer if there is nothing to print?
I want to implement the function of printing from different Internet services such as Alexa.
So what should I do?
One option is to select a specific Internet service, keep track of their API documentation, and write applications based on their API.
But I chose the lazy route. . .
There is a great website called \"If this is the case\" that triggers actions for different internet services (
Alexa, Google Home, Gmail, Facebook, Instagram, Twitter, etc)
Based on a set of criteria.
For example, if I post to Facebook (this)
\"So\" send me an emailmail (that).
So in the first half of this year I signed up for a free account and you can start creating a new \"applet\" for the different services you want to trigger \".
The \"this\" section of my applet will be Alexa.
The Alexa trigger has a lot to choose from, but I\'m going to pick a trigger that says \"ask what\'s on your shopping list.
We end up wanting it to trigger the Python script on the Raspberry Pi, so for the \"that\" section of the script, we want to select Webhooks.
In the Webhooks option, we can add a URL to our Pi, which we will return to later.
We can leave the method field as \"Get\" and select \"plain text\" for the content type \".
For the Body Field, click Add component and select the entire list \".
This will send the entire shopping list as a Get request.
The \"Internet\" section was processed in the previous step, so now let\'s handle the \"things\" section using Raspberry Pi.
In order to communicate with the \"if so\" webhooks applet, we need to set up a web server on Raspberry Pi.
There are a lot of different ways to set up a web server, but considering that I finally want to run a Python script, I decided to use a Python Flask server.
All the flasks in Pi
So all we have to do is start writing a test script: in this script, let\'s add some code that serves simple web pages.
Now, just save the program and run it using this command: with the command response, you will see that the default port that Flask is running is port 5000.
So in the web browser, if you type the IP address of the Pi: 5000, you should see that the \"Flask server is working!
\"We have the test Python code that was printed to the receipt printer before, and we have the test bottle server.
So next we need to combine them and include some code that pulls data from our Webhook applet.
Let\'s create a new Python file: and add the following code to it: you can run it and see if it returns any errors, but it can\'t work with our webhook yet, because so far the server is only running locally.
The Web hook does not yet have an external URL to connect.
We can set up port forwarding on the router, just use an external-facing IP address, but this is not too secure.
As another option, I decided to go with NGROK.
Ngrok can set up a secure connection to the network without exposing an external IP or disrupting port forwarding.
After signing up for a free account, it will give you an authorization token.
Then on your Raspberry Pi, you can download it, decompress it, connect your authorization token, and then run it on port 5000: * important * The free version of Ngrok does not give you a static address, so every time you re-
Run Ngrok and it will give you a different address.
If you want a static address so you don\'t have
Edit your webhook and then you will need to pay for the upgraded account.
Ngrok offers a free alternative to static IP called \"Serveo\" on www \". serveo.
On the result screen, it will give you a forwarding address (
We can use it in the Webhook applet.
So go back to \"if so\" and in the URL field, enter your Ngrok forwarding address and point it to the \"list\" page on our Flask server.
It looks like this should be the case and then proceed to save the changes.
To test it, keep Ngrok running, open a new terminal and run our python script.
Both projects are running and ask Alexa what\'s on your shopping list.
It should print out the results after a minute or two.
If you want it to print immediately, just go to the applet on IFTTT and click check now \".
If all goes well, the receipt printer should print out what\'s on your shopping list!
The last bit of code we need to add is a way to automatically start ngrok and our flask server every time the Pi starts.
We can do this easily by making our Python script executable: then we can edit our/etc/rc.
Local File, looks like this: there is a lot of blank in the case of the receipt printer I have.
With Raspberry Pi Zero as small as possible, I think it would be cool to hide it in the receipt printer so it looks like a device.
The only problem is that the receipt printer runs on 12 v and the Pi runs on 5 v.
So if we only want one power cord to power these two, we will have to reduce the 12 v power supply to 5 v.
Using a 7805 voltage regulator, a 1 uf capacitor and a 10 uf capacitor, I was able to create a simple 5 v regulator connected to the motherboard of the receipt printer.
I welded \"-
\"Wires to the common ground, then I weld the\" wires \"to the\" on \"side of the power switch so that the Pi turns on and off when the printer is on and off. Using a multi-
Meter, I test to confirm that the output of the Pi is safe.
And then I Weld in a micro
Usb cable and connect it to Pi.
After plugging the cable into the printer and flipping the switch, both the printer and Pi are on!
Finally, I drilled a hole to connect the USB cable from the Pi to the printer.
I found a place to put the 5 v regulator and Pi in the printer housing and then I put everything back together.
So now the printer has its own independent web server!
If you could take a look at \"if that\'s the case\", you might notice that it has a lot of different web services to connect.
So if you don\'t have Alexa or don\'t want to use Alexa, you can use this item to print it out from anywhere like Facebook, Twitter, Gmail, Google Home, after impression notes, QQ space, Flickr, wordpress, etc.
You can find the code for my print tweet on my Github page.
Now go and see what you can come up!
I bought an old, cheap hot receipt printer a while ago and I wanted to re-print it in a useful waypurpose it.
Then, during the holidays, I got an Amazon Echo Point and one of my most commonly used features was to add groceries to my shopping list.
So I think it would be cool to combine the two and use the receipt printer as an internet of things printer for Alexa (
Or Google Home or Siri, etc).
Let\'s see what needs to be done to achieve this idea.
Here are the sections I use in this project: the other things I use in this project are: the first step is to print the old receipt printer again.
I chose Raspberry Pi Zero W as the controller because it is cheap and small in size.
It is actually small enough to fit inside the receipt printer housing so there is no external connection!
The Pi Zero W also has Wifi built in, so basically everything is integrated into its small size.
To get the Pi up and running, we need to download the Raspbian OS and burn it to a microSD card using programs like Etcher.
Plug it into the Pi with the HDMI cable, keyboard, mouse, and then power on.
When the Pi is up and you are in the desktop interface, you can connect to the wireless by clicking on the wireless icon in the upper right corner and selecting the name of the wireless connection.
Then, if you right-click the same wireless icon, you can go to the network settings and set the static IP address so that we can easily connect to it over the network.
Finally, to click on the main menu, select Raspbian configuration editor and under the interface tab, make sure SSH is enabled.
Then save it and restart the Pi.
After restarting the Raspbery Pi, it should connect to your wireless network via static IP and enabling SSH.
So now we should be able to connect to it remotely from any other computer.
You need an SSH client to do this.
Putty is a good customer for Windows.
You can connect to it using the Pi static IP address we set earlier.
You can then log in using \"pi\" as your username and \"raspberry\" as your password.
After the login is successful, we should now be in the terminal interface of Pi.
Here we can enter the command that will be executed on the Raspberry Pi.
For example, one of the first things we have to do is make sure that the software on the Pi is up to date.
So in the terminal, we can type: this command will update the software library on the Pi.
Next, we can install ESC-
POS printer software and library required.
After that, we can now connect the printer to the Micro-of the Pi-USB port (
Use adapter)and turn it on.
Then, in our terminal, we can create a small python script in which we can add this python code to exit it (CTRL-X), save it (CTRL-Y)
Run it to test it, what is the benefit of the printer if there is nothing to print?
I want to implement the function of printing from different Internet services such as Alexa.
So what should I do?
One option is to select a specific Internet service, keep track of their API documentation, and write applications based on their API.
But I chose the lazy route. . .
There is a great website called \"If this is the case\" that triggers actions for different internet services (
Alexa, Google Home, Gmail, Facebook, Instagram, Twitter, etc)
Based on a set of criteria.
For example, if I post to Facebook (this)
\"So\" send me an emailmail (that).
So in the first half of this year I signed up for a free account and you can start creating a new \"applet\" for the different services you want to trigger \".
The \"this\" section of my applet will be Alexa.
The Alexa trigger has a lot to choose from, but I\'m going to pick a trigger that says \"ask what\'s on your shopping list.
We end up wanting it to trigger the Python script on the Raspberry Pi, so for the \"that\" section of the script, we want to select Webhooks.
In the Webhooks option, we can add a URL to our Pi, which we will return to later.
We can leave the method field as \"Get\" and select \"plain text\" for the content type \".
For the Body Field, click Add component and select the entire list \".
This will send the entire shopping list as a Get request.
The \"Internet\" section was processed in the previous step, so now let\'s handle the \"things\" section using Raspberry Pi.
In order to communicate with the \"if so\" webhooks applet, we need to set up a web server on Raspberry Pi.
There are a lot of different ways to set up a web server, but considering that I finally want to run a Python script, I decided to use a Python Flask server.
All the flasks in Pi
So all we have to do is start writing a test script: in this script, let\'s add some code that serves simple web pages.
Now, just save the program and run it using this command: with the command response, you will see that the default port that Flask is running is port 5000.
So in the web browser, if you type the IP address of the Pi: 5000, you should see that the \"Flask server is working!
\"We have the test Python code that was printed to the receipt printer before, and we have the test bottle server.
So next we need to combine them and include some code that pulls data from our Webhook applet.
Let\'s create a new Python file: and add the following code to it: you can run it and see if it returns any errors, but it can\'t work with our webhook yet, because so far the server is only running locally.
The Web hook does not yet have an external URL to connect.
We can set up port forwarding on the router, just use an external-facing IP address, but this is not too secure.
As another option, I decided to go with NGROK.
Ngrok can set up a secure connection to the network without exposing an external IP or disrupting port forwarding.
After signing up for a free account, it will give you an authorization token.
Then on your Raspberry Pi, you can download it, decompress it, connect your authorization token, and then run it on port 5000: * important * The free version of Ngrok does not give you a static address, so every time you re-
Run Ngrok and it will give you a different address.
If you want a static address so you don\'t have
Edit your webhook and then you will need to pay for the upgraded account.
Ngrok offers a free alternative to static IP called \"Serveo\" on www \". serveo.
On the result screen, it will give you a forwarding address (
We can use it in the Webhook applet.
So go back to \"if so\" and in the URL field, enter your Ngrok forwarding address and point it to the \"list\" page on our Flask server.
It looks like this should be the case and then proceed to save the changes.
To test it, keep Ngrok running, open a new terminal and run our python script.
Both projects are running and ask Alexa what\'s on your shopping list.
It should print out the results after a minute or two.
If you want it to print immediately, just go to the applet on IFTTT and click check now \".
If all goes well, the receipt printer should print out what\'s on your shopping list!
The last bit of code we need to add is a way to automatically start ngrok and our flask server every time the Pi starts.
We can do this easily by making our Python script executable: then we can edit our/etc/rc.
Local File, looks like this: there is a lot of blank in the case of the receipt printer I have.
With Raspberry Pi Zero as small as possible, I think it would be cool to hide it in the receipt printer so it looks like a device.
The only problem is that the receipt printer runs on 12 v and the Pi runs on 5 v.
So if we only want one power cord to power these two, we will have to reduce the 12 v power supply to 5 v.
Using a 7805 voltage regulator, a 1 uf capacitor and a 10 uf capacitor, I was able to create a simple 5 v regulator connected to the motherboard of the receipt printer.
I welded \"-
\"Wires to the common ground, then I weld the\" wires \"to the\" on \"side of the power switch so that the Pi turns on and off when the printer is on and off. Using a multi-
Meter, I test to confirm that the output of the Pi is safe.
And then I Weld in a micro
Usb cable and connect it to Pi.
After plugging the cable into the printer and flipping the switch, both the printer and Pi are on!
Finally, I drilled a hole to connect the USB cable from the Pi to the printer.
I found a place to put the 5 v regulator and Pi in the printer housing and then I put everything back together.
So now the printer has its own independent web server!
If you could take a look at \"if that\'s the case\", you might notice that it has a lot of different web services to connect.
So if you don\'t have Alexa or don\'t want to use Alexa, you can use this item to print it out from anywhere like Facebook, Twitter, Gmail, Google Home, after impression notes, QQ space, Flickr, wordpress, etc.
You can find the code for my print tweet on my Github page.
Now go and see what you can come up!
custom_message