Enable Javascript


Last Arduino/ESP project (click to open)

Gebruikerswaardering: 5 / 5

Ster actiefSter actiefSter actiefSter actiefSter actief
 


My intention was to combine a Android device with a ESP8266/Arduino and take advantage of many Android capabilities in HTML5+JavaScript. The result is an Android Bridge to and from Javascript and a few other options.

Forget building native mobile Android applications with PhoneGap, Cordova & Co!
Use this Android WebView APP and write the code directly in HTML+JavaScipt. Save your html and js files on SD and load them in the WebView with the HTML-button (last img. step 1).
Android minimum version 17 (Kitkat v4.2) (Old device? You can install a custom ROM. My old Acer Iconia Tab A500 runs on Kitkat v4.4.4)
WARNING: Protect your self wen using Android WebView, use only locally stored files!!!

In Android Bridge to/from JavaScript:

  • Up to 22 sensors
    (depends on hardware and Android version).
  • Compass/Orientation
    With True North.
  • GPS
  • Vibrate
  • Signal
    Adjustable duration in ms.
  • Toast
    Short message in a small popup.
  • SMS
    At an event, send a sort message.
  • E-mail
    Send an e-mail at alarm or other event.
    To one or multiple adresses (separated by a semicolon).
    With or without an attachement (photo, file: /sdcard/camtest/<name.ext>).
    You must have a gmail account!
  • Take a picture
    Photo in JPEG.
    Adjustable maxium height/width in pixels.
    Front, back and flash options.
    Save to folder of your choice (default folder camtest).
    Returns file name and path.
  • USB
    (OTG) Serial communication with ESP8266, Arduino, ... .

In JavaScript:

  • Sunrise, sun transit, sunset, position of the sun, longest and shortest day of the year.
    NREL's Solar Position Algorithm (SPA), calculates the solar zenith and azimuth angles in the period from the year -2000 to 6000, with uncertainties of +/- 0.0003 degrees based on the date, time, and location on Earth.
    Ideal for a suntrack system.
  • WebSocket Client.
    Communicate over (W)LAN and Internet with a (ESP) WebSocketServer.

Building a hybrid Android WebAPP in HTML5+ JavaScript
With all these options, it's easy to create an Android APP. Use in JavaScript that what you need. Use the code in the demo files AndroidInHtml.html and AndroidInHtml.js as a guide.
But you can also control a ESP8266, Arduino, ... with JavaScript using USB or (W)LAN. Then, you have a ESP8266/Arduino with touch screen and HTML5 Local Storage to Save and Load data on Androids SD card.
HTML5 Local Storage:
  localStorage.setItem(KEY, DATA);
  DATA = localStorage.getItem(KEY);
  localStorage.removeItem(KEY);   

Use HTML5 Canvas for a graphic UI, get a Widget library or goto jQuery Widget Factory.

Load local HTML like this: file:///storage/extSdCard/AndroidInHtml/AndroidInHtml.html
TIP:
Use (ES File) Explorer to copy the fullpath ;-) and follow steps 1-4.