Skip to content
Snippets Groups Projects
Commit d80a7e6f authored by yuichitamiya's avatar yuichitamiya
Browse files

add week13 and tips

parent 41bcdbf7
No related branches found
No related tags found
No related merge requests found
Pipeline #300070 passed
Showing
with 995 additions and 42 deletions
docs/Instruction/images/USB-D11C-serial-TH/hello.D11C.serial.5V.1.1.png

26.7 KiB

docs/Instruction/images/USB-D11C-serial-TH/hello.D11C.serial.5V.save-0ohm.traces.png

35.2 KiB

docs/Instruction/images/esp32-cam/Arduino_esp32.png

160 KiB

docs/Instruction/images/esp32-cam/arduino_serial_monitor.png

138 KiB

docs/Instruction/images/esp32-cam/arduino_setting.png

652 KiB

docs/Instruction/images/esp32-cam/esp32-cam_setup10-1.png

98.6 KiB

docs/Instruction/images/esp32-cam/hello.D11C.serial.5V.1.1.png

26.7 KiB

docs/Instruction/images/esp32-cam/image-2.png

6.03 KiB

docs/Instruction/images/i2c_oled/arduino_i2c_address_foung_.png

93.9 KiB

docs/Instruction/images/i2c_oled/image2cpp_1.png

172 KiB

docs/Instruction/images/i2c_oled/image2cpp_2.png

271 KiB

docs/Instruction/images/i2c_oled/oled_show.jpg

469 KiB

docs/Instruction/images/week13/I2C-communication-protocol-ESP32.png

155 KiB

...@@ -15,11 +15,27 @@ ...@@ -15,11 +15,27 @@
## PNGs ## PNGs
treces|holes|interior|holes + interior ### Original + holes
board|traces|interior|holes
:--:|:--:|:--:|:--:
![](../images/USB-D11C-serial-TH/hello.D11C.serial.5V.1.1.png)|![](../images/USB-D11C-serial-TH/hello.D11C.serial.5V.1.1.traces.png)|![](../images/USB-D11C-serial-TH/hello.D11C.serial.5V.1.1.interior.png)|![](../images/USB-D11C-serial-TH/hello.D11C.serial.5V.1.1.holes.png)
### Save 0ohm resistor
traces|holes|interior|holes + interior
:--:|:---:|:--:|:--: :--:|:---:|:--:|:--:
![](../images/USB-D11C-serial-TH/hello.D11C.serial.5V.1.1.traces.png)|![](../images/USB-D11C-serial-TH/hello.D11C.serial.5V.1.1.holes.png) |![](../images/USB-D11C-serial-TH/hello.D11C.serial.5V.1.1.interior.png)|![](../images/USB-D11C-serial-TH/USB-D11C-serial_holes_outline.png) ![](../images/USB-D11C-serial-TH/hello.D11C.serial.5V.save-0ohm.traces.png)| ![](../images/USB-D11C-serial-TH/hello.D11C.serial.5V.1.1.holes.png)|![](../images/USB-D11C-serial-TH/hello.D11C.serial.5V.1.1.interior.png)|![](../images/USB-D11C-serial-TH/USB-D11C-serial_holes_outline.png)
Download [CDR](../images/USB-D11C-serial-TH/USB-D11C-serial_TH.cdr) Download [CDR](../images/USB-D11C-serial-TH/USB-D11C-serial_TH.cdr)
## milled
### Original + holes
![](../images/USB-D11C-serial-TH/board_milled.jpg){width=200} ![](../images/USB-D11C-serial-TH/board_milled.jpg){width=200}
### Save 0ohm resistor
comming soon
# ESP32-CAM to Switch both
## Setup ESP-32 CAM Programming Environment
Ref. [ESP32-CAM_JP](https://jorublog.site/esp32-cam-setup/)
### Additional Boards manager URLs:
```
https://dl.espressif.com/dl/package_esp32_index.json
```
### Boards Manager
```
ESP32
```
![](../images/esp32-cam/Arduino_esp32.png)
### Setting
![](../images/esp32-cam/arduino_setting.png)
### Connection
USB-Serial|ESP32-CAM
-- |---
RX |UOT
TX |UOR
VCC |5V
GND |GND
|IO0 to GND (When Programming)
![](../images/esp32-cam/hello.D11C.serial.5V.1.1.png){width=300} | ![](../images/esp32-cam/esp32-cam_setup10-1.png)
!!! Note
**Select Bootloader Mode**
**GPIO0**
The ESP32 will enter the serial bootloader when GPIO0 is held low on reset. Otherwise it will run the program in flash.
GPIO0 Input| Mode
--|--
Low/GND | ROM serial bootloader for esptool
High/VCC|Normal execution mode
GPIO0 has an internal pullup resistor, so if it is left unconnected then it will pull high.
Ref. [Boot Mode Selection](https://docs.espressif.com/projects/esptool/en/latest/esp32/advanced-topics/boot-mode-selection.html)
### Code
```
void setup()
{
Serial.begin(9600); // 通信速度
}
void loop()
{
Serial.println("Hello, World"); // Hello, Worldを出力
delay(1000); // 1秒待つ
}
```
### Serial Monitor
- **IO0 disconnect to GND**(connect to internal Pull-up to execution mode)
- Push `rest button` on ESP32-CAM
![](../images/esp32-cam/arduino_serial_monitor.png)
## Switch bot
Ref. [ESP32 Swich bot_JP](https://jorublog.site/esp32cam-iot-swichbot/)
### Code
```
//アクセスするときはURLパラメーターの最後に&をつけること!
#include <WiFi.h>
// 使用するWi-Fiとそのパスワードに書き換えてください
const char* ssid = "fablabkannai";
const char* password = "marumie";
// ポート80番を使用
WiFiServer server(80);
// HTTPリクエストを格納する変数
String header;
// 値の設定に使用する変数
String valueString = String(5);
String delay_valueString = String(500);
int pos1 = 0;
int pos2 = 0;
//pin
const int servo_pin = 16;
//サーボモーターの回転角
const int servo_left = 26;
const int servo_center = 75;
const int servo_right = 123;
void setup() {
pinMode(4, OUTPUT);
//ledc setting
ledcSetup(0, 50, 10); // 0ch 50 Hz 10bit resolution
ledcAttachPin(servo_pin, 0); // 15pin, 0ch
//シリアル通信開始
Serial.begin(115200);
//起動時にフラッシュライトを点滅させる
for(int i=0; i<5; i=i+1) {
digitalWrite(4, HIGH);
delay(50);
digitalWrite(4, LOW);
delay(50);
}
// Wi-Fiに接続
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// ローカルIPを表示このIPにスマホなどからアクセスします
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
server.begin();
}
void loop(){
WiFiClient client = server.available(); // Listen for incoming clients
if (client) { // If a new client connects,
Serial.println("New Client."); // print a message out in the serial port
String currentLine = ""; // make a String to hold incoming data from the client
while (client.connected()) { // loop while the client's connected
if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte, then
Serial.write(c); // print it out the serial monitor
header += c;
if (c == '\n') { // if the byte is a newline character
// if the current line is blank, you got two newline characters in a row.
// that's the end of the client HTTP request, so send a response:
if (currentLine.length() == 0) {
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
// and a content-type so the client knows what's coming, then a blank line:
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println("Connection: close");
client.println();
// Display the HTML web page
client.println("<!DOCTYPE html><html>");
client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" http-equiv=\"content-type\" charset=\"utf-8\"><title>ESP32 servo controller</title>");
// CSS to style the on/off buttons
// Feel free to change the background-color and font-size attributes to fit your preferences
client.println("<style>.block{display: inline-block; vertical-align: middle; height: 50px; font-size: 0;}");
client.println(".btn-square-shadow {display: inline-block; width: 300px; height: 50px; text-decoration: none; background: #668ad8; color: #FFF; border-bottom: solid 4px #627295; border-radius: 3px; font-size: 30px;}");
client.println(".btn-square-shadow:active {-webkit-transform: translateY(4px); transform: translateY(4px); box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.2); border-bottom: none;}");
client.println("</style>");
client.println("<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js\"></script>");
// Web Page
client.println("</head><body style='text-align: center;'><h1>ESP32 サーボモーター コントロールパネル</h1>");
//servo slide bar <--------------------------------------------------------------------------------------------------------------------------------------------------------------------ESP32's IP address. To find open serial monitor with 115200bps
client.println("<div class='left block'> <a href='http://192.168.2.111/?angle=50&delay=500&'><button id='entrance_button' class='btn-square-shadow' type='button'>玄関の電気</button></a></div>");
client.println("<div class='right block'><a href='http://192.168.2.111/?angle=100&delay=500&'><button id='room_button' class='btn-square-shadow' type='button'>部屋の電気</button></a></div>");
client.println("</body></html>");
//HTTPリクエストの処理部分
delay_valueString = "500";
pos1 = header.indexOf('=',18);
pos2 = header.indexOf('&',18);
if(pos1!=-1 && pos2!=-1) {
delay_valueString = header.substring(pos1+1, pos2);
Serial.print("pos:");
Serial.println(pos1);
Serial.println(pos2);
} else {
Serial.print("defaultサーボ待機時間:");
Serial.println(delay_valueString.toInt());
}
Serial.print("サーボ待機時間:");
Serial.println(delay_valueString.toInt());
pos1 = header.indexOf('=');
pos2 = header.indexOf('&');
valueString = header.substring(pos1+1, pos2);
Serial.print("URLパラメーター:");
Serial.println(valueString);
if(valueString.toInt()>=26 && valueString.toInt()<=123) {
//サーボモーターを回転
digitalWrite(4, HIGH);
delay(50);
digitalWrite(4, LOW);
ledcWrite(0, servo_center);
delay(delay_valueString.toInt());
ledcWrite(0, valueString.toInt());
delay(delay_valueString.toInt());
ledcWrite(0, servo_center);
// バグ防止
delay(delay_valueString.toInt());
ledcWrite(0, 0);
digitalWrite(4, HIGH);
delay(50);
digitalWrite(4, LOW);
} else {
Serial.println("URLパラメーター エラー!");
}
// HTTPレスポンスの終了
client.println();
// Break out of the while loop
break;
} else {
currentLine = "";
}
} else if (c != '\r') {
currentLine += c;
}
}
}
// Clear the header variable
header = "";
// 接続を切断
client.stop();
Serial.println("Client disconnected.");
Serial.println("");
}
}
```
### Connection
ESP32-CAM|<br />
-- |---
5V |5V (Power+)
GND |GND(Power-)
3V3 |Servo VCC
IO16 |Servo signal
GND |Servo GND
### How to use
#### Direct switch
Open in browser
```
http://192.168.2.111/?angle=50&delay=500&
```
- 192.168.2.111: loacal IP address of ESP32-CAM in Arduio Sketch
- angle : servo rotate degree (23-123)
- delay: set delay when servo move back
#### Switch on screen
```
http://192.168.1.111
```
![](../images/esp32-cam/image-2.png)
This diff is collapsed.
...@@ -61,6 +61,10 @@ ...@@ -61,6 +61,10 @@
## Input devices ## Input devices
- [Step Response / CapacitiveSensor](http://academany.fabcloud.io/fabacademy/2021/labs/kannai/site/instruction/tips/step_response/) - [Step Response / CapacitiveSensor](http://academany.fabcloud.io/fabacademy/2021/labs/kannai/site/instruction/tips/step_response/)
## Networking and Communication
- [ESP32-CAM to switch bot](./tips/esp32-switch.md)
- [Find I2C OLED Address and Display original image](./tips/i2c_oled_address.md)
## Machine Building ## Machine Building
- [Machine Building Parts List](./tips/machine_building_parts_list.md) - [Machine Building Parts List](./tips/machine_building_parts_list.md)
- [DRV8846_Stepperboard](./tips/DRV8846_Stepperboard.md) - [DRV8846_Stepperboard](./tips/DRV8846_Stepperboard.md)
......
# 13. Networking and communications # 13. Networking and communications
This week I worked on defining my final project idea and started to getting used to the documentation process. ## Schedule
## Research - 5/21(Sat) local session 10:00-17:00
- [Applications and Implications](http://academy.cba.mit.edu/classes/applications_implications/index.html)
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
> "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." ## Instructors bootcamp 2023
## Useful links - January: instructor bootcamp @ Waag (+ distributed)
- [Fablab Amsterdam](http://fablab.waag.org/)
- [Jekyll](http://jekyll.org) ## USB-D11C-serial with 1x6 TH Pin and USB-A connector
- [Google](http://google.com)
- [Markdown](https://en.wikipedia.org/wiki/Markdown)
## Code Example [USB-D11C-serial with 1x6 TH Pin and USB-A connector](./tips/USB-D11C-serial-TH.md)
Use the three backticks to separate code.
``` ## Group Assignment
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever > send a message between two projects
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
```
## Gallery ### Assessment
![](../images/sample-photo.jpg) [Assessment](https://fabacademy.org/2022/nueval/embedded_networking_and_communications.html)
## Video > **What does "two projects" mean in the group assignment**
> Answer: You need to send a message between any combination of boards, computers and/or mobile devices. You need to write code that sends or receives the message in question.
### From Vimeo ### Todo
<iframe src="https://player.vimeo.com/video/10048961" width="640" height="480" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> [last year](http://academany.fabcloud.io/fabacademy/2021/labs/kannai/site/group_assignments/week13/#connect-esp-board-with-the-mobile-phone-with-wi-fi-succeeded)
<p><a href="https://vimeo.com/10048961">Sound Waves</a> from <a href="https://vimeo.com/radarboy">George Gally (Radarboy)</a> on <a href="https://vimeo.com">Vimeo</a>.</p>
### From Youtube [ESP32-CAM Switch bot](./tips/esp32-switch.md)
<iframe width="560" height="315" src="https://www.youtube.com/embed/jjNgJFemlC4" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe> ## Individual assignment
## 3D Models > design, build, and connect wired or wireless node(s)
> with network or bus addresses
<div class="sketchfab-embed-wrapper"><iframe width="640" height="480" src="https://sketchfab.com/models/658c8f8a2f3042c3ad7bdedd83f1c915/embed" frameborder="0" allow="autoplay; fullscreen; vr" mozallowfullscreen="true" webkitallowfullscreen="true"></iframe> ### Assessment
<p style="font-size: 13px; font-weight: normal; margin: 5px; color: #4A4A4A;"> [Assessment](https://fabacademy.org/2022/nueval/embedded_networking_and_communications.html)
<a href="https://sketchfab.com/models/658c8f8a2f3042c3ad7bdedd83f1c915?utm_medium=embed&utm_source=website&utm_campaign=share-popup" target="_blank" style="font-weight: bold; color: #1CAAD9;">Dita&#39;s Gown</a>
by <a href="https://sketchfab.com/francisbitontistudio?utm_medium=embed&utm_source=website&utm_campaign=share-popup" target="_blank" style="font-weight: bold; color: #1CAAD9;">Francis Bitonti Studio</a> > **Can we use arduino/commercial boards for networking?**
on <a href="https://sketchfab.com?utm_medium=embed&utm_source=website&utm_campaign=share-popup" target="_blank" style="font-weight: bold; color: #1CAAD9;">Sketchfab</a> > Answer: Yes, provided one of the boards is of your own design and fabrication. Commercial wireless modules can be used provided they are integrated into your own design. You can use a commercial networking module as long as it is integrated in your own design. Note the difference between board and module - those are two different things.
</p>
</div>
### Todo
#### I2C
- I2C = Inter-Integrated Circuit
- IIC(I-I-C)
- I^2C(I-squared-C), I2C(I-two-C)
![](./images/week13/I2C-communication-protocol-ESP32.png)
Ref. [ESP32 I2C Communication: Set Pins, Multiple Bus Interfaces and Peripherals (Arduino IDE)](https://randomnerdtutorials.com/esp32-i2c-communication-arduino-ide/)
#### Pull up resistor
- 10k ohm
|||
|:--:|:--:|
|Output device OLED|Networking I2C Board|
|10k |4.99k |
|![](http://academy.cba.mit.edu/classes/output_devices/OLED/hello.SSD1306.45.png){width=500}|![](http://academy.cba.mit.edu/classes/networking_communications/I2C/hello.I2C.t1614.png){width=500}|
- [OLED sch](https://learn.adafruit.com/assets/93884)
#### Address
Tips: [Find I2C OLED Address and Display original image](./tips/i2c_oled_address.md)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment