@woakas CTO at Ubidots
import pycom
import time
pycom.heartbeat(False)
for cycles in range(10): # stop after 10 cycles
pycom.rgbled(0x007f00) # green
time.sleep(5)
pycom.rgbled(0x7f7f00) # yellow
time.sleep(1.5)
pycom.rgbled(0x7f0000) # red
time.sleep(4)
import pycom
import time
pycom.heartbeat(False)
for cycles in range(10): # stop after 10 cycles
pycom.rgbled(0x007f00) # green
time.sleep(5)
pycom.rgbled(0x7f7f00) # yellow
time.sleep(1.5)
pycom.rgbled(0x7f0000) # red
time.sleep(4)
import machine
led=machine.Pin("G16",machine.Pin.OUT)
led.value(1)
led.value(0)
import machine
led = machine.Pin("G16", machine.Pin.OUT)
button = machine.Pin("G17", machine.Pin.IN, pull=machine.Pin.PULL_UP)
def handler(button):
led.toggle()
button.callback(trigger=machine.Pin.IRQ_FALLING, handler=handler)
import machine
button = machine.Pin("G17", machine.Pin.IN, pull=machine.Pin.PULL_UP)
button()
import time
import machine
led = machine.Pin("G16", machine.Pin.OUT)
eval("led.value(0)")
a = """import time
from machine import Pin
led = Pin('G10', mode=Pin.OUT, value=0)
for i in range(10):
led.toggle()
time.sleep(0.1)
"""
with open('/flash/main.py', 'w') as f:
f.write(a)
import _thread
import time
def th_func(delay, id):
while True:
time.sleep(delay)
print('Running thread %d' % id)
for i in range(3):
_thread.start_new_thread(th_func, (i + 1, i))
from network import Sigfox
import socket
import struct
# init Sigfox for RCZ1 (Europe)
sigfox = Sigfox(mode=Sigfox.SIGFOX, rcz=Sigfox.RCZ2)
# create a Sigfox socket
s = socket.socket(socket.AF_SIGFOX, socket.SOCK_RAW)
# make the socket blocking
s.setblocking(True)
# configure it as DOWNLINK specified by 'True'
s.setsockopt(socket.SOL_SIGFOX, socket.SO_RX, True)
# send values as little-endian and int, request DOWNLINK
s.send(struct.pack("<f", 23.2))