Rocket Surgery

Nick Moore
nick@zoic.org
https://nick.zoic.org/
@nickzoic

Cast

Rocketry

By Hohum - Own work, Public Domain, Wikimedia Commons

By NASA - Public Domain, Wikimedia Commons

MEMS

Micro Electro Mechanical Systems

MPU6050 die: about 2.7mm across

image: zeptobars.com

ESP32

ArduinoESP32RPi 2
AVR
ATMega328P
Tensilica
Xtensa LX6
ARM
Cortex A53
8 bit32 bit32 bit
1 core2 core4 core
20 MHz240 MHz900 MHz
2 KB RAM520 KB RAM1 GB RAM
32 KB Flash16 MB FlashMicroSDHC

ESP32 Features

MicroPython

micropython.org

# Set up the i2c bus, which is on pins 21 and 22.
# Then wake up the acc/gyr module by writing to
# its status register.

import machine
i2c = machine.I2C(
    freq=400000,
    scl=machine.Pin(22),
    sda=machine.Pin(21)
)
i2c.writeto_mem(104, 107, bytes([0]))

# Read a single record from the acc/gyr and expand
# it into a tuple of seven signed numbers:
# ax, ay, az, temperature, gx, gy and gz.

import struct

def read_acc():
    return struct.unpack(
        ">7h",
        i2c.readfrom_mem(104, 0x3b, 14)
    )
import time

# Wait for the WLAN to be available.

while not network.WLAN().isconnected():
    time.sleep(0.1)
# Connect up to an MQTT server

import umqtt.simple

cli = umqtt.simple.MQTTClient(
    'r0kk1t',
    'iot.eclipse.org'
)
cli.connect()
# Grab data and send timestamp plus data in an MQTT
# message.

while True:
    zz = [ time.ticks_ms() ] + list(read_acc())
    msg = ' '.join("%d" % x for x in zz)
    cli.publish('r0kk1t', msg)
    time.sleep(0.1)
import network
w = network.WLAN()
w.active(True)
w.config(protocol=network.MODE_LR)

from esp import espnow
espnow.init()
import struct
pfmt = "%12d %12d" + " %6d" * 7

while True:
    msg = espnow.recv()
    if msg:
        print(pfmt % struct.unpack(">LL7h", msg[1]))

video: John Spencer

PyCon AU 2018


rainbow snake logo: 2018.pycon-au.org

Questions / Comments

Nick Moore

Slides:

Content and images © Nick Moore except where otherwise noted