Tweet-a-watt Floating Division error

XBee projects like the adapter, xBee tutorials, tweetawatt/wattcher, etc. from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
brettinman
 
Posts: 6
Joined: Sat Jul 18, 2009 11:46 pm

Tweet-a-watt Floating Division error

Post by brettinman »

So I had the Tweet-A-Watt running great on my desktop (awesome kit, by the way). I then decided to move it to my server, since it's on 24/7 anyways and then I could shut down my desktop at night. The server is running Server 2003, if that's relevant. I'm using python 2.5 as suggested and I installed all the necessary packages. It runs fine until it is time for a Twitter update. Here's what I see in the command line:

Code: Select all

C:\>python25\python.exe wattcher\wattcher.py

1       Current draw, in amperes: 1.89373814042
        Watt draw, in VA: 257.734345351
                Wh used in last  0.0  seconds:  0.0
twittertime!
Traceback (most recent call last):
  File "wattcher\wattcher.py", line 300, in <module>
    update_graph(None)
  File "wattcher\wattcher.py", line 270, in update_graph
    wattsused += history.avgwattover5min()
  File "C:\wattcher\sensorhistory.py", line 124, in avgwattover5min
    return self.cumulative5mwatthr * (60.0*60.0 / (time.time() - self.fiveminute
timer))
ZeroDivisionError: float division
Any suggestions? Thanks!

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Tweet-a-watt Floating Division error

Post by adafruit »

this is a bug i need to fix. argh!
you could put a sleep() before that line :)

brettinman
 
Posts: 6
Joined: Sat Jul 18, 2009 11:46 pm

Re: Tweet-a-watt Floating Division error

Post by brettinman »

Like this?

Code: Select all

  
def avgwattover5min(self):
	time.sleep(1)
	return self.cumulative5mwatthr * (60.0*60.0 / (time.time() - self.fiveminutetimer))
It seems to be working now (I have it updating every hour to test), I'll report back later if all is still well.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Tweet-a-watt Floating Division error

Post by adafruit »

perfect :) you're a python pro!

brettinman
 
Posts: 6
Joined: Sat Jul 18, 2009 11:46 pm

Re: Tweet-a-watt Floating Division error

Post by brettinman »

Haha, thanks, but that would be my roommate the CS major (the name of my blog is "I Hate Software"). Just getting pyserial to talk to my Arduino was quite the ordeal. Thanks for the help! Tweeting is commencing perfectly.

brettinman
 
Posts: 6
Joined: Sat Jul 18, 2009 11:46 pm

Re: Tweet-a-watt Floating Division error

Post by brettinman »

Ok so that didn't quite fix the problem - it Tweets, but the current usage (average over 5 min) is reading as 0 (http://twitter.com/brettwattage). I looked in the directory and don't see the log file anywhere. Did I set the sleep too long or is it causing some other error?

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Tweet-a-watt Floating Division error

Post by adafruit »

i have seen this bug. its on my todo to fix. it only happens some times and not on my computer. however, im going to look at it in detail

brettinman
 
Posts: 6
Joined: Sat Jul 18, 2009 11:46 pm

Re: Tweet-a-watt Floating Division error

Post by brettinman »

No problem; I'll play around with things and see if I can fix it (it was running fine earlier so there must be something). Let me know if there's anything I can do to help troubleshoot it.

Locked
Please be positive and constructive with your questions and comments.

Return to “XBee products (discontinued)”