105 |
106 |
107 |
--------------------------------------------------------------------------------
/stk500.h:
--------------------------------------------------------------------------------
1 | //**** ATMEL AVR - A P P L I C A T I O N N O T E ************************
2 | //*
3 | //* Title: AVR061 - STK500 Communication Protocol
4 | //* Filename: command.h
5 | //* Version: 1.0
6 | //* Last updated: 09.09.2002
7 | //*
8 | //* Support E-mail: avr@atmel.com
9 | //*
10 | //**************************************************************************
11 |
12 | // *****************[ STK Message constants ]***************************
13 |
14 | #define STK_SIGN_ON_MESSAGE "AVR STK" // Sign on string for Cmnd_STK_GET_SIGN_ON
15 |
16 | // *****************[ STK Response constants ]***************************
17 |
18 | #define Resp_STK_OK 0x10 // ' '
19 | #define Resp_STK_FAILED 0x11 // ' '
20 | #define Resp_STK_UNKNOWN 0x12 // ' '
21 | #define Resp_STK_NODEVICE 0x13 // ' '
22 | #define Resp_STK_INSYNC 0x14 // ' '
23 | #define Resp_STK_NOSYNC 0x15 // ' '
24 |
25 | #define Resp_ADC_CHANNEL_ERROR 0x16 // ' '
26 | #define Resp_ADC_MEASURE_OK 0x17 // ' '
27 | #define Resp_PWM_CHANNEL_ERROR 0x18 // ' '
28 | #define Resp_PWM_ADJUST_OK 0x19 // ' '
29 |
30 | // *****************[ STK Special constants ]***************************
31 |
32 | #define Sync_CRC_EOP 0x20 // 'SPACE'
33 |
34 | // *****************[ STK Command constants ]***************************
35 |
36 | #define Cmnd_STK_GET_SYNC 0x30 // ' '
37 | #define Cmnd_STK_GET_SIGN_ON 0x31 // ' '
38 |
39 | #define Cmnd_STK_SET_PARAMETER 0x40 // ' '
40 | #define Cmnd_STK_GET_PARAMETER 0x41 // ' '
41 | #define Cmnd_STK_SET_DEVICE 0x42 // ' '
42 | #define Cmnd_STK_SET_DEVICE_EXT 0x45 // ' '
43 |
44 | #define Cmnd_STK_ENTER_PROGMODE 0x50 // ' '
45 | #define Cmnd_STK_LEAVE_PROGMODE 0x51 // ' '
46 | #define Cmnd_STK_CHIP_ERASE 0x52 // ' '
47 | #define Cmnd_STK_CHECK_AUTOINC 0x53 // ' '
48 | #define Cmnd_STK_LOAD_ADDRESS 0x55 // ' '
49 | #define Cmnd_STK_UNIVERSAL 0x56 // ' '
50 | #define Cmnd_STK_UNIVERSAL_MULTI 0x57 // ' '
51 |
52 | #define Cmnd_STK_PROG_FLASH 0x60 // ' '
53 | #define Cmnd_STK_PROG_DATA 0x61 // ' '
54 | #define Cmnd_STK_PROG_FUSE 0x62 // ' '
55 | #define Cmnd_STK_PROG_LOCK 0x63 // ' '
56 | #define Cmnd_STK_PROG_PAGE 0x64 // ' '
57 | #define Cmnd_STK_PROG_FUSE_EXT 0x65 // ' '
58 |
59 | #define Cmnd_STK_READ_FLASH 0x70 // ' '
60 | #define Cmnd_STK_READ_DATA 0x71 // ' '
61 | #define Cmnd_STK_READ_FUSE 0x72 // ' '
62 | #define Cmnd_STK_READ_LOCK 0x73 // ' '
63 | #define Cmnd_STK_READ_PAGE 0x74 // ' '
64 | #define Cmnd_STK_READ_SIGN 0x75 // ' '
65 | #define Cmnd_STK_READ_OSCCAL 0x76 // ' '
66 | #define Cmnd_STK_READ_FUSE_EXT 0x77 // ' '
67 | #define Cmnd_STK_READ_OSCCAL_EXT 0x78 // ' '
68 |
69 | // *****************[ STK Parameter constants ]***************************
70 |
71 | #define Parm_STK_HW_VER 0x80 // ' ' - R
72 | #define Parm_STK_SW_MAJOR 0x81 // ' ' - R
73 | #define Parm_STK_SW_MINOR 0x82 // ' ' - R
74 | #define Parm_STK_LEDS 0x83 // ' ' - R/W
75 | #define Parm_STK_VTARGET 0x84 // ' ' - R/W
76 | #define Parm_STK_VADJUST 0x85 // ' ' - R/W
77 | #define Parm_STK_OSC_PSCALE 0x86 // ' ' - R/W
78 | #define Parm_STK_OSC_CMATCH 0x87 // ' ' - R/W
79 | #define Parm_STK_RESET_DURATION 0x88 // ' ' - R/W
80 | #define Parm_STK_SCK_DURATION 0x89 // ' ' - R/W
81 |
82 | #define Parm_STK_BUFSIZEL 0x90 // ' ' - R/W, Range {0..255}
83 | #define Parm_STK_BUFSIZEH 0x91 // ' ' - R/W, Range {0..255}
84 | #define Parm_STK_DEVICE 0x92 // ' ' - R/W, Range {0..255}
85 | #define Parm_STK_PROGMODE 0x93 // ' ' - 'P' or 'S'
86 | #define Parm_STK_PARAMODE 0x94 // ' ' - TRUE or FALSE
87 | #define Parm_STK_POLLING 0x95 // ' ' - TRUE or FALSE
88 | #define Parm_STK_SELFTIMED 0x96 // ' ' - TRUE or FALSE
89 | #define Param_STK500_TOPCARD_DETECT 0x98 // ' ' - Detect top-card attached
90 |
91 | // *****************[ STK status bit definitions ]***************************
92 |
93 | #define Stat_STK_INSYNC 0x01 // INSYNC status bit, '1' - INSYNC
94 | #define Stat_STK_PROGMODE 0x02 // Programming mode, '1' - PROGMODE
95 | #define Stat_STK_STANDALONE 0x04 // Standalone mode, '1' - SM mode
96 | #define Stat_STK_RESET 0x08 // RESET button, '1' - Pushed
97 | #define Stat_STK_PROGRAM 0x10 // Program button, ' 1' - Pushed
98 | #define Stat_STK_LEDG 0x20 // Green LED status, '1' - Lit
99 | #define Stat_STK_LEDR 0x40 // Red LED status, '1' - Lit
100 | #define Stat_STK_LEDBLINK 0x80 // LED blink ON/OFF, '1' - Blink
101 |
102 |
103 | // *****************************[ End Of COMMAND.H ]**************************
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # esp8266 Uno Wifi
2 |
3 | This project runs on esp8266 and provides serial bridge services for uno,The first time you need to use the serial port to upload the sketch to esp8266.Then you can use WIFI SerialPort like using USB
4 |
5 | you can:
6 |
7 | + OTA(over the air) upload new sketch to esp8266
8 | + OTA(over the air) upload new sketch to UNO(without manual reset uno)
9 | + Access the serial port of the uno through web browser
10 | + Access uno serial port via TCP
11 | + Configuring access points and wifi using web browser
12 | + TCP channel(oseppBlock) and up to five WebSocket connections(Browser) receive data at the same time from the uno serial port
13 | + Control your robot using a web browser on any device anywhere
14 |
15 | 
16 |
17 | ESP8266 will have two IP addresses,depending on your network connection
18 | If your esp8266 is connected to the router and your device is also connected to the router, then you should access it with the IP address assigned by the router to ESP8266. The format of the IP address is usually 192.168.1.?
19 | If your device accesses ESP8266's WIFI access point then you should use 192.168.4.1 to access it
20 | No matter how you connect, they are all equivalent
21 |
22 | 
23 |
24 |
25 |
26 |
27 |
28 | - [esp8266 Uno Wifi](#esp8266-uno-wifi)
29 | - [1. setup esp8266](#1-setup-esp8266)
30 | - [2. setup Access point & connect to your router](#2-setup-access-point--connect-to-your-router)
31 | - [3. Connect esp8266 to uno](#3-connect-esp8266-to-uno)
32 | - [4. upload sketch to uno via OTA](#4-upload-sketch-to-uno-via-ota)
33 | - [5. upload sketch to esp8266(esp-01s) via OTA](#5-upload-sketch-to-esp8266esp-01s-via-ota)
34 | - [6. Web browser Serial monitor](#6-web-browser-serial-monitor)
35 | - [7. Using arduinoOTA and TCP Serial Monitors in oseppBlock](#7-using-arduinoota-and-tcp-serial-monitors-in-oseppblock)
36 | - [8. Virtual Joystick](#8-virtual-joystick)
37 |
38 |
39 |
40 | ---
41 |
42 | ## 1. setup esp8266
43 |
44 | + Load sketch **EspUnoWifi.ino** using arduino IDE
45 | + [install ESP8266 into your Arduino IDE](http://esp8266.github.io/Arduino/versions/2.0.0/doc/installing.html)
46 | + install[arduinoWebSockets](https://github.com/Links2004/arduinoWebSockets)Arduino Libraries
47 | Sketch -> Include Library -> Manage Libraries
48 | Search websockets and install **WebSockets by Markus Sattler**
49 | *[How to Install a Library](https://www.arduino.cc/en/guide/libraries)*
50 | + Set your router SSID and password in the sketch(*You can skip this step and then setting it in web browser*)
51 | `const char default_router_ssid[] = "YourRouterSSID";//your router ssid`
52 | `const char default_router_pswd[] = "YourRouterPassword";//your router password`
53 | + upload this project to ESP8266 via Serial port
54 | You need a UNO, don't switch on the power first,Connect them like this
55 |
56 | | ESP-01S | UNO |
57 | | :-----: | :---------: |
58 | | RX | RX |
59 | | TX | TX |
60 | | IO0 | GND |
61 | | GND | GND |
62 | | 3V3 | 3V3 |
63 | | | Reset-->GND |
64 |
65 | Now connect UNO and computer via USB.Since we connect UNO's Reset to GND, UNO is now bypassed.Esp-01's IO0 is connected to GND, so ESP01 enters the bootloader,use arduino IDE to upload the program will enter esp-01
66 | + Tool->Board->**Generic ESP8266 Module**
67 | + Tool->Flash Size->**1M(no SPIFFS)**
68 | + Tool->Port->**your serial com port**
69 | + click **upload**
70 | + If you fail, it may be that esp8266 does not enter bootloader mode, unplug the 3V3 from Uno, inserts it again after about 3 seconds, and then **upload** again
71 |
72 | ## 2. setup Access point & connect to your router
73 |
74 | If you have already set the router SSID and password in step 1, you can skip this step
75 |
76 | + Connect the power supply for ESP8266(just 3v3,gnd,rx,tx)
77 | + Log in to the access point **WIFI-ESP-SERIAL-xxxxxx** with any wifi-capable device and use the password **oseppesp**
78 | + Use a web browser to open URL:
79 | + Select **your router access point** at `WIFI SSID` and fill your router password in `WIFI Password` and chick nearby **update** button,esp8266 will restart so you will lose wifi connection,Wait a moment then re-Connect to the access point open URL: again.For unknown reasons, usually you will see the IP address is 0.0.0.0, then you need to manually reset the ESP8266 to make it connect to the route correctly...
80 | + If ESP8266 has successfully connected to your router then it will show an IP address at the bottom of the page.
81 | + Set a new esp8266 access point name and password for security,Fill in **AP SSID**, and **AP PSWD**,Password is at least 8 letters or it will not work,Click nearby **update** button.
82 | 
83 |
84 | ## 3. Connect esp8266 to uno
85 |
86 | | ESP-01s | uno |
87 | | ------: | ----- |
88 | | RX | TX |
89 | | TX | RX |
90 | | 3V3 | 3v3 |
91 | | GND | GND |
92 | | IO2 | reset |
93 |
94 | | Nodemcu | uno |
95 | | ------: | ----- |
96 | | RX | TX |
97 | | TX | RX |
98 | | VIN | 5V |
99 | | GND | GND |
100 | | D4 | reset |
101 |
102 | ## 4. upload sketch to uno via OTA
103 |
104 | + Tool->Board->**Arduino Uno WiFi**
105 | *You can't use `Uno WiFi` features just to be able to use arduino OTA*
106 | + Tool->Port->Network ports->**your network device**
107 | + click **upload**
108 | + If you see the following text, the upload was successful
109 | > Resetting the board
110 | Waiting for the upload to start
111 | OSEPP Esp8266 for UnoOTA, SYNC OK!184705
112 | Uploading the sketch
113 | Upload done! Flash used:2806 bytes
114 | Sketch uploaded successfully
115 | Resetting the board
116 | 
117 |
118 | ## 5. upload sketch to esp8266(esp-01s) via OTA
119 |
120 | + Tool->Board->**Generic ESP8266 Module**
121 | + Tool->Flash Size->**1M(no SPIFFS)**
122 | + Tool->Port->Network ports->**network device**
123 | + click **upload**
124 | + 
125 |
126 | ## 6. Web browser Serial monitor
127 |
128 | + Open the URL in web browser:`http://[esp8266 ip you see in port list or 192.168.4.1]?baudrate=115200`
129 | *note:You can specify the baud rate of the serial port by appending **?baudrate=nnnnn** to any url.*
130 | + Upload a sketch with serial output to UNO,[according to #4](#4-upload-sketch-to-uno-via-ota)
131 |
132 | ```arduino
133 | void setup() {
134 | // put your setup code here, to run once:
135 | Serial.begin(115200);
136 | }
137 |
138 | void loop() {
139 | // put your main code here, to run repeatedly:
140 | Serial.println(millis());
141 | delay(1000);
142 | }
143 | ```
144 |
145 | + You will see the serial data displayed in the web browser
146 | + You can try to send msg to uno, reset uno
147 | + 
148 |
149 | ## 7. Using arduinoOTA and TCP Serial Monitors in oseppBlock
150 |
151 | + Select the network device in the port list, or fill in the IP address.
152 | + Click on the upload icon to upload the sketch to UNO via OTA
153 | + Click on the connection icon, you can see the following window, the same as the USB connection
154 |
155 |
156 | ## 8. Virtual Joystick
157 |
158 | + Open `http://[esp8266 ip address]/joy` in web browser *phone, ipad, computer, any browser supporting HTML5*
159 | + Add `?baudrate=nnnnnn` at the end of the URL to set the baud rate you want like `http://192.168.0.88/joy?baudrate=115200`
160 | + Use mouse, or touch the screen with your finger and drag, support multi-touch (2 points)
161 | + In oseppBlock, you can use Block
162 | **Remote [Joy Channel]**
163 | **Remote Timeout[*]**
164 | To receive data and processing
165 | + In the Arduino IDE, you can use our OseppRemote library
166 |
167 | 
168 | 
169 |
--------------------------------------------------------------------------------
/data/serial.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Serial Monitor
9 |
10 |
118 |
119 |
120 |
129 |