HOME                                        

Part 1:  Test  Your  Aduino M4  MBC

Part 2:  Test  Your  Aduino M4  MBC   =>  

Circuit Tests (click .gif for video) Test:  Power Supplies, USB-FTDI, I2C, OLED, RTC, micro-SD

OLED Test

(Click for a short video)

 

 

BME280 Test

(Click for a short video)

 

 

RTC Test

(Click for a short video)

 

 

Micro-SD Test

(Click for a short video)

Overview

Once again we'll breadboard the circuits for our M4 SBC Weather Station one circuit at a time.

 

I2C, Pullup Resistors, 1.3" OLED

On the Adafruit ItsyBitsy M4 Express microcontroller board, we have connected a jumper wire from SCL (near pin 5) to SCK of the OLED. On the M4 we connected another jumper wire from SDA to SDA of the OLED. This almost completes our I2C connection; two 10K pullup resistors to 3.3v have been added to the circuit because Adafruit reports there are none (see page 17) on their M4 Express board.

As you can see in the adjacent .gif file (click it for a larger .mp4 video file), we are running Adafruit's test file.

I loaded the "ssd1306_128x64_i2c.ino" file found in the Arduino IDE under  "File|Examples|Adafruit SSD1306" and made a few changes:

 - line 30: changed "#define OLED_RESET 4"  to  "#define OLED_RESET -1"

 - line 59: changed "if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3D)) {"  to   "if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {"

These two lines will advise the driver there is no separate digital line to handle Reset and it will also change the I2C address from 0x3D to 0x3C.

The file has been saved to OLED_4-Wire.ino.

 

Note on 1.3" OLED Displays

There are at least three different OLED displays that appear to be the same until you take a closer look.

Banggood sells

 

 

BME280 Sensor

The next test uses portions of the "Weather_Inside_SD_Tone_Flash_2h.ino" file to test both the BME280 Temperature/Humidity/Barometric Pressure sensor as well as the OLED we tested earlier. Content will also go to the Serial Monitor running at 9600bps (default).

The needed test file is "BME280_OLED_Test.ino".

Upload it to your Aduino. Expect the display to blank briefly every 2.5 seconds. Breathe directly on the BME280 board and you should see both the Serial Monitor and OLED display reflect the change in temperature and humidity as it does in the short video.

Communication to the Arduino ATmega328P is via I2C so that should be working fine.

 

 

 

 

 

 

 

 

RTC Real Time Clock

On our breadboard we can simply add the Adafruit DS1307 RTC module. (Within the SBC design however, we'll add the components but not the Adafruit breakout board.) I removed the 2.2K pullup resistors from the board so the 10K units attached to the M4 module's I2C lines will take over. Click this link for more info on calculating pullup resistor values.

Remove the battery and upload this test file, BME280_OLED_RTC_Test.ino. The date and time will be pulled from your PC.

Shutdown the system, install the CR1220 battery and run the program again after repowering the breadboard. Once the program runs a second time, you should have the correct date and time. If the RTC drifts too much, just reattach your USB cable and rerun the program.

 

 

 

 

 

 

 

 

 

Micro-SD Board

The Adafruit ItsyBitsy M4 Express board uses the Microchip ATSAMD51G microcontroller which has many more I/O lines than the original ATmega328P. As such, some are labelled by function and not by digital/analog number. As an example with the old controller, A5 and A4 were available for I2C's SCL and SDA, respectively. A5 and A4 are separate pins on the new controller so you need to use the SCL and SDA pins that are adjacent to D5.

SPI pins on the old controller were numbered D10(SS), D11(MOSI), D12(MISO) and D13(SCK). On the new controller they are *, MO, MI and SCK. Historically we used D10 for the SS select signal so we'll do the same in our test code.

The Arduino test file, BME280_OLED_RTC_SD_Test.ino, continues with the previous test modules you've worked through and has an added test for the microSD card module, too. You may notice in the file that all of the text printable by the Serial Monitor is prefaced by "F()". This is to move the text out of global variables and into regular memory. Failure to do so resulted in a "Low memory resources can lead to unstable operation" or something like that in the older ATmega328P uC. This is no longer a concern with this big memory uC but we'll keep up the good habit.

In the test file the data is written to the SD card every 5 seconds. You will see "!" flash to the right of the current time on the OLED after the data is written to the microSD card. You will probably want to change the timers so that the screen is displayed for 10s (when movement occurs via the PIR) and the file is written every minute.

Part 2:  Test  Your  Aduino M4  MBC   =>  

 

TOP

Tags: Arduino-type Microcontroller, ATMega328P

 

HOME