1.- App converts an image: pozo_4.jpg to string Base64 by an extension.
The string is sent by Bluetooth HC-06 to Arduino.
Arduino receives the string, converts it into the file pozo_4.txt and saves it in a micro SdCard.
p9L2_Bluetooth_Base64_2.aia (78.7 KB)
- Asterik * for end_of_send
- You can try with pozo_4kB, pozo_20kB and pozo_50kB
- Arduino UNO, BluetoothHC06 module, SdCard reader and microSdCard:
- Micro SdCard Reader search image.
- Code Arduino.
#include <SD.h>
// const int CS = D8; // Para el NodeMcu
const int CS = 4; // Para el Arduino y Wemos ESP32
File miarchivo;
char rx_byte = 0;
void setup() {
Serial.begin(9600);
Serial.println("Iniciando SdCard...");
if (!SD.begin(CS)) {
Serial.println("Error al iniciar.");
return;
}
Serial.println("SdCard iniciada.");
miarchivo = SD.open("pozo_4.txt", FILE_WRITE); // Abre el archivo.
}
void loop() {
if(Serial.available()) {
rx_byte = Serial.read(); // Toma el caracter.
if (rx_byte != '*') {
miarchivo.print(rx_byte); // Guarda caracter.
} else {
miarchivo.close(); // Cierra el archivo.
Serial.println("Grabado.");
}
}
}
Arduino receives rx_byte, saves those bytes in SdCard, file pozo_4.txt
When the asterisk arrives, close file.
- Time to upload:
| Size file .jpg | Size Base64 .txt | Transmission time | |
|---|---|---|---|
| pozo_4.jpg | 3.879 | 5.241 | 9 seconds |
| pozo_20.jpg | 18.192 | 24.576 | 50 seconds |
| pozo_50.jpg | 42.983 | 58.067 | 120 seconds |

