Article 4WNGB RPizero hangs

RPizero hangs

by
JimfromIndy
from LinuxQuestions.org on (#4WNGB)
I have a simple RPi0 running Raspbian set up to measure the temp and pressure every ten minutes and post them along with the "ambiant" temp/pressure from Darksky to a MySQL database on my 1and1.com server. The RPi runs for 3-4 days, then just hangs. Won't respond to SSH. When I unplug it and plug it back in, it runs for 3-4 days and then does it again. Rinse and repeat....

How do I troubleshoot this?

Here's the Python code it runs every 10 minutes: [ignore the local MySQL commands. The execute is commented out....]

Code:#!/usr/bin/python
import sys
import Adafruit_DHT
import MySQLdb
import time
import urllib2

from Adafruit_BME280 import *

# BMP working, DHT not so much

sensor = BME280(address=0x76,t_mode=BME280_OSAMPLE_8, p_mode=BME280_OSAMPLE_8, h_mode=BME280_OSAMPLE_8)

# conn=MySQLdb.connect(host="192.168.2.204",user="jim",passwd="xxxxxxxx",db="EnviroLogger")
# c=conn.cursor()
humidity=0
temperaturec=0
# humidity, temperaturec = Adafruit_DHT.read_retry(11, 4)
temperaturef=((temperaturec*9.000)/5.000)+32.000

datatime=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())

dhtvalues="(null,'DHT-8200-Crawl',"+str(temperaturef)+","+str(humidity)+",null,'"+datatime+"')"

time.sleep(1)
BMPtemperaturef = ((sensor.read_temperature()*9.000)/5.000)+32.000
hectopascals = sensor.read_pressure()/100.0000
BMPhumidity = sensor.read_humidity()

bmpvalues="(null,'BMP-8200-Crawl',"+str(BMPtemperaturef)+","+str(BMPhumidity)+","+str(hectopascals)+",'"+datatime+"');"

finalSQLstring="INSERT INTO ResDataLog(ID,Location,Temperature, Humidity, Pressure, RecDate) VALUES " + dhtvalues +","+bmpvalues
# c.execute (finalSQLstring)
# conn.commit()

#Get Weather info from DarkSky

from forecastiopy import *

MyLatLong=[34.985928,-80.767389]
DarkSkyKey='6fab8f466aexxxxxxxxxxxxxafde'

fio=ForecastIO.ForecastIO(DarkSkyKey, latitude=MyLatLong[0], longitude=MyLatLong[1])
current = FIOCurrently.FIOCurrently(fio)
ambienttemp=current.temperature
ambienthumidity=current.humidity
ambientpressure=current.pressure

url="http://telemetry.xxxxxxxxxx/add_data.php?loc="+"BMP-8200-Crawl"+"&temp="+str(BMPtemperaturef)+"&hum="+str(BMPhumidity)+"&pr="+str(hectopascals)+"&atemp="+str(ambienttemp)+"&ahum="+str(ambienthumidity)+"&apress="+str(ambientpressure)
urllib2.urlopen(url)The code generates some type conversion warnings that seem to create email messages, but that doesn't seem to be the issue.latest?d=yIl2AUoC8zA latest?i=Z5K3C5zxmFE:KHlUAR2NodA:F7zBnMy latest?i=Z5K3C5zxmFE:KHlUAR2NodA:V_sGLiP latest?d=qj6IDK7rITs latest?i=Z5K3C5zxmFE:KHlUAR2NodA:gIN9vFwZ5K3C5zxmFE
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments