JavaScript hardverprogramozás

Miért pont JavaScript?

Tulajdonságok

 

  • ARM Linux alapú számítógép
  • Könnyű használat, nagy kapacitás
  • Szinte teljes Node.js és NPM támogatás
  • Drága (44 usd)
  • Egyszerűbb feladatokra túl overkill

Johnny Five - JavaScript Robotic Framework

Tulajdonságok

 

  • Node.js és NPM támogatás
  • Arduino, Tessel, Raspberry, stb.
  • Vizuális példakönyvtár
  • ESP8266 nem :(

A népszerű ESP8266

Tulajdonságok

  • Supports 802.11 b/g/n
  • Integrated low power 32 bit microcontroller
  • Integrated 10 bit analog to digital converter
  • Integrated full TCP/IP stack
  • Supports Station, Soft Access Point, Station + Soft Access Point modes
  • Built in TR switch, balun, LNA, power amplifier and matching network
  • Have internal PLL, regulators and power management units
  • Supports space diversity / antenna diversity
  • 2.4 GHz WiFi with support for WPA/WPA2
  • Supports WiFi Direct
  • Smart Link function supports for both Android and iOS devices
  • SDIO 2.0, (H) SPI, UART, I2C, I2S, IR Remote Control, PWM, GPIO
  • STBC, 1×1 MIMO, 2×1 MIMO
  • A-MPDU & A-MSDU aggregation and 0.4s guard interval
  • Wake up and transmit packets in less than 2mS
  • Up to +20 dBm output power in 802.11b mode
  • Standby power consumption is less than 1mW.
  • Deep sleep power is less than 10μA and power down leakage current is less than 5μA
  • Certified by FCC, CE, TELEC, WiFi Alliance and SRRC

ESP8266 Block diagram

Specifikációk

  • Operating Voltage : 3.0 ~ 3.6V
  • Average Operating Current : 80mA
  • Tensilica Xtensa LX106 32 bit RISC CPU running at 80 MHz
  • 4MB memory
  • 16 GPIO Pins
  • SPI
  • I2C
  • I2S
  • UART – 2x TX and 1x RX
  • 1x 10bit ADC
  • Operating Temperature : -40°C ~ 125°C
  • Frequency Range : 2400 ~ 2483.5MHz

Espruino

 

  • ESP8266
  • WEB IDE
  • Grafikus szerkesztő
  • Jól dokumentált
  • Rengeteg modult támogat
  • Rengeteg JavaScript parancsot kezel

Web IDE

Grafikus szerkesztő

Előkészületek

 

  • NodeMCU ESP12-e fejlesztői modul
  • CH340 usb driver telepítése
  • Esptool telepítése

  • Espruino letöltése
pip install esptool

Első lépések

// nézzük meg a portot

ls /dev/tty.*
// vagy
ls /dev/cu.*

// ürítsük ki az eszközt

esptool.py --port /dev/cu.wchusbserial14410 --baud 115200 erase_flash



// írjuk fel a firmware-t

esptool.py --port /dev/cu.wchusbserial14410 --baud 115200 \
  write_flash --flash_freq 80m --flash_mode dio --flash_size 32m \
  0x0000 "boot_v1.6.bin" 0x1000 espruino_esp8266_user1.bin \
  0x3FC000 esp_init_data_default.bin 0x3FE000 blank.bin

Próbáljuk ki

// lépjünk be

screen /dev/cu.wchusbserial14410 115200



 _____                 _
|   __|___ ___ ___ _ _|_|___ ___
|   __|_ -| . |  _| | | |   | . |
|_____|___|  _|_| |___|_|_|_|___|
          |_| http://espruino.com
 1v94 Copyright 2016 G.Williams
Espruino is Open Source. Our work is supported
only by sales of official boards and donations:
http://espruino.com/Donate
Flash map 4MB:512/512, manuf 0xc8 chip 0x4016

Írjunk kódot

process.memory()


// kimenet

={ "free": 1279, "usage": 121, "total": 1400, "history": 37 }



// lepjunk be a wifire

var wifi = require("Wifi");
wifi.connect("super-secure-network", { password: "iLoveIot" },
   function(err){if(err)console.log(err);else console.log("connected!");});

=undefined

// kicsit varunk

connected!
>

// nezzunk korul

>wifi.getStatus()
={
  "mode": "sta",
  "station": "connected",
  "ap": "disabled",
  "phy": "11n",
  "powersave": "ps-poll",
  "savedMode": "off"
 }

> wifi.getIP()
={
  "ip": "192.168.0.106",
  "netmask": "255.255.255.0",
  "gw": "192.168.0.1",
  "mac": "5c:cf:ff:06:c0:db"
 }

Használjuk a WEB IDE-t és írjunk bonyolultabb kódot

Köszönöm a figyelmet!

 

  • https://novucode.com
     
  • http://tessel.io
  • http://johnny-five.io
  • http://www.espruino.com
  • https://github.com/espressif/esptool
  • http://espressif.com
Made with Slides.com