Build a RFID card reader with Renesas AE-CLOUD1 and Medium One’s Prototyping Sandbox

This tutorial uses the Renesas Synergy AE-CLOUD1 as a RFID card reader. The AE-CLOUD1 connects to Medium One’s Prototyping Sandbox so that a new scanned RFID card key can be sent and processed.   The sandbox will perform the following operations: add, delete or verify a RFID card key.  The user can use the Medium One IoT Controller app on a smartphone to select the card processing mode.

Prerequisite:

  • AE-CLOUD1 DIAGNOSTICS INTELLIGENCE WITH SYNERGY SSP 1.3.2 AND WIFI [click here]

In this Quick Start Guide, you will:

  • Program the AE-CLOUD1 board with the modified firmware.
  • Use Medium One Workflows to turn on/off the green or red LEDs, set the RFID card process mode, and process a new card ID key received from the card reader
  • Use the Medium One IoT Controller app to control the LED on the AE-Cloud1 board and send commands to scan a RFID card.

Here’s what you need to get started:

  • Medium One Prototyping Sandbox Account [Buy Link]
  • Renesas Synergy AE-CLOUD1 [Buy-YSAECLOUD1]
  • Sparkfun RFID USB Reader [Buy-SEN-09963]
  • Sparkfun RFID Reader ID-12LA (125 kHz) [Buy-SEN-11827]
  • Windows PC or Mac OS (Note, this tutorial is based on MacOS)
  • 2.4 GHz WiFi Internet Access
  • Medium One IoT Controller App [download]
  • Software tools:
    • Renesas E2 Studio 5.4.0.23
    • Renesas SSP version 1.3.2
    • S5D9_IOT_ENABLER board file

 

STEP 1: SET UP RFID CARD READER AND AE-CLOUD1 BOARD

 

STEP 2: SET UP THE MOBILE APP

Note: These instructions are for the Android app, but the IOS app is similar.

Open the IoT Controller app and click on the plus sign in the bottom corner.

Now you can give your project a name and input your Username, Password, and API Key from the account set up. Select “Renesas”. Then press “Done”.

The profile name is any name that you want.   The API Login and Password are sent to your email account by MediumOne when you connect your AE-CLOUD1 board to the Renesas IOT Sandbox in the prerequisite tutorial.   The API key is the same one in m1config.txt used for the prerequisite tutorial.

If you entered everything correctly, you should see two blue circular icons on the bottom.  If you entered something incorrectly, the color of the of the plus circular icon will be red instead of blue.

Next, press “+Add New Widget”.

Select “Switch”.  Swipe the whole “switch” block to the right to access the settings.

The stream field is represented by a two-arrow icon.  The tag field is represented by a price tag icon. The delete button is represented by a trash can icon.

Press each icon to enter the field.  Type “raw” for the stream, and “redledsw” for the tag.

Press “+ Add New Widget” again.  Three more similar switches are created.   At the end, this is what your screen will look like.

Next, press “+Add New Widget”.

Select “Notification”.  Swipe the whole “Notification” block to the right to access the settings.

Press each icon to enter the field.  Type “notifications” for the stream, and “message” for the tag.

At the end, there are four “switch” blocks and one “notification” block.  The tag name will appear on each block.

 

Checkpoint

Go to your Medium One account and go to the “Dashboard” from the left-hand sidebar.  Click “Single User Real Time Events Stream”.

Select your user in the right hand corner of the widget.

Now, on the app, click on the “redledsw” switch to turn it on.

You should see an event show up on the widget.

Click the save icon (floppy disk) in the top right corner of the dashboard.

 

STEP 3: SET UP AE-CLOUD1 BOARD WITH S5D9 DIAGNOSTICS INTELLIGENCE

This step is same as the prerequisite tutorial.  If you have completed the tutorial, you can go to the next step.  Otherwise, you need to do this tutorial before the next step.

http://renesas-blog.mediumone.com/s5d9-diagnostics-intelligence-with-synergy-ssp-1-3-2-and-wifi/

Note:

  • Need to show how to create a new project on MediumOne’s cloud manually.
    1. Set up API registration user with name and password.
    2. Copy all the credential information for m1config.txt.
  • Need to create m1config.txt
  • Need to create wifi.txt

 

STEP 4: SET UP THE AE-CLOUD1 PROJECT

Create a workspace directory called aecloud_m1_project.   Your path directory should be something like this: C:\Users\mikel\e2_studio\workspace\aecloud_m1_project

Double click the E2 studio icon to launch the tool.  Choose the workspace directory and press OK.

Download the project archive file from Medium One’s Github repository.  (https://github.com/Medium-One/AE_Cloud1_labs)

Extract files from the zipfile.

Import the zip file into the E2 studio tool by selecting Import in the drop down menu.

Select Existing Projects into Workspace.  Press Next.

Select the directory where the zip file is downloaded from the MediumOne’s Github repos and extracted.   Check the project to import.   Press Finish.

The project is imported.   All the user source code files are in the src folder.  Double click on configuration.xml file.  Once the configuration page is displayed, click on “Generate Project Content”.

 

STEP 5:  RFID CARD READER CODE DISCUSSION

Open the net_thread_entry.c file.  This is the main c file responsible for the data exchange between the AE-CLOUD1 board and the Medium One Prototyping Sandbox.   Below is discussion of the code written for this tutorial.

First, this section of the code shown below is used to process MQTT messages from the broker (the Medium One Sandbox).    The “E” command changes the ON/OFF state of the green or red LED for the LED testing.   The “V” command makes the green LED blink once if the card scan passes or the red LED blinks once if the card scan fails.

Next, this section of code shown below is located at the end of the file.  The code is used to send data to the broker (Medium One Sandbox).   When a card is scanned, an event flag is triggered.   The code will check for this flag and send the new scanned key to the broker.

 

STEP 6: SET UP FREE E2 STUDIO LICENSE

Check License.

If this is what appears, you must locate the license file in the E2 Studio’s installed directory.   Click on the … box.

Click Browse.

Select the most recent free evaluation license file.  Press OK

Press OK again.

Press OK one more time.

 

STEP 7: BUILD PROJECT

Clean Project

Build (compile) Project.  Click the hammer.

There should be no errors.

 

STEP 8: PROGRAM BOARD

Make sure both USB cables (one for power and one for jlink) are connected to your computer or laptop at this point before proceeding.

Run debug.  This step programs the flash memory of the S5D9 processor (on the AE-CLOUD1 board) with your firmware’s executable file for running.  It sets the S5D9 processor in debug mode for single stepping or breakpoint setup.

Click Yes to override the old code if this window pops up.

Click Yes.

Click the box to remember my decision.  Then click Yes.

The debug perspective shows that it is ready to run.   Click the green arrow key or press F8.

The firmware is not at the main routine. Press F8 again.

The code is running.   “Running” is shown in the bottom left hand corner.

The file explorer of the USB drive G (AE-CLOUD1 board) will appear.

Many messages from the AE-CLOUD1 will appear.   “software_ver” indicates the firmware version.   Scan a card over the SparkFun RFID card reader.   It shows the scanned card key which was just sent to the Medium One Sandbox.

 

STEP 9:  WRITE WORKFLOW 1- SWITCH LED

Press these two switches to send event data to the sandbox.

The events will appear.

Go to “Config” on the left-hand sidebar in your Medium One account and click “Data Streams”.

Click “raw” and then click the active checkbox next to “redledsw” and “greenledsw”. Then click “Save Data Stream”.

Now go to your Workflow Studio in your Medium One account and click “Create”.

Give your workflow a name. We named ours “LED Control”.

Click the “Tags and Triggers” icon, which is the first icon on the right-hand sidebar.

Click “raw” and drag the “redledsw” and “greenledsw” tags into the main area of the workflow.

Now click on the “Modules” icon (the second icon in the sidebar), click on “Foundation” and drag a “Base Python” module into the workflow.

Double click on the base python block.  Click to add the 2nd input called in2.   Then press “save”.

Connect the bottom end of the switch tag to the “in1” and “in2” circles on the Base Python module.

Double-click on the Base Python module and copy and paste the following code (follow link) into the Script section, replacing any code that is originally there.

Now click “Save and Activate”.

 

Checkpoint

Plug the board in and open the IoT Controller app.  The board will enter the initial setup (both green and yellow led’s are turned on.)   Wait for all the LEDs to be turned off.

After the board is done setting up (within a minute), turn the app switch on and off. You should see the LED on the board turn on and off.

Unplug the board.

 

 

STEP 10: WRITE WORKFLOW 2: Set RFID Card Key Processing Mode (Add, Delete, Verify)

Press these two switches to send event data to the sandbox.

The events will appear.

Go to “Config” from the left-hand sidebar on your Medium One account and click “Data Streams”.

Click “raw” and then click the active checkbox next to “add_user_mode” and “del_user_mode”. Then click “Save Data Stream”.

Create a new stream called notification.  Click on “Create New Stream”.

Enter “notifications” for the Name field.  Choose “Never Expire.” Click “Save Data Stream.”

The new data stream is created.

Create a new workflow, name it, and drag the raw “add_user_mode” and “del_user_mode” tags into the workflow.

Drag a Base Python module into the workflow.

Double click on the base python block.  Click to add the 2nd input called in2.   Then press “save”.

Click the “Outputs” icon (third icon on sidebar) and drag one “Processed Stream – Single” output into the workflow.

Double click “Processed Stream – Single” output block.

Choose “notifications” for Datastreams field.   Click “Save.”

Connect the blocks as shown below.

Copy and paste the following code into the Script area, replacing any code (follow link below) that was previously there. Then click “Save”.

Now click on the “Revisions” icon (second from the bottom of the sidebar).

Click the checkmark under the latest revision to activate the workflow if it’s not activated.

 

Checkpoint

Go to your Mobile App.

Click the “add_user_mode” switch to change the state from OFF to ON.  A message will appear to indicate that the “add a user’s card key” mode is enabled, and the firmware is waiting for a user to scan a card.

Click the “add_user_mode” switch to change the state from ON to OFF.  A message will appear to indicate that the “verify a user’s card key” mode is enabled, and the firmware is waiting for a user to scan a card.

Click the “del_user_mode” switch to change the state from OFF to ON.  A message will appear to indicate that the “delete a user’s card key” mode is enabled, and the firmware is waiting for a user to scan a card.

Click the “del_user_mode” switch to change the state from ON to OFF.  A message will appear to indicate that the “verify a user’s card key” mode is enabled, and the firmware is waiting for a user to scan a card.

 

STEP 11: WRITE WORKFLOW 3: Process RFID card key.

Place the RFID key over the reader and hold it there until the buzzer sounds a beep.  This step will send the “card_key” tag to the cloud.

 

The “card_key” tag and value appear.

Go to “Config” from the left-hand sidebar on your Medium One account and click “Data Streams”.

Click “raw” and then click the active checkbox next to “card_key.” Then click “Save Data Stream”.

Now go to your Workflow Studio on your Medium One account and click “Create.”

Give your workflow a name. We named ours “Process RFID Card Key.”

Click the “Tags and Triggers” icon, which is the first icon on the right-hand sidebar. Click “raw” and drag the “card_key” tag into the main area of the workflow.

Now click on the “Modules” icon (the second icon in the sidebar), click on “Foundation” and drag a “Base Python” module into the workflow.

Click the “Outputs” icon (third icon on sidebar) and drag one “Processed Stream – Single” output into the workflow.

Double click “Processed Stream – Single” output block.

Choose “notifications” for Datastreams field.   Click “Save.”

Connect the blocks as shown below.

Copy and paste the following code into the Script area, replacing any code (follow link below) that was previously there. Then click “Save”.

Now click on the “Revisions” icon (second from the bottom of the sidebar).

Congrats! You have finished the tutorial.

Click the checkmark under the latest revision to activate the workflow if it’s not activated.

 

Checkpoint

Go to your Mobile App.  Let’s try out each of the different card key modes.

[Add Card Key Mode]

Click the “add_user_mode” switch to change the state from OFF to ON.  Wait for the message: “Add card ID: Please scan your card.”

Scan your card. This message will appear: “Add card (<the card key #1>). Pass!”   The green LED light will blink once.

[Verify Card Key Mode]

Click the “add_user_mode” switch to change the state from ON to OFF.  Wait for the message: “Verify card ID: Please scan your card.”

Scan your card key #1.  Because the keys match, this message will appear: “Verify card (<the card key #1>). Pass!” The green LED light blinks once.

Scan your card key #2.  Because the keys do not match, this message should appear: “Verify card (<the card key #2>). Fail!”  The red LED light blinks once.

[Delete Card Key Mode]

Click the “del_user_mode” switch to change the state from OFF to ON.  Wait for the message: “Delete card ID: Please scan your card.”

Scan your card key #1.  This message will appear: “Delete card (<the card key #1>). Pass!” The green LED light blinks once.

Click the “del_user_mode” switch to change the state from ON to OFF.  Wait for the message: “Verify card ID: Please scan your card.”

[Add Card Key Mode]

Click the “add_user_mode” switch to change the state from OFF to ON.  Wait for the message: “Add card ID: Please scan your card.”

Scan your card.  This message will appear: “Add card (<the card key #2>). Pass!”  The green LED light blinks once.

[Verify Card Key Mode]

Click the “add_user_mode” switch to change the state from ON to OFF.  Wait for the message: “Verify card ID: Please scan your card.”

Scan your card key #2.  Because the keys match, this message will appear: “Verify card (<the card key #2>). Pass!” The green LED light blinks once.

Scan your card key #1.  Because the keys do not match, this message will appear: “Verify card (<the card key #1>). Fail!”  The red LED light blinks once.

Congratulations!  You’re done.

Author: Rochelle Drenan