Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Katja K. OšljakLuka BirsaUrsa Primozic
Published

Home environment sensor with Visionect

How we made a home environment sensor with a Raspberry Pi and our e-paper device

Full instructions provided1,863
Home environment sensor with Visionect

Story

Read more

Code

code.txt

Plain text
[20140306T09:49:08.034570] New node id=409D, eui64=000D6F0003053413
[20140306T09:49:09.533744] 000D6F0003C16E48: data = {"noise": 16.532, "temp": 24.5, "fw": 28, "battery": 2464, "light": 1708, "voc": 400, "humidity": 1576, "pressure": 986.0, "voc_resistance": 14590, "shake": true}
[20140306T09:49:09.540727] 000D6F0003C16E48: score = 66.297 (temp=23.5/1.0 humidity=20.0326797386/-0.348102820428 voc=450/1 noise=16.532/1)
[20140306T09:49:09.544915] 000D6F0003C16E48: reply = '\x11\x00B' (kwargs={"home": true, "score": 66}, queue={})
[20140306T09:49:09.606970] Sequences: '8F' added
[20140306T09:49:09.842009] Sequences: '8F' done (ACK), removing.
[20140306T09:49:10.004599] 000D6F0003053413: received ping
[20140306T09:49:10.010692] 000D6F0003053413: reply = '\x10\x00' (kwargs={"home": true}, queue={})

code.txt

Plain text
var tail = new Tail("/var/log/ziggy.stdout.log"),
    pat = /\[.*?\] (.*?): data = (.*?})/g,
    sensors = {};

tail.on("line", function(line) {
  var data = pat.exec(line);
  if (data) {
    sensors[data[1]] = JSON.parse(data[2]);
  }
});

code.txt

Plain text
fetchData = function() {
    $.getJSON('data.json', function(new_data) {
        data = new_data;
        $.each(data, function(id, cube) {
            cube.voc = Math.max(cube.voc - 900, 0)*0.4 + Math.min(cube.voc, 900)
            cube.humidity = Math.min(95, Math.max(10, (cube.humidity -330*5.1)/(600/1000*5.1) + 55))
            cube.light = 10/6.0*(1+(cube.light/1024.0)*4.787*Math.exp(-(Math.pow((cube.light-2048)/400.0+1, 2)/50.0))) * (102400.0/Math.max(15, cube.light) - 25);
        });
        if ($('#data').is(':visible')) {
            renderData($('#data').data('id'));
        }
    });
}

code.txt

Plain text
# /etc/network/interfaces

auto wlan0
iface wlan0 inet static
        address 192.168.20.1
        netmask 255.255.255.0
        network 192.168.20.0
        broadcast 192.168.20.255

# /etc/dhcp/dhcpd.conf

subnet 192.168.20.0 netmask 255.255.255.0 {
    range 192.168.20.100 192.168.20.200;
    option routers 192.168.20.1;
    interface wlan0;
}

# /etc/hostapd/hostapd.conf

interface=wlan0
driver=nl80211
ssid=WIFI_NAME
hw_mode=g
channel=11
wpa=1
wpa_passphrase=WIFI_PASSWORD
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
wpa_ptk_rekey=600
macaddr_acl=0

# /etc/init.d/hostapd.conf

DAEMON_CONF=/etc/hostapd/hostapd.conf

Github

https://github.com/visionect/cubesensorsdislpay

Github

https://github.com/cloudhead/node-static

Credits

Katja K. Ošljak
4 projects • 22 followers
Contact
Luka Birsa
4 projects • 21 followers
@Visionect cofounder. We have an E Ink device with ridiculous autonomy running a Web-based software platform. Get our Dev kit @ http://www.visionect.com
Contact
Ursa Primozic
6 projects • 12 followers
Communications Manager for Visionect
Contact

Comments

Please log in or sign up to comment.