I am trying to send sensor reading from Arduino Uno to raspberry pi and I want to save this incoming sensor reading to SQLite which I downloaded to Raspberry pi. I used lm35 sensor on Arduino Uno and i used the i2c way for communication between Arduino Raspberry pi. I managed to transmit the data from the sensor to the arduino uno and from there to the Raspberry Pi. Then I showed this data in the interface I created with the guizero library on Raspberry Pi. With a button I added, I enabled the temperature data to be updated when the button is pressed. But my shortcoming here was missing the data in between and not being able to see all the data. For this, I decided to download SQLite and save the data here, but no matter how much I searched, I could not be successful. I tried many sample codes but could not adapt any of them against this application. I leave the code used below. I know that I make mistakes from time to time, but no matter how hard I searched, I couldn't find the right one. Is the SQLite I'm using a wrong choice? Any chance of what I'm doing getting fixed and still working? I don't know how to write the code in the marked field, I can't find it either. I'm pretty new to this stuff. Please help, thanks. (note:The marked place (!!!???) is wrong, but I can't find the correct one.)
Python:
from guizero import App, Text, PushButton
import smbus
import smbus as SMBus
import sqlite3
import time
import datetime
bus=smbus.SMBus(1)
address= 0x2a
app=App(title="Arduino'dan veri alma")
app.bg="white"
app.fg="black"
#dattabse bağla
conn=sqlite3.connect('deneme1.db')
c=conn.cursor()
#tablo oluşturma
def create_table():
c.execute('CREATE TABLE IF NOT EXISTS tablo(unix REAL, tarih REAL, sicaklik REAL)')
#verilerin tabloya yazılması
def dynamic_data_entry():
unix=int(time.time())
tarih=str(datetime.datetime.fromtimestamp(unix).strftime('%Y,-%m-%d %H:%M:%S'))
sicaklik=address.read_retry(3,5) (!!!???)
c.execute("INSERT INFO tablo (unix, tarih, nem, sicaklik) VALUES (?, ?, ?, ?)",
(unix, tarih, nem, sicaklik))
conn.commit()
data = bus.read_byte(address)
def gorev1(n):
for i in range(0,int(n)):
dynamic_data_entry()
time.sleep(1)
create_table()
x=input('kaç saniyelik veri kaydedilsin?')
y=input('kaç sn öncesini görmek istersin?')
gorev1(x)
c.close()
conn.close()