Luigi Francesco CerfedaDaniele Mazzei
Published © GPL3+

IoT Notes Printer: Your Smartphone Notes on Paper

The "Zerynth IoT Notes Printer" tries to create a handable medium for everyday communication.

BeginnerFull instructions provided17,743
IoT Notes Printer: Your Smartphone Notes on Paper

Things used in this project

Hardware components

STM32 Nucleo ST Nucleo
×1
Arduino Due
Arduino Due
×1
Adafruit Thermal Printer
×1
Adafruit CC3000 wifi shield
×1
Container
×1

Software apps and online services

Zerynth Studio
Zerynth Studio

Hand tools and fabrication machines

drill
hacksaw

Story

Read more

Schematics

Thermal Printer connections

Code

VIPER IoT Notes Printer - main.py

Python
################################################################################
# VIPER IoT Notes Printer
#
# Created by VIPER Team 2015 CC
# Authors: G. Baldi, D. Mazzei
################################################################################

# import everything needed
import streams
from drivers.thermalprinter import thermalprinter
from wireless import wifi
from drivers.wifi.cc3000 import cc3000_tiny as cc3000
# and also import the viperapp module
from libs.apps import viperapp
p = thermalprinter.ThermalPrinter(SERIAL1,19200)

s=streams.serial()

# save the template.html in the board flash with new_resource
new_resource("template.html")

# connect to a wifi network
try:
    cc3000.auto_init()

    print("Establishing Link...")
    wifi.link("SSID_WiFi",wifi.WIFI_WPA2,"PWD_WiFi")
    print("Ok!")        
except Exception as e:
    print(e)

def printMessage(msg):
    p.print_text("VIPER\n",justification="c", style="b")
    p.print_text("www.viperize.it\n\n",justification="c", style="b")
    p.print_text("Take me!\n",justification="c", style="b")
    p.print_text(msg)
    p.print_text("\n"*2+"*"*20+"\n"*3,justification="c")    
    
#### ViperApp Setup    
    
# :: Javascript to Python ::
# the following function will be called when the template button is pressed
def show_message(msg):
    print(msg)
    printMessage(msg)

# configure the viper app with a name, a descripton and the template url
vp = viperapp.ViperApp("Viper IoT Notes Printer","Print your message!","resource://template.html")

# everytime Javascript generates the event "showmsg" the function show_message is called
vp.on("showmsg",show_message)

# run the ViperApp!
vp.run()
# since vp.run starts a new thread, you can do whatever else you want down here!

template.html

HTML
<html>
    <head>
        <viper/>
        <viper-jquery/>
        <viper-jquery-mobile/>
        <meta name="viewport" content="width=device-width, initial-scale=1">
    </head>     
    <body>
        <div data-role="page">
            <div data-role="header" style="text-align:center"><h1>Viper Printer</h1></div>
            <div role="main" class="ui-content" style="text-align:center">
            <p>
                <label>Write your note:</label>
            </p>
            <p>
                <textarea id='txtData' rows='5' ></textarea>
            </p>
            <p>
            <button type=button onclick="javascript:getValue();" id='btnGet'>Print!</button>
            </p>     
            <p id="label"></p>
            </div>
            <div data-role="footer">Powered by Viper www.viperize.it</div>
        </div>
        <script>
            function getValue () {
                var text=$("#txtData").val();
                ViperApp.call('showmsg',text);
            }
        </script>

    </body>
</html> 

Credits

Luigi Francesco Cerfeda

Luigi Francesco Cerfeda

6 projects • 95 followers
Yet another Tony Stark wannabe
Daniele Mazzei

Daniele Mazzei

2 projects • 9 followers

Comments