From 02e2780d233c2d73fcbd32a2a970d5a6f3696224 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Thu, 26 Apr 2018 19:46:03 +0200 Subject: wip --- assignments/Makefile | 8 +- assignments/README.md | 2 + assignments/README.pdf | Bin 113254 -> 128533 bytes assignments/blink-a-led/blink-a-led.md | 4 +- assignments/blink-a-led/blink-a-led.pdf | Bin 722602 -> 722602 bytes assignments/blink-a-led/schematic/assignment-1.fzz | Bin 21480 -> 0 bytes .../blink-a-led/schematic/assignment-1_bb.pdf | Bin 354599 -> 0 bytes .../blink-a-led/schematic/assignment-1_schem.pdf | Bin 263607 -> 0 bytes assignments/blink-a-led/schematic/blink-a-led.fzz | Bin 0 -> 21480 bytes .../blink-a-led/schematic/blink-a-led_bb.pdf | Bin 0 -> 354599 bytes .../blink-a-led/schematic/blink-a-led_schem.pdf | Bin 0 -> 263607 bytes assignments/mqtt/mqtt.pdf | Bin 105234 -> 105234 bytes assignments/read-temperature/read-temperature.md | 8 ++ assignments/read-temperature/read-temperature.pdf | Bin 0 -> 790129 bytes .../schematic/read-temperature.fzz | Bin 0 -> 23036 bytes .../schematic/read-temperature_bb.pdf | Bin 0 -> 392490 bytes .../schematic/read-temperature_schem.pdf | Bin 0 -> 354997 bytes .../solution/read-temperature/read-temperature.ino | 14 ++ slides/Makefile | 4 +- slides/images/nodemcu.pgf | 6 +- slides/what-is-iot-slides.pdf | Bin 314263 -> 314262 bytes slides/what-is-iot-slides.tex | 155 +++++++++++++++++---- slides/what-is-iot-text.pdf | Bin 331141 -> 331142 bytes 23 files changed, 168 insertions(+), 33 deletions(-) delete mode 100644 assignments/blink-a-led/schematic/assignment-1.fzz delete mode 100644 assignments/blink-a-led/schematic/assignment-1_bb.pdf delete mode 100644 assignments/blink-a-led/schematic/assignment-1_schem.pdf create mode 100644 assignments/blink-a-led/schematic/blink-a-led.fzz create mode 100644 assignments/blink-a-led/schematic/blink-a-led_bb.pdf create mode 100644 assignments/blink-a-led/schematic/blink-a-led_schem.pdf create mode 100644 assignments/read-temperature/read-temperature.md create mode 100644 assignments/read-temperature/read-temperature.pdf create mode 100644 assignments/read-temperature/schematic/read-temperature.fzz create mode 100644 assignments/read-temperature/schematic/read-temperature_bb.pdf create mode 100644 assignments/read-temperature/schematic/read-temperature_schem.pdf create mode 100644 assignments/read-temperature/solution/read-temperature/read-temperature.ino diff --git a/assignments/Makefile b/assignments/Makefile index 864864e..2f97a07 100644 --- a/assignments/Makefile +++ b/assignments/Makefile @@ -1,4 +1,7 @@ -AS=blink-a-led mqtt +AS = +AS += blink-a-led +AS += read-temperature +AS += mqtt PDFS=$(foreach A,$(AS),$(A)/$(A).pdf) @@ -10,6 +13,9 @@ $(1)/$(1).pdf: $(1)/$(1).md endef $(eval $(foreach A,$(AS),$(call $(A_PATTERN),$(A)))) +clean: + @rm $(wildcard $(PDFS)) + %.pdf: %.md @echo pandoc $< @cd $(dir $<); pandoc $(notdir $<) -o $(notdir $@) diff --git a/assignments/README.md b/assignments/README.md index 363ce15..a6f4dc3 100644 --- a/assignments/README.md +++ b/assignments/README.md @@ -23,6 +23,8 @@ which should include "NodeMCU 1.0 (ESP-12E Module)". * Time * TimeAlarms * WifiManager +* *DHT sensor library* by Adafruit +* *Adafruit sensor library* by Adafruit ## Install Python 3 diff --git a/assignments/README.pdf b/assignments/README.pdf index 51f6f0b..df80c8d 100644 Binary files a/assignments/README.pdf and b/assignments/README.pdf differ diff --git a/assignments/blink-a-led/blink-a-led.md b/assignments/blink-a-led/blink-a-led.md index e7fb5d8..a08bc4e 100644 --- a/assignments/blink-a-led/blink-a-led.md +++ b/assignments/blink-a-led/blink-a-led.md @@ -15,9 +15,9 @@ Create a new sketch with *File* -> *New* and compile it with *ctrl-R*. Wire up this schematic on the bread board: -![](schematic/assignment-1_schem.pdf) +![](schematic/blink-a-led_schem.pdf) -![](schematic/assignment-1_bb.pdf) +![](schematic/blink-a-led_bb.pdf) The colors on the wires used does not matter. The resistors orientation is not important, but the LED's orientation is important. diff --git a/assignments/blink-a-led/blink-a-led.pdf b/assignments/blink-a-led/blink-a-led.pdf index 6456260..785547f 100644 Binary files a/assignments/blink-a-led/blink-a-led.pdf and b/assignments/blink-a-led/blink-a-led.pdf differ diff --git a/assignments/blink-a-led/schematic/assignment-1.fzz b/assignments/blink-a-led/schematic/assignment-1.fzz deleted file mode 100644 index da3ad5b..0000000 Binary files a/assignments/blink-a-led/schematic/assignment-1.fzz and /dev/null differ diff --git a/assignments/blink-a-led/schematic/assignment-1_bb.pdf b/assignments/blink-a-led/schematic/assignment-1_bb.pdf deleted file mode 100644 index 0995ece..0000000 Binary files a/assignments/blink-a-led/schematic/assignment-1_bb.pdf and /dev/null differ diff --git a/assignments/blink-a-led/schematic/assignment-1_schem.pdf b/assignments/blink-a-led/schematic/assignment-1_schem.pdf deleted file mode 100644 index a5241b2..0000000 Binary files a/assignments/blink-a-led/schematic/assignment-1_schem.pdf and /dev/null differ diff --git a/assignments/blink-a-led/schematic/blink-a-led.fzz b/assignments/blink-a-led/schematic/blink-a-led.fzz new file mode 100644 index 0000000..da3ad5b Binary files /dev/null and b/assignments/blink-a-led/schematic/blink-a-led.fzz differ diff --git a/assignments/blink-a-led/schematic/blink-a-led_bb.pdf b/assignments/blink-a-led/schematic/blink-a-led_bb.pdf new file mode 100644 index 0000000..0995ece Binary files /dev/null and b/assignments/blink-a-led/schematic/blink-a-led_bb.pdf differ diff --git a/assignments/blink-a-led/schematic/blink-a-led_schem.pdf b/assignments/blink-a-led/schematic/blink-a-led_schem.pdf new file mode 100644 index 0000000..a5241b2 Binary files /dev/null and b/assignments/blink-a-led/schematic/blink-a-led_schem.pdf differ diff --git a/assignments/mqtt/mqtt.pdf b/assignments/mqtt/mqtt.pdf index aa797bf..4c578f9 100644 Binary files a/assignments/mqtt/mqtt.pdf and b/assignments/mqtt/mqtt.pdf differ diff --git a/assignments/read-temperature/read-temperature.md b/assignments/read-temperature/read-temperature.md new file mode 100644 index 0000000..2528b4a --- /dev/null +++ b/assignments/read-temperature/read-temperature.md @@ -0,0 +1,8 @@ + +## Step 1 + +Wire up this schematic on the bread board: + +![](schematic/read-temperature_schem.pdf) + +![](schematic/read-temperature_bb.pdf) diff --git a/assignments/read-temperature/read-temperature.pdf b/assignments/read-temperature/read-temperature.pdf new file mode 100644 index 0000000..5a13441 Binary files /dev/null and b/assignments/read-temperature/read-temperature.pdf differ diff --git a/assignments/read-temperature/schematic/read-temperature.fzz b/assignments/read-temperature/schematic/read-temperature.fzz new file mode 100644 index 0000000..52a9fa0 Binary files /dev/null and b/assignments/read-temperature/schematic/read-temperature.fzz differ diff --git a/assignments/read-temperature/schematic/read-temperature_bb.pdf b/assignments/read-temperature/schematic/read-temperature_bb.pdf new file mode 100644 index 0000000..79cc8eb Binary files /dev/null and b/assignments/read-temperature/schematic/read-temperature_bb.pdf differ diff --git a/assignments/read-temperature/schematic/read-temperature_schem.pdf b/assignments/read-temperature/schematic/read-temperature_schem.pdf new file mode 100644 index 0000000..d01ab4b Binary files /dev/null and b/assignments/read-temperature/schematic/read-temperature_schem.pdf differ diff --git a/assignments/read-temperature/solution/read-temperature/read-temperature.ino b/assignments/read-temperature/solution/read-temperature/read-temperature.ino new file mode 100644 index 0000000..71e860e --- /dev/null +++ b/assignments/read-temperature/solution/read-temperature/read-temperature.ino @@ -0,0 +1,14 @@ +#include +#include + +const auto DHTPIN = D1; +const auto DHTTYPE = DHT22; + +DHT_Unified dht(DHTPIN, DHTTYPE); + +void setup() { +} + +void loop() { +} + diff --git a/slides/Makefile b/slides/Makefile index d6a5a26..e0cc2a6 100644 --- a/slides/Makefile +++ b/slides/Makefile @@ -45,7 +45,7 @@ $(P).md: Makefile include $(P).beamer.md.d include $(P).revealjs.md.d -%.beamer.md: %.md# %.beamer.md.d +%.beamer.md: %.md .var/QUICK $(RUN_PP_BEAMER) < $< > $@ %.beamer.md.d: %.md @@ -75,7 +75,7 @@ images/%.pdf: images/%.tex | images/pp-template Makefile mv $(patsubst %.pdf,%-full.pdf,$@) $@ -VARS=SLIDE_THEME +VARS=SLIDE_THEME QUICK define refresh = .var/$(1):: diff --git a/slides/images/nodemcu.pgf b/slides/images/nodemcu.pgf index 3ea9af0..f1a6f3b 100644 --- a/slides/images/nodemcu.pgf +++ b/slides/images/nodemcu.pgf @@ -1,13 +1,13 @@ \begin{tikzpicture} \path - (0, 0) node(flash)[draw, rectangle, + (0, 0) node(flash)[draw, rectangle, minimum height=1cm, minimum width=2cm] {Flash} - (0, 1.5) node(esp8266)[draw, rectangle, + (0, 1.5) node(esp8266)[draw, rectangle, minimum height=1cm, minimum width=2cm] {ESP8266} - (3.5, 1.5) node(cp201x)[draw, rectangle, + (3.5, 1.5) node(cp201x)[draw, rectangle, minimum height=0.75cm, minimum width=1cm] {CP201x} diff --git a/slides/what-is-iot-slides.pdf b/slides/what-is-iot-slides.pdf index 52c729b..cb3b978 100644 Binary files a/slides/what-is-iot-slides.pdf and b/slides/what-is-iot-slides.pdf differ diff --git a/slides/what-is-iot-slides.tex b/slides/what-is-iot-slides.tex index 8755756..68f0c06 100644 --- a/slides/what-is-iot-slides.tex +++ b/slides/what-is-iot-slides.tex @@ -447,6 +447,8 @@ The signaling does not specify any max data rate, very high rates \begin{frame}{Details: IP} \protect\hypertarget{details-ip}{} +\includegraphics{images/ip-header.pdf} + \note{Note that the “total length” field is 16 bits, 2 bytes, it’s maximum value is 64k, 65536.} @@ -455,6 +457,57 @@ maximum value is 64k, 65536.} \begin{frame}{Details: IP} \protect\hypertarget{details-ip-1}{} +\begin{center} +\iffalse +Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. +\fi + +\begin{tikzpicture}[scale=0.30] + \sffamily + \foreach \x in {0,7,8,15,16,31} % {0,...,32} + \node at (\x+0.5,20.5) {\scriptsize \x}; +% \foreach \x in {0,...,31} +% \node at (\x+0.5,13.5) {\scriptsize \x}; + \foreach \x in {0,8,16,32} % {0,...,32} + \draw[thick] (\x,20) -- (\x,21); + \foreach \x in {0,...,32} + \draw[thick] (\x,14) -- (\x,20); +% \foreach \x in {0,...,32} +% \draw[thick] (\x,13) -- (\x,14); + \node[thick] (bit1) at (-0.6,20.5) {\scriptsize bit}; +% \node[thick] (bit2) at (-0.6,13.5) {\scriptsize bit}; + +\iffalse + \draw [<->, thick] (-0.6, 19.9) -- (-0.6,15.1); + \draw [thick] (-1, 20) -- (-0.1,20); + \draw [thick] (-1, 15) -- (-0.1,15); + \node[fill=white] at (-1.1,17.5) {\tiny 20 bytes}; +\fi + \foreach \y/\v in {0,4,8,12,16,20} + \node at (-0.6,{19.5-(\v / 4)}) {\scriptsize \v}; + + \filldraw[thick,draw=black, fill=white] (0,20) rectangle (4,19); \node (mode) at (2,19.5) {\scriptsize version}; + \filldraw[thick,draw=black, fill=white] (4,20) rectangle (8,19); \node (mode) at (6,19.5) {\scriptsize len}; +% \draw[thick, draw=black, fill=white] (8,20) rectangle (16,19); \node (stratum) at (11.5,19.5) {\scriptsize type of service (TOS)}; + \draw[thick, draw=black, fill=white] (8,20) rectangle (16,19); \node (stratum) at (11.5,19.5) {\scriptsize TOS}; + \draw[thick, draw=black, fill=white] (16,20) rectangle (32,19); \node (li) at (24,19.5) {\scriptsize full length of packet}; + \filldraw[thick,draw=black, fill=white] (0,19) rectangle (16,18); \node (mode) at (8,18.5) {\scriptsize identification}; +% \draw[thick, draw=black] (16,19) rectangle (19,18); \filldraw[white] (16.5,18.43) rectangle (19,18.88); \node [](li) at (17.5,18.67) {\tiny IP flags}; \node at (16.5,18.25) {\tiny x};\node at (17.5,18.25) {\tiny D};\node at (18.5,18.25) {\tiny M}; + \draw[thick, draw=black] (16,19) rectangle (19,18); \filldraw[white] (16.5,18.43) rectangle (19,18.88); \node at (16.5,18.5) {\scriptsize X};\node at (17.5,18.5) {\scriptsize D};\node at (18.5,18.5) {\scriptsize M}; + \draw[thick, draw=black, fill=white] (19,19) rectangle (32,18); \node (li) at (24,18.5) {\scriptsize fragment Offset}; + \filldraw[thick,draw=black, fill=white] (0,18) rectangle (8,17); \node (mode) at (4,17.5) {\scriptsize time to live (TTL)}; + \draw[thick, draw=black, fill=white] (8,18) rectangle (16,17); \node (stratum) at (11.5,17.5) {\scriptsize protocol}; + \draw[thick, draw=black, fill=white] (16,18) rectangle (32,17); \node (li) at (24,17.5) {\scriptsize header checksum}; + \filldraw[thick,draw=black, fill=white] (0,17) rectangle (32,16); \node (mode) at (16,16.5) {\scriptsize source IP address}; + \filldraw[thick,draw=black, fill=white] (0,16) rectangle (32,15); \node (mode) at (16,15.5) {\scriptsize destination IP address}; + \draw[thick,draw=black, fill=white] (0,15) rectangle (31.5,14); + \draw[fill=white, draw=white] (31.4,14.96) rectangle (31.6,14.05); + \draw[thick] (31.5,14.97) decorate [decoration=saw] { -- (31.5,14.02)}; + \node (mode) at (16,14.5) {\scriptsize IP options (variable length)}; +\end{tikzpicture} + +\end{center} + \end{frame} \hypertarget{lecture-esp8266}{% @@ -463,16 +516,91 @@ maximum value is 64k, 65536.} \begin{frame}{NodeMCU hardware} \protect\hypertarget{nodemcu-hardware}{} +\includegraphics{images/NodeMCU-–-Board-de-desarrollo-con-módulo-ESP8266-WiFi-y-Lua-4.jpg} + \end{frame} \begin{frame}{NodeMCU hardware} \protect\hypertarget{nodemcu-hardware-1}{} +\begin{center} +\begin{tikzpicture} + +\path + (0, 0) node(flash)[draw, rectangle, + minimum height=1cm, minimum width=2cm] {Flash} + + (0, 1.5) node(esp8266)[draw, rectangle, + minimum height=1cm, minimum width=2cm] {ESP8266} + + (3.5, 1.5) node(cp201x)[draw, rectangle, + minimum height=0.75cm, minimum width=1cm] + {CP201x} + + (5.5, 1.5) node(usb)[] + {USB} +; + +\draw[-] (esp8266) -- node[node font=\footnotesize, right]{QSPI} (flash); +\draw[-] (esp8266) -- node[node font=\footnotesize, above]{UART} (cp201x) -- (usb); + +\node[rectangle, draw, fit=(esp8266) (flash), inner sep=2 mm, + label={[name=esp12_label,anchor=south]ESP-12}] + (esp12){}; + +\node[rectangle, draw, thick, fit=(esp12_label) (esp12) (cp201x), inner sep=3 mm, + label={[anchor=north]south:NodeMCU}] + (nodemcu){}; + +\end{tikzpicture} + +\end{center} + \end{frame} \begin{frame}{ESP8266 software layers} \protect\hypertarget{esp8266-software-layers}{} +\begin{center} +\begin{tikzpicture} + +\node (rect_hw) [rectangle, draw, anchor=south west, + minimum width=6 cm, minimum height=1 cm, + label={[anchor=south]center:ESP8266 Hardware}] at (0, 0) {}; + +\draw[thick] (-0.5, 1.25) -- (6.5, 1.25) ; + +\node [rectangle, draw, anchor=south west, + minimum width=4 cm, minimum height=1 cm, + label={[anchor=south]center:ESP SDK}] at (0, 1.5) {}; + +\node [rectangle, draw, anchor=south west, + minimum width=2 cm, minimum height=1 cm, + label={[align=center, text width=1cm]center:GCC libc}] at (4, 1.5) {}; + +\node [rectangle, draw, anchor=south west, + minimum width=6 cm, minimum height=1 cm, + label={[anchor=south]center:ESP interface}] at (0, 2.5) {}; + +\node [rectangle, draw, anchor=south west, + minimum width=2 cm, minimum height=1 cm, + label={[align=center, text width= 2cm]center:Generic Arduino}] at (0, 3.5) {}; + +\node [rectangle, draw, anchor=south west, + minimum width=2 cm, minimum height=1 cm, + label={[align=center, text width= 2cm]center:Ethernet}] at (2, 3.5) {}; + +\node [rectangle, draw, anchor=south west, + minimum width=2 cm, minimum height=1 cm, + label={[align=center, text width= 2cm]center:ESP APIs}] at (4, 3.5) {}; + +\draw [decorate, decoration={brace,amplitude=5pt, raise=-4pt}] (-0.5,2.5) -- (-0.5,4.5) node [black,midway,rotate=90, above] {Arduino}; + + +\end{tikzpicture} + +\end{center} + \end{frame} \begin{frame}{ESP8266 + Arduino} @@ -497,6 +625,8 @@ maximum value is 64k, 65536.} \begin{frame}{Arduino IDE} \protect\hypertarget{arduino-ide}{} +\includegraphics{images/arduino-ide.png} + \end{frame} \begin{frame}[fragile]{Arduino code structure} @@ -1098,31 +1228,6 @@ PubSubClient is our MQTT client implementation. \end{frame} -\begin{frame}{Assignment: MQTT} -\protect\hypertarget{assignment-mqtt}{} - -\end{frame} - -\hypertarget{assignments}{% -\section{Assignments}\label{assignments}} - -\begin{frame}{Assignment: Arduino} -\protect\hypertarget{assignment-arduino}{} - -\begin{itemize} -\tightlist -\item - Hello world on serial console -\item - Blink a led -\item - Read the temperature every second, print to serial console -\item - Print available heap -\end{itemize} - -\end{frame} - \begin{frame}{Assignment: Network play time} \protect\hypertarget{assignment-network-play-time}{} diff --git a/slides/what-is-iot-text.pdf b/slides/what-is-iot-text.pdf index e1c80ad..5f9f0e1 100644 Binary files a/slides/what-is-iot-text.pdf and b/slides/what-is-iot-text.pdf differ -- cgit v1.2.3