{"id":21553,"date":"2024-06-20T18:44:55","date_gmt":"2024-06-20T18:44:55","guid":{"rendered":"https:\/\/wolles-elektronikkiste.de\/?p=21553"},"modified":"2024-06-20T18:44:55","modified_gmt":"2024-06-20T18:44:55","slug":"atmega328pb-based-boards","status":"publish","type":"post","link":"https:\/\/wolles-elektronikkiste.de\/en\/atmega328pb-based-boards","title":{"rendered":"ATmega328PB based boards"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">About this Post<\/h2>\n\n<p>The ATmega328PB is a further development of the good old ATmega328P, which you may know from various boards such as the Arduino UNO R3, the classic Arduino Nano V3 or the Arduino Pro Mini. Compared to the ATmega328P, the ATmega328PB is certainly not a revolution, but it does have some useful additional features.&nbsp;<\/p>\n<p>There is now a whole range of boards that are equipped with the ATmega328PB. I took a closer look at the <a href=\"https:\/\/joy-it.net\/de\/products\/ARD-NanoV4-MC\" target=\"_blank\" rel=\"noopener\">ARD-NanoV4-MC<\/a> from <a href=\"https:\/\/joy-it.net\/de\/\" target=\"_blank\" rel=\"noopener\">Joy-IT<\/a> as a representative of Nano-style boards. The <a href=\"https:\/\/www.pololu.com\/category\/239\/a-star-328pb-micro\" target=\"_blank\" rel=\"noopener\">A-Star 328PB Micro<\/a> from <a href=\"https:\/\/www.pololu.com\/\" target=\"_blank\" rel=\"noopener\">Pololu<\/a> and the <a href=\"https:\/\/shop.watterott.com\/Wattuino-Pro-Mini-PB-5V-16MHz-ATmega328PB_1\" target=\"_blank\" rel=\"noopener\">Wattuino Pro Mini PB<\/a> from <a href=\"https:\/\/www.watterott.net\/\" target=\"_blank\" rel=\"noopener\">Watterott electronic<\/a> are representatives of the Pro Mini style.<\/p>\n<p>In the article, you will see that the board packages recommended by the manufacturers have implemented the advantages of the ATmega328PB to varying degrees and in different ways. I don&#8217;t want to say if better or worse because it depends on your preferences and what you want to do with your board. And nobody is forcing you to use the recommended board package.<\/p>\n\n<p>This is what you can expect in this article:<\/p>\n<ul>\n<li><a href=\"#328pb_vs_328p\">ATmega328PB vs. ATmega328P &#8211; Overview<\/a><\/li>\n<li><a href=\"#nanov4_mc\">&#8220;Nano-style&#8221; board using the example of ARD-NanoV4-MC<\/a>\n<ul>\n<li><a href=\"#install_board_package\">Installation of the recommended board package<\/a><\/li>\n<li><a href=\"#pinout_nanov4_mc\">Pinout<\/a><\/li>\n<li><a href=\"#serial1_nanov4_mc\">Using Serial1<\/a><\/li>\n<li><a href=\"#wire1_nanov4_mc\">Using Wire1<\/a><\/li>\n<li style=\"text-align: left;\"><a href=\"#spi1_nanov4_mc\">Using SPI1<\/a><\/li>\n<li><a href=\"#timer_pwm_nanov4_mc\">Additional Timer \/ PWM<\/a><\/li>\n<li><a href=\"#ocm_nanov4_mc\">Output Compare Modulator<\/a><\/li>\n<li><a href=\"#aco_nanov4_mc\">Analog Comparator Output<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#astar_328pb_micro\">&#8220;Pro Mini style&#8221; board using the Pololu A-Star 328PB Micro as an example<\/a>\n<ul>\n<li><a href=\"#install_pololu_package\">Installation of the recommended board package<\/a><\/li>\n<li><a href=\"#pinout_astar_328pb\">Pinout<\/a><\/li>\n<li><a href=\"#upload_burn_bootloader\">Sketch upload \/ burning the bootloader<\/a><\/li>\n<li><a href=\"#serial1_astar_328pb\">Using Serial1<\/a><\/li>\n<li><a href=\"#wire1_spi1_astar_328pb\">Using Wire1 and SPI1<\/a><\/li>\n<li><a href=\"#aco_timer_ocm\">Analog Comparator, Timer and Output Compare Modulator<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#wattuino_pro_mini_pb\">Wattuino Pro Mini PB<\/a><\/li>\n<li><a href=\"#change_board_package\">Changing the board package<\/a><\/li>\n<\/ul>\n\n<h2 class=\"wp-block-heading\" id=\"328pb_vs_328p\">ATmega328PB vs. ATmega328P &#8211; Overview<\/h2>\n\n<p>The ATmega328PB is downwards compatible with the ATmega328P. This means that sketches that you have written for the ATmega328P and boards based on it will also work on the ATmega328PB. You can find a data sheet for the ATmega328PB <a href=\"https:\/\/ww1.microchip.com\/downloads\/en\/DeviceDoc\/40001906A.pdf\" target=\"_blank\" rel=\"noopener\">here<\/a> at Microchip.<\/p>\n<p>These are the most important changes from my point of view:<\/p>\n<ul>\n<li>One additional USART (Serial), TWI (I2C) and SPI interface each.<\/li>\n<li>Two additional 16-bit Timers\/Counter (Timer\/Counter 3, Timer\/Counter 4).<\/li>\n<li>Four additional I\/O pins (PE0, PE1, PE2, PE3).\n<ul>\n<li>One GND and one VCC pin were sacrificed for PE0 and PE1.<\/li>\n<li>The pins for ADC6 and ADC7 now also have an I\/O pin function (PE2 and PE3).<\/li>\n<\/ul>\n<\/li>\n<li>Output Compare Modulator: combines the outputs of Timer\/Counter 3 and Timer\/Counter 4 on PD2.<\/li>\n<li>Analog Comparator Output on PE0.<\/li>\n<li>PTC: Peripheral Touch Controller. The PTC allows you to evaluate capacitive touch sensors attached to the I\/O pins. However, the Atmel Start QTouch\u00ae Configurator must be used for this. I&#8217;m not going to go into that.<\/li>\n<\/ul>\n<p>A complete summary of the differences can be found in the application note <a href=\"https:\/\/www.microchip.com\/en-us\/application-notes\/an42559\" target=\"_blank\" rel=\"noopener\">AN42559<\/a> from Microchip.<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ATmega328P_vs_ATmega328PB-1024x528.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"528\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ATmega328P_vs_ATmega328PB-1024x528.png\" alt=\"Pinout ATmega328P vs. Atmega328PB\" class=\"wp-image-21409\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ATmega328P_vs_ATmega328PB-1024x528.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ATmega328P_vs_ATmega328PB-300x155.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ATmega328P_vs_ATmega328PB-768x396.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ATmega328P_vs_ATmega328PB-1536x793.png 1536w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ATmega328P_vs_ATmega328PB-1320x681.png 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ATmega328P_vs_ATmega328PB.png 2000w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Pinout ATmega328P vs. ATmega328PB (click on the image to enlarge)<\/figcaption><\/figure>\n\n<h2 class=\"wp-block-heading\" id=\"nanov4_mc\">&#8220;Nano-style&#8221; board using the example of ARD-NanoV4-MC<\/h2>\n\n<p>I will use the ARD-NanoV4-MC to show how to utilize the additional functions offered by the ATmega328PB. You can also find the board under the name &#8220;ARD NANO V4 (MINICORE)&#8221;. I call it &#8220;NanoV4-MC&#8221; for short.&nbsp;<\/p>\n<p>On the <a href=\"https:\/\/joy-it.net\/de\/products\/ARD-NanoV4-MC\" target=\"_blank\" rel=\"noopener\">Joy-IT website<\/a> you will find the exemplary documentation of the NanoV4-MC with data sheets and instructions in various languages.&nbsp;<\/p>\n<p>I would like to take this opportunity to say that neither Joy-IT nor Pololu or Watterott pay me in any way for presenting their products.<\/p>\n\n<h3 class=\"wp-block-heading\" id=\"install_board_package\">Installation of the recommended board package<\/h3>\n\n<p>Joy-IT has provided the MiniCore board package from <a href=\"https:\/\/github.com\/MCUdude\" target=\"_blank\" rel=\"noopener\">MCUdude<\/a> for the NanoV4-MC, which you can find <a href=\"https:\/\/github.com\/MCUdude\/MiniCore\" target=\"_blank\" rel=\"noopener\">here<\/a> on GitHub.<\/p>\n<p>I will not go into detail about installing board packages in the Arduino IDE. If required, refer to the Joy-IT instructions. Here is the short version:<\/p>\n<ul>\n<li>In the Arduino IDE, go to File \u2192 Preferences.<\/li>\n<li>Click on the icon next to &#8220;Additional boards manager URLs&#8221;.<\/li>\n<li>Add the line: &#8220;https:\/\/mcudude.github.io\/MiniCore\/package_MCUdude_MiniCore_index.json&#8221; (without quotation marks), then confirm &#8220;OK&#8221; twice.<\/li>\n<li>Click on the icon for the board management on the left-hand side of the IDE and enter &#8220;MiniCore&#8221; as the search term.<\/li>\n<li>Install MiniCore by MCUdude.<\/li>\n<\/ul>\n<p>To set the correct board, select &#8220;MiniCore \u2192 ATmega328&#8221; under &#8220;Tools \u2192 Board&#8221;. Moreover, you must specify &#8220;328PB&#8221; and set the &#8220;Clock&#8221; to &#8220;External 16 MHz&#8221;. <\/p>\n\n<h3 class=\"wp-block-heading\" id=\"pinout_nanov4_mc\">Pinout <\/h3>\n\n<p>Here is the pinout (with kind permission of Joy-IT):<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_pinout--1024x635.webp\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"635\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_pinout--1024x635.webp\" alt=\"\" class=\"wp-image-21421\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_pinout--1024x635.webp 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_pinout--300x186.webp 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_pinout--768x476.webp 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_pinout--1536x953.webp 1536w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_pinout--1320x819.webp 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_pinout-.webp 1543w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Pinout ARD-NanoVC-MC, Copyright: Joy-IT<\/figcaption><\/figure>\n\n<p>At first glance, it looks like an Arduino Nano. The main differences are:<\/p>\n<ul>\n<li>Additional pins D23 and D24.<\/li>\n<li>The second I2C interface (Wire1) is implemented at D23 and D24.<\/li>\n<li>A6 and A7 can be used as GPIOs (D20\/D21).<\/li>\n<li>The second SPI interface is allocated to pins A0, A1 and A7.<\/li>\n<li>Serial1 is allocated to pins D11 and D12.<\/li>\n<\/ul>\n\n<h3 class=\"wp-block-heading\" id=\"serial1_nanov4_mc\">Using Serial1<\/h3>\n\n<p>Since the program upload to Arduino boards is managed via USART (Serial), the use of Serial for other purposes is sometimes problematic. For this reason, most people use SoftwareSerial in such cases, but it is more resource-intensive than HardwareSerial.<\/p>\n<p>I would like to use a simple application example to show you how to use Serial1. First, connect two NanoV4-MC boards as follows:<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_serial_1-1024x511.webp\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"511\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_serial_1-1024x511.webp\" alt=\"Serial1 communication using the ATmega328PB based NanoV4-MC\" class=\"wp-image-21424\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_serial_1-1024x511.webp 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_serial_1-300x150.webp 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_serial_1-768x383.webp 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_serial_1-860x430.webp 860w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_serial_1-1320x658.webp 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_serial_1.webp 1460w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Serial1 communication between two NanoV4-MC<\/figcaption><\/figure>\n\n<p>Then upload the following sketch to both NanoV4-MC boards (preferably with different names so that you can open two serial monitors):<\/p>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-group=\"nanov4_mc_serial_serial1.ino\" data-enlighter-title=\"nanov4_mc_serial_serial1.ino\">void setup() {\n  Serial.begin(9600);\n  Serial1.begin(9600);\n}\n\nvoid loop() { \n  if (Serial1.available()) {\n    Serial.write(Serial1.read());\n  }\n  if (Serial.available()) {\n    Serial1.write(Serial.read());\n  }\n}<\/pre>\n\n<p>Now you can exchange messages using the serial monitor. If you only have a NanoV4-MC available, you can also choose a different board on the other side and use SoftwareSerial there. It is important that the same baud rate is set on both sides. If you are using a 3.3 volt based board on the other side, you will need to add voltage dividers or a level shifter in between. You can find out more about Serial and SoftwareSerial <a href=\"https:\/\/wolles-elektronikkiste.de\/en\/serial-and-softwareserial\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n\n<h3 class=\"wp-block-heading\" id=\"wire1_nanov4_mc\">Using Wire1<\/h3>\n\n<p>Many external devices are controlled via I2C (Wire). It becomes problematic if you have several devices with the same I2C address. If there are only two devices with the same address, you can control one via Wire and the other via Wire1. The prerequisite is that libraries, if used, allow passing Wire objects. I will show you how to work with Wire and Wire1 in parallel using the ADS1115 as an example.<\/p>\n<p>This is the circuit:&nbsp;<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_wire_wire1_ads1115-1024x498.webp\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"498\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_wire_wire1_ads1115-1024x498.webp\" alt=\"Using Wire and Wire1 in parallel with the ATmega328PB-based NanoV4-MC\" class=\"wp-image-21429\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_wire_wire1_ads1115-1024x498.webp 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_wire_wire1_ads1115-300x146.webp 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_wire_wire1_ads1115-768x374.webp 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_wire_wire1_ads1115-1320x642.webp 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/ard_nano_v4_mc_wire_wire1_ads1115.webp 1432w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Using Wire and Wire1 on the NanoV4-MC<\/figcaption><\/figure>\n\n<p>And here is the corresponding sketch:<\/p>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-group=\"nanov4_mc_wire_wire1.ino\" data-enlighter-title=\"nanov4_mc_wire_wire1.ino\">#include&lt;ADS1115_WE.h&gt; \n#include&lt;Wire.h&gt;\n#include&lt;Wire1.h&gt;\n#define I2C_ADDRESS 0x48\n\nADS1115_WE adc_0 = ADS1115_WE(&amp;Wire, I2C_ADDRESS);\nADS1115_WE adc_1 = ADS1115_WE(&amp;Wire1, I2C_ADDRESS);\n\nvoid setup() {\n  Wire.begin();\n  Wire1.begin();\n  Serial.begin(9600);\n  if(!adc_0.init()){\n    Serial.println(\"ADS1115 0 not connected!\");\n  }\n  else{\n    Serial.println(\"ADS1115 0 successfully connected!\");\n  }\n  if(!adc_1.init()){\n    Serial.println(\"ADS1115 1 not connected!\");\n  }\n  else{\n    Serial.println(\"ADS1115 1 successfully connected!\");\n  }\n}\n\nvoid loop() {}<\/pre>\n\n<p>As expected, the output is:<\/p>\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/output_nanov4_mc_wire_wire1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"467\" height=\"41\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/output_nanov4_mc_wire_wire1.png\" alt=\"Output of nanov4_mc_wire_wire1.ino\" class=\"wp-image-21479\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/output_nanov4_mc_wire_wire1.png 467w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/output_nanov4_mc_wire_wire1-300x26.png 300w\" sizes=\"auto, (max-width: 467px) 100vw, 467px\" \/><\/a><figcaption class=\"wp-element-caption\">Output of nanov4_mc_wire_wire1.ino<\/figcaption><\/figure>\n\n<h3 class=\"wp-block-heading\" id=\"spi1_nanov4_mc\">Using SPI1<\/h3>\n\n<p>In principle, you can use SPI1, but passing it to objects does not work as easily as with Wire1. The main problem is that SPI1 has been defined in the MiniCore library as an object of the class &#8220;SPI1Class&#8221; and most libraries do not recognize &#8220;SPI1Class&#8221;.<\/p>\n<p>However, direct use of SPI1, i.e. via <code>SPI1.transfer()<\/code> and Co, is not a problem. If you only want to use SPI1 because you need the standard SPI pins for other purposes, then you could change to the Pololu board package. We&#8217;ll come to that later.<\/p>\n\n<h3 class=\"wp-block-heading\" id=\"timer_pwm_nanov4_mc\">Additional Timer \/ PWM <\/h3>\n\n<p>The ATmega328PB has the additional Timer\/Counter 3 and 4. The systematics of the associated registers correspond to that of Timer\/Counter 1, which I have described in detail <a href=\"https:\/\/wolles-elektronikkiste.de\/en\/timer-and-pwm-part-2-16-bit-timer1\" target=\"_blank\" rel=\"noopener\">here<\/a>. The OC3A and OC4A outputs are located at PD0 (RX\/D0) and PD1 (TX\/D1). Here is a simple example of a PWM signal that is output to OCRA:<\/p>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">void setup(){\n  noInterrupts();\n  \/\/ prescaler: 8, top = ICR3, clear at OCR3A, set at top, output at OC3A\n  TCCR3A = (1 &lt;&lt; COM3A1) | (1 &lt;&lt; WGM31);\n  TCCR3B = (1 &lt;&lt; WGM33) | (1 &lt;&lt; WGM32) | (1 &lt;&lt; CS31);\n  DDRD = (1 &lt;&lt; DDD0); \/\/ PD0 to OUTPUT\n  OCR3A = 9999;\n  ICR3 = 39999; \/\/ pwm frequency 50 Hz, duty cycle 25%\n  interrupts();\n}\n\nvoid loop() {}<\/pre>\n\n<p>And as always with this topic, I recommend the great tool <a href=\"https:\/\/dbuezas.github.io\/arduino-web-timers\/#mcu=ATMEGA328PB&amp;timer=0\" target=\"_blank\" rel=\"noopener\">Arduino Web Timers<\/a> by <a href=\"https:\/\/github.com\/dbuezas\" target=\"_blank\" rel=\"noopener\">David Buezas<\/a>. With this tool, you can make your settings using tick boxes and do not have to laboriously search for the register settings from the data sheet.<\/p>\n\n<h3 class=\"wp-block-heading\" id=\"ocm_nanov4_mc\">Output Compare Modulator<\/h3>\n\n<p>OC3B and OC4B share pin PD2 (D2) and form the Output Compare Modulator with which you can combine the two PWM signals. There are two settings:<\/p>\n<ol>\n<li>PD2 is set to HIGH:\n<ul>\n<li>PD2 Level = Signal<sub>OC3B<\/sub> <strong>|<\/strong> Signal<sub>OC4B<\/sub><\/li>\n<li>This means that the signals are logically OR-linked.<\/li>\n<\/ul>\n<\/li>\n<li>PD2 is set to LOW:&nbsp;\n<ul>\n<li>PD2 Level = Signal<sub>OC3B<\/sub> <strong>&amp;<\/strong> Signal<sub>OC4B<\/sub><\/li>\n<li>This means that the signals are logically AND-linked.&nbsp;<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n<p>As an example, we take two PWM signals with a duty cycle of 25%. The PWM frequency of OC4B should be twenty times the PWM frequency of OC3B.<\/p>\n<p>Here&#8217;s the sketch:<\/p>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-group=\"output_compare_modulator_example.ino\" data-enlighter-title=\"output_compare_modulator_example.ino\">void setup(){\n  noInterrupts();\n  \/\/ OC3B settings:\n  TCCR3A = (1 &lt;&lt; COM3B1) | (1 &lt;&lt; WGM31);\n  TCCR3B = (1 &lt;&lt; WGM33) | (1 &lt;&lt; WGM32) | (1 &lt;&lt; CS31);\n  OCR3B = 9999;\n  ICR3 = 39999;\n  \n  \/\/ OC4B settings:\n  TCCR4A = (1 &lt;&lt; COM4B1) | (1 &lt;&lt; WGM41);\n  TCCR4B = (1 &lt;&lt; WGM43) | (1 &lt;&lt; WGM42) | (1 &lt;&lt; CS41);\n  OCR4B = 399;\n  ICR4 = 1999;\n  \n  \/\/ PD2 settings\n  DDRD = (1 &lt;&lt; DDD2);\n  \/\/ PORTD |= (1&lt;&lt;PD2);\n  interrupts();\n}\n\nvoid loop() {}\n<\/pre>\n\n<p>The signal to PD2 depends on whether you leave line 17 commented out or uncomment it. To obtain the individual signals OC3B and OC4B, you must uncomment line 17 and comment lines 4 to 7 and 10 to 13 respectively.<\/p>\n<p>With a <a href=\"https:\/\/wolles-elektronikkiste.de\/en\/logic-analyzer\" target=\"_blank\" rel=\"noopener\">Logic Analyzer<\/a> I got the following outputs:<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/oc3b_oc4b_modulation_oc3b_signal-1024x465.webp\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"465\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/oc3b_oc4b_modulation_oc3b_signal-1024x465.webp\" alt=\"Logic Analyzer output from output_compare_modulator_example.ino\" class=\"wp-image-21435\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/oc3b_oc4b_modulation_oc3b_signal-1024x465.webp 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/oc3b_oc4b_modulation_oc3b_signal-300x136.webp 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/oc3b_oc4b_modulation_oc3b_signal-768x349.webp 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/oc3b_oc4b_modulation_oc3b_signal-1536x698.webp 1536w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/oc3b_oc4b_modulation_oc3b_signal-1320x600.webp 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/oc3b_oc4b_modulation_oc3b_signal.webp 1745w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Logic Analyzer output from output_compare_modulator_example.ino<\/figcaption><\/figure>\n\n<h3 class=\"wp-block-heading\" id=\"aco_nanov4_mc\">Analog Comparator Output<\/h3>\n\n<p>The Analog Comparator compares two voltages and indicates which of the two is greater. With the ATmega328P, you have to query the ACO bit (Analog Comparator Output), or set up an interrupt. The ATmega328PB, on the other hand, has an additional ACO pin (PE0 \/ D23).&nbsp;<\/p>\n<p>Here is a small example in which we apply half the supply voltage at AIN0 (PD6 \/ D6) and connect a variable voltage source to AIN1 (PD7 \/ D7) using a potentiometer. An LED attached to the ACO pin indicates which voltage is higher.<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/analog_comparator-1024x615.webp\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"615\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/analog_comparator-1024x615.webp\" alt=\"Analog Comparator Output Example\" class=\"wp-image-21439\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/analog_comparator-1024x615.webp 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/analog_comparator-300x180.webp 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/analog_comparator-768x461.webp 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/analog_comparator.webp 1204w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Analog Comparator Output Example<\/figcaption><\/figure>\n\n<p>Here is the amazingly short sketch:<\/p>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-group=\"analog_comparator_output.ino\" data-enlighter-title=\"analog_comparator_output.ino\">void setup() {\n  ACSR = 0x00;    \n  ADCSRB = 0x00;\n  ACSRB = (1 &lt;&lt; ACOE);  \/\/ Analog Comparator Output Enable\n} \n\nvoid loop() {}<\/pre>\n\n<p>If the voltage at D7 is higher than at D6, the LED is off. If the voltage at D7 is lower, the LED is on. The inputs for the Analog Comparator can be multiplexed to all analog pins. But that would be going a bit too far here. <\/p>\n\n<h2 class=\"wp-block-heading\" id=\"astar_328pb_micro\">&#8220;Pro Mini Style&#8221; board using the Pololu A-Star 328PB Micro as an example<\/h2>\n\n<p>If you prefer an ATmega328PB based board in Pro Mini style, you could go for the Pololu A-Star 328PB Micro. It is available in four variants:<\/p>\n<ul>\n<li>5 volts &#8211; 20 MHz<\/li>\n<li>5 volts &#8211; 16 MHz<\/li>\n<li>3.3 volts &#8211; 12 MHz<\/li>\n<li>3.3 volts &#8211; 8 MHz<\/li>\n<\/ul>\n<p>Pololu points out that the 20 MHz model is operated outside the specification (max. 16 MHz). I used the 20 MHz version for several hours, and it worked flawlessly &#8211; which, of course, is no guarantee!<\/p>\n<p>The A-Star 328PB is also well documented on the <a href=\"https:\/\/www.pololu.com\/category\/239\/a-star-328pb-micro\" target=\"_blank\" rel=\"noopener\">Pololu website<\/a> with instructions, specifications and schematics. There is also a <a href=\"https:\/\/forum.pololu.com\/\" target=\"_blank\" rel=\"noopener\">Pololu forum<\/a> that you can contact if you encounter any problems. <\/p>\n\n<h3 class=\"wp-block-heading\" id=\"install_pololu_package\">Installation of the recommended board package<\/h3>\n\n<p>The installation in the Arduino IDE is described in detail <a href=\"https:\/\/www.pololu.com\/docs\/0J74\" target=\"_blank\" rel=\"noopener\">here<\/a> on the Pololu website. The ultra-short version is:<\/p>\n<ol>\n<li>Add the following board manager URL: &#8220;https:\/\/files.pololu.com\/arduino\/package_pololu_index.json&#8221;.<\/li>\n<li>Install the board package: &#8220;Pololu A-Star Boards&#8221;.<\/li>\n<li>Select the following board: &#8220;Pololu A-Star Boards&#8221; \u2192 &#8220;Pololu A-Star 328PB&#8221;.<\/li>\n<li>Set the correct variant in terms of voltage and clock.<\/li>\n<\/ol>\n\n<h3 class=\"wp-block-heading\" id=\"pinout_astar_328pb\">Pinout<\/h3>\n\n<p>Although the A-Star 328PB Micro has the same dimensions as an Arduino Pro Mini board, the two additional GPIOs PE0 (D22) and PE1 (D23) and AREF are implemented on it. Furthermore, there is a reverse-protected battery input (BAT+), an additional VCC pin and an ISP header. The latter is very practical for uploading via programmer.<\/p>\n<p>Here is the pinout diagram (with kind permission of Pololu):<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/pinout_a_star_328pb_micro-1024x602.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"602\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/pinout_a_star_328pb_micro-1024x602.jpg\" alt=\"\" class=\"wp-image-21444\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/pinout_a_star_328pb_micro-1024x602.jpg 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/pinout_a_star_328pb_micro-300x177.jpg 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/pinout_a_star_328pb_micro-768x452.jpg 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/pinout_a_star_328pb_micro.jpg 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Pinout Diagram A-Star 328PB Micro, Copyright: Pololu<\/figcaption><\/figure>\n\n<h3 class=\"wp-block-heading\" id=\"upload_burn_bootloader\">Sketch upload \/ burning the bootloader<\/h3>\n\n<h4 class=\"wp-block-heading\">Via Serial with USB-to-TTL adapter<\/h4>\n\n<p>To upload via Serial, you will need a USB-to-TTL adapter (also known as an FTDI adapter). Please note that RX must be connected to TX and TX to RX. In addition, the operating voltage of the adapter must match that of the A-Star 328PB Micro. &nbsp;<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/astar_328PB_serial_upload-1024x255.webp\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"255\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/astar_328PB_serial_upload-1024x255.webp\" alt=\"USB-to-TTL adapter on the A-Star 328PB Micro\" class=\"wp-image-21492\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/astar_328PB_serial_upload-1024x255.webp 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/astar_328PB_serial_upload-300x75.webp 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/astar_328PB_serial_upload-768x191.webp 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/astar_328PB_serial_upload.webp 1218w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">USB-to-TTL adapter on the A-Star 328PB Micro<\/figcaption><\/figure>\n\n<p>If the upload via adapter does not work and aborts with an &#8220;acess denied&#8221; error message, this could be because the serial monitor is still open. Close it and then it should work.<\/p>\n\n<h4 class=\"wp-block-heading\">Upload via ISP \/ burning the bootloader<\/h4>\n\n<p>If you prefer to upload via ISP, you will need a programmer. The advantage of this method is that you save the memory space for the bootloader (= 512 bytes of flash). The disadvantage is that you have no connection to the serial monitor.<\/p>\n<p>When uploading via ISP, the bootloader is deleted. If you want to switch back to the serial upload, you must first burn the bootloader.<\/p>\n<p>Inexpensive programmers can be found under the search term USBASP or USBtinyISP. I have tested these and various others, and they all worked perfectly.<\/p>\n\n<h4 class=\"wp-block-heading\">The all-rounder: Pololu USB AVR Programmer v2.1<\/h4>\n\n<p>The <a href=\"https:\/\/www.pololu.com\/product\/3172\" target=\"_blank\" rel=\"noopener\">Pololu USB AVR Programmer v2.1<\/a> is an ideal addition to the A-Star 328BP Micro. It is a USB-to-TTL adapter and an ISP programmer in one. For program upload via serial you can plug it in directly, for programming via ISP you connect the ISP headers. <\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/programmer_with_astar328pb-2-1024x319.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"319\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/programmer_with_astar328pb-2-1024x319.jpg\" alt=\"\" class=\"wp-image-21470\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/programmer_with_astar328pb-2-1024x319.jpg 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/programmer_with_astar328pb-2-300x93.jpg 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/programmer_with_astar328pb-2-768x239.jpg 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/programmer_with_astar328pb-2-1320x411.jpg 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/programmer_with_astar328pb-2.jpg 1500w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">A harmonious duo: A-Star 328 PB Micro and USB AVR Programmer v2.1<\/figcaption><\/figure>\n\n<p>If you choose this model, I recommend that you read the <a href=\"https:\/\/www.pololu.com\/docs\/0J67\" target=\"_blank\" rel=\"noopener\">instructions<\/a>. Some settings of this programmer, such as the operating voltage, are made via a user interface. <\/p>\n\n<h3 class=\"wp-block-heading\" id=\"serial1_astar_328pb\">Using Serial1<\/h3>\n\n<p>Using Serial1 is just as easy as it is with the NanoV4-MC. As a test, you could let two A-Star 328 PB Micro &#8220;talk&#8221; to each other. To do this, connect TXD1 to RXD1, RXD1 to TXD1 and GND to GND.<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/astar_serial1-1024x284.webp\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"284\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/astar_serial1-1024x284.webp\" alt=\"\" class=\"wp-image-21503\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/astar_serial1-1024x284.webp 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/astar_serial1-300x83.webp 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/astar_serial1-768x213.webp 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/astar_serial1-1536x426.webp 1536w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/astar_serial1-1320x366.webp 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/astar_serial1.webp 1592w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Serial1 connection of two A-Star 328PB Micro<\/figcaption><\/figure>\n\n<p>Take nanov4_mc_serial_serial1.ino from above as the sketch. <\/p>\n\n<h3 class=\"wp-block-heading\" id=\"wire1_spi1_astar_328pb\">Using Wire1 and SPI1<\/h3>\n\n<p>As far as Wire1 and SPI1 are concerned, the Pololu board package takes a different approach to the MiniCore package. Parallel use of Wire (&#8220;Wire0&#8221; \/ &#8220;TWI0&#8221;) and Wire1 or of SPI (&#8220;SPI0&#8221;) and SPI1 is not possible. Instead, you set which of the interfaces you want to use in the Arduino IDE:<\/p>\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"443\" height=\"83\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/wire_spi_coice.png\" alt=\"\" class=\"wp-image-21506\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/wire_spi_coice.png 443w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/wire_spi_coice-300x56.png 300w\" sizes=\"auto, (max-width: 443px) 100vw, 443px\" \/><\/figure>\n\n<p>You can switch back and forth, but not within one sketch. As an example, I will show how to control ADXL345 modules via SPI. To do this, I connected one module to SPI0 and the other to SPI1:<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/pololu_astar_spi0_spi1-1024x533.webp\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"533\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/pololu_astar_spi0_spi1-1024x533.webp\" alt=\"ADXL345 modules on SPI0 and SPI1 of the A-Star 328PB Micro\" class=\"wp-image-21463\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/pololu_astar_spi0_spi1-1024x533.webp 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/pololu_astar_spi0_spi1-300x156.webp 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/pololu_astar_spi0_spi1-768x400.webp 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/pololu_astar_spi0_spi1.webp 1166w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">ADXL345 modules on SPI0 and SPI1 of the A-Star 328PB Micro<\/figcaption><\/figure>\n\n<p>The sketch is the same for both modules and SPI interfaces:<\/p>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include&lt;ADXL345_WE.h&gt;\n#include&lt;SPI.h&gt;\n#define CS_PIN 10   \/\/ Chip Select Pin\n\nbool use_spi = true;    \/\/ specific for ADXL345_WE\nADXL345_WE myAcc = ADXL345_WE(&amp;SPI, CS_PIN, use_spi);\n\nvoid setup(){\n  Serial.begin(9600);\n  Serial.println(\"ADXL345 SPI-Test\");\n  if(!myAcc.init()){\n    Serial.println(\"ADXL345 not connected!\");\n  }\n  else {\n    Serial.println(\"ADXL345 successfully connected!\");\n  }\n}\n\nvoid loop() {}<\/pre>\n\n<p>If you do not like the behavior of Wire and SPI when using the Pololu package, you could switch to the MiniCore package. <\/p>\n\n<h3 class=\"wp-block-heading\" id=\"aco_timer_ocm\">Analog Comparator Output, Timer and Output Compare Modulator<\/h3>\n\n<p>As my example sketches for the NanoV4-MC address the registers of the ATmega328PB directly, they work in the same way for the A-Star 328PB Micro.&nbsp;<\/p>\n\n<h2 class=\"wp-block-heading\" id=\"wattuino_pro_mini_pb\">Wattuino Pro Mini PB<\/h2>\n\n<p>I will keep this section short, as things are repetitive. You can get the Wattuino Pro Mini PB in two versions:<\/p>\n<ul>\n<li>5 volts \/ 16 MHz<\/li>\n<li>3.3 volts \/ 8 MHz<\/li>\n<\/ul>\n<p>An &#8211; in comparison, less detailed &#8211; documentation can be found <a href=\"https:\/\/learn.watterott.com\/breakouts\/wattuino-pro-mini\/#wattuino-pro-mini-pb\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n<p>Watterott suggests using the <a href=\"https:\/\/github.com\/watterott\/ATmega328PB-Testing?tab=readme-ov-file#atmega328pb-testing\" target=\"_blank\" rel=\"noopener\">ATmega328PB-Testing<\/a> board package for the Wattuino Pro Mini PB. You can also install the package directly or via the board manager of the Arduino IDE. The board manager URL is:<\/p>\n<p>&#8220;https:\/\/github.com\/watterott\/ATmega328PB-Testing\/raw\/master\/package_m328pb_index.json&#8221;<\/p>\n\n<p>The pinout design is almost identical to that of the Arduino Pro Mini. Only the pins for PE0 (SDA1 \/ 22) and PE1 (SCL1 \/ 23) have been added. As with the original Pro Mini, AREF is not implemented. You can find the circuit diagram of the board <a href=\"https:\/\/github.com\/watterott\/Wattuino\/blob\/master\/hardware\/Wattuino-Pro-Mini-PB_v10.pdf\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/wattuino-1024x447.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"447\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/wattuino-1024x447.jpg\" alt=\"\" class=\"wp-image-21459\" style=\"width:570px;height:auto\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/wattuino-1024x447.jpg 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/wattuino-300x131.jpg 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/wattuino-768x335.jpg 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/wattuino-1536x670.jpg 1536w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/wattuino-1320x576.jpg 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/wattuino.jpg 1800w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Wattuino Pro Mini PB<\/figcaption><\/figure>\n\n<p>Serial1 works as with the other boards. Wire1 and SPI1 again have the problem that they are objects of the classes TwoWire1 and SPI1Class respectively. For this reason, the use of libraries that use Wire or SPI is also only common here with restrictions, although work seems to have been done on the problem. Personally, I would rather recommend using the board packages from Pololu or MCUdude.<\/p>\n\n<h2 class=\"wp-block-heading\" id=\"change_board_package\">Changing the board package<\/h2>\n\n<p>As you have seen, the characteristics of the boards considered here are largely determined by the board package used. You are free to choose the board package as long as it is written for the ATmega328PB. For some changeovers, e.g. from the Pololu package to MiniCore, you must first burn the bootloader. It should also be noted that the Arduino pin designations for PE0 and PE1 may be different.<\/p>\n\n<h2 class=\"wp-block-heading\">Acknowledgement<\/h2>\n\n<p>Many thanks to Pololu, Joy-IT and Watterott for their kind support!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I will go into the differences of the ATmega328PB vs. the ATmega328P and introduce three 328PB-based boards and board packages. <\/p>\n","protected":false},"author":1,"featured_media":21414,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[543],"tags":[2520,2527,2526,2519,2532,2518,2528,718,764,2522,2525,1497,983,2523,2524,2521,2534,1446],"class_list":["post-21553","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-boards-and-microcontrollers","tag-a-star-pololu-328pb-micro","tag-aco-en","tag-analog-comparator","tag-ard-nanov4-mc-en","tag-atmega328pb-en","tag-atmega328pb-vs-atmega328p-en","tag-board-package","tag-burn-bootloader","tag-isp-en","tag-minicore-en","tag-output-compare-modulator-en","tag-pinout-en","tag-pwm-en","tag-serial1-en","tag-spi1-en","tag-wattuino-pro-mini-pb-en","tag-wifi1-en","tag-wire1-en"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>ATmega328PB based boards &#8226; Wolles Elektronikkiste<\/title>\n<meta name=\"description\" content=\"I will go into the differences of the ATmega328PB vs. the ATmega328P and introduce three 328PB-based boards and board packages.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wolles-elektronikkiste.de\/en\/atmega328pb-based-boards\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ATmega328PB based boards &#8226; Wolles Elektronikkiste\" \/>\n<meta property=\"og:description\" content=\"I will go into the differences of the ATmega328PB vs. the ATmega328P and introduce three 328PB-based boards and board packages.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wolles-elektronikkiste.de\/en\/atmega328pb-based-boards\" \/>\n<meta property=\"og:site_name\" content=\"Wolles Elektronikkiste\" \/>\n<meta property=\"article:published_time\" content=\"2024-06-20T18:44:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/postimage_328pb.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"820\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Wolfgang Ewald\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Wolfgang Ewald\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"15 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/atmega328pb-based-boards#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/atmega328pb-based-boards\"},\"author\":{\"name\":\"Wolfgang Ewald\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\"},\"headline\":\"ATmega328PB based boards\",\"datePublished\":\"2024-06-20T18:44:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/atmega328pb-based-boards\"},\"wordCount\":2649,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\"},\"image\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/atmega328pb-based-boards#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/postimage_328pb.jpg\",\"keywords\":[\"A-Star Pololu 328PB Micro\",\"ACO\",\"Analog Comparator\",\"ARD-NanoV4-MC\",\"Atmega328PB\",\"ATmega328PB vs. ATmega328P\",\"board package\",\"burn bootloader\",\"ISP\",\"MiniCore\",\"Output Compare Modulator\",\"Pinout\",\"PWM\",\"Serial1\",\"SPI1\",\"Wattuino Pro Mini PB\",\"WiFi1\",\"Wire1\"],\"articleSection\":[\"Boards and Microcontrollers\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/atmega328pb-based-boards#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/atmega328pb-based-boards\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/atmega328pb-based-boards\",\"name\":\"ATmega328PB based boards &#8226; Wolles Elektronikkiste\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/atmega328pb-based-boards#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/atmega328pb-based-boards#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/postimage_328pb.jpg\",\"datePublished\":\"2024-06-20T18:44:55+00:00\",\"description\":\"I will go into the differences of the ATmega328PB vs. the ATmega328P and introduce three 328PB-based boards and board packages.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/atmega328pb-based-boards#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/atmega328pb-based-boards\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/atmega328pb-based-boards#primaryimage\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/postimage_328pb.jpg\",\"contentUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/postimage_328pb.jpg\",\"width\":1200,\"height\":820},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/atmega328pb-based-boards#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Startseite\",\"item\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"ATmega328PB based boards\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#website\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\",\"name\":\"Wolles Elektronikkiste\",\"description\":\"Die wunderbare Welt der Elektronik\",\"publisher\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\",\"name\":\"Wolfgang Ewald\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\",\"contentUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\",\"width\":512,\"height\":512,\"caption\":\"Wolfgang Ewald\"},\"logo\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"ATmega328PB based boards &#8226; Wolles Elektronikkiste","description":"I will go into the differences of the ATmega328PB vs. the ATmega328P and introduce three 328PB-based boards and board packages.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wolles-elektronikkiste.de\/en\/atmega328pb-based-boards","og_locale":"en_US","og_type":"article","og_title":"ATmega328PB based boards &#8226; Wolles Elektronikkiste","og_description":"I will go into the differences of the ATmega328PB vs. the ATmega328P and introduce three 328PB-based boards and board packages.","og_url":"https:\/\/wolles-elektronikkiste.de\/en\/atmega328pb-based-boards","og_site_name":"Wolles Elektronikkiste","article_published_time":"2024-06-20T18:44:55+00:00","og_image":[{"width":1200,"height":820,"url":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/postimage_328pb.jpg","type":"image\/jpeg"}],"author":"Wolfgang Ewald","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Wolfgang Ewald","Est. reading time":"15 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/wolles-elektronikkiste.de\/en\/atmega328pb-based-boards#article","isPartOf":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/atmega328pb-based-boards"},"author":{"name":"Wolfgang Ewald","@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46"},"headline":"ATmega328PB based boards","datePublished":"2024-06-20T18:44:55+00:00","mainEntityOfPage":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/atmega328pb-based-boards"},"wordCount":2649,"commentCount":0,"publisher":{"@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46"},"image":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/atmega328pb-based-boards#primaryimage"},"thumbnailUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/postimage_328pb.jpg","keywords":["A-Star Pololu 328PB Micro","ACO","Analog Comparator","ARD-NanoV4-MC","Atmega328PB","ATmega328PB vs. ATmega328P","board package","burn bootloader","ISP","MiniCore","Output Compare Modulator","Pinout","PWM","Serial1","SPI1","Wattuino Pro Mini PB","WiFi1","Wire1"],"articleSection":["Boards and Microcontrollers"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/wolles-elektronikkiste.de\/en\/atmega328pb-based-boards#respond"]}]},{"@type":"WebPage","@id":"https:\/\/wolles-elektronikkiste.de\/en\/atmega328pb-based-boards","url":"https:\/\/wolles-elektronikkiste.de\/en\/atmega328pb-based-boards","name":"ATmega328PB based boards &#8226; Wolles Elektronikkiste","isPartOf":{"@id":"https:\/\/wolles-elektronikkiste.de\/en#website"},"primaryImageOfPage":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/atmega328pb-based-boards#primaryimage"},"image":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/atmega328pb-based-boards#primaryimage"},"thumbnailUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/postimage_328pb.jpg","datePublished":"2024-06-20T18:44:55+00:00","description":"I will go into the differences of the ATmega328PB vs. the ATmega328P and introduce three 328PB-based boards and board packages.","breadcrumb":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/atmega328pb-based-boards#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wolles-elektronikkiste.de\/en\/atmega328pb-based-boards"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wolles-elektronikkiste.de\/en\/atmega328pb-based-boards#primaryimage","url":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/postimage_328pb.jpg","contentUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2024\/06\/postimage_328pb.jpg","width":1200,"height":820},{"@type":"BreadcrumbList","@id":"https:\/\/wolles-elektronikkiste.de\/en\/atmega328pb-based-boards#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Startseite","item":"https:\/\/wolles-elektronikkiste.de\/en"},{"@type":"ListItem","position":2,"name":"ATmega328PB based boards"}]},{"@type":"WebSite","@id":"https:\/\/wolles-elektronikkiste.de\/en#website","url":"https:\/\/wolles-elektronikkiste.de\/en","name":"Wolles Elektronikkiste","description":"Die wunderbare Welt der Elektronik","publisher":{"@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wolles-elektronikkiste.de\/en?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46","name":"Wolfgang Ewald","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png","url":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png","contentUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png","width":512,"height":512,"caption":"Wolfgang Ewald"},"logo":{"@id":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png"}}]}},"_links":{"self":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/posts\/21553","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/comments?post=21553"}],"version-history":[{"count":0,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/posts\/21553\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/media\/21414"}],"wp:attachment":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/media?parent=21553"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/categories?post=21553"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/tags?post=21553"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}