One of the most powerful features of the Kitsi Platform is that Virtual Blocks can be specially designed to help Hardware Blocks behave in specific ways. In this article, we will use the NFC-PN532 Virtual Block, which was created to use the Breadboard Block to control a 3rd party electronic module used to read NFC tags.
Before starting, make sure you have already installed the required "NFC-PN532" Virtual Block from the Market Place. If this is the first time installing blocks, we recommend you have a quick look at the article How To Install Virtual Blocks And Widgets.
NOTE: This guide requires the Virtual Block NFC-PN532 version 1.4.1 and Breadboard build 266. If you don't know how to identify the versions of your blocks, please read our article How To Know The Software And Firmware Version Of My Block.
If you just want to see it working, here is a TLDR:
- Connecting the PN532 module to the breadboard is easy, just make sure the board is configured as I2C. Most modules have a small DIP switch that you can use to select the desired communication protocol. Depending on the module you are using the location of
the dip switch may change. Use the following picture as a reference, just make sure that the combination you select is I2C.
- Connect the module to the Breadboard as shown in the picture below. Make sure that the SCL pin from the module is connected to the Breadboard's input 0 (IO0):
- Power up your Breadboard, WiFi and Power Station blocks and make sure they appear online:
- From the "Virtual Blocks" menu list, add an NFC-PN532 virtual block and from its Properties Panel, click on the red 'sync' button to initialize the communication between the Breadboard and the NFC module. The NFC-PN532 Virtual Block takes care of configuring the required pins in the Breadboard, so you don't have to worry about this.
After a few seconds, the icon's colour should change to green an a notification pop up. Your NFC module should also light up its internal LED. If the sync process doesn't work the first time, double check your connections and try again.
- To start recording tags, just click on the white 'plus' icon, you can add as many as you need. You can alternatively give them a different name.
- Click on the yellow record button, it should start flashing red, this indicates the program is now waiting for an NFC tag to be recorded. While the button is flashing, position an NFC tag on top of the module. The icon should then change to green, indicating that the tag has been recognized and stored. Do this process for all the tags you want to recognize until their icons are green:
- Add a Sound Player block and attach it as a child of the NFC-PN532 Canvas block:
- Open the NFC-PN532's Logic Maker and add 3 Input gates and 3 Action gates. From the Input gates, select the name of the cards you recorded in the Properties Panel and from the Action gates select the sounds you would like to reproduce when a tag is detected. For example, if you didn't change the names, you could select:
Input Gate Action Gate Card-1 --> Beep Card-2 --> Horn NONE --> Error
The 'NONE' input will be triggered when a tag is detected that doesn't match any of the recorded tags.
Click on 'Apply'
- You should now be able to present a tag on top of the NFC module and see the gates light up and produce the selected sound:
You can, of course, trigger any action you want, not just playing sounds. For example, you could control a servo motor to unlock a door and send an Email to notify you when someone enters the building!
If this article was helpful to you, please rate it and comment!