Created
December 20, 2016 03:16
-
-
Save insom/b80b13f20cc7ff6ca992f540ed288be5 to your computer and use it in GitHub Desktop.
Micropython Temperature Logger
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 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) |
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
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