GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - sdbondi/Arduino-Talk: Arduino and web communication

BranchesTags
Open more actions menu

Latest commit

 

History

23 Commits
23 Commits

Folders and files

NameName
Last commit message
Last commit date
Comet
Comet
 
 
.gitignore
.gitignore
 
 
LICENSE.txt
LICENSE.txt
 
 
README.md
README.md
 
 
TODO.md
TODO.md
 
 
arduino-comet-talk.sublime-project
arduino-comet-talk.sublime-project
 
 
readme.html
readme.html
 
 

Repository files navigation

Arduino talk

A JSON-based API for Arduino with all the supporting software.

About

A simple API to issue commands to your Arduino Microcontroller from you web browser though a simple JSON API interface. This is currently an early "planning"/POC release of this project and I'll probably end up rewriting it. Suggestions/forks welcome!

It does work quite well as it is now. I have used it to turn on relays and LEDS remotely (setting pinMode and digitalWrite). I also can poll (analogRead) from a temperature sensor.

The reason I used Comet (long AJAX requests) is because:

  • All you need is PHP with shared memory enabled (Most hosting packages support this - could change to filesystem based IPC).
  • All modernish mobile browsers support AJAX (TOFIX: Admitidly I've used HTML5 FormData which is only supported by Android 4+ browsers).
  • Allows clients on both ends to poll when they are ready - simple and reliable architecture.

I plan to implement a websocket version.

#Comet

##Basics I'll draw a picture and put it here but for now I'll explain it simply. Using http requests only, I make AJAX requests to a PHP 'routing' script. I use comet techniques to allow data to be passed through as soon as it is received. The routing script uses shared memory to communicate between processes (requests).

There is a python server which also uses those same AJAX requests to get and send its data. It's responsible for translating the JSON-based commands to the succinct Arduino protocol as well as translating the results back to JSON.

It consists of 4 parts:

##Javascript API I have implemented a comet client API and a sugary Arduino API on top of that to make programming web interfaces for your projects as easy as possible with a good knowledge of javascript.

An Example: This will send 2 commands at once, run them and return both results in one request. You can chain as many as you like before flushing.

var arduino = new Arduino({comet:{url:'comet-router?action={action}'}});

arduino.open(function() {
  this
    .pinMode(2, 'output')
    .digitalWrite(2, 1)
    .pinMode('A0', 'input')
    .analogRead('A0')
    .flush(function(results) { console.log(results); })
});

results could be ['ACK', 'ACK', 'ACK', 128]

PHP Command Router

Furnisheds requests from JS and Python and relays messages using shared memory objects. You will not be able to run script server on Windows.

Python server

Resposible for translating the JSON commands to commands the Arduino understands. It connects to the Arduino through serial.

Arduino code

Resposible for understanding the commands received and executing them.

License

See the LICENSE

TODO

See TODO.md

About

Arduino and web communication

Resources

Readme
License
Activity

Stars

4 stars

Watchers

2 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.