Messaggi: 479
 Discussioni: 81
 Registrato: Oct 2015
	
 Reputazione: 
15
	 
	
		
		
		25/05/2016, 22:11 
(Questo messaggio è stato modificato l'ultima volta il: 02/07/2016, 12:09 da LaPa.)
		
	 
	
		Salve, 
ho un raspberry pi 2 model b con Rasbian, un sensore di temperatura digitale DS18B20, un display 16X2, vorrei leggere la temperatura sul display. Sapreste indicarmi lo schema da seguire su breadbord, il software per fare funzionare il tutto?
C'è un tutorial per tutto ciò?
Grazie
LaPa
	
	
	
With a little/big help from my friends 
 
 
 
	
	
	
		
 Messaggi: 479
 Discussioni: 81
 Registrato: Oct 2015
	
 Reputazione: 
15
	 
	
	
		Il tutorial di Adafruit è per un altro modello di Raspberry rispetto al mio, funziona ugualmente con il mio?
	
	
	
With a little/big help from my friends 
 
 
 
	
	
	
		
 Messaggi: 6,993
 Discussioni: 281
 Registrato: Mar 2015
	
 Reputazione: 
370
	 
	
	
		certamente, quello è il primo modello, (ne ho due) il pin GPIO ha solo 26 Pin, identici ai primi 26 Pin del tuo modello.
	
	
	
	
	
 
 
	
	
	
		
 Messaggi: 6,993
 Discussioni: 281
 Registrato: Mar 2015
	
 Reputazione: 
370
	 
	
	
		Bé, te lo sapremmo forse dire, se ci mostri lo script Python che hai usato..
	
	
	
	
	
 
 
	
	
	
		
 Messaggi: 479
 Discussioni: 81
 Registrato: Oct 2015
	
 Reputazione: 
15
	 
	
	
		#da 14 elements
import os 
import glob
import time 
import sys 
import datetime 
import urllib2 
 
baseURL = "https://api.thingspeak.com/update?api_key=NO3LIQBPEYI7BFAA"
#initiate the temperature sensor 
os.system('modprobe w1-gpio') 
os.system('modprobe w1-therm') 
 
#set up the location of the sensor in the system 
base_dir = '/sys/bus/w1/devices/' 
device_folder = glob.glob(base_dir + '28-041620352dff')[0]
device_file = device_folder + '/w1_slave' 
 
def read_temp_raw(): #a function that grabs the raw temperature data from the sensor
     f = open(device_file, 'r')
     lines = f.readlines()
     f.close()
     return lines 
 
def read_temp(): #a function that checks that the connection was good and strips out the temperature
     lines = read_temp_raw()
     while lines[0].strip()[-3:] != 'YES':
         time.sleep(0.2)
         lines = read_temp_raw()
     equals_pos = lines[1].find('t=')
     if equals_pos !=-1:
         temp_string = lines[1][equals_pos+2:]
         temp_c = float(temp_string)/1000.0
         temp_f = temp_c * 9.0/5.0 + 32.0
         return temp_c 
 
while True: #infinite loop
     tempin = read_temp() #get the temp
     values = [datetime.datetime.now(), tempin]
     g = urllib2.urlopen(baseURL + "&field1=%s" % (tempin))
     time.sleep(60)
	
	
	
With a little/big help from my friends 
 
 
 
	
	
	
		
 Messaggi: 479
 Discussioni: 81
 Registrato: Oct 2015
	
 Reputazione: 
15
	 
	
		
		
		16/06/2016, 00:19 
(Questo messaggio è stato modificato l'ultima volta il: 16/06/2016, 00:20 da LaPa.)
		
	 
	
		e questo è quello che appare nella shell quando s'interrompe la trasmissione dati
Traceback (most recent call last):
  File "/mnt/usbhdd/ProvaDS18B20ThingSpeak.py", line 79, in <module>
    g = urllib2.urlopen(baseURL + "&field1=%s" % (tempin))
  File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 431, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 449, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1240, in https_open
    context=self._context)
  File "/usr/lib/python2.7/urllib2.py", line 1197, in do_open
    raise URLError(err)
URLError: <urlopen error [Errno -2] Name or service not known>
>>>
	
	
	
With a little/big help from my friends 
 
 
 
	
	
	
		
 Messaggi: 479
 Discussioni: 81
 Registrato: Oct 2015
	
 Reputazione: 
15
	 
	
	
		E' possibile che l'interruzione sia dovuta a micro interruzioni su canale wireless?
	
	
	
With a little/big help from my friends 
