NearBus is a Cloud Connector that allows you to fully integrate in the cloud different MCU platforms (like Arduino, OpenPicus, etc.) in a very easy and transparent way. Installing a light agent (the NearAgent) in your MCU hardware the NearBus system will allow you to see the MCU as a real extension of the cloud, controlling it via the NearAPI (a very simple set of Web Services API functions).
There is no PC or gateway involved in this implementation. The Arduino will connect directly to the NearHub server through the internet access router and you will be able to control it from your web browser.
The NearBus Concept
The NearBus system proposes a different paradigm to support a large deployment of simple controlled devices. Instead of the traditional concept of "connect" a remote device to the cloud (to control it), the NearBus system "maps" the device into the cloud, doing a mirroring (or replication) of small part of the microcontroller's memory into the cloud memory. Under this paradigm, reading or writing on the Cloud's memory will have the same effect as if you were reading or writing directly into the microcontroller's memory, simplifying the way in which the device is controlled.
This mirroring process between the Microcontroller's memory and the Cloud memory is called the MemoryMap process, so under the NearBus paradigm we say that the remote device more than "connected" to the Cloud will be "Mapped" into the Cloud.
Although this instructive only show how to control a LED, the NearBus system offers all the MCU's features (like ADC, PWM, etc).
To implement this App Note you will need:
- 1 Arduino Ethernet Board
- 1 LED
- 1 Current limiter Resistor ( 330 Ohms or similar value)
- 1 Ethernet Internet connection (with a RJ45 cable)
- Implementation time: 20 min
- Difficulty Level: Low
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Sing Up a New User
a- Go to the SIGN UP screen ( www.nearbus.net ) and set up a new user. Only the username, email and password are required to setup your new account.
b- Then, login into the NearBus website using your new user and password.
Step 2: Define a New Device
From the top menu bar select the NEW DEVICE option to create a new device.
To setup the new device you should configure the followings field in order to define it. Take in account that only the SHARED SECRET field is mandatory (the password). The other fields are optional, so it is not necessary configure they for this first example.
- Device Name: optional (eg. My Device)
- Location: nothing
- Function: nothing
- Shared Secret: Mandatory (length of 8). It is the same as you should configure in the Arduino (eg. 12345678)
- Callback Function: nothing
- Refresh Rate: nothing (default 1000ms)
Note: When you create a new device, the NearBus system will generate a unique device ID (likeNB1xxxxx) that will be showed in the DEVICE LIST screen (do not confuse it with the DEVICE NAME field !!).
Take in account that you will need to configure this ID in the Arduino's code as explained in the following step.
Step 3: Download and Install the NearAgent Code Library
a- Download the Arduino NearBus library from the following link:
Download Arduino Ethernet Agent
Note: This code only include a simple implementation of the NearBIOS features in order to simplify its understanding.
b- Upload it to the Arduino Ethernet board, you only have to unzip the file and copy it into the Arduino library folder (remember to restart the Arduino IDE).
c- Load the "Hello World" code from the example section in the IDE menu.
Step 4: Set the Agent's Configuration
a- Change the configuration settings in the Arduino main code, as showed in the next picture:
- Device_ID: Unique device identifier generated by the system (you can find it in the Device List screen).
- Password: User generated (shared secret).
- Arduino Ethernet MAC: Ethernet MAC Address (you can find it printed in the Arduino Ethernet board).
b- Compile and upload the code "Hello World" to the Arduino Ethernet board.
Important: Because in this example the Arduino will work in VMCU mode, you will not need modify the Arduino's code. The Arduino will be controlled from the Cloud through the NearBIOS.
Step 5: Verify That Your Arduino Is UP
In the Device List screen, your Arduino should go Up (green) in a few seconds.
Important: The screen does not refresh in an automatic way, so you should reload it in order to get the device status.
If your Arduino remains DOWN, make the following verifications:
1- Verify that the green light in the Arduino's Ethernet connector is flashing.
2- Verify that your internet connection if Up (if you can surf by internet).
3- Verify that your Arduino is configured Ok (the 8 character password, the Device_ID and the Arduino's MAC).
4- Reset the Arduino, to ensure that it is properly initialized.
Step 6: Wire Your Arduino
Wire a LED with a current limiter resistor to the Arduino's Pin 3 (NearBus Channel 0).
Step 7: Control the LED From the Cloud
a- Select the "CONFIG DEVICE" option in the drop-down menu from the DEVICE LIST screen.
b- Put the Channel 0 in Manual Mode (check de MAN check-box for Channel 0).
c- Control your LED: Change the FUNCTION drop-down menu to UP, and the Arduino's Pin 3 should go UP and the LED will light :).