Create a gist now

Instantly share code, notes, and snippets.

@insom /boot.py
Created Dec 20, 2016

What would you like to do?
Micropython Temperature Logger
import gc
import webrepl
from machine import Pin, I2C
from bme280 import BME280
from socket import socket, AF_INET, SOCK_DGRAM
from time import sleep
webrepl.start()
gc.collect()
bus = I2C(scl=Pin(5), sda=Pin(4), freq=100000)
b = BME280(i2c=bus)
s = socket(AF_INET, SOCK_DGRAM)
s.connect(('192.168.0.1', 5555))
while True:
s.send(b.values[0])
sleep(5)
require 'socket'
ss = TCPSocket.new('127.0.0.1', 2003)
us = UDPSocket.new
us.bind('0.0.0.0', 5555)
while x = us.recvfrom(100)[0]
next if x.empty?
right = x.split('C').first
p ("mobile.bme280 #{ right } #{ Time.now.utc.to_i }\n")
ss.write("mobile.bme280 #{ right } #{ Time.now.utc.to_i }\n")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment