This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import the interface to Tessel hardware | |
var tessel = require('tessel'); | |
//Install mqtt library using: npm install mqtt | |
var mqtt = require('mqtt'); | |
var client = mqtt.connect({ | |
servers:[{'host':'mqtt.relayr.io'}], | |
// Add your credentials here. | |
username: "<my device ID>", // add your own |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Property: isOn | |
* Returns: boolean (true or false) if led is on | |
* | |
* Checks the led to see if it is on or not. | |
*/ | |
if (led.isOn) | |
{ | |
console.log('The green LED is currently on.'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en | |
wifi.setmode(wifi.STATION) | |
wifi.sta.config("iotlab1","IoTInnoLab") | |
mqttOnline = false | |
mqttSubSuccess = false | |
-- timer vars | |
mainTimerId = 0 -- we have seven timers! 0..6 | |
mainInterval = 1000 -- milliseconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Setup the WiFi in station mode. | |
if not wifi.sta.getip() then | |
wifi.setmode(wifi.STATION) | |
wifi.sta.config("iotlab1", "IoTInnoLab") | |
print(wifi.sta.getip()) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./luatool/luatool.py -p /dev/ttyUSB0 -f ~/lua/esp8266/dht_test.lua -t main.lua -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function print_dht_data(pin) | |
local status, temp, humi, temp_dec, humi_dec = dht.read(pin) | |
if status == dht.OK then | |
-- Integer firmware using this example. | |
print( | |
string.format( | |
'DHT Temperature:%d.%03d - Humidity:%d.%03d\r\n', | |
math.floor(temp), | |
temp_dec, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://nodemcu-build.com/builds/nodemcu-master-10-modules-2016-03-17-10-58-23-float.bin | |
http://nodemcu-build.com/builds/nodemcu-master-10-modules-2016-03-17-10-58-23-integer.bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ffi = require("ffi") | |
ffi.cdef[[ | |
typedef long time_t; | |
typedef int clockid_t; | |
typedef struct timespec { | |
time_t tv_sec; /* seconds */ | |
long tv_nsec; /* nanoseconds */ | |
} nanotime; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ffi = require("ffi") | |
ffi.cdef[[ | |
typedef long time_t; | |
typedef struct timeval { | |
time_t tv_sec; | |
time_t tv_usec; | |
} timeval; | |
int gettimeofday(struct timeval* t, void* tzp); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: nginx; mode: flyspell-prog; ispell-local-dictionary: "american" -*- | |
### This file contains a map directive that is used to block the | |
### invocation of HTTP methods. Out of the box it allows for HEAD, GET and POST. | |
map $request_method $simple_not_allowed_method { | |
default 1; | |
GET 0; | |
HEAD 0; | |
POST 0; |