Skip to content

Instantly share code, notes, and snippets.

@karlp
karlp / wemos_dht.lua
Last active June 30, 2016 14:09
Publish DHT22 to MQTT on an ESP8266 (wemos D1 mini)
-- DHT22 to MQTT Publisher
-- Andrew Elwell, 2016-06-08
client='ESP-'..node.chipid()
m = mqtt.Client(client, 60)
m:lwt("status/"..client, "offline", 0, 1)
m:connect("10.1.1.251", 1883, 0, 1, function(hohoho)
print("connected")
hohoho:publish(string.format("status/%s", client, 0, 1))
@karlp
karlp / gist:6502796
Last active December 22, 2015 16:58
#!/usr/bin/python
# script to poll growatt PV inverter and spit out values
# Andrew Elwell <Andrew.Elwell@gmail.com> 2013-09-01
import ConfigParser
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
import time
import mosquitto
@karlp
karlp / gist:2953799
Created June 19, 2012 12:10 — forked from jnareb/gist:2953631
libmodbus - reading from many slave_ids via RTU
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <modbus.h>
#define SM4_ID 3
#define P120_ID 2