Serial Monitor Archives - CyberBlogSpot https://cyberblogspot.com/tag/serial-monitor/ Not just another blogspot site Wed, 01 Feb 2023 19:33:54 +0000 en hourly 1 https://wordpress.org/?v=6.5.5 https://cyberblogspot.com/wp-content/uploads/2018/08/cropped-iphone-iphone3gs-32x32.jpg Serial Monitor Archives - CyberBlogSpot https://cyberblogspot.com/tag/serial-monitor/ 32 32 How to Test an ESP-01 ESP8266 Module https://cyberblogspot.com/how-to-test-an-esp-01-esp8266-module/ https://cyberblogspot.com/how-to-test-an-esp-01-esp8266-module/#respond Wed, 01 Feb 2023 19:31:54 +0000 https://cyberblogspot.com/?p=4652 When you buy a new ESP-01 ESP8266 module, the very first thing to do is to test it. That is, you need to make sure that you have a good and working ESP-01 module. We will take a look at the different methods of testing the ESP-01 ESP8266 Wi-Fi module. Differences Between ESP-01 and ESP-01S… Read More »How to Test an ESP-01 ESP8266 Module

The post How to Test an ESP-01 ESP8266 Module appeared first on CyberBlogSpot.

]]>
A picture of an ESP-01 ESP8266 module that is ready for testing
Figure 1. ESP-01 ESP8266 Module

When you buy a new ESP-01 ESP8266 module, the very first thing to do is to test it. That is, you need to make sure that you have a good and working ESP-01 module. We will take a look at the different methods of testing the ESP-01 ESP8266 Wi-Fi module.

Differences Between ESP-01 and ESP-01S ESP8266 Module

Before we proceed, be aware that there are two (2) versions of ESP-01 modules. The older ESP-01 module and the newer ESP-01S module. Both modules are functionally the same. However, there are two points worth mentioning here.

Picture showing the differences between an ESP-01 and ESP-01S ESP8266 modules prior to testing
Figure 2. ESP-01 Module and ESP-01S Module Comparison

First, the ESP-01 has two (2) LEDs, a red LED power indicator and a blue LED that indicates serial activity. On the other hand, the newer ESP-01S has only one (1) LED, the blue LED light (see Figure 2 above). Moreover, the blue LED serial activity indicator light is wired differently on each module. That is, on an ESP-01 module, it is connected on the TX pin (GPIO1) while on the ESP-01S module, it is connected on the GPIO2 pin. And as a side note, pins GPIO0 and GPIO1 are both serial TX capable pins (refer to the ESP-01S schematic diagram at the end of this article).

Second, the ESP-01S module has three (3) additional on-board resistors used as pull-up resistors. These pull-up resistors are 12K-ohm resistors each connected on the GPIO0, the RESET, and the CH_PD pins. You may also want to refer again to the ESP-01S schematic diagram included at the end of this article.

Quick and Dirty Test

The ESP-01 module is shipped with a program called AT firmware. The firmware will let you send AT commands to configure and program the module. More important, the module is configured as a Wi-Fi Access Point (AP) when shipped. Therefore, a quick and dirty test is to power the ESP-01 module and use a smartphone to connect to the Access Point.

Power up the ESP-01 module as shown in Figure 3. Notice that we need to connect the ESP-01 module to a 3.3V power supply. Do not connect the ESP-01 module to the 3.3V output of an Arduino board. Provide a separate 3.3V power supply with sufficient current capacity. Also, note that a 10K ohms resistor is connected from the CH_PD pin to the VCC or the 3.3V supply. The CH_PD (Chip Power Down / Enable Pin) pin has to be pulled up to the VCC for the module to function. If you have the ESP-01S module, you do not need to connect a 10K ohm resistor on the CH_PD pin. As per discussion above on the differences between the ESP-01 and the ESP-01S modules, the ESP-01S already has a 12K-ohm pull-up resistor on the CH_PD pin.

A picture depicting how to supply power to the ESP-01 ESP8266 Wi-Fi module in order to do a quick test
Figure 3. ESP-01 8266 Module with Power Supply

After powering up, you should see the ESP-01 access point when you scan for Wi-Fi devices. The default SSID of the ESP-01 module I am using is ESP_7B0F95. See Figure 4.

Screenshot of a smartphone Wi-Fi settings showing the SSID of nearby Wi-Fi devices.
Figure 4. Smartphone Wi-Fi Scan

Connect to the ESP-01 Access Point.

Screenshot of an Android smartphone Wi-Fi settings showing the module as connected to the smartphone.
Figure 5. Smartphone Wi-Fi Connected to ESP-01 Access Point

Click on the Settings icon (gear icon) and see the network details of the ESP-01 module Access Point.

Screenshot of a smartphone Wi-Fi settings showing the network characteristics of the ESP-01 ESP8266 module acting as an access point.
Figure 6. The ESP-01 Access Point Network Properties

AT Command Test

For the next test, you need an ESP-01 programmer or flasher. An inexpensive programmer/flasher is shown below in Figures 7. In Figure 8, the ESP-01 module is shown inserted into the programmer/flasher. If you do not have a programmer/flasher, it is possible to use an Arduino board as a programmer/flasher. Also, if you have a USB-to-serial(TTL) converter, you could wire it up as an ESP-01 programmer/flasher.

Picture of an inexpensive ESP-01 ESP8266 programmer/flasher for testing the ESP-01 module.
Figure 7. An ESP-01 Programmer/Flasher
Picture showing the ESP-01 ESP8266 module inserted on an ESP-01 programmer/flasher.
Figure 8. ESP-01 Module on a Programmer/Flasher

Insert the ESP-01 module to the programmer as shown in Figure 8 and plug the programmer to the computer. If it is your first time to use your programmer/flasher, you may have to install its device driver. Open the Arduino IDE and set the appropriate COM port for your programmer (Figure 9). For the meantime, there is no need to set the Board type.

Picture of the Arduino IDE showing how to select the proper COM port.
Figure 9. The Arduino IDE Showing How to Select COM port

Open the Serial Monitor and change the settings as shown in Figure 10. The line ending setting must be set to both newline and carriage return, “Both NL & CR”. Additionally, the baud rate setting must be set to “115200 baud”.

Screenshot of Arduino IDE serial monitor annotated with the proper line ending setting and baud rate setting.
Figure 10. The Arduino IDE Serial Monitor Settings

Now type “AT”, press the return key and the ESP-01 module should reply “OK”.

To view the ESP-01 module firmware version, type “AT+GMR”.

Type “AT+CIFSR” to view the Access Point’s IP address and network MAC address. See Figure 11 for the output display.

Screenshot of the Arduino IDE serial monitor showing the results of testing an ESP-01 8266 module with AT commands.
Figure 11. The Arduino IDE Serial Monitor Showing the Results of AT Commands

For a complete guide on the ESP-01 module AT commands, see ESP8266 – AT Command Reference.

Programming with Arduino IDE

In the next test, we will upload a modified version of the sample sketch Blink from the Arduino IDE. The sketch should make the blue LED on the ESP-01 module turn on and off.

IMPORTANT
Uploading an Arduino sketch to the ESP-01 module will erase the AT firmware. The AT commands will not work anymore after the upload. If you want to be able to restore the original firmware, please see the article
How to Save and Restore ESP8266 and ESP32 Firmware.

With the ESP-01 module still in the programmer/flasher, open the Arduino IDE and change the Board setting to “Generic ESP8266 Module” as shown in Figure 12.

Screenshot of the Arduino IDE showing how to set the board prior to testing the ESP-01 ESP8266 Wi-Fi module.
Figure 12. The Arduino IDE Showing How to Set the MCU Board

Create a new sketch, copy and paste the blink program shown below. Upload the sketch to the ESP-01 module. The blue LED should start blinking after successfully uploading the sketch.

/*
 * cyberblogspot.com 01Feb2023
 */

#define LED_BUILTIN 1                // GPIO1 for ESP-01, GPIO2 for ESP-01S
                                     // Change to 2 for ESP-01S module
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);   
}

void loop() {
  digitalWrite(LED_BUILTIN, LOW);   // Turn the LED on (ESP-01 LED is active low)
  delay(1000);                      
  digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off 
  delay(1000);                     
}

Schematic Diagram of ESP-01S ESP8266 Wi-Fi Module

Schematic diagram of ESP-01S ESP8266 Wi-Fi module that can be used for reference purposes especially when testing the module
Figure 13. ESP-01S Wi-Fi Module Schematic Diagram

Related Articles on How to Test an ESP-01 ESP8266 Module

How to Set up Arduino IDE for ESP8266 Programming
How to Program ESP-01 with Arduino IDE
How to Control ESP-01 thru a Router
How to Control ESP-01 Without a Router
ESP-01 with RTC and LCD Display
ESP-01 ESP8266 NTP Clock with LCD Display
How to Test NodeMCU V3 Using Esptool
NodeMCU V3 ESP8266 Pinout and Configuration
How to Use AT-09 BLE with Arduino and Smartphone

References on How to Test an ESP-01 ESP8266 Module

ESP8266 on Wikipedia

The post How to Test an ESP-01 ESP8266 Module appeared first on CyberBlogSpot.

]]>
https://cyberblogspot.com/how-to-test-an-esp-01-esp8266-module/feed/ 0
How to Enable Serial Monitor on Digispark ATtiny85 https://cyberblogspot.com/how-to-enable-serial-monitor-on-digispark-attiny85/ https://cyberblogspot.com/how-to-enable-serial-monitor-on-digispark-attiny85/#comments Wed, 18 Jan 2023 01:14:31 +0000 https://cyberblogspot.com/?p=5739 The Serial Monitor in Arduino IDE is an indispensable tool for debugging purposes. However, although a Digispark ATtiny85 development board has a USB interface, the Serial Monitor does not work with it. The main reason is that the USB interface in the Digispark board is not a serial COM port. The second reason is that… Read More »How to Enable Serial Monitor on Digispark ATtiny85

The post How to Enable Serial Monitor on Digispark ATtiny85 appeared first on CyberBlogSpot.

]]>
The Serial Monitor in Arduino IDE is an indispensable tool for debugging purposes. However, although a Digispark ATtiny85 development board has a USB interface, the Serial Monitor does not work with it. The main reason is that the USB interface in the Digispark board is not a serial COM port. The second reason is that the ATtiny85 chip does not have a UART port. And third, the Digispark board lacks a UART to USB bridge circuitry to translate UART signals to USB signals. In this article, we will take a look at how to enable the Serial Monitor when using a Digispark ATtiny85 development board.

To enable the Arduino IDE Serial Monitor on a Digispark ATtiny85 board, connect a USB-to-Serial converter. Then use the SoftwareSerial library in the Arduino IDE to create a UART port on the ATtiny85 chip.

Picture of Fritzing breadboard diagram showing how to connect the Digispark ATtiny85 board to a USB to serial converter to enable the serial monitor when working with Digispark ATtiny85
Figure 1. Fritzing Breadboard Diagram of Digispark ATtiny85 with a USB-to-Serial Converter

For Digispark ATtiny85 pinout guide, kindly see Digispark ATtiny85 Pinout and Configuration.

Schematic diagram for connecting the Digispark ATtiny85 board to a USB to UART converter to enable the serial monitor of the Arduino IDE.
Figure 2. Schematic Diagram of Digispark ATtiny85 and USB-to-Serial Converter Connection

Step by Step Guide For Serial Monitor

STEP 1 – Connect a USB-to-Serial Converter

First, connect a USB-to-serial converter to the Digispark ATtiny85 board as shown in Figure 1 and Figure 2.

There are many inexpensive USB-to-serial converters on the Internet. Examples of USB-to-serial converters are shown below in Figure 3. These converters are sometimes referred to as USB-to-serial TTL converters or USB-to-UART converters. Also, the converters use a variety of chips, hence, they may be referred to by their chip names. Some of the popular USB-to-serial chip names that you may encounter are FTDI, CP2104, CH304, and PL2303.

Picture of the different types of USB-to-serial converter used for activating the serial monitor on Digispark ATtiny85 when working with Arduino IDE
Figure 3. USB-to-Serial Converters

STEP 2 – Install the USB-to-Serial Converter Device Driver

Download and install the device driver for your USB-to-serial converter. Because USB-to-serial converters use different chips, you need to search the internet for the device driver for your particular USB-to-serial converter.

You can do a quick test if you have the right device driver installed. Open the Arduino IDE and go to the Tools/Port menu. You should see an additional port instead on only COM1 on the Serial Ports list when you plug in your USB-to-serial converter. Please see Figure 4.

Screenshot of the Arduino IDE showing the serial COM ports list.
Figure 4. Arduino IDE Showing Serial Ports List

STEP 3 – Install the Board Core ATTinycore by Spence Konde

Although we may use the original Digistump AVR board core, I prefer to use the ATTinyCore as it supports almost all of the ATtiny line of AVR chips. Additionally, the ATTinyCore gives us the option to program the ATtiny85 in several ways: no bootloader, Optiboot, and Micronucleus (Digispark) modes. If you need help in installing the ATTinyCore, please see How to Install ATTinyCore on Arduino IDE.

STEP 4 – Use Software Serial to Create UART Ports on ATtiny85

Open the Arduino IDE and upload the sketch shown below. If you need help in uploading the sketch using the board core ATtinyCore, you may visit How to Program Digispark ATtiny85 Board with Arduino IDE.

IMPORTANT NOTE
Before hitting the Upload button to install the sketch, unplug both USB cables for the Digispark board and the USB-to-serial converter. Plug in the USB cable for the Digispark board when prompted by the Arduino IDE. When the sketch upload is done, unplug the USB cable from the Digispark board. Connect the USB cable for the USB-to-serial converter and proceed to STEP 5 for testing the Serial Monitor.

/* cyberblogspot.com 15Jan2023 */

#include "SoftwareSerial.h"

SoftwareSerial mySerial(1, 0);  //RX, TX  PB1, PB0

void setup() { 
  mySerial.begin(19200);
  
  mySerial.println("Change baud rate to 19200");
  mySerial.println("Type something and press ENTER");
}

void loop() {
  if (mySerial.available()){
    mySerial.println(mySerial.readString());
  }
}

The sketch above needs no explanation. Simply include the library header file for the SoftwareSerial library. You do not have to download the SofwareSerial library as it should come with the ATtinyCore board core installation.

Regarding the code creating the SoftwareSerial object in line 5,

SoftwareSerial mySerial(1, 0); //RX, TX PB1, PB0

you may use any two (2) available ATtiny85 ports available. In this case, I used PB1 for RX (receiver) and PB0 for TX (transmitter).

STEP 5 – Test the Serial Monitor

After uploading the sketch to the Digispark ATtiny85 board, unplug the USB cable from the Digispark board. Plug in the USB cable for the USB-to-serial converter.

Then, select the correct COM port for your USB-to-serial converter in the Arduino IDE “Tools/Port” menu. Test the program and you should now be able to use the Serial Monitor on the Digispark ATtiny85 board.

References on How to Enable Serial Monitor on Digispark ATtiny85

USB-to-serial adapter – Wikipedia article on USB to Serial Converter
How to Install Arduino IDE on Windows 10
How to Install ATTinyCore on Arduino IDE
How to Use Arduino as ISP Programmer
How to Program ATtiny85 with Arduino IDE
Digispark ATtiny85 Pinout and Configuration
How to Program Digispark ATtiny85 Board with Arduino IDE
Digispark USB Device Not Recognized
How to Use AT-09 BLE with Arduino and Smartphone

The post How to Enable Serial Monitor on Digispark ATtiny85 appeared first on CyberBlogSpot.

]]>
https://cyberblogspot.com/how-to-enable-serial-monitor-on-digispark-attiny85/feed/ 2