Code Monkey home page Code Monkey logo

devshield-arduino-clock's Introduction

BERGCloud Arduino Devshield Clock

A simple example of how to set the system time on an Arduino using a BERGCloud devshield and a server using a Sinatra app.

Setup

To get this working for yourself, you'll need an Arduino (or compatible third party) of the Uno, Leonardo or similar, as well as an BERGCloud Arduino Devshield and a BERGCloud Bridge (available together in the Devkit).

  1. Once you've claimed your devshield on the BERGCloud remote, you'll need to create a project here.

  2. Click the 'edit' link, and add a command with code of 1 and command-name of send-time.

  3. Go back to project view page, copy the code block including the Project Key, and paste it over the example one in the Arduino sketch.

  4. Copy your project's API Token into config.yml, replacing the example one.

  5. Either upload the Sinatra app to Heroku or host it somewhere else accessible to the web.

  6. Finally, add the publically accessible URL of the base of your project into the Web Service URL field on the edit page of your project. Now you should be set to go.

Note: you're going to have to do most of these steps anyway to get a project up and running. The only step required if you've already got it working is to add the send-time command on your project page.

Flow

This process works because when your devshield connects to BERGCloud, an HTTP request is automatically sent to the /cloud-event/announce endpoint, containing the device address and its timezone.

The server then sends a request back to that devshield with current time, offset by 23 seconds to account for lag. You might need to fine-tune this depending on how it works for you.

Once the Arduino receives the command back from the server containing the time, it unpacks it and uses the Arduino Time library to keep track of the system time.

Bitdeli Badge

devshield-arduino-clock's People

Contributors

alfo avatar bitdeli-chef avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.