preloader

Pozetron Quickstart Guide

This guide will teach you everything you need to know to get the LEDs blinking (the hello world of embedded devices) on your new IoT device. All you will need is a provisioned device from our store or one that you’ve made yourself (ESP32 | ESP8266).

Choose Your Own Adventure

We have a few flavors of the code for this Quickstart depending on the board that you have. If you have a board which isn’t listed then this first version is for you.



# We'll import everything we need here.
import time
import sys

# This is a pointer to the module object instance itself. We use this so we can reference module level variables
# inside our main_loop(). This is more memory efficient than using a class and looks better than `global`.
main = sys.modules[__name__]

# We don't know if this board has any LEDs so we'll blink a fake one!
fake_led = type('', (), {})()

# This will make our fake LED print the value out to the serial port whenever it is set.
# You won't see this unless you attach the device to your computer, which is a good exercise for the reader.
fake_led.value = print 

# Set our fake LED to "off" initially.
fake_led.value(0)

# `log` will write this line back to the Pozetron logs. You can see them in the App when Log Mode is on.
# You can select either "Log Mode Memory" or "Log Mode File" to enable it.
log('Setup Complete')

# Our main loop will continue to run while the device remains powered on.
def main_loop():
        # Fake LED goes on
        main.fake_led.value(1)
        # Sleep for one second
        time.sleep(1)
        # Fake LED goes off
        main.fake_led.value(0)
        time.sleep(4)

All you need to do to get this on your own device is click the “Deploy Now” button. This will take you to a page to review the code one last time, select your device and press “Deploy”. That’s it! The next time your device connects, which is usually within 60 seconds, it will see the new module is available and download it.

You will need to either Reset the device if it has a Reset button, disconnect the power and reconnect it or restart your device through the App so that it can begin to use it’s new main.

Boards with LEDs

As promised, we also have a few different versions for common boards which come with LEDs to flash.

Adafruit Feather HUZZAH32



# We'll import everything we need here.
import sys
import machine
import time

# This is a pointer to the module object instance itself. We use this so we can reference module level variables
# inside our main_loop(). This is more memory efficient than using a class and looks better than `global`.
main = sys.modules[__name__]

# We have an LED on Pin 13 on the Huzzah32. Let's blink it!
led = machine.Pin(13, machine.Pin.OUT)

# Set our LED to "off" initially.
led.value(0)

# `log` will write this line back to the Pozetron logs. You can see them in the App when Log Mode is on.
# You can select either "Log Mode Memory" or "Log Mode File" to enable it.
log('Setup Complete')

# Our main loop will continue to run while the device remains powered on.
def main_loop():
        # LED goes on
        main.led.value(1)
        # Sleep for one second
        time.sleep(1)
        # LED goes off
        main.led.value(0)
        time.sleep(4)

Adafruit Feather HUZZAH



# We'll import everything we need here.
import sys
import machine
import time

# This is a pointer to the module object instance itself. We use this so we can reference module level variables
# inside our main_loop(). This is more memory efficient than using a class and looks better than `global`.
main = sys.modules[__name__]

# We have an LED on Pin 0 on the Huzzah. Let's blink it!
led = machine.Pin(0, machine.Pin.OUT)

# Set our LED to "off" initially. Note: the LED is reverse wired so setting the pin LOW will turn the LED on.
led.value(1)

# `log` will write this line back to the Pozetron logs. You can see them in the App when Log Mode is on.
# You can select either "Log Mode Memory" or "Log Mode File" to enable it.
log('Setup Complete')

# Our main loop will continue to run while the device remains powered on.
def main_loop():
        # LED goes on
        main.led.value(0)
        # Sleep for one second
        time.sleep(1)
        # LED goes off
        main.led.value(1)
        time.sleep(4)

Free Registration

No credit card required. Limited time only.

Register Free