- Removed obsolete script `script_SANSDEMARRAGE.sh`. - Added new `Camera.py` and `Connexion.py` files for camera handling and socket communication. - Implemented `First_Try.py` for initial camera preview testing. - Created `Humidity.py` for humidity sensor data acquisition. - Developed `Send_data_stocked.py` for managing and sending stored data. - Introduced `Time_Lapse_Connection.py` and `Time_Lapse_NoConnection.py` for connected and offline modes. - Added `get_from_server.py` for retrieving camera status from the server. - Updated `sync_offline_data.py` for synchronizing offline data. - Created `timelapse.service` for managing the timelapse service on Raspberry Pi. - Established package structure with `__init__.py` and `api_client.py` for API interactions. - Enhanced `capture.py` for managing image captures and data storage. - Configured `config.py` for centralized configuration management. - Developed `sensors.py` for handling environmental sensors and camera operations. - Implemented `timelapse_offline.py` and `timelapse_online.py` for capturing images in offline and online modes.
53 lines
1.2 KiB
Python
53 lines
1.2 KiB
Python
import smbus2
|
|
import RPi.GPIO as GPIO
|
|
import time
|
|
|
|
"""
|
|
>>> bus = smbus2.SMBus(1)
|
|
>>> ans = bus.write_byte(0x44, 0xFD)
|
|
>>> smbus2.i2c_msg.read(0x44,6)
|
|
i2c_msg(68,1,b'\x00\x00\x00\x00\x00\x00')
|
|
>>> taa=smbus2.i2c_msg.read(0x44,6)
|
|
>>> bus.i2c_rdwr(taa)
|
|
>>> data = list(taa)
|
|
>>> print(data)
|
|
[112, 174, 89, 60, 78, 165]
|
|
"""
|
|
|
|
def main():
|
|
i2cbus = smbus2.SMBus(1)
|
|
addressSHT40 = 0x44
|
|
meas_sht40(i2cbus, 0x44)
|
|
|
|
|
|
|
|
def meas_sht40(bus, addressSHT40):
|
|
CMD_measure = 0xFD #cmd de mesure
|
|
#bus.write_byte(0x00, 0x06)
|
|
#time.sleep(1.1)
|
|
bus.write_byte(0x44, 0x39)
|
|
time.sleep(1.1)
|
|
while 1:
|
|
time.sleep(1.1)
|
|
#data = bus.read_i2c_block_data(0x44, 0, 6) #Lecture des 6 octets
|
|
data = []
|
|
|
|
bus.write_byte(0x44, 0xFD)
|
|
byte = bus.read_block_data(0x44,3)
|
|
data.append(byte)
|
|
print(f"Octet {i}: {byte:#04x}")
|
|
time.sleep(1.15)
|
|
|
|
#print(data)
|
|
|
|
"""
|
|
temp_raw = (data[0] << 8) + data[1]
|
|
humidity_raw = (data[3] <<8) + data[4]
|
|
"""
|
|
temperature = 10000*(data/65535.0)
|
|
#temperature = -45 + 175*data/65535
|
|
#print(temperature)
|
|
|
|
|
|
if __name__=="__main__":
|
|
main() |