Easy Iot With Micropython On Esp Socs: @mnemote
Easy Iot With Micropython On Esp Socs: @mnemote
with MicroPython
on ESP SoCs
Nick Moore
@mnemote
[email protected]
What is a SoC
System on a Chip, or System on a Module
No OS FreeRTOS Linux
ESP8266 / ESP32
ESP8266 CPU
Arduino ESP8266
AVR Tensilica
ATMega328P Xtensa LX106
8 bit 32 bit
1 core 1 core
32 KB Flash 4 MB Flash
ESP32 CPU
ESP32 Modules
WROOM-32 or ESP-32S
ESP32 Networking
ESP32 I/O
Digital I/O
ADC inputs
DAC outputs
PWM outputs
Capacitive Touch Inputs
Hall E ect Sensor
RMT "Remote Control"
module
ESP IDF
IoT Development Framework
github: espressif/esp-
idf
https://buzzconf.io/sessions/airborne-iot-build-a-rocket/
MicroPython
micropython.org
MicroPython
Python 3.4
C99
MIT-
licensed
MicroPython Platforms
PyBoard (ARM
Cortex)
16-bit PIC
ESP8266
ESP32
OR
http://micropython.org/downloads#esp32
Running MicroPython — 1
Running MicroPython — 2
>>> help('modules')
__main__ flashbdev random uos
_boot framebuf re upip
_onewire gc select upip_utarfile
_thread hashlib socket urandom
apa106 heapq ssl ure
array inisetup struct uselect
binascii io sys usocket
btree json time ussl
builtins machine ubinascii ustruct
cmath math ucollections utime
collections micropython uctypes utimeq
dht neopixel uerrno uzlib
ds18x20 network uheapq zlib
errno onewire uio
esp os ujson
Running MicroPython — 4
Running MicroPython — 5
Running MicroPython — 7
File
transfer
FUSE
mount
Di
runtime
>>> import os
>>> os.listdir()
['boot.py']
>>> f = open('hello.world', "w")
>>> f.write("Hello, World!")
13
>>> f.close()
>>> os.listdir()
['boot.py', 'hello.world']
Programming MicroPython — Networking — 1
class Accelerometer:
def __init__(self, i2c=None, address=104):
self.i2c = i2c or machine.I2C(freq=400000,
scl=machine.Pin(22), sda=machine.Pin(21))
self.address = address
self.i2c.writeto_mem(self.address, 107, bytes([0])
def read_xyz(self):
return struct.unpack(
">3h", self.i2c.readfrom_mem(104, 59, 6)
)
Developing MicroPython
/**
* @brief Get flash chip size, as set in binary image header
*
* @note This value does not necessarily match real flash size.
*
* @return size of flash chip, in bytes
*/
size_t spi_flash_get_chip_size();
#include "esp_spi_flash.h"
#include "esp_spi_flash.h"
#include "esp_spi_flash.h"
#include "esp_spi_flash.h"
#include "esp_spi_flash.h"
#define MICROPY_PORT_BUILTIN_MODULES \
{ MP_OBJ_NEW_QSTR(MP_QSTR_esp), (mp_obj_t)&esp_module }, \
esp32/Make le
SRC_C = \
modesp.c \
How do C modules work? — 9
@internetofshit
/r/theinternetofshit
arlogilbert.com
3. Internet Not Found
telegraph.co.uk
4. Cryptography
5. Awful Software
The software for things like lightbulbs is often awful, Matthew Garrett on iRainbow
and open to all kinds of exploitation. Lightbulbs
This shouldn't be too surprising since even the manufacturers TrendMicro on HID remote door
of unlocks
electronic locks have trouble getting this right. Mirai DDoS
6. Update Cycle
It's hard enough to get people to change their smoke alarm batteries or update Internet
Explorer.
No-one ever is going to re ash their thermostat.
While devices are reloading, they are generally unavailable.
Complaints → Requirements
Wednesday, September 27
https://www.meetup.com/MicroPython-Meetup/
http://hackmelbourne.org
BuzzConf Nights
Thursday, September 28
Loop Bar
https://www.meetup.com/BuzzConf/
LinuxConf 2018
Tutorial:
https://linux.conf.au/
Questions / Comments
Nick Moore
Mnemote Pty Ltd
[email protected]
http://mnemote.com/
@mnemote
Slides:
http://nick.zoic.org/talk/yow1/