PWM on an Oscilloscope

What PWM looks like on an oscilloscope. PWM is Pulse Width Modulation which can be used to change the brightness of an LED. This article and video shows PWM on an oscilloscope by using the Fade example sketch or program from the Arduino IDE. An LED and series resistor is connected to an Arduino Uno pin and the Arduino sketch continually adjusts the brightness of the LED by using PWM on the pin.

Video Showing PWM on an Oscilloscope

The following video shows PWM on an oscilloscope that is continually changing in order to change the brightness of the LED. Both the LED and Arduino Uno can be seen in the inset video. PicoScope is a PC based oscilloscope that connects to the USB port of a computer. Software running on the computer acts as the oscilloscope screen and control panel and can be seen in the video.

Hardware and Software for the PWM Demo

Find the Fade sketch in the Arduino IDE under File → Examples → 01.Basics → Fade from the top menu. The oscilloscope GND is connected to the Arduino GND. Pin 9 of the Arduino is used as the measurement point to measure the PWM waveform on the oscilloscope. The image below shows how the LED and series resistor are connected to the Arduino Uno. For more information, see the related Fade tutorial on the Arduino website.

Fade Arduino Example used to Show PWM on an Oscilloscope

Fade Arduino Example used to Show PWM on an Oscilloscope

How PWM Works

PWM changes the duty cycle of a square wave, which means that it changes the ratio of its on time to its off time. When the square wave is on, or at 5V, for longer than it is off, the LED will burn brighter. If the square wave is off, or at GND, for longer than it is on, the LED will burn dimmer.

Duty cycle of a PWM waveform is usually given as a percentage. If the duty cycle is 80%, then the on cycle of the square wave is on for 80% of the time and off for 20% of the time. A square wave with a 50% duty cycle has an equal on and off time.

 

Arduino Genuino Zero Atmel Studio Can Not Upgrade Firmware

Arduino Genuino Zero Atmel Studio can not upgrade firmware after trying to connect to target microcontroller using device programming dialog box or start without debugging icon. How to fix the firmware upgrade problem when the firmware won’t upgrade. A failed firmware upgrade prevents the use of the target board with Atmel Studio 7. The firmware appears to upgrade, but does not, as described below.

Genuino Zero Atmel Studio can’t Upgrade Firmware Problem

After opening the Programming Dialog box in Atmel Studio 7, or trying to program or debug the board, the Firmware Upgrade dialog box opens. After clicking the Upgrade button in the dialog box, the firmware appears to upgrade immediately. When trying to connect to the board again with Atmel Studio, the Firmware Upgrade dialog box appears again saying that the firmware needs upgrading. The dialog box appears as follows after the attempted upgrade that does not work. Here the Firmware Upgrade dialog box appears after the Apply button was clicked in the Device Programming dialog box.

Arduino Genuino Zero Atmel Studio Can Not Upgrade Firmware

Arduino Genuino Zero Atmel Studio Can Not Upgrade Firmware

This problem occurred on my Genuino Zero board, but I have read reports of it happening on Arduino M0 Pro boards and Atmel SAMD21 Xplained boards as well. The firmware that Atmel Studio is attempting to upgrade is the firmware in the embedded debugger (EDBG) chip found on Arduino Genuino Zero, Arduino M0 Pro and SAMD21 Xplained Pro boards.

Arduino Genuino Zero Atmel Studio Can Not Upgrade Firmware Solution

This solution simply stops stops Atmel Studio from automatically checking if the firmware needs upgrading. It does not actually upgrade the firmware on the EDBG chip.

The following steps describe how to bypass the firmware upgrade in Atmel Studio.

1. Open the Device Programming Dialog Box

Start Atmel Studio and then click the Device Programming icon as shown in the image below. The icon is found on the top toolbar. This opens the Device Programming dialog box.

Atmel Studio Device Programming Icon

Atmel Studio Device Programming Icon

2. Open the Device Programming Settings

In the Device Programming dialog box, select EDBG as the tool and SWD for the interface. In the Device field, select the target microcontroller on the board. For Arduino / Genuino Zero / M0 Pro boards this is ATSAMD21G18A. For the Atmel SAMD21 Xplained Pro, it is ATSAMD21J18A.

When clicking the Apply button in the Device Programming dialog box, the Firmware Upgrade dialog box appears and then fails to properly upgrade the firmware. Instead of clicking the Apply button, click the Settings icon at the right of the Device Programming dialog box as shown in the image below.

Device Programming Settings

Device Programming Settings

3. Disable the Check Firmware Setting

In the Options dialog box, find Tools near the bottom of the left pane and expand it. Click the Tool settings item to select it. In the right pane, double click True at the right of Check firmware to change it to False. These steps are shown in the image below.

Disable Check Firmware

Disable Check Firmware

Click the OK button to close the dialog box.

4. Test the Changes

Finally test the changes. Back in the Device Programming dialog box, with the correct tool, device and interface selected, click the Apply button. This time the Firmware Upgrade dialog box should not appear and it should be possible to program and debug the target microcontroller. Click the Read button next to Device Signature to make sure that the communications with the target microcontroller is working. These steps are shown in the image below.

Read Device Signature

Read Device Signature

Conclusion

After completing the above steps, I was able to program my Arduino Genuino Zero board using Atmel Studio. I first backed up the bootloader using the Device Programming dialog box and then loaded a C program that blinks the on-board LED. This proved that the EDBG interface could be used to read and write without upgrading the firmware.

Although this solution may not be ideal because the EDBG firmware is not updated to the latest version, it still solved the problem of having an endless firmware upgrade loop that fails to upgrade the firmware and then prevents use of the target board with Atmel Studio.

 

Wemos SAMD21 M0 Arduino M0 Compatible Board

An Arduino M0 compatible board called Wemos SAMD21 M0 is available from several online shops such as Banggood, AliExpress and Amazon, and also appears from several sellers on eBay. What appears to be the same board is also marketed as RobotDyn SAMD21M0. This blog post provides more information on the board.

An image of the Wemos SAMD21 M0 is shown below. As can be seen in the image, the Wemos logo appears on the board near the SAMD21G18A microcontroller chip. This board is not an exact copy or clone of the Arduino M0, but has a few differences such as the extra TXD and RXD pins found at the end of the board.

WeMos SAMD21 M0 Arduino M0 Compatible

WeMos SAMD21 M0 Arduino M0 Compatible

Wemos SAMD21 M0 Board Logo

Apparently this board is not actually made by the Wemos company, but the board is silk-screened with the Wemos logo. This has been mentioned on the Arduino forum in a few places. Here are a couple of examples:

Arduino forum message mentioning that the Wemos board does not appear on the official Wemos website.

An Arduino forum user mentions that Wemos does not admit the existence of this board.

Arduino M0 Compatible

The Wemos SAMD21 M0 board is compatible with the Arduino M0 which was originally from arduino.org when arduino.org and arduino.cc were having their fight. Now that the two companies have finished fighting and merged back together, the Arduino M0 board is listed on the arduino.cc website.

Circuit Diagram

I have not found a circuit diagram for the Wemos SAMD21 M0 after extensive searching. As the board is compatible with the Arduino M0, the Arduino M0 information page will be useful. A circuit diagram or schematic for the Arduino M0 can be found under the DOCUMENTATION tab on this page.

Wrong Information

On many of the sellers web pages for the Wemos SAMD21 M0, there is incorrect information about the board that describes it as an Arduino Zero or Arduino M0 Pro. The information also mentions that it has Atmel’s embedded debugger (EDBG) on the board – this is not true. Only the Genuino Zero and Arduino M0 Pro have the EDBG.

Older Boards

Some users of earlier boards complained about the power LED being too bright. There were also complaints about the board not working with the Arduino IDE. This has changed with the newer boards. I have not had these problems with boards ordered in 2018.

Hardware Differences

Although the Wemos SAMD21 M0 board is compatible with the Arduino M0, it is not a clone or exact copy of the Arduino M0, but rather a variant of it.

Two extra serial port pins can be seen at the end of the board. These pins are labeled TXD and RXD. The power supply looks different between the boards and some of the components such as LEDs are in slightly different locations on the boards.

Wemos SAMD21 M0 Quick Start Tutorial

A Wemos SAMD21 M0 quick start tutorial can be found on the Starting Electronics website. This tutorial shows how to install the programming tools to program the Arduino M0 and compatible boards in the Arduino IDE. It shows how to blink the on-board LED as a quick test to see that the board is working and then shows how to use the serial ports to communicate with the Arduino IDE Serial Monitor.

Go to the Wemos SAMD21 M0 tutorial →

GY-BMP280-3.3 Pressure Sensor Module Arduino Tutorial and Pinout

GY-BMP280-3.3 high precision atmospheric pressure sensor module for Arduino – tutorial on first use and testing of the module as well as GY-BMP280-3.3 pressure sensor module pinout. The same module is sold under different names such as BMP280-3.3 or just BMP280, although BMP280 is the actual pressure sensor chip that can be seen just below the capacitor at the top of the module, as shown in the image below.

GY-BMP280-3.3 Pressure Sensor Module

GY-BMP280-3.3 Pressure Sensor Module

GY-BMP280-3.3 Pressure Sensor Module Basic Information

The least you need to know before using this module is presented below.

What the GY-BMP280-3.3 Pressure Sensor Module Can Measure

It can measure both atmospheric pressure and temperature. Because it can measure atmospheric pressure, it can be used to calculate altitude.

BMP280 Datasheet

The module uses a BMP280 barometric pressure sensor from Bosch. A datasheet on the BMP280 can be found on the BMP280 page on the Bosch website. This datasheet and web page is for the actual BMP280 device found on the GY-BMP280-3.3 module.

Operating Voltage

The GY-BMP280-3.3 operates from 3.3V, so requires 3.3V power and must be driven with 3.3V logic levels. Some modules that use the BMP280 device have a voltage regulator and level shifters so that it can be operated from a 5V controller such as an Arduino Uno. This module does not have any regulator or level shifters.

From the BMP280 datasheet:
Minimum power supply voltage – 1.71V
Maximum power supply voltage – 3.6V
Absolute maximum power supply voltage – 4.25V

Direct connection to a 3.3V Arduino such as an Arduino Due, Arduino Zero, Arduino M0 or Arduino M0 Pro is fine, so long as the pressure sensor is powered from the Arduino 3.3V pin. For 5V Arduinos such as the Arduino Uno or Arduino MEGA, it must be powered from the Arduino 3.3V pin, and must be interface to the Arduino using a level shifter for the data and clock pins.

I have seen videos on YouTube where this module is connected directly to a 5V Arduino and powered from 5V. This is extremely bad engineering practice and could result in severely damaging or destroying the BMP280 device. It is sheer luck if the device actually works and does not blow up.

Interfacing

I2C or SPI can be used to interface or connect the module to an Arduino or other microcontroller. Pin 6 of the module controls the I2C address of the module which can be set to either 0x76 when pin 6 is left unconnected or 0x77 when pin 6 is pulled to Vcc (3.3V).

Wrong Information

The Internet is full of wrong information regarding this sensor module. Tutorials on powering this device from 5V and not using level shifters on the data pins are out there. Or if the advice is to power the module from 3.3V, then the data pins are directly connected to 5V Arduino pins without level shifters.

Another mistake that I have seen is that people do not know that the I2C address can be changed by using pin 6 of the module, as can be seen in the pinout for the module (link in the section below). What they then do is modify the Arduino driver to change its I2C address so that it matches the default I2C address of the module, instead of just pulling pin 6 high so that the module address matches the driver address.

GY-BMP280-3.3 Pressure Sensor Module Pinout

Refer to the GY-BMP280-3.3 pressure sensor module pinout page for the module’s pinout and circuit diagram.

GY-BMP280-3.3 Pressure Sensor Module Tutorial

A tutorial on basic use and testing of the GY-BMP280-3.3 pressure sensor module on the Starting Electronics website shows how to connect the module to both 3.3V and 5V Arduino boards. An Arduino Due is used to demonstrate how to wire the module to a 3.3V Arduino. For 5V Arduino boards, an Arduino Uno is used to demonstrate how to use a transistor level shifter to wire the module for 5V use.

The tutorial also shows how to install drivers for the pressure sensor module and then test the module to make sure that it can read pressure and temperature.

Go to the tutorial now →

Can’t Find Arduino M0 PRO or Zero in IDE

What to do when you can’t find Arduino M0 Pro or Zero in IDE board list. How to install Arduino M0, M0 Pro or Zero software in the Arduino IDE. Arduino boards are selected from the top Arduino IDE menu under Tools → Board, but if the Arduino M0, Arduino M0 PRO or Arduino Genuino Zero boards are not found on the menu, additional software must be installed within the Arduino IDE.

When the software is installed, the following boards will be supported by the Arduino IDE:

  • Arduino/Genuino Zero
  • Arduino/Genuino MKR1000
  • Arduino MKRZERO
  • Arduino MKR FOX 1200
  • Arduino MKR WAN 1300
  • Arduino MKR GSM 1400
  • Arduino M0 Pro
  • Arduino M0
  • Arduino Tian
  • Adafruit Circuit Playground Express

Can’t Find Arduino M0 PRO or Zero on the Menu in the Arduino Software

In the image below, the Arduino M0 Pro, Arduino M0 and Genuino Zero are missing from the Arduino IDE board list menu. The steps below show how to solve the problem and get the additional Arduino boards listed on the menu.

Can't Find Arduino M0 PRO or Zero in IDE - Arduino IDE Board List Missing M0 and Zero

Can’t Find Arduino M0 PRO or Zero in IDE – Arduino IDE Board List Missing M0 and Zero

How to Install Software for the Arduino M0, M0 Pro and Genuino Zero

The following screen captures show how to install software for the Arduino M0, M0 Pro and Genuino Zero boards in the Arduino IDE. Only one package must be installed for all three boards and is done within the Arduino IDE.

After installation, the following boards will be available in the Arduino IDE: Arduino/Genuino Zero, Arduino/Genuino MKR1000, Arduino MKRZERO, Arduino MKR FOX 1200, Arduino MKR WAN 1300, Arduino MKR GSM 1400, Arduino M0 Pro, Arduino M0, Arduino Tian and Adafruit Circuit Playground Express.

1. Open the Boards Manager

From the top Arduino IDE menu, select Tools → Board → Boards Manager… to open the Boards Manager dialog box.

Open the Arduino IDE Boards Manager

Open the Arduino IDE Boards Manager

2. Select Arduino SAMD Boards and Install

In the Boards Manager dialog box, type M0 into the search field to easily find the SAMD package for Cortex-M0+ boards as shown in the image below.

Search for M0 in the Boards Manager Dialog Box

Search for M0 in the Boards Manager Dialog Box

Click anywhere on the Arduino SAMD Boards (32-bits ARM Cortex-M0+) by Arduino item to select it. After selecting it, an Install button will appear as can be seen in the above image. Click the Install button to install the software package. This may take some time, depending on the speed of your Internet connection. Click the Close button in the dialog box after the installation has finished.

3. Find the Arduino Zero and M0 Boards on the Arduino IDE Menu

After the software package has been installed, the new Arduino boards can be seen on the Arduino IDE Board menu found under Tools →Board as shown in the image below.

A new section called Arduino SAMD (32-bits ARM Cortex-M0+) Boards can be seen on the Board menu which contains Arduino M0, M0 Pro, Zero, MKR boards and others.

Arduino M0 and Genuino Zero on the Arduino IDE Board List

Arduino M0 and Genuino Zero on the Arduino IDE Board List

Program the Arduino M0 Pro or Arduino Zero

Select the desired board from the Arduino IDE Board menu and then select the correct Port number from the menu item below Board on the Tools Menu. The Arduino board can now be programmed in the usual manner.

For Arduino boards such as the Zero and M0 that have two USB ports for programming, make sure that the correct board and port is selected from the Board menu – i.e. Programming Port or Native USB Port. This port name must correspond to the port on the board that the cable is plugged into.

For example, a Arduino M0 Pro board is shown below with the USB cable plugged into the programming port. Arduino M0 Pro (Programming Port) must therefore be selected from the Arduino IDE board menu.

Arduino M0 Pro Programming Port

Arduino M0 Pro Programming Port