2-Bullet Tuesday - Edition #65


  • administrators

    Hi!
    Welcome back to 2-Bullet Tuesday, where we’ll share useful tips and awesome stuff sent in by Omega2 users all around the world. Check out creative projects and tutorials that will supercharge your IoT development!

    Omega Tip #1

    Building Custom Kernel Modules for the Omega2
    This week’s featured project is actually more of a tip and is brought to you by an active member of the Onion Community, Maximiliam Gerhardt. Max prepared a detailed guide on how to build a custom Kernel Module for the Omega2 using the LEDE Build System. For some background, kernel modules are code that can be loaded into the kernel dynamically (ie without having to reboot) to extend the functionality the kernel, and thereby, your device.

    test1

    This continues down the path of our previous tips on Setting up the LEDE Build System and Cross Compiling C programs and goes even further.

    test2

    This very thorough guide covers what a Kernel Module is and why it’s useful, a full procedure for building a sample “Hello World” Kernel Module, and, the icing on the cake, builds on this knowledge to create a kernel module for accepting input from a USB XBox Joystick!

    test3

    Thank you for such an amazing and detailed tutorial, Max! We especially like how you presented a topic super clearly, and then immediately used it to make something awesome!

    Check out the Hackster Post

    Omega Tip #2

    Using RFID & NFC Expansion to write/read NDEF Data
    Last week we guided you through setting up your RFID & NFC Expansion and then reading and writing Mifare Ultralight tags. This week, we’ll continue using the new RFID & NFC Expansion, but this time, we’ll be writing standardized NDEF messages to a MiFare Classic card that can be read by other NFC enabled devices like smartphones!

    logo

    We’ll guide you through the installation process and the hardware setup. Then we’ll jump into reading & writing NDEF data. So, let’s get started!

    Installation of the tools

    If you haven’t followed our earlier tip about setting up the RFID & NFC Expansion, take a look at that for more details. If you’re in a hurry, here are the commands you’ll need to run:

    opkg update
    opkg install nfc-exp
    

    This will install the libnfc and libfreefare libraries and utilities that we’ll be using for this week’s tip. For more details on these libraries and utilities, see our Docs article on using the RFID & NFC Expansion.

    Hardware Setup

    Plug your Expansion into any Dock that features the Expansion Header: the (Expansion Dock, Power Dock 2, or Arduino Dock 2. Now power on your Omega and you are all set to go!

    Please note: During the boot process, the Expansion draws a lot of current. We recommend connecting it to a Dock while the Omega is powered off. If the Omega is powered on, the large current draw may cause the Omega to reboot.

    NDEF? What is That?

    NDEF stands for NFC Data Exchange Format and it is a standardized data format for exchanging data between NFC enabled devices. Rather than writing raw data like we did previously, the NDEF format allows us to give context to the data we’re writing. This allows the device that reads the NDEF-formatted data to automatically take action based on the data it reads, for example: opening a browser to navigate to a website stored on the card, or connecting to a WiFi network based on the network name and password stored on the card. In our case, we’ll be using NDEF to write a plain-text message to start.

    If you’re interested in learning more about NDEF, Adafruit has a great article on the topic.

    Writing NDEF Message to the Card

    Let’s get started! For this example, we will be writing a plain-text (human-friendly) message to a Mifare Classic 1K Card.
    logo

    First, we’ll need to write the message we plan to write to the card. On your Omega, create a file called ndef-message.txt and populate it with the following text:

    Hello World, I'm using Onion RFID & NFC Expansion
    

    Now, we’ll write this message to your Mifare Classic card. From the command line, issue the following:

    mifare-classic-write-ndef -y -o ndef-message.txt
    

    And you’ll see something like the following:

    write

    The -y option tells the program we’re sure about what we’re doing and that it doesn’t need to prompt for any confirmation. The -i ndef-message.txt argument specifies the contents of ndef-message.txt as the NDEF message to be written

    Our message has been written to the card successfully! Now let’s read the card’s NDEF content!

    Reading NDEF Message from the Card

    In order to read card’s NDEF content, issue the following command from your terminal:

    mifare-classic-read-ndef -y -o read-ndef-message.txt
    

    This well read the contents of the card, and store them on the Omega’s filesystem in a file called read-ndef-message.txt. You can use cat to see the message:

    read

    Formatting the Card

    If you’ve written a whole bunch of NDEF records to your card and want a clean slate, you can use the mifare-classic-format command to delete of the content currently stored on the card. The card will still be usable, it will just be empty. Just note that this operation cannot be reversed and all data on the card will be lost, so please proceed with caution and back up the data that you wish to save.

    In order to format your card, run the following command:

    mifare-classic-format -fy
    

    format

    This will perform a fast format (erases only MAD) and will not ask for confirmation.

    Going Further

    And there you have it, we’ve learned how to read and write NDEF messages to a MiFare Classic card. As mentioned, NDEF messages are super useful since they can be quickly read by other devices, including most modern smartphones, opening the door to lots of awesome security, information sharing, and automation applications. We can’t wait to see all of the awesome NFC projects you all come up with!

    Subscribe

    Make sure to subscribe to 2-Bullet Tuesday to get technical tips about using the Omega, projects created by Omega2 users, and, occasionally, special promotions for the Onion Online Store sent directly to your inbox!

    subscribe

    P.S. We're going to be out in Silicon Valley for a double-header in mid-May. Come see us at IoT World in Santa Clara May 14-17 & MakerFaire Bay Area May 18-20.
    IoT



Looks like your connection to Community was lost, please wait while we try to reconnect.