×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Raspberry PI basic Project

Raspberry PI basic Project

Raspberry PI basic Project

(OP)
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")



RE: Raspberry PI basic Project

What are the error messages? What do they say?

James P. Cottingham
I'm number 1,229!
I'm number 1,229!

RE: Raspberry PI basic Project

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][/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.


RE: Raspberry PI basic Project

(OP)

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")


RE: Raspberry PI basic Project

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!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close