atmega328 + onewire ds18b20 + ethernet enc28j60/w5500
- easy customization through direct index.htm and app.js editing and debugging locally
- automatic compilatio of index.htm.h and app.js.h to be included as flash string
- alloc automatically a backlog of temperature recording based upon available ram
- ( see prerequisites prj )
- disable ENABLE_CORS in production
- set temperature device id to add a description (optional) in app.js
- start
code .
from sketch folder - program the chip
ctrl+shift+p
through usbasp programmer ( before apply actrl+alt+r
to invoke prebuildgen-h
) - drag
index.htm
andapp.js
into code - config
app.js
- tune baseurl
- double click
index.htm
from file manager to open in a browser - now webpage talk to atmega webapi through enc28j60 ( can use F12 and set some breakpoints from browser, may need useful to click on browser pretty button to format code because its minified )
- note : modified app.js and index.htm will compiled into flash automatically through prebuild utility gen-h
address | content type | result example |
---|---|---|
/tempdevices |
json | {"tempdevices":["28886f5a050000dd","2865e05a0500001a","28af8123070000e2"]} |
/temp/id |
text | 19.562500 |
/info |
json | {"freeram":187, "history_size":123, "history_interval_sec":10} |
/temphistory |
json | [{"28886f5a050000dd":[20,20,20,20,20,20,20,20,20,20,21,24,25,27,28]},{"2865e05a0500001a":[20,20,20,20,20,20,20,20,20,20,20,20,20,20,20]},{"28af8123070000e2":[21,21,21,21,21,21,21,21,21,21,21,21,21,21,21]}] |
/app.js |
js | content of app.js |
/ |
html | content of index.htm |
serial debug included
ENC28J60 (udp disabled)
UIP_CONF_UDP=0
inUIPEthernet/utility/uipethernet-conf.h
Sketch uses 30606 bytes (93%) of program storage space. Maximum is 32768 bytes.
Global variables use 1308 bytes (63%) of dynamic memory, leaving 740 bytes for local variables. Maximum is 2048 bytes.
W5500
Sketch uses 27076 bytes (82%) of program storage space. Maximum is 32768 bytes.
Global variables use 702 bytes (34%) of dynamic memory, leaving 1346 bytes for local variables. Maximum is 2048 bytes.
if want to use the device to push a notification
- in
Config.h
- ensure
USE_EXTERNAL_INTERRUPT
defined - change if needed used pin
EXTERNAL_INTERRUPT_PIN
( see atmega pinmapping ) - define header file
- ensure
#define PUSHINGBOX_IP 213,186,33,19
#define PUSHINGBOX_HOSTNAME "api.pushingbox.com"
#define PUSHINGBOX_QUERY "/pushingbox?devid=xxx"
- see prerequisite considerations
- ENABLE_CORS even disabled not imply any check at server(atmega)-side so effectively a non-browser request can execute request from any crossing domain; can mitigate wrapping with nginx