Saturday, January 5, 2013

Arduino CnC

Here is something I've been thinking about developing it, it is still on the drawing board :)

Arduino CnC

Arduino CnC is complete solution that acts as a gateway between your Arduino and the internet. Using Arduino CnC you will be able to communicate with your Arduino using any device connected to the internet. You can monitor and process sensory data from your Tablet. Use your phones browser to turn LEDs on and off, change RGB color, drive motors and servos. Opening a whole new world to Arduino Developers.

Diagram of how Arduino CnC works:


 
Terms:

Slave Client: The PC that the Arduino is connect to.
Arduino: The Arduino connected to the Slave Client.
Control Page: The html5 and javascript code that is used to monitor and control the Arduino.
Arduino CnC: The cloud server running jabber, the online IDE, and the host for the Control Pages.
Control Client: Tablet, Laptop, Phone, etc. that open the Control Pages that are hosted on the Arduino CnC using their web browsers.
Base Sketch: The original sketch that can read and write to all pins on the Arduino. The Base Sketch also includes code that allows the Control Page to initialize the pins as well as set the update frequencies for the Arduino.


How it works:

From the Arduino
1) The Slave Client is started, after which it logs into the Arduino CnC using its username and password.
2) The Slave Client then establishes a serial communication to the Arduino.
3) A heat sensor connected to the Arduino is read by the Base Sketch.
4) The Base Sketch then writes this data using the USB serial communication to the Slave Client. The message also includes userID of the receiving Control Client.
5) The Slave Client sends this message string to Arduino CnC. (Only the Control Page that the message was sent to will be able to see and respond to it.)
6) The Arduino CnC stores the message and waits for the Control Client  to come online to send the message.
7) The Control Client uses the Control Page to receiving and print the message to the screen.

To the Arduino
1) The Slave Client is started, after which it logs into Arduino CnC using its username and password.
2) The Slave Client then establishes a serial communication to the Arduino.
3) A Control Client opens a Control Page.
4) User press a HTML button on the Control Client.
5) The Control Page running on the Control Client, authenticates with Arduino CnC and passes the message string along with the recipient.
6) Arduino CnC stores the message waiting for the Slave Client to come online. If the Slave Client is already online the message is forwarded without any delay.
7) The receiving Slave Client uses the already established USB connection to pass the message string along to the Arduino.
8) The Base Sketch on the Arduino receives the message and turns a LED on.


Base Sketch

Using the Base Sketch it will be possible to read and write and perform most common function with the Arduino without having to write and upload any custom sketch.

The Base Sketch will allow to get analog feedback, set pins to input/output. Read pin values and set PWM on digital pins. You can also program the Arduino to continuously send data using the Base Sketch. This would allow for receiving heat and humidity data every second without having to make a request for each read.

Advanced Development

The Base Sketch can be used as a template to include other functions such as servo control, I2C data reading, etc. The authors will be encouraged to share these sketches with the community using Arduino CnC or GIThub, etc.

We will be adding sketches derived from the Base Sketch for servo and step motor control. One-wire heat sensor communication, humidity and temperature sensors, LCD screen controls, etc.

Basic Client Development using Control Pages

The simplest way to build a client for your Arduino will be to study our one led example javascript code.

To run this sample you will have to:

1) Sign up to the cloud server.
2) Add two username and password pairs.
3) Download and Install the Desktop Client.
4) From the desktop client settings screen select your Arduino and enter one of the username password pairs you created using the cloud service.
5) Upload the C&C Base sketch to your Arduino
6) Click on the example.html in the cloud. You can load this from your phone or tablet as well.
7) Fill in the login information (the second username and password you created). Also type the username you created for your PC client as the receiving devices ID.
8) That’s it, now pressing the buttons on your tablet should blink and turn the status led connected to Pin 13 on your arduino board.

After completing the steps above you can try our one button example. For this you will need to attach a button to your Arduino. You can choose any pin you want to as this will be set from the HTML page. After completing the steps for the Led example you will see that when you press the button that you connected to your Arduino, a rectangle on your tablet will light up. And when you press this rectangle the status led on pin 13 on your Arduino will turn on.

The basic client uses jsonp to run. This way we have to sacrifice some speed for flexibility. The client has to establish and login for each request. However it allows for the html to run from any host or domain with pure HTML5 code, a single html file with embedded javascript is all you need.
For real-time communication please continue reading.


Advanced Client Development

Arduino CnC uses the well know jabber/GTalk XMPP protocol for communication. For more real-time communication you will need to keep your communication to the cloud server open all the time. This can be done using almost every language. You will find PHP, Android and iOS samples for this in the repository. Each sample runs a jabber chat client within. The client connects to the cloud server and keeps the connection open. When you press a button on the client the message is sent directly to your Arduino without a delay. Similarly any message coming from the arduino is received by the client device and displayed. The examples uses a pot on the analog pins that the Arduino samples 10 times each second and relays to the cloud and then to the client which in Turn draws this as a moving time graph on your screen.

If you have a servo connected to your Arduino you can also try rotating it using the onscreen controls found on the sample apps.

3 comments:

  1. In fact your creative writing abilities have inspired me to start my own blog now. Really blogging is spreading its wings rapidly. Your write up is a fine example of it.Sale CNC Routers

    ReplyDelete
  2. Really amazing, Your articles were very nice and full of information. Thanks, great post. I really like your point of view!
    I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work.
    XMPP

    ReplyDelete
  3. Extraordinary things you've generally imparted to us. Simply continue written work this sort of posts.The time which was squandered in going for educational cost now it can be utilized for studies.Thanks https://www.hekl-metall.de/stanzteile-biegeteile/

    ReplyDelete