Introduction: An Easy Way to Control Your Arduino From Internet :)

This instructive describes step by step how to configure an Arduino Ethernet board tocontrol a LED from the Cloud, (the "Hello World" example in the microcontroller's world). This trivial example is intended to introduce you the way how the NearBus connector  works.

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).

Required Components

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


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.

Troubleshooting :(
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 :).

Step 8: Testing More Features

If you want to try more features available in the function drop-down menu please refer to the HELP section for a detailed description of the NearBIOS features.

If you are interested in know more about this App Note please contact us atinfo@nearbus.net or visit www.nearbus.net

Comments

author
carishmaaa (author)2016-03-15

If i run this code the error message like this pop out C:\Users\Admin\Desktop\NearBusEther_v16\examples\Hello_World_Ether\Hello_World_Ether.ino:47:52: fatal error: NearbusEther_v16.h: No such file or directory

Can u tell me the resaon y is this not running?

author
ArielC71 (author)carishmaaa2016-12-22

You must upload the NearbusEther library

author
ibocan4423 (author)2016-10-11

Hello , can this be done with ethernet module instead of ethernet shield ?

Thanks ..

author
minimeccanica (author)2016-02-26

Is this applicable to Yùn?

Thx

author
MusaS4 (author)2016-01-30

Anyway I can do this without the Ethernet Shield? If I keep the Arduino plugged into my laptop maybe?

author
Studvio (author)2015-10-16

HI, I would like to develop my own web interface to control my Arduino. Would it be possible to automatically pass the necessary values from my webpage(s) to yours, and then yours will be passed onto my connected board please? Thank you.

author
Studvio (author)Studvio2015-10-16

Nevermind my question... I should've read the Wiki/Help section on Nearbus website before posting :-)

author
DmitriyD1 (author)2015-05-13

author
lkumar11 (author)2014-08-24

lovely! but will this work with GSM sim 900 module and arduino uno?

author
kamlesh2303 (author)2014-07-24

works like butter many thanks...

author
tsbeanie (author)2014-05-28

will this work with wifi shield? thanks!

author
cksiamcn (author)2013-10-09

thanks you so much