Introduction: IoT Notes Printer: Your Smartphone Notes on Paper
The "Zerynth IoT Notes Printer" tries to create a handable medium for everyday communication.
Thanks to the Zerynth App you can write text messages and send them to a small thermal printer programmed with Zerynth and connected to the network via a microcontroller and a wi-fi chip.
DISCLAIMER: Viper is now operating under the brand name Zerynth! Some elements (pictures, videos, code, etc..) may still have the old name. For any doubt, please, open a thread on our community forum http://community.zerynth.com/
Step 1: Why This Project?
The techno-stress in the era of IoT
We always eulogize to the virtues and the benefits of the Internet of Things, dreaming of a future in which everything is connected to the network and can interact with us.
However, making a further stretch of the imagination is not difficult to see disaster scenarios, where man is under the yoke of electronic devices and lives forever with a kind of notification anxiety.
The development of the Internet and social networks, in fact, has "forced" to a new way of communicating, perhaps more efficiently than ever before but definitely more stressful.
The "techno-stress", condition due to the excessive and simultaneous information conveyed by electronic devices, is even listed among the new occupational diseases.
The victim of techno-stress undergoes an overload of information and stimuli due to the connection and continuous interaction with computers, tablets, smartphones and now, thanks to IoT, also with everyday objects connected to the network.
Moreover, the notification is a sign that someone or something, somewhere, is considering us. Every time we get a message, a call or an e-mail becomes hard to resist the temptation to see what that is, causing us a state of excitation and anxiety.
So how can we protect us from techno-stress?
Perhaps the method most extreme, but certainly more effective, is the technological fasting. We should "pull the plug", log off.
If the technological fasting seems a bit excessive solution you can start with something less radical, re-establishing a contact between the digital and the physical world.
Step 2: VIPER IoT Notes Printer
Just imagine how much stress could be avoided if all daily notifications, mostly useless and unnecessary, were gathered together, maybe printed on paper (the gold old paper), and are shown to us only in the evening or when you are on metro.
This would make it possible to take full advantage of "dead time" and not waste precious minutes to the battery life of the smartphone.
And how many times you've had to make a shopping list for a large group of people, perhaps for a dinner with roommates. How would it be easier to write the list on a shared app and then getting the final list on a piece of paper, before you leave home?
VIPER makes this possible. The "Zerynth IoT Notes Printer" tries to create a handable medium for everyday communication. Thanks to the Zerynth App you can write text messages and send them to a small thermal printer programmed with Zerynth and connected to the network via a microcontroller and a wi-fi chip.
Ok, at this point I should be succeeded in convince you of the utility of the project. If still you ask: "But why should I print a text message sent from a smartphone?", honesty the best answer I can give is: "Because you can, and it's fun to do".
Moreover, through this simple project we can show the potential of Zerynth and of the Zerynth App.
Step 3: Required Material
The project is very simple and requires few elements.
First you need Zerynth Studio (download it here).
Zerynth is an easy to use development suite for the high level design of interactive objects ready for the cloud and the IoT. With Zerynth creatives, designers and professionals can develop in Python for Arduino DUE, ST Nucleo and most of Particle (formerly Spark) products, and similar boards using paradigms and features typical of PC and mobile programming.
In this project we will see also how to use the Zerynth App (http://bit.ly/ZerynthApp), which allows you to control the "virtualized" objects via mobile without having to develop a specific Android app to each project.
Moving on to the hardware side, for this project you need one of the boards among those supported by Zerynth, such as ST Nucleo or Arduino Due.
Obviously you need an element that connects the board to the Internet, such as the wi-fi shield of Adafruit. However you can use any other adapter that mounts the wifichip CC3000 Texas Instruments (ttp://www.ti.com/product/cc3000 ).
It will then be necessary a device that can print. A very affordable gadget is the Thermal Printer from Adafruit ( http://www.adafruit.com/products/597).
Also known as receipt printers, they’re what you see at the ATM or grocery store. This printer is ideal for interfacing with a microcontroller, you simply need a 3.3V to 5V TTL serial output from your microcontroller to print text with any kind of formatting, barcodes, bitmap graphics and even QR code.
As specified here https://learn.adafruit.com/mini-thermal-receipt-p... you also need:
- very common 2.25" wide thermal paper
- 5 Volt to 9 Volt regulated DC power supply that can provide 1.5 Amps
- 2.1mm jack adapter, which you can attach to the printer’s red/black wires
Finally you need to get a nice container in which to put it all. We chose a nice box painted with the American flag, found in a common gift shop, but you can pick any way you like. The important thing is that it must be large enough to hold the boards and that is not too difficult to drill (note that you have to practice a hole on the top to accommodate the thermal printer!).
Step 4: Assembling the Circuit
The RX-TX pins of the printer must be connected to the TX-RX pins of the serial port chosen on the microcontroller. The serial port used in the code (see below) is the "Serial1", located on pins D24 and D25 of Morphos Headers in ST Nucleo and on pins D18 and D19 in the headers of Arduino Due.
Step 5: "Viperizing" the Printer
Using Zerynth is very easy!
Let's leave out the operations of connecting and "virtualizing" of the board (already explained here https://www.instructables.com/id/A-multithreaded-b... and we go to the creation of a new project in Zerynth.
As you can see in the first figure, it takes only two steps:
- click on the button "Browse Project"
- click on the "New Project"
Now just fill in the fields with the project title and an optional description. Zerynth also allows you to insert tags. This will make it much easier to filter results when searching through old projects.
After creating the project by clicking on the "Create" button, we will have a blank text editor to copy the code presenting in main.py, the main file on which is written in Zerynth / Python language the logic of the program.
You need to edit SSID_WiFi and PWD_WiFi with the name and password of the WiFi network to which you will connect the printer.
In order to interact with the Zerynth App you need to add another file to the project. It is an HTML file that defines the interface that will have the specific App.
To add a file to the project just click on the "Current Project", then "Add files to project" and finally, after naming the file ("template.html") on the "Create" button, as shown in second figure.
Again we will have a blank field on which to copy the code, which is defined in HTML5 (and through the library jQuery Mobile) the interface of the App.
To get a better idea of the functioning and the philosophy behind the development of interfaces via the Zerynth App refer to examples found at this address: http://doc.viperize.it/0.2.0.0008/generated/exg_ot...
At this point you have to compile the script and upload it to the board. After turning on the printer, this will automatically connect to the preset network.
Then just open theZerynth App, which will go in search of "virtualized" objects connected to the network, select the object of interest (in this case, of course, the "Zerynth IoT Notes Printer") and you can interact with the printer!
The code has many comments and should be easy to understand. However, to get a better idea of the operation please refer to the example "Thermal Printer Basics" contained in the Zerynth Studio.
Step 6: Adding More Functionalities
There is a hardware device closely related to VIPER: the TOI Shield, available here: http://bit.ly/TOI_Shield-Futura_Shop
It is a multiboard shield that presents a set of sensors and actuators, including sensors for touch detection, infrared LED, microphone, light sensor and temperature sensor. Adding TOI Shield to the printer would extend its functionality, and perhaps you might be able to create a really useful device. How about try?
Luigi F. Cerfeda (@L_F_Cerfeda) - VIPER team