Week 13 - Networking
Notes
- Purposes: Parallelism(Difference micro-controller have different specific job)
- Most important: RS-232 (Serial)
- I2C (or TWI)
- SPI (used in program ISP/ read microSD)
-
USB VUSB(1.1 slow), Lufa (usb driver)
- 802.11 Wifi
- RN4871
- ESP8266
- ESP32 wifi bluetooth
Links
RS232 Serial Bus:
At the beginning, only node 1 sent back the ‘node 1’, and the node 0 flash sent back some strange characters. After some debugging, it turns out the node 1 will need longer bit_delay.
For 9600 baut rate: the standard delay time is 1/9600 = 104 us. In practice, it’s tolerent from [101, 112] for ATtiny45.
The keyboard will input 0/1, and the two chips will flash the light when they receive the character, and the corresponding chip will flash twice and send the ‘node x’ back.
ESP8266
First, I tested communicate using my computer using pyserial miniterm:
python -m serial.tools.miniterm /dev/tty.usbserial-AC01YC2I 9600
And I tested TCP client and TCP server.
Tested command:
join access point
station mode
AT+CWMODE=1\r\n
join access point
AT+CWJAP="EECS-MTL-RLE",""\r\n
list IP address
AT+CIFSR\r\n
TCP client: Get web page
AT+CIPSTART=1,"TCP","18.62.27.58",8000
AT+CIPSEND=1,38
GET / HTTP/1.1
HOST: 18.62.27.58
TCP server: send Web page
multiple connection mode
AT+CIPMUX=1\r\n
start TCP server, on port 80
AT+CIPSERVER=1,80\r\n
send Web page reply on connection 0, with character count
AT+CIPSEND=0,44\r\n
HTTP/1.1 200 OK\r\n
\r\n
<html><body>hello world\r\n
Get web page from PC:
Send web page, using arduino to pass command through with two serial communication:
The eagle file for ESP8266 in the fab lab can be found here 12Q.
Questions
How to debug when the wifi module is talking with MCU in serial?
Ben suggests to use FTDI to USB and listen only to RX channel.
Can ATtiny44 work on 115200 baudrate?
It can reach 115200 (from echo hello world example).
Also, ESP8266 could change the baudrate by command:
AT+UART_DEF=9600,8,1,0,0
or
AT+UART_DEF=115200,8,1,0,0
Can AVR have two serial communications?
Yes. There’s hardware serial (Universal Serial Interface: MISO & MOSI), and can also implement software serial.
Design the board for ATmega328P
ATmega328P AU Eagle Library.
Code for SerialPassThrough
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);// RX, TX
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
}
void loop() {
if (Serial.available()) { // If anything comes in Serial (USB)
Serial1.write(Serial.read()); // read it and send it out Serial1
}
if (Serial1.available()) { // If anything comes in Serial1
Serial.write(Serial1.read()); // read it and send it out Serial (USB)
}
}