Networking & Communications
Read a sensor
This week's mission is to design and build a wired or wireless network connecting at least two processors.
At the very bottom of the network stack is the physical layer. This is where electrical signals or light pulses or radio waves actually transmit information from place to place.
The next layer up is the link layer. This layer covers communication with devices that share a physical communications medium. In a typical home network, this is how your computer talks to your home "router."
The third layer is the network layer. In the majority of cases, this is dominated by Internet Protocol (IP). This is where the magic of the Internet happens, and you get to talk to a computer halfway around the world, without needing to know where it is.
The transport layer takes care of where to deliver your message to, usually with port numbers. The two most popular transport layer protocols are TCP and UDP.
So we've connected your browser to the web server software on the other end, but how does the server know what page you want? How can you post a question or an answer? These are things that application-layer protocols handle. For web traffic, this is the HyperText Transfer Protocol (HTTP). There are thousands of application-layer protocols: SMTP, IMAP, and POP3 for email; XMPP, IRC, ICQ for chat; Telnet, SSH, RDP for remote administration; etc.
The term "TCP/IP" stands for Transmission Control Protocol / Internet Protocol and refers to a number of protocols. The "IP" part of the term, which stands for Internet Protocol, is used by TCP and UDP, to transport them from one network to another. Think of IP as a sort of high-way that allows other protocols to get on and find their way to other computers. TCP and UDP are the "trucks" on the highway, and the "load" they are carrying are protocols such as HTTP, File Transfer Protocol (FTP) and more. TCP and UDP are transport protocols used by protocols such as FTP, HTTP, and SMTP.
TCP or UDP?
For information that needs reliability, sequence transmission and data integrity -- TCP is the transport protocol to use. For data that require real-time transmission with low overhead and less processing (eg. live broadcasts and online games) -- UDP is the right choice.
UDP: fast, simple, send all together
TCP: reliable, bigger, send separately
HTTP: port 80 of TCP
MQTT: IoT, M2M, TCP/IP port 1883 is reserved for use with MQTT.
First try with Adafruit's ESP8266
I want to thoroughly understand how network works first before getting stucked by hardware problems, so I tried it on Adafruit's board first.
Only one ADC pin to connect to ananlog sensors
The Serial Peripheral Interface bus (SPI) is a synchronous serial communication interface specification used for short distance communication, primarily in embedded systems.
The SPI bus specifies four logic signals:
* SCLK: Serial Clock (output from master).
* MOSI: Master Output Slave Input, or Master Out Slave In (data output from master).
* MISO: Master Input Slave Output, or Master In Slave Out (data output from slave).
* SS: Slave Select (often active low, output from master).
Bit banging is a technique for serial communications using software instead of dedicated hardware. The implementation in software can be a solution when specific hardware support is not available or requires a more expensive microcontroller.
General Purpose Input/Output Interface (GPIO): When the I/O is not powered by external circuits, the I/O will remain to be the state that it was used the last time.
Unity talk to ESP through wifi
ESP as server, Unity as a client
Add another client from another ESP
Have fun with wifi camera - Cydorg
So I tied a wifi camera to Mr. Corbu, to experience the world from a dog's eyes.
A lot of boring legs and feet and wires from his angle...
Shock sensor control Unity Game