I have after several months, finally got my RPI 3B+ running and have a sensor (SHT31-D) working on it. That's it after several months. Frustrated doesn't come close. But I got this far. I need help.
Here's my code:
Code: Select all
import smbus import time # Get I2C bus bus = smbus.SMBus(1) # SHT31 address, 0x44(68) bus.write_i2c_block_data(0x44, 0x2C, [0x06]) time.sleep(0.5) # SHT31 address, 0x44(68) # Read data back from 0x00(00), 6 bytes # Temp MSB, Temp LSB, Temp CRC, Humididty MSB, Humidity LSB, Humidity CRC data = bus.read_i2c_block_data(0x44, 0x00, 6) # Convert the data temp = data * 256 + data cTemp = -45 + (175 * temp / 65535.0) fTemp = -49 + (315 * temp / 65535.0) humidity = 100 * (data * 256 + data) / 65535.0 # Output data to screen print "Temperature in Celsius is : %.2f C" %cTemp print "Temperature in Fahrenheit is : %.2f F" %fTemp print "Relative Humidity is : %.2f %%RH" %humidity
These are the problems I'm trying to overcome:
1. Have the sensor continue providing data more than one time when I type: sudo python sht31.py
2. have the data saved (data logging)
3. Have that data sent to my MySQL website
I have created the database on my website and have the username, password and info for the database. I built my website so that's the easy part for me. This has take months to get this little amount of info. All help would be greatly appreciated.