Found 203 Articles for Arduino

ArduinoJSON: Working with Flash Strings

Yash Sanghvi
Updated on 26-Jul-2021 10:25:29

102 Views

The syntax for deserialization is as follows −deserializeJson(doc, json)where doc is the JSON Document in which you will store the deserialized output, and json is the buffer containing the JSON contents.The good news is that the buffer can be taken directly from the PROGMEM. In other words, if you don't want to store a heavy JSON string into the RAM, you can store it into the program memory or the flash, using the F() macro, and the deserialization will work just fine.ExampleFor example, the following snippet works perfectly fine.StaticJsonDocument doc; DeserializationError error = deserializeJson(doc, F("{\"name\":\"Yash\", \"designation\":\"student\"}") );You can now go ... Read More

ArduinoJSON: Memory Allocation

Yash Sanghvi
Updated on 26-Jul-2021 10:22:28

1K+ Views

You can declare two types of JSON Documents with the ArduinoJson library - StaticJsonDocument and DynamicJsonDocument. Both need the capacity (in bytes) to be specified at the time of declaration.For static docs, the declaration syntax is −StaticJsonDocument doc_name;For example −StaticJsonDocument myDoc;For dynamic docs, the declaration syntax is −DynamicJsonDocument doc_name(capacity);For example, DynamicJsonDocument myDoc(4096); The difference between the two is that static doc allocates memory on the stack. Therefore, it doesn't need to call malloc() and free(), and is therefore faster.Dynamic docs allocate memory in the heap, and therefore, is slightly slower and should be used for larger JSONs, which don't fit in ... Read More

ArduinoJSON: Serialize and Deserialize

Yash Sanghvi
Updated on 26-Jul-2021 10:20:48

5K+ Views

The ArduinoJSON library, as the name suggests, helps you work with JSON objects on Arduino. In order to install it, go to the Library Manager, and search for ArduinoJSON. Install the library by Benoit Blanchon.This is one of the very heavily documented libraries. In fact, it has its own website: https://arduinojson.org/. You can find answers to several questions on this website.In this article, we will look at Serialization (generating a JSON document), and deserialization (parsing a JSON document) using this library.SerializationLet's start with Serialization. It is pretty straightforward. And if you've worked with python, the code will look all the ... Read More

Arduino – base64 encode and decode

Yash Sanghvi
Updated on 26-Jul-2021 10:09:45

4K+ Views

Arduino contains a library that helps with base64 encode and decode. You can download it from the Library Manager. Search for base64, and install the library by Densaugeo.Now, open a new sketch and run the following sample code −#include "base64.hpp" unsigned char normal_text[20] = "Hello World"; unsigned char base64_text[20]; unsigned char decoded_text[20]; void setup() {    // put your setup code here, to run once:    Serial.begin(9600);    Serial.println();    int base64_length = encode_base64(normal_text, 12, base64_text);    Serial.print("Base64 Text: ");Serial.println((char *) base64_text);    Serial.print("Base64 Length: ");Serial.println(base64_length);    int decoded_length = decode_base64(base64_text, decoded_text);    Serial.print("Decoded Text: ");Serial.println((char ... Read More

How to get data of any size from the EEPROM with Arduino?

Yash Sanghvi
Updated on 26-Jul-2021 10:03:34

468 Views

Arduino Uno has 1 kB of EEPROM storage. EEPROM is a type of non-volatile memory, i.e., its contents are preserved even after power-down. Therefore, it can be used to store data that you want to be unchanged across power cycles. Configurations or settings are examples of such data.In this article, we will see how to get data of any size (not just a byte) from the EEPROM. We will be walking through an inbuilt example in Arduino. The EEPROM examples can be accessed from − File → Examples → EEPROM.ExampleWe will look at the eeprom_get example. This example assumes that ... Read More

How to put data of any size in the EEPROM using Arduino?

Yash Sanghvi
Updated on 26-Jul-2021 09:56:42

971 Views

Arduino Uno has 1 kB of EEPROM storage. EEPROM is a type of non-volatile memory, i.e., its contents are preserved even after power-down. Therefore, it can be used to store data that you want to be unchanged across power cycles. Configurations or settings are examples of such data.In this article, we will see how to put data of any size (not just a byte) in the EEPROM. We will be walking through an inbuilt example in Arduino. The EEPROM examples can be accessed from: File → Examples → EEPROM.ExampleWe will look at the eeprom_put example. The main function of interest ... Read More

How to update existing data in EEPROM with Arduino?

Yash Sanghvi
Updated on 26-Jul-2021 09:48:09

910 Views

Arduino Uno has 1 kB of EEPROM storage. EEPROM is a type of non-volatile memory, i.e., its contents are preserved even after power-down. Therefore, it can be used to store data that you want to be unchanged across power cycles. Configurations or settings are examples of such data.In this article, we will see how to update existing data in the EEPROM. We will be walking through an inbuilt example in Arduino. The EEPROM examples can be accessed from: File → Examples → EEPROM.ExampleWe will look at the eeprom_update example. You essentially use the EEPROM.update() function. The EEPROM.update() function is different ... Read More

How to clear the EEPROM with Arduino?

Yash Sanghvi
Updated on 26-Jul-2021 09:44:25

6K+ Views

Arduino Uno has 1 kB of EEPROM storage. EEPROM is a type of non-volatile memory, i.e., its contents are preserved even after power-down. Therefore, it can be used to store data that you want to be unchanged across power cycles. Configurations or settings are examples of such data.In this article, we will see how to clear the EEPROM, i.e., set all its bytes to 0. We will be walking through an inbuilt example in Arduino. The EEPROM examples can be accessed from − File → Examples → EEPROM.ExampleWe will look at the eeprom_clear example. It is very easy. You essentially ... Read More

How to write data into EEPROM with Arduino?

Yash Sanghvi
Updated on 26-Jul-2021 09:40:24

962 Views

Arduino Uno has 1 kB of EEPROM storage. EEPROM is a type of non-volatile memory, i.e., its contents are preserved even after power-down. Therefore, it can be used to store data that you want to be unchanged across power cycles. Configurations or settings are examples of such data.ExampleWe will see how to write data to the EEPROM in this example. We will be walking through an inbuilt example in Arduino. The EEPROM examples can be accessed from − File → Examples → EEPROM.We will look at the eeprom_write example. It is quite straightforward, thanks to the EEPROM library. A word ... Read More

How to read data from EEPROM in Arduino?

Yash Sanghvi
Updated on 26-Jul-2021 09:37:07

2K+ Views

Arduino Uno has 1 kB of EEPROM storage. EEPROM is a type of non-volatile memory, i.e., its contents are preserved even after power-down. Therefore, it can be used to store data that you want to be unchanged across power cycles. Configurations or settings are examples of such data.ExampleWe will see how to read data from EEPROM in this example. We will be walking through an inbuilt example in Arduino. The EEPROM examples can be accessed from − File → Examples → EEPROM.We will look at the eeprom_read example. It is quite straightforward, thanks to the EEPROM library.We begin with the ... Read More

Previous 1 ... 4 5 6 7 8 ... 21 Next
Advertisements