Commit a7e3f354 by ripuks

Emb Software project

parents
# -*- coding: utf-8 -*-
# Original code found at:
# https://gist.github.com/DenisFromHR/cc863375a6e19dce359d
"""
Compiled, mashed and generally mutilated 2014-2015 by Denis Pleic
Made available under GNU GENERAL PUBLIC LICENSE
# Modified Python I2C library for Raspberry Pi
# as found on http://www.recantha.co.uk/blog/?p=4849
# Joined existing 'i2c_lib.py' and 'lcddriver.py' into a single library
# added bits and pieces from various sources
# By DenisFromHR (Denis Pleic)
# 2015-02-10, ver 0.1
"""
# i2c bus (0 -- original Pi, 1 -- Rev 2 Pi)
I2CBUS = 1
# LCD Address
ADDRESS = 0x3F
import smbus
from time import sleep
class i2c_device:
def __init__(self, addr, port=I2CBUS):
self.addr = addr
self.bus = smbus.SMBus(port)
# Write a single command
def write_cmd(self, cmd):
self.bus.write_byte(self.addr, cmd)
sleep(0.0001)
# Write a command and argument
def write_cmd_arg(self, cmd, data):
self.bus.write_byte_data(self.addr, cmd, data)
sleep(0.0001)
# Write a block of data
def write_block_data(self, cmd, data):
self.bus.write_block_data(self.addr, cmd, data)
sleep(0.0001)
# Read a single byte
def read(self):
return self.bus.read_byte(self.addr)
# Read
def read_data(self, cmd):
return self.bus.read_byte_data(self.addr, cmd)
# Read a block of data
def read_block_data(self, cmd):
return self.bus.read_block_data(self.addr, cmd)
# commands
LCD_CLEARDISPLAY = 0x01
LCD_RETURNHOME = 0x02
LCD_ENTRYMODESET = 0x04
LCD_DISPLAYCONTROL = 0x08
LCD_CURSORSHIFT = 0x10
LCD_FUNCTIONSET = 0x20
LCD_SETCGRAMADDR = 0x40
LCD_SETDDRAMADDR = 0x80
# flags for display entry mode
LCD_ENTRYRIGHT = 0x00
LCD_ENTRYLEFT = 0x02
LCD_ENTRYSHIFTINCREMENT = 0x01
LCD_ENTRYSHIFTDECREMENT = 0x00
# flags for display on/off control
LCD_DISPLAYON = 0x04
LCD_DISPLAYOFF = 0x00
LCD_CURSORON = 0x02
LCD_CURSOROFF = 0x00
LCD_BLINKON = 0x01
LCD_BLINKOFF = 0x00
# flags for display/cursor shift
LCD_DISPLAYMOVE = 0x08
LCD_CURSORMOVE = 0x00
LCD_MOVERIGHT = 0x04
LCD_MOVELEFT = 0x00
# flags for function set
LCD_8BITMODE = 0x10
LCD_4BITMODE = 0x00
LCD_2LINE = 0x08
LCD_1LINE = 0x00
LCD_5x10DOTS = 0x04
LCD_5x8DOTS = 0x00
# flags for backlight control
LCD_BACKLIGHT = 0x08
LCD_NOBACKLIGHT = 0x00
En = 0b00000100 # Enable bit
Rw = 0b00000010 # Read/Write bit
Rs = 0b00000001 # Register select bit
class lcd:
#initializes objects and lcd
def __init__(self):
self.lcd_device = i2c_device(ADDRESS)
self.lcd_write(0x03)
self.lcd_write(0x03)
self.lcd_write(0x03)
self.lcd_write(0x02)
self.lcd_write(LCD_FUNCTIONSET | LCD_2LINE | LCD_5x8DOTS | LCD_4BITMODE)
self.lcd_write(LCD_DISPLAYCONTROL | LCD_DISPLAYON)
self.lcd_write(LCD_CLEARDISPLAY)
self.lcd_write(LCD_ENTRYMODESET | LCD_ENTRYLEFT)
sleep(0.2)
# clocks EN to latch command
def lcd_strobe(self, data):
self.lcd_device.write_cmd(data | En | LCD_BACKLIGHT)
sleep(.0005)
self.lcd_device.write_cmd(((data & ~En) | LCD_BACKLIGHT))
sleep(.0001)
def lcd_write_four_bits(self, data):
self.lcd_device.write_cmd(data | LCD_BACKLIGHT)
self.lcd_strobe(data)
# write a command to lcd
def lcd_write(self, cmd, mode=0):
self.lcd_write_four_bits(mode | (cmd & 0xF0))
self.lcd_write_four_bits(mode | ((cmd << 4) & 0xF0))
# write a character to lcd (or character rom) 0x09: backlight | RS=DR<
# works!
def lcd_write_char(self, charvalue, mode=1):
self.lcd_write_four_bits(mode | (charvalue & 0xF0))
self.lcd_write_four_bits(mode | ((charvalue << 4) & 0xF0))
# put string function with optional char positioning
def lcd_display_string(self, string, line=1, pos=0):
if line == 1:
pos_new = pos
elif line == 2:
pos_new = 0x40 + pos
elif line == 3:
pos_new = 0x14 + pos
elif line == 4:
pos_new = 0x54 + pos
self.lcd_write(0x80 + pos_new)
for char in string:
self.lcd_write(ord(char), Rs)
# clear lcd and set to home
def lcd_clear(self):
self.lcd_write(LCD_CLEARDISPLAY)
self.lcd_write(LCD_RETURNHOME)
# define backlight on/off (lcd.backlight(1); off= lcd.backlight(0)
def backlight(self, state): # for state, 1 = on, 0 = off
if state == 1:
self.lcd_device.write_cmd(LCD_BACKLIGHT)
elif state == 0:
self.lcd_device.write_cmd(LCD_NOBACKLIGHT)
# add custom characters (0 - 7)
def lcd_load_custom_chars(self, fontdata):
self.lcd_write(0x40);
for char in fontdata:
for line in char:
self.lcd_write_char(line)
import paho.mqtt.client as mqtt
import I2C_LCD_driver
# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
# Subscribing in on_connect() means that if we lose the connection and
# reconnect then subscriptions will be renewed.
client.subscribe("embedded/#")
# The callback for when a PUBLISH message is received from the server.
def on_message(client, userdata, msg):
print(msg.topic+" "+str(msg.payload))
if(msg.topic == "embedded/hall"):
print("Hall sensor data received")
mylcd.lcd_display_string(msg.payload, 1,11)
if(msg.topic == "embedded/temp"):
print("Temp sensor data received")
mylcd.lcd_display_string(msg.payload, 2,11)
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect("85.119.83.194", 1883, 60)
mylcd = I2C_LCD_driver.lcd()
mylcd.lcd_display_string("Hall sens:", 1)
mylcd.lcd_display_string("Temp sens:", 2)
# Blocking call that processes network traffic, dispatches callbacks and
# handles reconnecting.
# Other loop*() functions are available that give a threaded interface and a
# manual interface.
client.loop_forever()
#!/usr/bin/env python3
# This program is for logging MQTT messages into different log files.
# Log
#
import paho.mqtt.client as mqtt
import logging
#topics and corresponding files
topic1="embedded/hall"
file1="hall.log"
topic2="embedded/temp"
file2="temp.log"
#sets the format for the log file entries
formatter = logging.Formatter('%(asctime)s %(message)s',datefmt='%d/%m/%Y %H:%M:%S')
#function for setting up new loggers
def setup_logger(name, log_file, level=logging.INFO):
handler=logging.FileHandler(log_file)
handler.setFormatter(formatter)
logger=logging.getLogger(name)
logger.setLevel(level)
logger.addHandler(handler)
return logger
#callback function that will run when the client connects with the MQTT broker
def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
client.subscribe(topic1)
client.subscribe(topic2)
#callback function that will run when a message is received
def on_message(client, userdata, msg):
print(msg.payload.decode())
print(msg.topic)
if(msg.topic==topic1):
logger1.info(msg.payload.decode())
if(msg.topic==topic2):
logger2.info(msg.payload.decode())
logger1=setup_logger("logger1", file1)
logger2=setup_logger("logger2", file2)
client = mqtt.Client()
client.connect("85.119.83.194",1883,60) #instead of localHost, an IP address can be used
client.on_connect = on_connect
client.on_message = on_message
client.loop_forever()
EMBEDDED SOFTWARE WORKSHOP PROJECT
AUTHORS:
RIM PUKS 182558 IASM
INDREK GUITOR 182555 IASM
LINK TO VIDEO
https://drive.google.com/file/d/1WoQsEd66PgRu2aDheJ49QU8MXd5tRifi/view?usp=sharing
SCHEMATIC ILLUSTRATING THE PROJECT IS ADDED TO GIT
SUMMARY
The main goal of this project was to test different ways to send data using MQTT. This project uses the public broker iot.eclipse.org.
The system logs, displays and uploads Hall sensor and temperature data.
Hall sensor node
This is Sparkfun ESP32 Thing with internal Hall sensor. Since the previous lab task (Mario ESP32 task) was written with Eclipse in C, it was decided
that this task would be in different language, Arduino.
ESP32 first connects to wifi and gets IP address, after which it connects to MQTT broker to publish and subscribe to the hall sensor topic.
Then the ESP32 reads the HALL sensor (reads magnitude of a magnetic field) every second and sends the data to this server.
It also reads the data published to this server and reacts to it. For example, if the hall sensor
value is low (under 0), it turns on the blue LED, if the hall sensor value is high (over 0) it turns the LED off.
Temperature sensor node
This node composes of Wemos D1 Mini with attached AM2302 temperature sensor shield. It reads the sensor value using Adafruit Sensor library and
publishes the temperature sensor value to "embedded/temp" topic.
It is programmed using ITT IoT software framework.
Raspberry Pi
The Raspberry Pi has 3 Python scripts running concurrently. Each of them is its own MQTT node.
- Display node
Display node subscribes to "embedded/hall" and "embedded/temp" topics and displays their newest values on LCD screen. Communication with the screen uses I2C protocol.
- Logger node
Logger node also subscribes to "embedded/hall" and "embedded/temp" topics. It then writes them to a corresponding file (temp.log and hall.log).
It also adds a timestamp.
- Thingspeak node
This node also subscribes to the same topics as the previous nodes. Every 20 seconds, it uploads the temperature and Hall sensor values to the Thingspeak
database.
\ No newline at end of file
import paho.mqtt.client as mqtt
from time import sleep
hallValue = None
tempValue = None
#Thingspeak topics
TS_Topic = "channels/774222/publish/5FB6LNOHESRBEIDG"
#Eclipse broker topics
hall_topic= "embedded/hall"
temp_topic= "embedded/temp"
# The callback for when the client receives a CONNACK response from the server.
def on_connect_E(client, userdata, flags, rc):
print("Connected to iot.Eclipse.org with result code "+str(rc))
# Subscribing in on_connect() means that if we lose the connection and
# reconnect then subscriptions will be renewed.
client.subscribe("embedded/#")
# The callback for when the client receives a CONNACK response from the server.
def on_connect_TS(client, userdata, flags, rc):
print("Connected to Thingspeak with result code "+str(rc))
# The callback for when a PUBLISH message is received from the server.
def on_message(client, userdata, msg):
print(msg.topic+" "+str(msg.payload))
if(msg.topic == hall_topic):
global hallValue
print("Hall sensor data received")
hallValue = msg.payload
if(msg.topic == temp_topic):
global tempValue
print("Temp sensor data received")
tempValue = msg.payload
E_client = mqtt.Client()
E_client.on_connect = on_connect_E
E_client.on_message = on_message
E_client.connect("85.119.83.194", 1883, 60)
TS_client = mqtt.Client()
TS_client.on_connect = on_connect_TS
TS_client.connect("mqtt.thingspeak.com",1883,60)
# handles reconnecting.
# Other loop*() functions are available that give a threaded interface and a
# manual interface.
E_client.loop_start()
TS_client.loop_start()
while (True):
sleep(20)
print "Sleep over"
payload = ''
if(hallValue):
payload = payload + 'field1=' + str(hallValue) + '&'
if(tempValue):
payload = payload + 'field2=' + str(tempValue) + '&'
if(payload):
payload = payload + 'status=MQTTPUBLISH'
TS_client.publish(TS_Topic, payload)
print "Publishing"
hallValue = None
tempValue = None
05/05/2019 23:10:19 32.00
05/05/2019 23:10:20 36.00
05/05/2019 23:10:21 34.00
05/05/2019 23:10:22 33.00
05/05/2019 23:10:23 34.00
05/05/2019 23:10:24 35.00
05/05/2019 23:10:25 35.00
05/05/2019 23:10:26 35.00
05/05/2019 23:10:27 33.00
05/05/2019 23:10:28 34.00
05/05/2019 23:10:29 35.00
05/05/2019 23:10:30 33.00
05/05/2019 23:10:31 34.00
05/05/2019 23:10:32 38.00
05/05/2019 23:10:33 33.00
05/05/2019 23:10:34 34.00
05/05/2019 23:10:35 36.00
05/05/2019 23:10:36 26.00
05/05/2019 23:10:37 31.00
05/05/2019 23:10:38 33.00
05/05/2019 23:10:39 38.00
05/05/2019 23:10:40 32.00
05/05/2019 23:10:41 36.00
05/05/2019 23:10:42 37.00
05/05/2019 23:10:43 35.00
05/05/2019 23:10:44 36.00
05/05/2019 23:10:45 35.00
05/05/2019 23:10:46 32.00
05/05/2019 23:10:47 35.00
05/05/2019 23:10:48 37.00
05/05/2019 23:10:49 36.00
05/05/2019 23:10:50 33.00
05/05/2019 23:10:51 35.00
05/05/2019 23:10:52 35.00
05/05/2019 23:10:53 35.00
05/05/2019 23:10:54 35.00
05/05/2019 23:10:55 35.00
05/05/2019 23:10:56 33.00
05/05/2019 23:10:57 37.00
05/05/2019 23:10:58 37.00
05/05/2019 23:10:59 35.00
05/05/2019 23:11:00 33.00
05/05/2019 23:11:01 34.00
05/05/2019 23:11:02 35.00
05/05/2019 23:11:03 37.00
05/05/2019 23:11:04 39.00
05/05/2019 23:11:05 35.00
05/05/2019 23:11:06 34.00
05/05/2019 23:11:07 35.00
05/05/2019 23:11:09 34.00
05/05/2019 23:11:09 37.00
05/05/2019 23:11:10 35.00
05/05/2019 23:11:11 34.00
05/05/2019 23:11:12 33.00
05/05/2019 23:11:13 34.00
05/05/2019 23:11:14 33.00
05/05/2019 23:11:15 35.00
05/05/2019 23:11:16 33.00
05/05/2019 23:11:18 36.00
05/05/2019 23:11:18 33.00
05/05/2019 23:11:19 41.00
05/05/2019 23:11:20 35.00
05/05/2019 23:11:22 33.00
05/05/2019 23:11:22 33.00
05/05/2019 23:11:24 35.00
05/05/2019 23:11:24 36.00
05/05/2019 23:11:25 34.00
05/05/2019 23:11:27 32.00
05/05/2019 23:11:27 38.00
05/05/2019 23:11:30 33.00
05/05/2019 23:11:30 36.00
05/05/2019 23:11:30 36.00
05/05/2019 23:11:31 33.00
05/05/2019 23:11:32 31.00
05/05/2019 23:11:34 32.00
05/05/2019 23:11:34 40.00
05/05/2019 23:11:36 50.00
05/05/2019 23:11:36 41.00
05/05/2019 23:11:38 37.00
05/05/2019 23:11:38 38.00
05/05/2019 23:11:40 40.00
05/05/2019 23:11:40 34.00
05/05/2019 23:11:42 33.00
05/05/2019 23:11:42 19.00
05/05/2019 23:11:44 34.00
05/05/2019 23:11:44 37.00
05/05/2019 23:11:46 34.00
05/05/2019 23:11:46 35.00
05/05/2019 23:11:48 33.00
05/05/2019 23:11:48 36.00
05/05/2019 23:11:50 39.00
05/05/2019 23:11:50 32.00
05/05/2019 23:11:52 32.00
05/05/2019 23:11:52 38.00
05/05/2019 23:11:54 33.00
05/05/2019 23:11:54 36.00
05/05/2019 23:11:56 28.00
05/05/2019 23:11:56 36.00
05/05/2019 23:11:58 39.00
05/05/2019 23:11:58 34.00
05/05/2019 23:12:00 37.00
05/05/2019 23:12:00 32.00
05/05/2019 23:12:02 33.00
05/05/2019 23:12:02 34.00
05/05/2019 23:12:03 34.00
05/05/2019 23:12:04 33.00
05/05/2019 23:12:05 35.00
05/05/2019 23:12:07 37.00
05/05/2019 23:12:07 37.00
05/05/2019 23:12:08 36.00
05/05/2019 23:12:09 35.00
05/05/2019 23:12:11 33.00
05/05/2019 23:12:11 35.00
05/05/2019 23:12:13 34.00
05/05/2019 23:12:13 34.00
05/05/2019 23:12:15 39.00
05/05/2019 23:12:16 33.00
05/05/2019 23:12:17 33.00
05/05/2019 23:12:17 31.00
05/05/2019 23:12:18 35.00
05/05/2019 23:12:20 29.00
05/05/2019 23:12:20 33.00
05/05/2019 23:12:22 34.00
05/05/2019 23:12:23 33.00
05/05/2019 23:12:23 33.00
05/05/2019 23:12:25 34.00
05/05/2019 23:12:25 34.00
05/05/2019 23:12:26 35.00
05/05/2019 23:12:27 31.00
05/05/2019 23:12:29 36.00
05/05/2019 23:12:29 36.00
05/05/2019 23:12:31 31.00
05/05/2019 23:12:31 35.00
05/05/2019 23:12:33 35.00
05/05/2019 23:12:33 35.00
05/05/2019 23:12:35 34.00
05/05/2019 23:12:35 31.00
05/05/2019 23:12:37 36.00
05/05/2019 23:12:38 37.00
05/05/2019 23:12:38 34.00
05/05/2019 23:12:40 34.00
05/05/2019 23:12:40 36.00
05/05/2019 23:12:42 38.00
05/05/2019 23:12:42 35.00
05/05/2019 23:12:44 34.00
05/05/2019 23:12:44 37.00
05/05/2019 23:12:46 35.00
05/05/2019 23:12:46 35.00
05/05/2019 23:12:48 33.00
05/05/2019 23:12:48 37.00
05/05/2019 23:12:50 56.00
05/05/2019 23:12:50 34.00
05/05/2019 23:12:52 35.00
05/05/2019 23:12:52 42.00
05/05/2019 23:12:54 35.00
05/05/2019 23:12:54 30.00
05/05/2019 23:12:56 36.00
05/05/2019 23:12:56 35.00
05/05/2019 23:12:58 32.00
05/05/2019 23:12:58 32.00
05/05/2019 23:13:00 35.00
05/05/2019 23:13:00 34.00
05/05/2019 23:13:02 33.00
05/05/2019 23:13:02 35.00
05/05/2019 23:13:03 36.00
05/05/2019 23:13:05 33.00
05/05/2019 23:13:05 34.00
05/05/2019 23:13:07 33.00
05/05/2019 23:13:07 33.00
05/05/2019 23:13:09 35.00
05/05/2019 23:13:09 36.00
05/05/2019 23:13:11 39.00
05/05/2019 23:13:11 33.00
05/05/2019 23:13:12 36.00
05/05/2019 23:13:14 33.00
05/05/2019 23:13:14 34.00
05/05/2019 23:13:16 33.00
05/05/2019 23:13:16 33.00
05/05/2019 23:13:18 32.00
05/05/2019 23:13:18 33.00
05/05/2019 23:13:20 32.00
05/05/2019 23:13:20 37.00
05/05/2019 23:13:21 34.00
05/05/2019 23:13:23 36.00
05/05/2019 23:13:23 35.00
05/05/2019 23:13:25 36.00
05/05/2019 23:13:25 35.00
05/05/2019 23:13:27 34.00
05/05/2019 23:13:27 36.00
05/05/2019 23:13:29 36.00
05/05/2019 23:13:30 33.00
05/05/2019 23:13:30 36.00
05/05/2019 23:13:32 36.00
05/05/2019 23:13:32 35.00
05/05/2019 23:13:34 39.00
05/05/2019 23:13:34 36.00
05/05/2019 23:13:35 37.00
05/05/2019 23:13:37 35.00
05/05/2019 23:13:37 34.00
05/05/2019 23:13:39 35.00
05/05/2019 23:13:39 36.00
05/05/2019 23:13:41 34.00
05/05/2019 23:13:41 30.00
05/05/2019 23:13:43 30.00
05/05/2019 23:13:43 29.00
05/05/2019 23:13:45 35.00
05/05/2019 23:13:46 37.00
05/05/2019 23:13:47 35.00
05/05/2019 23:13:47 39.00
05/05/2019 23:13:49 32.00
05/05/2019 23:13:49 36.00
05/05/2019 23:13:51 34.00
05/05/2019 23:13:51 33.00
05/05/2019 23:13:53 15.00
05/05/2019 23:13:53 7.00
05/05/2019 23:13:55 -135.00
05/05/2019 23:13:55 35.00
05/05/2019 23:13:57 39.00
05/05/2019 23:13:57 34.00
05/05/2019 23:13:59 33.00
05/05/2019 23:14:00 36.00
05/05/2019 23:14:01 32.00
05/05/2019 23:14:02 37.00
05/05/2019 23:14:03 35.00
05/05/2019 23:14:04 35.00
05/05/2019 23:14:05 35.00
05/05/2019 23:14:06 38.00
05/05/2019 23:14:07 39.00
05/05/2019 23:14:08 37.00
05/05/2019 23:14:09 38.00
05/05/2019 23:14:10 34.00
05/05/2019 23:14:10 31.00
05/05/2019 23:14:12 30.00
05/05/2019 23:14:12 34.00
05/05/2019 23:14:14 38.00
05/05/2019 23:14:15 31.00
05/05/2019 23:14:16 37.00
05/05/2019 23:14:16 36.00
05/05/2019 23:14:18 37.00
05/05/2019 23:14:19 34.00
05/05/2019 23:14:20 35.00
05/05/2019 23:14:20 31.00
05/05/2019 23:14:22 32.00
05/05/2019 23:14:22 34.00
05/05/2019 23:14:24 35.00
05/05/2019 23:14:25 30.00
05/05/2019 23:14:25 33.00
05/05/2019 23:14:27 31.00
05/05/2019 23:14:28 33.00
05/05/2019 23:14:29 33.00
05/05/2019 23:14:30 36.00
05/05/2019 23:14:31 35.00
05/05/2019 23:14:32 37.00
05/05/2019 23:14:33 35.00
05/05/2019 23:14:34 37.00
05/05/2019 23:14:35 35.00
05/05/2019 23:14:36 34.00
05/05/2019 23:14:37 32.00
05/05/2019 23:14:38 36.00
05/05/2019 23:14:39 35.00
05/05/2019 23:14:40 37.00
05/05/2019 23:14:41 38.00
05/05/2019 23:14:42 35.00
05/05/2019 23:14:43 36.00
05/05/2019 23:14:44 33.00
05/05/2019 23:14:45 34.00
05/05/2019 23:14:46 37.00
05/05/2019 23:14:47 39.00
05/05/2019 23:14:48 30.00
05/05/2019 23:14:49 31.00
05/05/2019 23:14:50 34.00
05/05/2019 23:14:51 33.00
05/05/2019 23:14:52 37.00
05/05/2019 23:14:53 33.00
05/05/2019 23:14:54 32.00
05/05/2019 23:14:55 30.00
05/05/2019 23:14:56 32.00
05/05/2019 23:14:57 35.00
05/05/2019 23:14:58 30.00
05/05/2019 23:14:59 35.00
05/05/2019 23:15:00 29.00
05/05/2019 23:15:01 40.00
05/05/2019 23:15:02 33.00
05/05/2019 23:15:03 33.00
05/05/2019 23:15:04 33.00
05/05/2019 23:15:05 36.00
05/05/2019 23:15:06 32.00
05/05/2019 23:15:07 39.00
05/05/2019 23:15:08 34.00
05/05/2019 23:15:09 24.00
05/05/2019 23:15:10 -76.00
05/05/2019 23:15:11 41.00
05/05/2019 23:15:12 33.00
05/05/2019 23:15:13 35.00
05/05/2019 23:15:14 32.00
05/05/2019 23:15:15 35.00
05/05/2019 23:15:16 35.00
05/05/2019 23:15:17 36.00
05/05/2019 23:15:18 30.00
05/05/2019 23:15:19 40.00
05/05/2019 23:15:20 32.00
05/05/2019 23:15:21 35.00
05/05/2019 23:15:22 32.00
05/05/2019 23:15:23 38.00
05/05/2019 23:15:24 34.00
05/05/2019 23:15:25 37.00
05/05/2019 23:15:26 36.00
05/05/2019 23:15:27 40.00
05/05/2019 23:15:28 33.00
05/05/2019 23:15:29 33.00
05/05/2019 23:15:30 36.00
05/05/2019 23:15:31 39.00
05/05/2019 23:15:32 37.00
05/05/2019 23:15:33 37.00
05/05/2019 23:15:34 37.00
05/05/2019 23:15:35 32.00
05/05/2019 23:15:36 35.00
05/05/2019 23:15:37 34.00
05/05/2019 23:15:38 33.00
05/05/2019 23:15:39 36.00
05/05/2019 23:15:40 31.00
05/05/2019 23:15:41 35.00
05/05/2019 23:15:42 36.00
05/05/2019 23:15:43 36.00
05/05/2019 23:15:44 38.00
05/05/2019 23:15:45 42.00
05/05/2019 23:15:46 33.00
05/05/2019 23:15:47 30.00
05/05/2019 23:15:48 35.00
05/05/2019 23:15:49 34.00
05/05/2019 23:15:50 33.00
05/05/2019 23:15:51 35.00
05/05/2019 23:15:52 34.00
05/05/2019 23:15:53 38.00
05/05/2019 23:15:54 36.00
05/05/2019 23:15:55 32.00
05/05/2019 23:15:56 36.00
05/05/2019 23:15:57 26.00
05/05/2019 23:15:58 33.00
05/05/2019 23:15:59 34.00
05/05/2019 23:16:00 34.00
05/05/2019 23:16:01 34.00
05/05/2019 23:16:02 38.00
05/05/2019 23:16:03 36.00
05/05/2019 23:16:04 33.00
05/05/2019 23:16:05 37.00
05/05/2019 23:16:06 39.00
05/05/2019 23:16:07 34.00
05/05/2019 23:16:08 34.00
05/05/2019 23:16:09 36.00
05/05/2019 23:16:10 33.00
05/05/2019 23:16:11 30.00
05/05/2019 23:16:12 33.00
05/05/2019 23:16:13 35.00
05/05/2019 23:16:14 37.00
05/05/2019 23:16:15 38.00
05/05/2019 23:16:16 35.00
05/05/2019 23:16:17 31.00
05/05/2019 23:16:18 30.00
05/05/2019 23:16:19 35.00
05/05/2019 23:16:20 35.00
05/05/2019 23:16:21 35.00
05/05/2019 23:16:22 37.00
05/05/2019 23:16:23 38.00
05/05/2019 23:16:24 32.00
05/05/2019 23:16:25 38.00
05/05/2019 23:16:26 36.00
05/05/2019 23:10:19 25.70
05/05/2019 23:10:21 25.70
05/05/2019 23:10:23 25.70
05/05/2019 23:10:25 25.70
05/05/2019 23:10:27 25.70
05/05/2019 23:10:29 25.70
05/05/2019 23:10:31 25.70
05/05/2019 23:10:33 25.70
05/05/2019 23:10:35 25.70
05/05/2019 23:10:37 25.70
05/05/2019 23:10:39 25.70
05/05/2019 23:10:41 25.70
05/05/2019 23:10:43 25.70
05/05/2019 23:10:45 25.70
05/05/2019 23:10:47 25.70
05/05/2019 23:10:49 25.70
05/05/2019 23:10:51 25.70
05/05/2019 23:10:53 25.70
05/05/2019 23:10:55 25.70
05/05/2019 23:10:57 25.70
05/05/2019 23:10:59 25.70
05/05/2019 23:11:01 25.70
05/05/2019 23:11:03 25.70
05/05/2019 23:11:05 25.70
05/05/2019 23:11:07 25.70
05/05/2019 23:11:09 25.70
05/05/2019 23:11:11 25.70
05/05/2019 23:11:13 25.70
05/05/2019 23:11:15 25.70
05/05/2019 23:11:17 25.70
05/05/2019 23:11:19 25.70
05/05/2019 23:11:21 25.70
05/05/2019 23:11:23 25.70
05/05/2019 23:11:25 25.70
05/05/2019 23:11:27 25.70
05/05/2019 23:11:29 25.70
05/05/2019 23:11:31 25.70
05/05/2019 23:11:33 25.70
05/05/2019 23:11:35 25.70
05/05/2019 23:11:37 25.70
05/05/2019 23:11:39 25.70
05/05/2019 23:11:41 25.70
05/05/2019 23:11:43 25.70
05/05/2019 23:11:45 25.70
05/05/2019 23:11:47 25.70
05/05/2019 23:11:49 25.70
05/05/2019 23:11:51 25.70
05/05/2019 23:11:53 25.70
05/05/2019 23:11:55 25.70
05/05/2019 23:11:57 25.70
05/05/2019 23:11:59 25.70
05/05/2019 23:12:01 25.70
05/05/2019 23:12:03 25.70
05/05/2019 23:12:05 25.70
05/05/2019 23:12:07 25.70
05/05/2019 23:12:09 25.70
05/05/2019 23:12:11 25.70
05/05/2019 23:12:13 25.70
05/05/2019 23:12:15 25.70
05/05/2019 23:12:17 25.70
05/05/2019 23:12:19 25.70
05/05/2019 23:12:21 25.70
05/05/2019 23:12:23 25.70
05/05/2019 23:12:25 25.70
05/05/2019 23:12:27 25.70
05/05/2019 23:12:29 25.70
05/05/2019 23:12:31 25.70
05/05/2019 23:12:33 25.70
05/05/2019 23:12:35 25.70
05/05/2019 23:12:37 25.70
05/05/2019 23:12:39 25.70
05/05/2019 23:12:41 25.70
05/05/2019 23:12:43 25.70
05/05/2019 23:12:45 25.70
05/05/2019 23:12:47 25.70
05/05/2019 23:12:49 25.70
05/05/2019 23:12:51 25.70
05/05/2019 23:12:53 25.70
05/05/2019 23:12:55 25.70
05/05/2019 23:12:57 25.70
05/05/2019 23:12:59 25.70
05/05/2019 23:13:01 25.70
05/05/2019 23:13:03 25.70
05/05/2019 23:13:05 25.70
05/05/2019 23:13:07 25.70
05/05/2019 23:13:09 25.70
05/05/2019 23:13:11 25.70
05/05/2019 23:13:13 25.70
05/05/2019 23:13:15 25.70
05/05/2019 23:13:17 25.70
05/05/2019 23:13:19 25.70
05/05/2019 23:13:21 25.70
05/05/2019 23:13:23 25.70
05/05/2019 23:13:25 25.70
05/05/2019 23:13:27 25.70
05/05/2019 23:13:29 25.70
05/05/2019 23:13:31 25.70
05/05/2019 23:13:33 25.70
05/05/2019 23:13:35 25.80
05/05/2019 23:13:37 25.80
05/05/2019 23:13:39 25.80
05/05/2019 23:13:41 25.80
05/05/2019 23:13:43 25.80
05/05/2019 23:13:45 25.80
05/05/2019 23:13:47 25.80
05/05/2019 23:13:49 25.90
05/05/2019 23:13:51 25.90
05/05/2019 23:13:53 25.90
05/05/2019 23:13:55 26.00
05/05/2019 23:13:57 26.00
05/05/2019 23:13:59 26.00
05/05/2019 23:14:01 26.00
05/05/2019 23:14:03 26.00
05/05/2019 23:14:05 26.00
05/05/2019 23:14:08 26.00
05/05/2019 23:14:09 26.00
05/05/2019 23:14:12 26.00
05/05/2019 23:14:14 26.00
05/05/2019 23:14:16 26.00
05/05/2019 23:14:18 26.00
05/05/2019 23:14:20 26.00
05/05/2019 23:14:22 26.00
05/05/2019 23:14:24 26.00
05/05/2019 23:14:26 26.00
05/05/2019 23:14:28 26.00
05/05/2019 23:14:30 26.00
05/05/2019 23:14:32 26.00
05/05/2019 23:14:34 26.10
05/05/2019 23:14:36 26.10
05/05/2019 23:14:38 26.10
05/05/2019 23:14:40 26.10
05/05/2019 23:14:42 26.10
05/05/2019 23:14:44 26.10
05/05/2019 23:14:46 26.10
05/05/2019 23:14:48 26.20
05/05/2019 23:14:50 26.20
05/05/2019 23:14:52 26.20
05/05/2019 23:14:54 26.20
05/05/2019 23:14:56 26.20
05/05/2019 23:14:58 26.20
05/05/2019 23:15:00 26.20
05/05/2019 23:15:02 26.20
05/05/2019 23:15:04 26.20
05/05/2019 23:15:06 26.20
05/05/2019 23:15:08 26.20
05/05/2019 23:15:10 26.20
05/05/2019 23:15:12 26.20
05/05/2019 23:15:14 26.20
05/05/2019 23:15:16 26.20
05/05/2019 23:15:18 26.20
05/05/2019 23:15:20 26.20
05/05/2019 23:15:22 26.20
05/05/2019 23:15:24 26.20
05/05/2019 23:15:26 26.20
05/05/2019 23:15:28 26.20
05/05/2019 23:15:30 26.20
05/05/2019 23:15:32 26.20
05/05/2019 23:15:34 26.20
05/05/2019 23:15:36 26.20
05/05/2019 23:15:38 26.20
05/05/2019 23:15:40 26.20
05/05/2019 23:15:42 26.20
05/05/2019 23:15:44 26.20
05/05/2019 23:15:46 26.20
05/05/2019 23:15:48 26.20
05/05/2019 23:15:50 26.20
05/05/2019 23:15:52 26.20
05/05/2019 23:15:54 26.20
05/05/2019 23:15:56 26.20
05/05/2019 23:15:58 26.20
05/05/2019 23:16:00 26.10
05/05/2019 23:16:02 26.10
05/05/2019 23:16:04 26.20
05/05/2019 23:16:06 26.10
05/05/2019 23:16:08 26.10
05/05/2019 23:16:10 26.10
05/05/2019 23:16:12 26.10
05/05/2019 23:16:14 26.10
05/05/2019 23:16:16 26.10
05/05/2019 23:16:18 26.10
05/05/2019 23:16:20 26.10
05/05/2019 23:16:22 26.10
05/05/2019 23:16:24 26.10
05/05/2019 23:16:26 26.20
05/05/2019 23:16:28 26.10
05/05/2019 23:16:30 26.10
05/05/2019 23:16:32 26.10
05/05/2019 23:16:34 26.10
05/05/2019 23:16:36 26.10
05/05/2019 23:16:38 26.10
05/05/2019 23:16:40 26.10
05/05/2019 23:16:42 26.10
05/05/2019 23:16:44 26.10
05/05/2019 23:16:46 26.10
05/05/2019 23:16:48 26.10
05/05/2019 23:16:50 26.10
05/05/2019 23:16:52 26.10
05/05/2019 23:16:54 26.10
05/05/2019 23:16:56 26.10
05/05/2019 23:16:58 26.10
05/05/2019 23:17:00 26.10
05/05/2019 23:17:02 26.10
05/05/2019 23:17:04 26.10
05/05/2019 23:17:06 26.10
05/05/2019 23:17:08 26.10
05/05/2019 23:17:10 26.10
05/05/2019 23:17:12 26.10
05/05/2019 23:17:14 26.10
05/05/2019 23:17:16 26.10
05/05/2019 23:17:18 26.00
05/05/2019 23:17:20 26.10
05/05/2019 23:17:22 26.00
05/05/2019 23:17:24 26.00
05/05/2019 23:17:26 26.00
05/05/2019 23:17:28 26.10
05/05/2019 23:17:30 26.00
05/05/2019 23:17:32 26.00
05/05/2019 23:17:34 26.00
05/05/2019 23:17:36 26.00
05/05/2019 23:17:38 26.00
05/05/2019 23:17:40 26.00
05/05/2019 23:17:42 26.00
05/05/2019 23:17:44 26.00
05/05/2019 23:17:46 26.00
05/05/2019 23:17:48 26.00
05/05/2019 23:17:50 26.00
05/05/2019 23:17:52 26.00
05/05/2019 23:17:54 26.00
05/05/2019 23:17:56 26.00
05/05/2019 23:17:58 26.00
05/05/2019 23:18:00 26.00
05/05/2019 23:18:03 26.00
05/05/2019 23:18:04 26.00
05/05/2019 23:18:07 26.00
05/05/2019 23:18:09 26.00
05/05/2019 23:18:12 26.00
05/05/2019 23:18:13 26.00
05/05/2019 23:18:15 26.00
05/05/2019 23:18:17 25.90
05/05/2019 23:18:19 25.90
05/05/2019 23:18:21 26.00
05/05/2019 23:18:23 26.00
05/05/2019 23:18:25 25.90
05/05/2019 23:18:27 25.90
05/05/2019 23:18:29 25.90
05/05/2019 23:18:31 25.90
05/05/2019 23:18:33 25.90
05/05/2019 23:18:35 25.90
05/05/2019 23:18:37 25.90
05/05/2019 23:18:39 25.90
05/05/2019 23:18:41 25.90
05/05/2019 23:18:43 25.90
05/05/2019 23:18:45 25.90
05/05/2019 23:18:47 25.90
05/05/2019 23:18:49 25.90
05/05/2019 23:18:51 25.90
05/05/2019 23:18:53 25.90
05/05/2019 23:18:55 25.90
05/05/2019 23:18:57 25.90
05/05/2019 23:18:59 25.90
05/05/2019 23:19:01 25.90
05/05/2019 23:19:03 25.90
05/05/2019 23:19:05 25.90
05/05/2019 23:19:07 25.90
05/05/2019 23:19:09 25.90
05/05/2019 23:19:11 25.90
05/05/2019 23:19:13 25.90
05/05/2019 23:19:15 25.90
05/05/2019 23:19:17 25.90
05/05/2019 23:19:19 25.80
05/05/2019 23:19:21 25.90
05/05/2019 23:19:23 25.90
05/05/2019 23:19:25 25.90
05/05/2019 23:19:27 25.80
05/05/2019 23:19:29 25.80
05/05/2019 23:19:31 25.80
05/05/2019 23:19:33 25.80
05/05/2019 23:19:35 25.80
05/05/2019 23:19:37 25.80
05/05/2019 23:19:39 25.80
05/05/2019 23:19:41 25.80
05/05/2019 23:19:43 25.80
05/05/2019 23:19:45 25.80
05/05/2019 23:19:47 25.80
05/05/2019 23:19:49 25.80
05/05/2019 23:19:51 25.80
05/05/2019 23:19:53 25.80
05/05/2019 23:19:55 25.80
05/05/2019 23:19:57 25.80
05/05/2019 23:19:59 25.80
05/05/2019 23:20:01 25.80
05/05/2019 23:20:03 25.80
05/05/2019 23:20:05 25.80
05/05/2019 23:20:07 25.80
05/05/2019 23:20:09 25.80
05/05/2019 23:20:11 25.80
05/05/2019 23:20:13 25.80
05/05/2019 23:20:15 25.80
05/05/2019 23:20:17 25.80
05/05/2019 23:20:19 25.80
05/05/2019 23:20:21 25.80
05/05/2019 23:20:23 25.80
05/05/2019 23:20:25 25.80
05/05/2019 23:20:27 25.80
05/05/2019 23:20:29 25.80
05/05/2019 23:20:31 25.80
05/05/2019 23:20:33 25.80
05/05/2019 23:20:35 25.80
05/05/2019 23:20:37 25.80
05/05/2019 23:20:39 25.80
05/05/2019 23:20:41 25.80
05/05/2019 23:20:43 25.80
05/05/2019 23:20:45 25.80
05/05/2019 23:20:47 25.80
05/05/2019 23:20:49 25.80
05/05/2019 23:20:51 25.80
05/05/2019 23:20:53 25.70
05/05/2019 23:20:55 25.80
05/05/2019 23:20:57 25.70
05/05/2019 23:20:59 25.70
05/05/2019 23:21:01 25.70
05/05/2019 23:21:03 25.70
05/05/2019 23:21:05 25.80
05/05/2019 23:21:07 25.70
05/05/2019 23:21:09 25.70
05/05/2019 23:21:11 25.80
05/05/2019 23:21:13 25.70
05/05/2019 23:21:15 25.70
05/05/2019 23:21:17 25.70
05/05/2019 23:21:19 25.70
05/05/2019 23:21:21 25.70
05/05/2019 23:21:23 25.70
05/05/2019 23:21:25 25.70
05/05/2019 23:21:27 25.70
05/05/2019 23:21:29 25.70
05/05/2019 23:21:31 25.70
05/05/2019 23:21:33 25.70
05/05/2019 23:21:35 25.70
05/05/2019 23:21:37 25.70
#include <Arduino.h>
#include <ittiot.h>
#include <DHT.h>
#define DHTPIN D3 // what pin we're connected to. Change this to D3 if your shield has one leg removed.
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE);
void iot_connected()
{
Serial.println("MQTT connected callback");
iot.log("IoT DHT example!");
}
void setup()
{
Serial.begin(115200);
Serial.println("Booting");
iot.printConfig(); // print json config to serial //Peale Serial.begin ja enne iot.setup
iot.setup();
pinMode(16, OUTPUT);
dht.begin();
}
void loop()
{
iot.handle();
float t = dht.readTemperature();
if(std::isnormal(t)){
char buf[10]; // Put whatever length you need here
String(t).toCharArray(buf,10);
digitalWrite(16,HIGH);
iot.publishMsgTo("embedded/temp",buf, false);
}
delay(2000);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment