Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Relay Hat Question - I2C
#6
For sure.  This is from the writeup I found for the specific HAT system I have. 

http://wiki.52pi.com/index.php?title=Doc...oldid=5501


I can do a direct control from a terminal with this

Ch1 relay ON
<code>i2cset -y 1 0x10 0x01 0xFF </code>
CH1 relay OFF
<code>i2cset -y 1 0x10 0x01 0x00</code>

Or by running my .py file
My ch1on.py looks like this:
<code>
import time as t
import smbus
import sys

DEVICE_BUS = 1
DEVICE_ADDR = 0x10
bus = smbus.SMBus(DEVICE_BUS)

bus.write_byte_data(DEVICE_ADDR, 1, 0xFF)
sys.exit()
</code>

My ch1off.py file looks like this:

<code>
import time as t
import smbus
import sys

DEVICE_BUS = 1
DEVICE_ADDR = 0x10
bus = smbus.SMBus(DEVICE_BUS)

bus.write_byte_data(DEVICE_ADDR, 1, 0x00)
sys.exit()
</code>


My original design is using this style in a cron job as an alarm and it has worked just fine. (except I have alarm1, alarm2, etc)

But my next project is a 16 channel sprinkler system and I wanted a user interface for it as its for my neighbor and he needs to be able to modify the times himself.  This seemed like a great solution as long as I can get the program to actuate my relays
Reply


Messages In This Thread
Relay Hat Question - I2C - by mg360 - 2016 Sep 08, 11:50 PM
RE: Relay Hat Question - I2C - by dan - 2016 Sep 09, 08:54 PM
RE: Relay Hat Question - I2C - by mg360 - 2016 Sep 09, 09:51 PM
RE: Relay Hat Question - I2C - by schmooot - 2019 Oct 10, 07:37 PM
RE: Relay Hat Question - I2C - by dan - 2019 Oct 11, 01:33 PM
RE: Relay Hat Question - I2C - by schmooot - 2019 Oct 11, 03:29 PM
RE: Relay Hat Question - I2C - by dan - 2019 Oct 11, 07:30 PM
RE: Relay Hat Question - I2C - by schmooot - 2019 Oct 15, 05:19 PM
RE: Relay Hat Question - I2C - by dan - 2019 Oct 15, 08:36 PM
RE: Relay Hat Question - I2C - by schmooot - 2019 Oct 15, 08:51 PM
RE: Relay Hat Question - I2C - by dan - 2019 Oct 16, 02:18 PM
RE: Relay Hat Question - I2C - by dan - 2019 Oct 20, 02:38 PM
RE: Relay Hat Question - I2C - by Andre - 2021 Feb 16, 03:29 AM
RE: Relay Hat Question - I2C - by dan - 2021 Feb 16, 04:27 PM

Forum Jump:


Users browsing this thread: 5 Guest(s)