You are currently viewing python code for IoT Notes Printer using arduino Due
Python Code For IoT Notes Printer Using Arduino Due

python code for IoT Notes Printer using arduino Due

Spread the love

Introduction :

In this article we going to implement IOT base project python code for IoT Notes Printer using arduino Duethis project tries to make a handable medium for everyday communication.

In this project we use Zerynth App (link is available in resources) this help you can write text messages and send them to a thermal printer and connected to the network using a microcontroller and a wi-fi chip.

Python Code For IoT Notes Printer Using Arduino Due
Python Code For IoT Notes Printer Using Arduino Due

Pre-requirement for python code for IoT Notes Printer using arduino Due:

  • Arduino IDE
  • Arduino Due
  • python envi.
  • Zerynth App
  • Hacksaw
  • Adafruit CC3000 wifi shield
  • Container
  • Adafruit Thermal Printer
  • STM32 Nucleo ST Nucleo

Procedure :

python code for IoT Notes Printer using arduino Due (VIPER)


# import all required library
import streams
from drivers.thermalprinter import thermalprinter
from wireless import wifi
from drivers.wifi.cc3000 import cc3000_tiny as cc3000
#Then 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>
    <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> 

Summary :

In this article we implemented IOT base project Python Code For IoT Notes Printer Using Arduino Due. so about this project code you have any problem then please free to ask me

Resources : Arduino official site

BEST OF LUCK!!

I am Mr. Sachin pagar Embedded system engineer, the founder of Pythonslearning, a Passionate Educational Blogger and Author, who love to share the informative content on educational resources.

sachin Pagar

I am Mr. Sachin pagar Embedded system engineer, the founder of Pythonslearning, a Passionate Educational Blogger and Author, who love to share the informative content on educational resources.

Leave a Reply