Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Raspberry PI basic Project 1

Status
Not open for further replies.

Zack68

IS-IT--Management
Nov 3, 2017
2
US
Hello All,

I am trying an basic IoT project: Raspberry Pi 3 + Two Ds1820 temperature sensors: I set up the Raspberry PI with the NOODS and its working.
I can read the temperature for the sensors; I have a python program to read the temp automatically.
The problem, the error messages keep pop up when I run the module.
Any idea? any ready program for this project to go with for now?
Thank You

this is my code
import os

import time

import smtplib




DS18B20_1="/sys/bus/w1/devices/28-00000923F159/W1_slave"

DS18B20_2="/sys/bus/w1/devices/28-00000923dab2/w1_slave"

counter1= 1

counter2= 1




print ("Welcome" )




while True:

first=open(DS18B20_1,"r")

data1-first.read()

first.close()




second=open(DS18B20_2,"r")

data2=second.read()

second.close()




(discard,sep,reading1)=data1.partition('t=')

(discard,sep,reading2)=data2.partition('t=')




temp1=float (reading1)/1000

temp2=float (reading2)/1000




round1=int(temp1)

round2=int(temp2)

counter1+1



counter2=1




print(str(counter1)+" return ="+str(round1)+" *C")

print(str(counter2)+" supply ="+str(round2)+" *C")



 
What are the error messages? What do they say?


James P. Cottingham
I'm number 1,229!
I'm number 1,229!
 
I'll never understand why someone will come on a site like this, and say their program is getting a bunch of error messages, and then NOT give a single error message!

Can you guess what the very first question will be?

Also, please put your code into a code block (
Code:
). Python's flow control is partially defined by indentation and the way you've listed it loses all of the indentation, so there's really no way for us to know how your code is really written. Again you leave us guessing.


 

Sorry Guys for the inconvenience [censored]..

the error:

No directory for "/sys/bus/w1/devices/28-00000923F159/W1_slave"


note: only Welcome was printed before I got the error message when I run it


import os
import time

DS18B20_1="/sys/bus/w1/devices/28-00000923F159/W1_slave"

DS18B20_2="/sys/bus/w1/devices/28-00000923dab2/w1_slave"

counter1= 1

counter2= 1


print ("Welcome" )

while True:

first=open(DS18B20_1,"r")

data1-first.read()

first.close()

second=open(DS18B20_2,"r")

data2=second.read()

second.close()

(discard,sep,reading1)=data1.partition('t=')

(discard,sep,reading2)=data2.partition('t=')


temp1=float (reading1)/1000

temp2=float (reading2)/1000

round1=int(temp1)
round2=int(temp2)

counter1+1
counter1=1

print(str(counter1)+" return ="+str(round1)+" *C")

print(str(counter2)+" supply ="+str(round2)+" *C")


 
The problem lies in
Code:
DS18B20_1="/sys/bus/w1/devices/28-00000923F159/W1_slave"
DS18B20_2="/sys/bus/w1/devices/28-00000923dab2/w1_slave"

The error indicates that those directories do not exist.
1) Make sure that the directory does exist. Is "w1_slave" a file or part of the directory?
2) I'm not all that familiar with PI but the next question that comes to mind is where is the program running? It could be the program is looking for this file from a where it is run from. For example, if the program is run from "/My File/this place" then the program could be looking at "/My File/sys/bus/w1/devices/28-00000923F159/W1_slave" when your you expect "/sys/bus/w1/devices/28-00000923F159/W1_slave" to begin from the root directory. Look at Absolute vs. Relative Paths.


James P. Cottingham
I'm number 1,229!
I'm number 1,229!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top