Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8082

Python • I2C in python script

$
0
0
Short version: How do I send an I2C command from a python script

Long version: I have a project in mind using an RPi and an SDR as part if an alarm system. Running on the RPi will be an app (rtl_433) that logs to syslog and a python script that reads the syslog (continuously) and if a match is found, sends a message to a hat via the I2C interface.

rtl_433 sample code for the latter is

Code:

 if "closed" in data:                if data["closed"] == 0:                    print(label + ' Battery empty!')
I want it to say

Code:

 if "closed" in data:                if data["closed"] == 0:                    send_I2C(1):
or something like that. I am not a python programmer. I'm a long time assembly language programmer and recent C/C++ programmer (Arduino), but not a python programmer.

This will also be my first real experience with an RPi. I'm fundamentally a Windows guy, but am pretty comfortable with Linux.

Any hints appreciated.

Statistics: Posted by alan-bc — Sat Aug 09, 2025 4:54 pm



Viewing all articles
Browse latest Browse all 8082

Trending Articles