Clipper LTE 4G Breakout

Where do I find UART?

@patmolloy from machine import UART

Full script for random colours via LTE here :)

import lte
import time
import requests
from machine import Pin, PWM, UART
import plasma
from plasma import plasma2040

NUM_LEDS = 67

MOBILE_APN = "Your APN Here"

# Setting this to True will attempt to resume an existing connection
RESUME = False

PIN_TX = 8
PIN_RST = 11
PIN_NETLIGHT = 10
PIN_RX = 9
UART_ID = 1

plasmauart = UART(UART_ID, tx=Pin(PIN_TX, Pin.OUT), rx=Pin(PIN_RX, Pin.OUT))
plasmareset = Pin(PIN_RST, Pin.OUT)
plasmanetlightpin = Pin(PIN_NETLIGHT, Pin.OUT)

# WS2812 / NeoPixel™ LEDs
led_strip = plasma.WS2812(NUM_LEDS, 0, 0, plasma2040.DAT)
# Start updating the LED strip
led_strip.start()

# Fix the eye-searing brightness of the onboard LED with PWM
class Netlight:
    def __init__(self):
        self.pin = PWM(Pin(PIN_NETLIGHT, Pin.OUT), freq=1000)

    def value(self, value):
        self.pin.duty_u16(value * 2000)

con = lte.LTE(MOBILE_APN, uart=plasmauart, reset_pin=plasmareset, netlight_pin=plasmanetlightpin, netlight_led=Netlight(), skip_reset=RESUME)

while (True):
    
    con.start_ppp(connect=not RESUME)
    
    req = requests.get("https://random-flat-colors.vercel.app/api/random?count=2").json()
    colour =  tuple( int( req['colors'][0][i:i+2], 16 ) for i in (1, 3, 5) )
    
    print ( colour[0], colour[1], colour[2] )
    
    for i in range(NUM_LEDS):
        led_strip.set_rgb(i, colour[0], colour[1], colour[2] )
    
    con.stop_ppp()
    
    time.sleep (60*30)

1 Like

Sweet!

I don’t have the LEDs (yet!) but it works and I can print out the req result just fine!

Kudos :-)

Cheers

Pat