Found 387 Articles for Hardware

Cron Jobs in Arduino

Yash Sanghvi
Updated on 26-Jul-2021 11:17:13

1K+ Views

The CronAlarms library in Arduino helps you set cron jobs in Arduino. If you aren't aware of cron jobs, they are scheduled tasks to be carried out at a fixed time interval. An example can be sending a health packet to a server every day at midnight.In order to install this library, search for CronAlarms in the Library Manager and install the library by Martin Laclaustra.Once installed, go to - File → Examples → CronAlarms.Open CronAlarms_example. If you go through the example, you will see that they are doing the following −Set the time to Saturday 8:29:00am Jan 1 2011, using ... Read More

ArduinoJSON: Filtering Data

Yash Sanghvi
Updated on 26-Jul-2021 11:06:53

601 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 how to filter data from a larger JSON and produce a smaller JSON.Once you download the ArduinoJSON library, go to: File→Examples→ArduinoJSONExampleThe example we should look at is the JsonFilterExample. The code is ... Read More

ArduinoJSON: Working with Flash Strings

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

106 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

483 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

988 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

930 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

7K+ 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

Advertisements