element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Summer of Green Tech Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Summer of Green Tech Design Challenge
  • More
  • Cancel
Summer of Green Tech Design Challenge
Blog Home monitoring system #2
  • Blog
  • Forum
  • Documents
  • Leaderboard
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Summer of Green Tech Design Challenge to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: redcharly
  • Date Created: 7 Oct 2023 4:22 PM Date Created
  • Views 678 views
  • Likes 5 likes
  • Comments 6 comments
  • summer of green tech design challenge
  • seeedstudio
  • Xiao
  • samd21
Related
Recommended

Home monitoring system #2

redcharly
redcharly
7 Oct 2023

PWM on XIAO SAMD21

In this second blog we will see our XIAO SAMD21 in action with the sensor boards we received in the kit. Before testing the sensors, I was very curious to try using PWM on the XIAO. For this reason I used “Fade” among the basic Arduino IDE examples.

image


In this case, to use the LED on the board, I slightly modified the code. 

image

This time too there were no problems and the application worked perfectly.

/*
  Based on:    "Fading" and using builtin LED
  This example shows how to fade an LED using the analogWrite() function.
  created 1 Nov 2008
  by David A. Mellis
  modified 30 Aug 2011
  by Tom Igoe

  This example code is in the public domain.
  https://www.arduino.cc/en/Tutorial/BuiltInExamples/Fading
*/

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  // fade in from min to max in increments of 5 points:
  for (int fadeValue = 0; fadeValue <= 255; fadeValue += 5) {
    // sets the value (range from 0 to 255):
    analogWrite(LED_BUILTIN, fadeValue);
    // wait for 30 milliseconds to see the dimming effect
    delay(30);
  }

  // fade out from max to min in increments of 5 points:
  for (int fadeValue = 255; fadeValue >= 0; fadeValue -= 5) {
    // sets the value (range from 0 to 255):
    analogWrite(LED_BUILTIN, fadeValue);
    // wait for 30 milliseconds to see the dimming effect
    delay(30);
  }
}

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

DHT20 Sensor

Now we will see our XIAO SAMD21 in action with the sensor boards we received in the kit.

The first board we will try is Temperature & Humidity Sensor V2.0 (DHT20). We will find the information on the site: Grove - Temperature & Humidity Sensor V2.0 (DHT20) - Seeed Studio

It is a very interesting sensor and its characteristics are these:

  • High Accuracy:
    • Temperature Accuracy:± 0.5 ℃
    • Humidity Accuracy:± 3 % RH ( 25 ℃ )
  • Wide measurement ranges:
    • Measuring Range (Humidity):0 ~ 100% RH
    • Measuring Range (Temperature):-40 ~ + 80 ℃
  • Better compatibility:
    • Digital output
    • I²C interface
  • Fully calibrated
  • Excellent long-term stability
  • Quick response and anti-interference capability
  • Wide voltage support 2.5-5.5V DC

In order to use this temperature sensor in the Arduino IDE, we need to install the libraries related to the DHT20 sensor. Just do a search among the installable libraries to find the one we need to use this sensor. Once the DHT20 library has been installed, we will also find among the available examples some that use the DHT20.

The sensor output is of the I2C type and the connection to the Seeed Studio XIAO SAMD21 is immediate. Simply connect the sensor power supply to the 3V3 and GND PINS and connect the SDA and SCL terminals to the corresponding PINs.

image

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Another sensor I'm interested in trying is the Grove - 3-Axis Digital Accelerometer(±1.5g). It also has very interesting features and can be used in many applications, for example 3-axis motion/orientation sensing, gesture detection including shake detection and tap detection.

First of all you need to load the library: GitHub - Seeed-Studio/Accelerometer_MMA7660: Seeed 3-Axis Digital Accelerometer(±1.5g) library.

Once the library has been installed, among the examples we will find: Accelerometer_MMA7660 which allows you to view the acceleration values detected on the three axes on the terminal. This obviously can be an excellent starting point for creating more complex applications.

image

Let's now try how this board works.

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

In this blog we saw an application of PWM using XIAO SAMD21 and then we tested two of the 5 sensors from the Seeed kit. In particular we used the two sensors with I2C connection and both worked very well without any configuration problems.

  • Sign in to reply
  • redcharly
    redcharly over 2 years ago in reply to beacon_dave

    Thank you  beacon_dave !! 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • beacon_dave
    beacon_dave over 2 years ago in reply to redcharly

    I'm seeing them here now - all looks good. Thanks. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • redcharly
    redcharly over 2 years ago in reply to beacon_dave

    I've removed the 4 images and I loaded them again.

    Hope now all is ok!!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • beacon_dave
    beacon_dave over 2 years ago in reply to redcharly

    I'm still not seeing them here. Perhaps wait and see if anyone else notices it or not.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • redcharly
    redcharly over 2 years ago in reply to beacon_dave

    It's strange, I opened the page with another browser and also with my account disconnected and I see all the images correctly: could you please check in a few minutes and confirm if everything is fine?  Thanks

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube