Skip to content
Snippets Groups Projects
Commit 94305dba authored by Adrián Torres's avatar Adrián Torres
Browse files

adrianino_bluetooth

parent b671880b
No related branches found
No related tags found
No related merge requests found
Pipeline #233191 passed
......@@ -113,6 +113,12 @@
<li><a href="#motor" class="button">DC Motor</a></li>
<li><a href="#servo" class="button">Servo motor</a></li>
</ul>
<ul class="actions">
<li><a href="#networking" class="button primary">Networking</a></li>
<li><a href="#hc05" class="button">Bluetooth - HC05</a></li> </ul>
<ul class="actions">
<li><a href="#conclusions" class="button primary">Conclusions</a></li>
<li><a href="#pcb" class="button primary">PCB Prototype</a></li>
......@@ -1268,7 +1274,7 @@ void loop(void)
<li><b>Programming</b></li>
<p>Here you will find the programming to use an analog sensor such as the NTC sensor. Here you can find the Arduino and Processing files to download. Below you can see a video of how it works.</p>
<p>Here you will find the programming to use a Step Response sensor. Here you can find the Arduino and Processing files to download. Below you can see a video of how it works.</p>
<p><a href="assignments/adrianino/step_response_txrx/step_response_txrx.ino"><b>- Arduino Step Responde TX/RX</b></a>
<p><a href="assignments/adrianino/step_response_processing/step_response.pde"><b>- Processing Step Response TX/RX</b></a></p>
......@@ -1759,7 +1765,7 @@ void loop() {
<p>In my case the number is <b>0x3C.</b></p>
<p>Once I know what the OLED number is, I go on to test Hello_OLED program. You will need to install the <b>Adafruit SSD1306</b> and <b>GFX</b> libraries. If you need more information you can follow the <a href="https://randomnerdtutorials.com/guide-for-oled-display-with-arduino/"><b>following tutorial.</b></a> Below you can see a video of how it works. <b>Recommendation:</b> Download the program from the link, in the text the symbols <b><></b> of the libraries are missing.</p>
<p>Once I know what the OLED number is, I go on to test Hello_OLED program. You will need to install the <b>Adafruit SSD1306</b> and <b>GFX</b> libraries. If you need more information you can follow the <a href="https://randomnerdtutorials.com/guide-for-oled-display-with-arduino/"><b>following tutorial.</b></a> <a href="https://lastminuteengineers.com/oled-display-arduino-tutorial/"><b>Another tutorial.</b></a> Below you can see a video of how it works. <b>Recommendation:</b> Download the program from the link, in the text the symbols <b><></b> of the libraries are missing.</p>
<p><a href="assignments/adrianino/hello_oled/hello_oled.ino"> <b>- Arduino Hello_OLED</b></a></p>
......@@ -1923,7 +1929,46 @@ void loop() {
<p><video controls width="100%"; max-width="800"><source src="images/adrianino/servo.mp4" type="video/mp4"></video></p>
<h1><a id="networking"></a>Networking and Communicaions</h1>
<h2><a id="hc05"></a>Bluetooth - HC05</h2>
<p>Through an <a href="https://www.amazon.es/05-Bluetooth-transceptor-06-inal%C3%A1mbrica-Transceiver-Comunicaci%C3%B3n/dp/B0722MD4FY/ref=sr_1_14?__mk_es_ES=%C3%85M%C3%85%C5%BD%C3%95%C3%91&crid=3KNYHONMHC266&dchild=1&keywords=arduino+hc05&qid=1622389252&sprefix=arduino+hc%2Caps%2C172&sr=8-14"><b>HC-05 module</b></a> we can connect the Adrianino by Bluetooth and be able to send and receive data through a smartphone or communicate with another board. To use the HC-05 module we will only need <b>VCC(5V)</b>, <b>GND</b>, <b>TX</b> and <b>RX.</b> The connection will be made through the FTDI pins, through which we will power the module, as well as communicate with the TX and RX pins.</p>
<span class="image main"><img src="images/adrianino/a_44.jpg" alt="" /></span>
<p>Before connecting the module directly to the Adrianino we must check a list of operations. The HC-05 modules can work as masters or slaves, have different speeds, name or even password. To do this, using an FTDI and the Arduino Serial Monitor, we will verify the following commands that you can find in this <a href="https://s3-sa-east-1.amazonaws.com/robocore-lojavirtual/709/HC-05_ATCommandSet.pdf"><b>document.</b></a></p>
<p><img src="images/adrianino/a_45.png" width="60%"; max-width="700" /></p>
<p>The HC-05 modules have two operating modes AT1 (normal mode. Led flashing fast) and AT2 (programming mode. Led flashing slow). By default, when connecting the FTDI and the module to the computer, the AT1 mode works. If, before connecting everything, we keep the small button pressed, we will enter AT2 mode.</p>
<p>We will open the Arduino serial monitor and configure the bottom part, we must choose <b>“Both NL and CR”</b> and the speed <b>“38400 baud”</b> (the speed to communicate in AT MODE 2).To check that the module works, we will write in the AT terminal and it will answer us OK. If not, we must check the above. You can find more information in this <a href="https://naylampmechatronics.com/blog/24_configuracion-del-modulo-bluetooth-hc-05-usando-comandos-at.html"><b>tutorial.</b></a></p>
<p>If the module is new from the factory and we type the following instructions, the following will come out:
<li><b>AT+NAME</b> -> Name
<li><b>AT+PSWD</b> -> Password
<li><b>AT+UART</b> -> Communication speed.</p>
<p><img src="images/adrianino/a_46.jpg" width="60%"; max-width="700" /></p>
<p>It is important to know these three data, because later we will use them. Above all the speed, it will be at the speed that the module communicates with the Adrianino.</p>
<p>We will load the following program by which we will send values from 0 to 9 and we will blink the LED that is on the PA1 pin (Arduino pin 8). <b>Important</b> not to load the program with the HC-05 module connected. Download the program from the link.</p>
<p><a href="assignments/adrianino/bluetooth/bluetooth.ino"><b>- Arduino Bluetooth</b></a>
<p>Once everything is configured, we will connect the module to the Adrianino as in the image. VCC with VCC, GND with GND, TX with TX and RX with RX.</p>
<p><img src="images/adrianino/a_47.jpg" width="70%"; max-width="700" /></p>
<p>I will power Adrianino through the 9V battery. Using a smartphone (it only works with Android) I download the <a href="https://play.google.com/store/apps/details?id=project.bluetoothterminal"><b>MIT App Inventor.</b></a>Bluetooth Terminal HC-05 application. This application allows us to scan the devices and we can send simple information. If we want to create a specific application we can use the <a href="week12.html"><b>MIT App Inventor.</b></a></p>
<p>Here you can see a video where I connect to the HC-05 bluetooth module and send values to the Adrianino, responding to the LED.</p>
<p><video controls width="100%"; max-width="800"><source src="images/adrianino/bluetooth.mp4" type="video/mp4"></video></p>
<h1><a id="conclusions"></a>Conclusions</h1>
<p>My idea of creating Adrianino has been so that anyone who does the Fab Academy has no fear of electronics. It has the evolution of the UPDI + VCC, which avoids the need to have an FTDI connected to power the board. It is a <b>modular board</b> that everyone can test the different inputs and outputs that appear in the following photo.</p>
......
//Fab Academy 2021 - Fab Lab León
//Bluetooth
//Adrianino
//ATtiny1614
const int led = 8; // LED pin
int option;
void setup(){
Serial.begin(9600); //speed of the communications
pinMode(led, OUTPUT);
}
void loop(){
//if there is pending information
if (Serial.available()>0){
//let's read the option
char option = Serial.read();
//if the option is between '1' and '9'
if (option >= '1' && option <= '9')
{
//we subtract the value '0' to obtain the number sent
option -= '0';
for(int i=0;i<option;i++){
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(200);
}
}
}
}
//tx_rx03 Robert Hart Mar 2019.
//https://roberthart56.github.io/SCFAB/SC_lab/Sensors/tx_rx_sensors/index.html
//Modified by Adrián Torres Omaña
//Fab Academy 2021
//Step Response TX, RX
//SAMDino
//SAMD11C
// Program to use transmit-receive across space between two conductors.
// One conductor attached to digital pin, another to analog pin.
//
// This program has a function "tx_rx() which returns the value in a long integer.
//
// Optionally, two resistors (1 MOhm or greater) can be placed between 5V and GND, with
// the signal connected between them so that the steady-state voltage is 2.5 Volts.
//
// Signal varies with electric field coupling between conductors, and can
// be used to measure many things related to position, overlap, and intervening material
// between the two conductors.
//
long result; //variable for the result of the tx_rx measurement.
int analog_pin = 5; // PA05 of the SAMD11C
int tx_pin = 8; // PA08 of the SAMD11C
void setup() {
pinMode(tx_pin,OUTPUT); //Pin 2 provides the voltage step
Serial.begin(115200);
}
long tx_rx(){ //Function to execute rx_tx algorithm and return a value
//that depends on coupling of two electrodes.
//Value returned is a long integer.
int read_high;
int read_low;
int diff;
long int sum;
int N_samples = 100; //Number of samples to take. Larger number slows it down, but reduces scatter.
sum = 0;
for (int i = 0; i < N_samples; i++){
digitalWrite(tx_pin,HIGH); //Step the voltage high on conductor 1.
read_high = analogRead(analog_pin); //Measure response of conductor 2.
delayMicroseconds(100); //Delay to reach steady state.
digitalWrite(tx_pin,LOW); //Step the voltage to zero on conductor 1.
read_low = analogRead(analog_pin); //Measure response of conductor 2.
diff = read_high - read_low; //desired answer is the difference between high and low.
sum += diff; //Sums up N_samples of these measurements.
}
return sum;
} //End of tx_rx function.
void loop() {
result = tx_rx();
result = map(result, -400, 2000, 0, 1024); //I recommend mapping the values of the two copper plates, it will depend on their size
Serial.println(result);
delay(100);
}
docs/images/adrianino/a_44.jpg

329 KiB

docs/images/adrianino/a_45.png

232 KiB

docs/images/adrianino/a_46.jpg

46.3 KiB

docs/images/adrianino/a_47.jpg

297 KiB

File added
......@@ -86,14 +86,18 @@
<li><a href="#button" class="button">Button</a></li>
<li><a href="#pir" class="button">Pyroelectric</a></li>
<li><a href="#radar" class="button">Doppler radar</a></li>
<li><a href="#ultrasonic" class="button">Ultrasonic sensor</a></li></ul>
<li><a href="#ultrasonic" class="button">Ultrasonic sensor</a></li>
</ul>
<ul class="actions"><li><a href="#hall" class="button">Hall effect</a></li>
<li><a href="#temperature" class="button">Temperature</a></li>
<li><a href="#photo" class="button">Phototransistor</a></li>
<li><a href="#photoir" class="button">Phototransistor IR</a></li>
<li><a href="#photoir" class="button">Phototransistor IR</a></li>
</ul>
<ul class="actions"><li><a href="#step" class="button">Step Response</a></li></ul>
<!--
......@@ -895,11 +899,110 @@ void loop()
}</code></pre>
<p><video controls width="100%"; max-width="800"><source src="images/adrianino/flight.mp4" type="video/mp4"></video></p>
-->
<h2><a id="step"></a>Step Response.</h2>
<p>The step-response is a sensor that is made with two sheets of copper, separated from each other by a porous insulating material. It can be used to calculate the value of force, weight, resistance ... I have followed <a href="https://roberthart56.github.io/SCFAB/SC_lab/Sensors/tx_rx_sensors/index.html"><b>Robert Hart's tutorial</b></a> as well as <a href="http://academy.cba.mit.edu/classes/input_devices/step/hello.txrx.45.mp4"><b>Neil's examples.</b></a></p>
<p>A series of pulses is sent through the TX electrode, which, depending on the material between the two electrodes, allows more or less that series of pulses to pass. In the following graph you can see how it works. The other electrode will be connected between two resistors, one for pull-up and the other for pull-down and to an analog input.</p>
<p><img src="images/adrianino/a_38.jpg" width="70%"; max-width="700" /></p>
<li><b>Connection and schematic</b></li>
<p>In this case, being a component without a module, I create my own. I design and manufacture a small board where I solder two 1M resistors and with flat connectors where there is no room for errors when connecting it. I use the analog input from the SAMD11C PA05 (Arduino pin 5) for the RX and a digital output from the SAMD11C PA08 (Arduino pin 8). Then with a connector there are two cables that connect the two electrodes (<a href="https://www.3m.com/3M/en_US/company-us/all-3m-products/~/3M-Conductive-Copper-Foil-Tape-3313/?N=5002385+3293242553&rt=rud"><b>3M™ Copper Foil Tape</b></a>).</p>
<span class="image main"><img src="images/adrianino/a_39.jpg" alt="" /></span>
<p>Here you can find the design in Eagle and the PNG's to create the board.</p>
<p><a href="assignments/adrianino/step_response_eagle.zip"><b>- Step Response Schematic + Board</b></a>
<p><a href="assignments/adrianino/step_response_png.zip"><b>- Step Response traces</b></a></p>
<p><img src="images/adrianino/a_40.png" width="50%"; max-width="700" /></p>
<li><b>Programming</b></li>
<p>Here you will find the programming to use a Step Response sensor. Here you can find the Arduino and Processing files to download. Below you can see a video of how it works.</p>
<p><a href="assignments/adrianino/step_response_txrx/step_response_txrx.ino"><b>- Arduino Step Responde TX/RX</b></a>
<p><a href="assignments/adrianino/step_response_processing/step_response.pde"><b>- Processing Step Response TX/RX</b></a></p>
<pre><code>//tx_rx03 Robert Hart Mar 2019.
//https://roberthart56.github.io/SCFAB/SC_lab/Sensors/tx_rx_sensors/index.html
//Modified by Adrián Torres Omaña
//Fab Academy 2021
//Step Response TX, RX
//SAMDino
//SAMD11C
// Program to use transmit-receive across space between two conductors.
// One conductor attached to digital pin, another to analog pin.
//
// This program has a function "tx_rx() which returns the value in a long integer.
//
// Optionally, two resistors (1 MOhm or greater) can be placed between 5V and GND, with
// the signal connected between them so that the steady-state voltage is 2.5 Volts.
//
// Signal varies with electric field coupling between conductors, and can
// be used to measure many things related to position, overlap, and intervening material
// between the two conductors.
//
long result; //variable for the result of the tx_rx measurement.
int analog_pin = 5; // PA05 of the SAMD11C
int tx_pin = 8; // PA08 of the SAMD11C
void setup() {
pinMode(tx_pin,OUTPUT); //Pin 2 provides the voltage step
Serial.begin(115200);
}
long tx_rx(){ //Function to execute rx_tx algorithm and return a value
//that depends on coupling of two electrodes.
//Value returned is a long integer.
int read_high;
int read_low;
int diff;
long int sum;
int N_samples = 100; //Number of samples to take. Larger number slows it down, but reduces scatter.
sum = 0;
for (int i = 0; i < N_samples; i++){
digitalWrite(tx_pin,HIGH); //Step the voltage high on conductor 1.
read_high = analogRead(analog_pin); //Measure response of conductor 2.
delayMicroseconds(100); //Delay to reach steady state.
digitalWrite(tx_pin,LOW); //Step the voltage to zero on conductor 1.
read_low = analogRead(analog_pin); //Measure response of conductor 2.
diff = read_high - read_low; //desired answer is the difference between high and low.
sum += diff; //Sums up N_samples of these measurements.
}
return sum;
} //End of tx_rx function.
void loop() {
result = tx_rx();
result = map(result, -400, 2000, 0, 1024); //I recommend mapping the values of the two copper plates, it will depend on their size
Serial.println(result);
delay(100);
}</code></pre>
<p>This first video you can see how the two electrodes work with several sheets as intermediate material.</p>
<p><video controls width="100%"; max-width="800"><source src="images/adrianino/step1.mp4" type="video/mp4"></video></p>
<p>In this second video you can see how it works with a sponge as an intermediate material.</p>
<p><video controls width="100%"; max-width="800"><source src="images/adrianino/step2.mp4" type="video/mp4"></video></p>
-->
......
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