MetaView
Published © Apache-2.0

Water Temperature Tracking Device

I live on a lake and always wanted to measure and track its water temperature. Hologram Nova and RaspberryPi would make it possible.

BeginnerFull instructions provided709
Water Temperature Tracking Device

Things used in this project

Hardware components

Hologram Nova
Hologram Nova
×1
Raspberry Pi Zero Wireless
Raspberry Pi Zero Wireless
×1
Temperature Sensor
Temperature Sensor
×1

Story

Read more

Code

Python script

Python
#!/usr/bin/python
# -*- coding: utf-8 -*-

import time

temps = []

try:
	# 1-Wire Slave-Liste lesen
	file = open('/sys/devices/w1_bus_master1/w1_master_slaves')
	w1_slaves = file.readlines()
	file.close()

	# Fuer jeden 1-Wire Slave aktuelle Temperatur auslesen
	idx = 0
	for line in w1_slaves:
		# 1-wire Slave extrahieren
		w1_slave = line.split("\n")[0]

		try:
			# 1-wire Slave Datei lesen
			name = '/sys/bus/w1/devices/' + str(w1_slave) + '/w1_slave'
			file = open(name)
			filecontent = file.read()
			file.close()

			# Temperaturwere auslesen und konvertieren
			print(filecontent)
			stringvalue = filecontent.split("\n")[1].split(" ")[9]
			print(stringvalue)
			temperature = float(stringvalue[2:]) / 1000

			#Temperatur ausgeben
			print(str(w1_slave) + ': %6.2f °C' % temperature)
			temps.append(temperature)
			
		except:
			print(name + ' does not exist.')
		
		idx = idx + 1
		time.sleep(1)

except:
	print('w1_master_slaves not found.')

from Hologram.HologramCloud import HologramCloud
hologram = HologramCloud(dict(), network='cellular')
result = hologram.network.connect()
if result == False:
	print(' Failed to connect to cell network')
	
for idx in range(0, len(temps)):

	print('%6.2f °C' % temps[idx])

	result = hologram.sendMessage('{"temperature": %6.2f}' % temps[idx], ["Zernsee" + str(idx+1)])
	print(result)

	time.sleep(10)

hologram.network.disconnect()

Credits

MetaView

MetaView

1 project • 10 followers

Comments

Add projectSign up / Login