Skip to content

Instantly share code, notes, and snippets.

View jeanfbrito's full-sized avatar
🌱
Seeding the future!

Jean Brito jeanfbrito

🌱
Seeding the future!
View GitHub Profile
@jeanfbrito
jeanfbrito / README.md
Created August 21, 2016 04:22 — forked from foosel/README.md
First experiments with NodeMCU to publish the current settings of my adjustable height working desk to MQTT

First experiments with NodeMCU to publish the current settings of my adjustable height working desk to MQTT.

NodeMCU can be found here: https://github.com/nodemcu/nodemcu-firmware

Note that you'll need a current version with support for floats (which the ultrasonic sensor library utilizes), I'm using 0.9.5 2015-03-18 with float support myself.

Support for the HC-SR04 sensor in NodeMCU can be found here: https://github.com/sza2/node_hcsr04

I provided my slightly adjusted version which makes measuring a non-blocking afair, allowing for callbacks when the measurement completes.

@jeanfbrito
jeanfbrito / main.js
Created February 17, 2016 17:04
Xadow ADXL345 + OLED display working
// Load accelerometer
var adxl345 = require('jsupm_adxl345');
// Instantiate on I2C bus
var adxl = new adxl345.Adxl345(0);
// Initialize the hardware device
var screen = new (require("jsupm_i2clcd").SSD1308)(0, 0x3C);
// Displays a message on the OLED display
@jeanfbrito
jeanfbrito / mosquitto3.lua
Created February 1, 2016 04:41
Estufa v0.3
-- Your access point's SSID and password
local SSID = "greenhouse"
local SSID_PASSWORD = "senhasupersecreta"
local DEVICE = "undefined"
local timesRunned = 0
SDA_PIN = 6 -- sda pin, GPIO12
SCL_PIN = 5 -- scl pin, GPIO14
-- configure ESP as a station
-- Your access point's SSID and password
local SSID = "greenhouse"
local SSID_PASSWORD = "senhasupersecreta"
local DEVICE = "undefined"
local temperature = 27.5
local timesRunned = 0
-- configure ESP as a station
wifi.setmode(wifi.STATION)
wifi.sta.config(SSID,SSID_PASSWORD)
// The received message is stored in 'msg'
// It will have at least a 'payload' property:
// console.log(msg.payload);
// The 'context' object is available to store state
// between invocations of the function
// context = {};
//expects JSON payload and destination specified in topic
var key = "your api key here";
@jeanfbrito
jeanfbrito / influxdb.lua
Created January 6, 2016 18:41
NodeMCU and InfluxDB
-- Your access point's SSID and password
local SSID = "greenhouse"
local SSID_PASSWORD = "senhasupersecreta"
local DEVICE = "device001"
local temperature = 27.5
-- configure ESP as a station
wifi.setmode(wifi.STATION)
wifi.sta.config(SSID,SSID_PASSWORD)
wifi.sta.autoconnect(1)
@jeanfbrito
jeanfbrito / init.lua
Created November 30, 2015 18:44
Sensor da Estufa V0.1
--- Config
SSID = "Dark side of the Force"
PASSWORD = "senhasupersecreta"
TIMEOUT = 30000000 -- 30s
--- Station modes
STAMODE = {
STATION_IDLE = 0,
STATION_CONNECTING = 1,
STATION_WRONG_PASSWORD = 2,
@jeanfbrito
jeanfbrito / bh1750.lua
Last active February 1, 2016 03:49
ESP8266 BH1750FVI Test
-- ***************************************************************************
-- BH1750 module for ESP8266 with nodeMCU
-- BH1750 compatible tested 2015-1-22
--
-- Written by xiaohu
--
-- MIT license, http://opensource.org/licenses/MIT
-- ***************************************************************************
local moduleName = ...
local M = {}
@jeanfbrito
jeanfbrito / init.lua
Last active November 30, 2015 16:35
NodeMCU DHT22 test
pin = 4
status,temp,humi,temp_decimial,humi_decimial = 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_decimial,
math.floor(humi),
@jeanfbrito
jeanfbrito / Symlinks for me
Created October 18, 2015 06:57
Symlinks for my personal use