Tag Archives: arduino

Arduino reading and writing string to EEPROM

The arduino and ESP8266 EEPROM library only provides functions to read and write one byte at a time from the internal EEPROM. Note that EEPROM has limited number of writes.

In this tutorial I will provide some functions to store string to EEPROM and Read back to String variable. String is basically character array terminated with null (0x00).

Continue reading Arduino reading and writing string to EEPROM

Interfacing of RFID RC522 with Arduino UNO

In this tutorial we will learn How to interface Arduino UNO with RC522 RF ID Reader using Arduino library for MFRC522 and other RFID RC522 based modules.

This library read and write different types of Radio-Frequency IDentification (RFID) cards on your Arduino or NodeMCU using a RC522 based reader connected via the Serial Peripheral Interface (SPI) interface. Before we move to actual code lets know more about RF ID.

RF ID Reader MFRC-522
RF ID Reader

Continue reading Interfacing of RFID RC522 with Arduino UNO

“error: cannot access /dev/ttyUSB0” Arduino (NodeMCU) esp8266

Question: Getting permission “error: cannot access /dev/ttyUSB0”
Answer: Just open terminal (Ctrl+Alt+T) and type this command and enter root password
$ sudo usermod -a -G dialout ${USER}

On Linux (Ubuntu), Arduino IDE will not be able to upload sketches (or communicate with the board at all) if you don’t change permissions on /dev/ttyUSB0 appropriately. Same as with the NodeMCU ESPlorer IDE, etc. Actually, this very problem comes up whenever you want to access a (virtual) Serial COM port on Linux.

It might happen that when you upload a sketch – after you have selected your board and serial port -, you get an error Error opening serial port … If you get this error, you need to set serial port permission.

Open Terminal and type:

$ ls -l /dev/ttyUSB*

you will get something like:

crw-rw---- 1 root dialout 188, 0 5 apr 23.01 ttyUSB0

The “0” at the end of USB might be a different number, or multiple entries might be returned. The data we need is “dialout” (is the group owner of the file).

Now we just need to add our user to the group:

$ sudo usermod -a -G dialout ${USER}

NOTE: where USER is NOT  your linux user name keep as it is.

In some cases, You will need to log out and log in again for this change to take effect.

Add NodeMCU ESP8266 to Arduino IDE

In this tutorial, we’ll learn how to program your NodeMCU or ESP8266 using an Arduino IDE. NodeMCU board is not available by default.

The NodeMCU ESP8266 is a low-cost WiFi module built by Espressif Systems. Its popularity has been growing among the hardware community thanks to its nice features and stability, to the point that it can be easily programmed using your Arduino IDE.

Requirements

  1. Arduino IDE version 1.7 or higher
  2. Active Internet connection
  3. NodeMCU or ESP8266 board (for testing only)

Step 1: Adding ESP8266 URL to Arduino IDE Board Manger

  1. Make sure you are using Arduino IDE version 1.7 or higher.
  2. Add additional URL for board manager. Go to File >> Preferences and paste below url in Additional Board Manager URLs.                                                               http://arduino.esp8266.com/stable/package_esp8266com_index.json

JSON URL for ESP8266 in Arduino IDE

Note: Sometimes pakage_esp8266com_index.json link is down due to heavy download try again after few hours.

Step 2: Open Board Manager

  1. Go to Tools >> Boards >> Board Manager

Board Mnanger Link

Step 3: Search and Installing Node MCU (ESP8266) in Arduino IDE

  1. Type “ESP8266” in search box.
  2. Select ESP8266 Community. (If internet is not available then you will not find ESP8266)
  3. Click on Install Button. Download progress starts. wait for finish.
Install NodeMCU
Installing ESP8266

Step 4: Verify installation of ESP8266

  1. Go to Tools>>Boards>> select NodeMCU (If you don’t find NodeMCU, check your installation is ok)
  2. Select proper Com port
  3. Upload blink example and check is it working. on board LED uses GPIO2
NodeMCU board in Arduino IDE
NodeMCU board is visible

Additional Resources

  1. Installing ESP32 in Arduino IDE
  2. Getting Started with ESP8266
  3. ESP8266 IOs
  4. NodeMCU Pin Numbers and Confusions (Must read)

 

 

 

How to convert integer to string and string to int on Arduino ?

New version of Arduino supports String data type . In this tutorial we will see both integer to string and string to integer conversion. Conversion of integer to string can be done using single line statement.

Example 1: Integer to String Conversion Arduino
int a = 1234;
String myStr;
myStr = String(a);   //Converts integer to string

Example 2: String to Integer conversion Arduino
String val = “1234”;
int result = val.toInt();  //Converts string to integer

Continue reading How to convert integer to string and string to int on Arduino ?