• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » Base64 Encoding on ESP32 Arduino (Base64 for Images)

By Abhishek Ghosh March 12, 2019 6:40 pm Updated on March 12, 2019

Base64 Encoding on ESP32 Arduino (Base64 for Images)

Advertisement

Base64 images are easy to transmit over the network. Base64 encoding of images for CSS is highly discussed on our blog. Base64 is not new to our regular readers but the current application is different. Here is How to Use Base64 Encoding on ESP32 Arduino.

ESP32 lacks sufficient RAM which limits the actual capabillity. You can actually use HTTP POST (like we have shown with IBM Watson IoT Platform) to send data to IBM’s server. IBM IoT also has limit of sending images (you have to use bin instead of JSON/text).

Base64 Encoding on ESP32 Arduino

Original Arduino’s way of Base64 is the below (which many readers at least used for different projects):

Advertisement

---

Vim
1
2
3
4
5
6
7
8
9
10
#include <base64.h>
void setup() {
  Serial.begin(115200);
  String toEncode = "Hello World";
  String encoded = base64::encode(toEncode);
  Serial.println(encoded);
}
void loop() {}

ESP32 Arduino officially has the required library for basic functions around Base64 :

Vim
1
https://github.com/espressif/arduino-esp32/blob/a59eafbc9dfa3ce818c110f996eebf68d755be24/tools/sdk/include/wpa_supplicant/crypto/base64.h

Decoding a Base64 will go like this :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
extern "C" {
#include "crypto/base64.h"
}
void setup() {
  Serial.begin(115200);
  char * toDecode = "paste--base64---code--here";
  size_t outputLength;
  unsigned char * decoded = base64_decode((const unsigned char *)toDecode, strlen(toDecode), &amp;outputLength);
  Serial.print("Length of decoded message: ");
  Serial.println(outputLength);
  Serial.printf("%.*s", outputLength, decoded);
  free(decoded);
}
void loop() {}

Encoding of the phrase Hello World! will be in this way :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
extern "C" {
#include "crypto/base64.h"
}
void setup() {
  Serial.begin(115200);
  char * toEncode = "Hello World";
  size_t outputLength;
  unsigned char * encoded = base64_encode((const unsigned char *)toEncode, strlen(toEncode), &amp;outputLength);
  Serial.print("Length of encoded message: ");
  Serial.println(outputLength);
  Serial.printf("%.*s", outputLength, encoded);
  free(encoded);
}
void loop() {}

One can change ESP32 camera’s input to Base64 in this way :

Vim
1
2
3
4
5
6
7
8
9
10
size_t size = image.size;
const uint8_t* image = image.data;
 
uint8_t *buffer = calloc((size + 2 - ((size + 2) % 3)) / 3 * 4 + 1, sizeof(char));   // <--- equation from internet
size_t buff_size = 0;
int err = mbedtls_base64_encode(buffer, (size + 2 - ((size + 2) % 3)) / 3 * 4 + 1, &buff_size, image, size);
if (err != 0) {
ESP_LOGE(TAG, "error base64 encoding, error %d, buff size: %d", err, buff_size);  
return;
}

I beleive that using other kind of microprocessors with higher RAM is practical if the purpose is sending reasonable size image over web services, email. Camera with ESP32 with IoT works actually pushes it towards the end of capabillity due to hardware restriction. It is not abnormal to get hanged! You can resize image to tiny and send it.

Tagged With base64 for windows , arduino base64 decode esp32 , base64 arduino DECODE IMAGE , arfiomo bade64 omage , arduino mac libraries b64 , arduino encoder image base 64 , arduino crypto base64 , arduino base64 image , arduino base64 encode jpeg , himage converter arduino

This Article Has Been Shared 741 Times!

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Base64 Encoding on ESP32 Arduino (Base64 for Images)

  • ESP32 Arduino with DHT11 Sensor : Connection & Code

    Here is Connection & Working Code for ESP32 Arduino with DHT11 Sensor. We will use Adafruit’s libraries for DHT11 and DH22 Temperature Humidity Modules.

  • ESP32 Arduino Built-in Hall Sensor Code & Theory

    ESP32 has a Hall Effect Sensor near pin 22. Here is ESP32 Arduino Built-in Hall Sensor Code & Theory. Here is something about Hall Effect Sensor as well.

  • ESP32 Relay Control : Shift 3.3V Signal to 5V Signal

    Relay connected to ESP32 may not properly function. There are many ways to shift 3.3V signal to 5V signal. Here is ESP32 Relay Control Guide.

  • Send-Receive Message on PC Over Bluetooth From ESP32 Arduino

    Peoples often seek guides on serial connection over Bluetooth. Here is How to Send-Receive Message on PC Over Bluetooth From ESP32 Arduino.

  • Detect Samsung Smartwatch BLE and Trigger IBM Watson IoT Event

    We can trigger ESP32 to send message to IBM Watson IoT in Presence of a Particular Samsung Galaxy Smartwatch. This involves BLE and WiFi.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • What is an Automatic Ethanol Fireplace February 8, 2023
  • Disadvantages of Cloud-Native Computing February 7, 2023
  • Projector Screen Basics February 6, 2023
  • What is Configuration Management February 5, 2023
  • What is ChatGPT? February 3, 2023

About This Article

Cite this article as: Abhishek Ghosh, "Base64 Encoding on ESP32 Arduino (Base64 for Images)," in The Customize Windows, March 12, 2019, February 8, 2023, https://thecustomizewindows.com/2019/03/base64-encoding-on-esp32-arduino-base64-for-images/.

Source:The Customize Windows, JiMA.in

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT