I2C and DS2482 with temp sensors

1,084 views
Skip to first unread message

DavidVT

unread,
Nov 15, 2013, 6:06:56 AM11/15/13
to web...@googlegroups.com
Looking for other's experience with the DS2482 within WEBIOPI?

Being fairly new to webiopi, I tend to hang back and read before posting.
I have some recent success with the DS2482 (not using rpidom), thanks to Eric's post:
http://trouch.com/2013/03/31/rpidom-et-webiopi-1-wire/

I see others mention the I2C connection with the DS2482 but I don't see a ton of momentum at the newbie level where I still am.

I was trying to use webiopi for my OWB (wood burning boiler) but could not make my remote sensors work directly off the Pi's GPIO after the in house testing had been successful.
I bought this add on card and initially gave up on webiopi in favor of the OWFS solution. That allowed me to test and succeed at reading the remote sensors via the new i2c circuit board (where the ds2482-100) is installed. I was also able to upload via python to google docs.

Now that I am confident the hardware works, I returned to this group and Eric's site in search of a webiopi solution. A few hours ago I was successful using the guidance from Eric's post ( with a little help from google translate). Now to get the sensors up on the webiopi gauge page I had working before....

First specific question to all: please help me understand what this means at the end of his post: (in the translated English)
"But we must now Register for the bridge over the I2C bus by hand. "

I hope this thread can collect i2c / DS2482 discussions..

Thank you
David

DavidVT

unread,
Nov 15, 2013, 7:23:37 AM11/15/13
to web...@googlegroups.com
At the moment I seem to have both Web apps running and the temperature data showing in OWSERVER (:2121) and WEBIOPI (:8000)
It is nice to finally see the boiler temps on the webiopi driven gauges!

I suspect a reboot may reveal the answer to my register for the bridge question above.

Message has been deleted

Robert More

unread,
Nov 15, 2013, 3:45:14 PM11/15/13
to web...@googlegroups.com
The DS2482 is not automatically detected like the DS18B20, so you will have to manually register it as in the example Eric provided:

# Finally, the bridge over the I2C interface is recorded 
for Raspberry # Revision 1, replace i2c i2c-1-0 
$ echo ds2482 0x18  | sudo tee / sys / bus / i2c / devices / i2c - 1 / new_device

DavidVT

unread,
Nov 16, 2013, 5:10:45 AM11/16/13
to web...@googlegroups.com
I just did a reboot and find the webiopi based gauges are all coming up with zeros. I believe this is the indication that I must run that registration line now.
Thank you

DavidVT

unread,
Nov 17, 2013, 6:09:42 AM11/17/13
to web...@googlegroups.com
I am able to reboot the Pi and then:
1 - run a simple script to stop webiopi and load the appropriate modules
2 - from the command line enter the echo .....  | sudo tee ....   line manually   (can not figure out how to make that work in the script)
3 - manually confirm the 1wire sensors are now in the device folders
4 - restart webiopi  and then see the sensor data in my webiopi web page!

DavidVT

unread,
Nov 17, 2013, 7:55:30 PM11/17/13
to web...@googlegroups.com
FYI project details:

Old Hardy stainless OWB heating a 170 year old farm house in rural Vermont. I am setting all this up for an eventual replacement of the old outdoor boiler to something more ecology friendly and efficient. This is one of those getting the black eye for smoke. Mine is not bad as I only burn dry hardwood but I know it could be more efficient. I easily burn 14 cords in the heating season!
A basement heat exchanger connects the wood heat water loop to the normally idle oil fired pressurized system when zone demands call for heat.
The fire is controlled by a solenoid operated supply air valve and a powered fan on that same supply.

Monitoring hardware is the v2 Raspberry Pi with a European sourced i2c daughter board and cat5 connecting 1wire temperature sensors.

Future plans will allow the pi to make heating decision based on ambient temperatures, over heat situations, under heat situations and low water in the OWB.
A secondary future goal will be to control the two fire control functions as stages based on tank temperature (air solenoid,fan). The pi will need to control ac voltage outputs to these two circuits. Some kind of PID control loop watching ambient, rate of rise/fall,etc.

Logging and graphing over time will be important and has not yet been initiated.

Alarms will be needed for over heat, under heat, low water and have not yet been initiated.

I am a PLC ladder logic and old visual interdev kind of person. I did ground breaking business web stuff prior to 9/11 with databases etc but that is pretty ancient stuff now. I have a learning curve with this project and the Pi but I enjoy the challenge in Linux.

Thanks in advance for any help with this,

David

DavidVT

unread,
Nov 30, 2013, 6:40:51 PM11/30/13
to web...@googlegroups.com
I used the notes from Stuart Marsden to manually register the DS2482. It works well bit is lost at every reboot.
The module loading is scripted easily but I need help moving the last step to a script. My Linux inexperience is revealed with this question!

How do I run this command in a shell script?

echo ds2482 0x18 | sudo tee -a /sys/bus/i2c/devices/i2c-0/new_device

Thank you!!

trouch

unread,
Nov 30, 2013, 6:45:03 PM11/30/13
to web...@googlegroups.com
I guess your script is running as root.
you can try this :
echo "ds2482 0x18" >> /sys/bus/i2c/devices/i2c-0/new_device
sleep 1
for rev1 board : i2c-0
for rev2 board : i2c-1

Eric.




--
You received this message because you are subscribed to the Google Groups "WebIOPi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webiopi+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

DavidVT

unread,
Dec 1, 2013, 12:15:12 AM12/1/13
to web...@googlegroups.com
Thank you Eric for that guidance with scripting syntax. 
I was able to finish the tiny registration script and test it.  I have now inserted it into crontab via @reboot so the DS2482 is registered at boot.
It worked great and I was then able to remove OWFS from the system as I will no longer use it.
David

DavidVT

unread,
Dec 9, 2013, 8:13:06 PM12/9/13
to web...@googlegroups.com
Staying with this thread as I add features I wanted to discuss the best way to pull sensor data from webiopi for use in other scripts/programs on the same Raspberry.

These other scripts/programs have no function with the webiopi web GUI, rather they just want to pull sensor data for charting, history, etc.

I have a python script that is using webiopi.client to 127.0.0.1 so to pull temperatures and then upload them to google documents.
It works fine but I think there must be a better way to access the device data without using webiopi.client. Is this correct?

Another use would be to feed an rrd process.

Thoughts?

------
Some of the code, borrowed and sewn together from a few web searches with thx to numerous authors:
(The complete program works for now)

#setting up the imports and google docs are removed to focus on the webiopi.client connection query of this post
# Create a WebIOPi client
client = PiHttpClient("127.0.0.1")
client.setCredentials("", "")

# 1wire sensors connected via webiopi and working from webiopi GUI.
sensors = ['temp0','temp1','temp2','temp3']
names = ['Boiler', 'HeatEx', 'Basement', 'Outdoor']

# Continuously append data
while(True):
row = []
worksheet = gc.open(spreadsheet).sheet1

for x in range(len(sensors)):
# Reach back to webiopi for the 1wire data
output = Temperature(client, sensors[x]).getFahrenheit() #<===. This works but is there a better way???
temp = float(output)
row.extend([temp]) # then cycle through the sensor list appending each to row[]
sleep(2) # a little pause
# finally upload to google docs spreadsheet, example truncated here

Eric PTAK

unread,
Dec 11, 2013, 2:52:35 AM12/11/13
to web...@googlegroups.com
why making another process on the same machine ?
you can upload data in the loop function in a custom webiopi script


DavidVT

unread,
Dec 11, 2013, 3:59:06 PM12/11/13
to web...@googlegroups.com
Ok thank you,
I had thought those were only for the web interface and custom controls.
My learning continues!!
I will attempt to follow your advice and integrate the google doc export.
David

DavidVT

unread,
Dec 12, 2013, 7:59:57 AM12/12/13
to web...@googlegroups.com
I have spent a few hours moving code to script.py so to run this as suggested.
Unfortunately I ran into what is likely another Neubie snag:

When I start webiopi in debug mode it faults on not being able to import 'gspread' which is used to upload to google docs.

Gspread works fine from my other python programs in the same Pi.

Is this perhaps a python version issue?

Thoughts??

Toshi Bass

unread,
Dec 12, 2013, 2:53:30 PM12/12/13
to web...@googlegroups.com
Hi David,

Me thinks we need some more info on this, you suspect the problem may be the python version, so what version are you using in your other scripts and what version is your webiopi using ? Hint in the webiopi debug screen when it first loads states which python version its using.

If there different versions then google Gspread and see if it is supposed to function in both python 2.7 and 3,2 or if there are differences.

If there the same version then I suggest you post your script so we can look for a problem also a copy of the debug screen would be usefull as well.

Toshi 

David Covell

unread,
Dec 12, 2013, 4:16:26 PM12/12/13
to web...@googlegroups.com
Hi,
This is the kind of thing I am trying to do inside webiopi script.py:

http://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/connecting-to-google-docs

In my case I am using i2c sourced one wire sensors.  My sensors all work to a webiopi HTML page like yours.   

I want to data log to google spreadsheet.  I am currently doing this with a stand along python program using webiopi.client access to local host.  Eric suggested moving all that inside script.py.

I will post more code once I clean it up a bit. 

David
--
You received this message because you are subscribed to a topic in the Google Groups "WebIOPi" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/webiopi/uewV_YLjIe4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to webiopi+u...@googlegroups.com.

DavidVT

unread,
Dec 14, 2013, 1:30:27 PM12/14/13
to web...@googlegroups.com
I was able to import GSPREAD to script.py after making a copy from Python 2.7 over to latest Python lib directory.
I have yet try an upload to google docs but will report when I do.
Below zero temps have me leaving the boiler monitor alone for the moment.
David

Toshi Bass

unread,
May 1, 2014, 9:00:20 AM5/1/14
to web...@googlegroups.com
Hi David

Any chance to get a copy of this tiny registration script you made I need to do same same thanks

Toshi

David Covell

unread,
May 1, 2014, 5:21:48 PM5/1/14
to web...@googlegroups.com
Hello Toshi,
Rather than leaving you hanging, here is a link that I started with, not webiopi but it has nice examples of interacting with gspread.

My efforts using this directly with webiopi paused after numerous sd card failures.  I have some early work in dropbox but the last working versions went up into SD card heaven....

I still have a stand alone script like the example above that continues to send my temps to gspread via cronjob.  That works pretty well and I added some error checking.

Your email is a good incentive to get back to it, so thank you for the nudge!

The secret to making it work with webiopi was the python version hint you gave me in this thread!  

David

Sent from my IOS7 iPad
--
You received this message because you are subscribed to a topic in the Google Groups "WebIOPi" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/webiopi/uewV_YLjIe4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to webiopi+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Toshi Bass

unread,
May 1, 2014, 6:02:00 PM5/1/14
to web...@googlegroups.com
Hi David

I tried to reply to a post higher up this tread thinking it would include the original post as well but clearly that didn't work so sorry for misunderstanding and lack of clear information.

What I was after was tiny registration script to initiate DS2482 mentioned in the below posts
 
Toshi

trouch 
11/30/13


I guess your script is running as root.
you can try this :
echo "ds2482 0x18" >> /sys/bus/i2c/devices/i2c-0/new_device sleep 1

for rev1 board : i2c-0
for rev2 board : i2c-1

Eric.

DavidVT
12/1/13

David Covell

unread,
May 1, 2014, 6:19:36 PM5/1/14
to web...@googlegroups.com
Ok Toshi,
This is probably what you want, assuming 0x18 is correct for your device.
I had lots of help with this, thanks to those who helped me!
But I thought the new webiopi had this included now?

Runs from crontab
@reboot sudo ./i2cbridge.sh


< I2cbridge.sh >

#!/bin/sh
#run as root (sudo)
service webiopi stop
modprobe wire
modprobe w1_therm
modprobe i2c_bcm2708
modprobe ds2482
echo "ds2482 0x18" >> /sys/bus/i2c/devices/i2c-1/new_device
sleep 2
service webiopi restart


David
--
Reply all
Reply to author
Forward
0 new messages