Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Testing CircuitPython on Teensy 4.0 – IoT made easy IoTeensy! @adafruit @CircuitPython @arturo182 @tannewt @NXP @PaulStoffregen

Testing CircuitPython on Teensy 4.0 – IoT made easy IoTeensy (video)! Scott and Artur have done an amazing job bringing CircuitPython to the NXP iMX RT1062, this chip holds a lot of promise! I threw together a quick IoT project to test I2C and SPI – the OLED is an I2C device, and the AirLift Featherwing provides WiFi over SPI. This demo connects to my AP, then queries the adafruit quote service to get an inspirational quote every 3 seconds. The JSON is parsed, split, and displayed on the OLED by scrolling. Was really fast to put together, only about 20 minutes and 100 lines of code.

Discussion on PJRC forums here and on the MicroPython forums, and loading it up here.

Code is here:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import time
import board
import busio
from digitalio import DigitalInOut
import adafruit_esp32spi.adafruit_esp32spi_socket as socket
from adafruit_esp32spi import adafruit_esp32spi
import adafruit_requests as requests
import adafruit_ssd1306
print("ESP32 SPI webclient test")
JSON_URL = "https://www.adafruit.com/api/quotes.php"
i2c = busio.I2C(board.SCL, board.SDA, frequency=100000)
display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, addr=0x3c)
# If you have an externally connected ESP32:
esp32_cs = DigitalInOut(board.D5)
esp32_reset = DigitalInOut(board.D6)
esp32_ready = DigitalInOut(board.D9)
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
requests.set_socket(socket, esp)
if esp.status == adafruit_esp32spi.WL_IDLE_STATUS:
    print("ESP32 found and in idle mode")
print("Firmware vers.", esp.firmware_version)
print("MAC addr:", [hex(i) for i in esp.MAC_address])
display.fill(0)
display.text("Found ESP32", 0, 0, 1)
display.show()
for ap in esp.scan_networks():
    print("\t%s\t\tRSSI: %d" % (str(ap['ssid'], 'utf-8'), ap['rssi']))
print("Connecting to AP...")
display.text("Connecting to AP", 0, 8, 1)
display.show()
while not esp.is_connected:
    try:
        esp.connect_AP(b'adafruit', b'ffffffff')
    except RuntimeError as e:
        print("could not connect to AP, retrying: ",e)
        continue
print("Connected to", str(esp.ssid, 'utf-8'), "\tRSSI:", esp.rssi)
print("My IP address is", esp.pretty_ip(esp.ip_address))
print("IP lookup adafruit.com: %s" % esp.pretty_ip(esp.get_host_by_name("adafruit.com")))
print("Ping google.com: %d ms" % esp.ping("google.com"))
display.text("Connected: "+str(esp.ssid, 'utf-8'), 0, 16, 1)
display.text("IP: "+esp.pretty_ip(esp.ip_address), 0, 24, 1)
display.show()
def wrap_nicely(string, max_chars):
        """A helper that will return a list of lines with word-break wrapping.
        :param str string: The text to be wrapped.
        :param int max_chars: The maximum number of characters on a line before wrapping.
        """
        string = string.replace('\n', '').replace('\r', '') # strip confusing newlines
        words = string.split(' ')
        the_lines = []
        the_line = ""
        for w in words:
            if len(the_line+' '+w) <= max_chars:
                the_line += ' '+w
            else:
                the_lines.append(the_line)
                the_line = ''+w
        if the_line:      # last line remaining
            the_lines.append(the_line)
        # remove first space from first line:
        the_lines[0] = the_lines[0][1:]
        return the_lines
while True:
    print()
    print("Fetching json from", JSON_URL)
    r = requests.get(JSON_URL)
    j = r.json()
    print('-'*40)
    print(j)
    print('-'*40)
    quote = j[0]['text']
    author = j[0]['author']
    r.close()
    display.fill(0)
    lines = wrap_nicely(quote, 21)
    lines.append(" ")
    lines.append(author)
    print(lines)
    for i, line in enumerate(lines[:-2]):
        display.fill(0)
        display.text(line, 0, 0, 1)
        if len(lines) > i+1:
            display.text(lines[i+1], 0, 8, 1)
        if len(lines) > i+2:
            display.text(lines[i+2], 0, 16, 1)
        if len(lines) > i+3:
            display.text(lines[i+3], 0, 24, 1)
        display.show()
        time.sleep(0.5)
    time.sleep(3)
print("Done!")


We are angry, frustrated, and in pain because of the violence and murder of Black people by the police because of racism. We are in the fight AGAINST RACISM. George Floyd was murdered, his life stolen. The Adafruit teams have specific actions we’ve done, are doing, and will do together as a company and culture. We are asking the Adafruit community to get involved and share what you are doing. The Adafruit teams will not settle for a hash tag, a Tweet, or an icon change. We will work on real change, and that requires real action and real work together. That is what we will do each day, each month, each year – we will hold ourselves accountable and publish our collective efforts, partnerships, activism, donations, openly and publicly. Our blog and social media platforms will be utilized in actionable ways. Join us and the anti-racist efforts working to end police brutality, reform the criminal justice system, and dismantle the many other forms of systemic racism at work in this country, read more @ adafruit.com/blacklivesmatter

Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on code.org, jump into CircuitPython to learn Python and hardware together, TinyGO, or even use the Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for CircuitPython, MakeCode, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.

Join 20,000+ makers on Adafruit’s Discord channels and be part of the community! http://adafru.it/discord

Have an amazing project to share? The Electronics Show and Tell is every Wednesday at 7pm ET! To join, head over to YouTube and check out the show’s live chat – we’ll post the link there.

Join us every Wednesday night at 8pm ET for Ask an Engineer!

Follow Adafruit on Instagram for top secret new products, behinds the scenes and more https://www.instagram.com/adafruit/

CircuitPython – The easiest way to program microcontrollers – CircuitPython.org


Maker Business — To make it through a tough business cycle, layoffs should be a last resort

Wearables — Battery wars

Electronics — Build It!

Python for Microcontrollers — Python on Microcontrollers Newsletter: New Hardware, Python Releases and Much More! #Python #Adafruit #CircuitPython @circuitpython @micropython @ThePSF

Adafruit IoT Monthly — BLE Store Capacity Indicator, Aquarium Automation, and more!

Microsoft MakeCode — MakeCode Arcade Game Garden Jam!

EYE on NPI — Maxim’s Himalaya uSLIC Step-Down Power Module #EyeOnNPI @maximintegrated @digikey

New Products – Adafruit Industries – Makers, hackers, artists, designers and engineers! — New Products 7/29/20 featuring Black LED Diffusion Acrylic Panel 12″ x 12″ – 0.1″ / 2.6mm thick! @adafruit #adafruit #newproducts

Get the only spam-free daily newsletter about wearables, running a "maker business", electronic tips and more! Subscribe at AdafruitDaily.com !



No Comments

No comments yet.

Sorry, the comment form is closed at this time.