1

The goal is to design thermostat system via stacking Raspberry pi HATs:

  1. Raspberry pi (3B+ or 4)
  2. 4-channel relay
  3. TFT Touch Display

It would be preferable that community experience point out any obstacles before I purchase the relay-HAT and steer away from a poor design decision. Below is a preliminary analysis, however, I would like the community's experience to review and pick it apart for any obstacles.

A touch-display hat was purchased from Amazon.com: based on the pinout data from the waveshare website the display uses:

DISPLAY: 
=======
PIN GPIO 
11  17   TP_IRQ Touch Panel interrupt, low level while the Touch Panel detects touching
18  24   LCD_RS     Instruction/Data Register selection
19  10   LCD_SI / TP_SI     SPI data input of LCD/Touch Panel
21   9   TP_SO  SPI data output of Touch Panel
22  25   RST    Reset
23  11   LCD_SCK / TP_SCK   SPI clock of LCD/Touch Panel
24   8   LCD_CS     LCD chip selection, low active
26   7   TP_CS  Touch Panel chip selection, low active

The DockerPi 4 Channel Relay display indicates I2C relay control. Given that the display uses the GPIO & PINS listed above.

I2C pinout:

  • I2C pins in BCM mode are: 2, 3
  • I2C pins in WiringPi are: 8, 9

QUESTIONS

  1. Can the two hats stack and perform their respective functions?
  2. Or is there a feature that I have not considered that may be an obstacle?

BONUS ROUND

If you have had success stacking multiple HATs, please indicate which HATs and any lessons-learned in your reply.

UPDATE: Fail-safe \ failure-mode

Because the application is HVAC (heating , air-conditioning), it is important to understand failsafe modes and ensure that relays are not engaged in a failure mode

gatorback
  • 637
  • 1
  • 5
  • 16
  • Just a quick and dirty reply. Warning: no guarantee no nothing won't meltdown or blow up. I skimmed the datasheets found there is 70% chance OK, for the following reasons: (1) Touch display is SPI, and relay is I2C, (2) I2C relay has well documented instructions to change addresses, and further more, if you use Ri4B, you can choose one of the multiple (max 5, stable 3) I2C channels to avoid any GPIO pin conflicts. – tlfong01 Jan 31 '20 at 03:36
  • References: (1) I2C Four Channel Relay (with demo python program) - DockerPi https://wiki.52pi.com/index.php/DockerPi_4_Channel_Relay_SKU:_EP-0099#Configuring_I2C.28Raspberry_Pi.29 (2) Rpi SPI 3.5" 480x320 Touch Screen TFT LCD - WaveShare https://www.waveshare.com/3.5inch-rpi-lcd-a.htm – tlfong01 Jan 31 '20 at 03:38
  • 1
    @tlfong01 Thanks for responding. Please consider moving your responses to an answer and sharing any lesson-learned. – gatorback Jan 31 '20 at 03:45
  • Thank you for nice words and suggestion. So I will be writing up an answer. Cheers. – tlfong01 Jan 31 '20 at 03:52
  • I know your question is how to stack hats. I can convenience why NOT to use hats, but it depends if your project is Micky Mouse or NASA. Perhaps you can give a rough idea of you long term project spec, say IoT app oriented, using 50+ sensors/actuators motors (DC/BLDC/unipolar/bipolar/microstepping stepping) relay/solenoid 10+ USB/RS485/RS232 standard/TTL adapters, SPI (5+ mux/nonmux channels), I2C (5+ mux/nomux channels), PAN/LAN/WAN BlueTooth/2/5G Wifi/ISM4xx/9yyMHz network, ... I do have loads of painful failing experience of stacking/ HATS (Rpi26/40 pin, PCIe bus, ..) Cheers. – tlfong01 Jan 31 '20 at 04:45
  • @tlfong01 My goal is to build several thermostats: a thermal sensor is not discussed and is obviously necessary. Relays are used to signal (24V) for cooling, heat, and fan in a heatpump application. It is not NASA, however, the thermostat needs to be reliable, because it will be deployed 1000 miles away. In English, we say lesson-learned: these are experiences shared with newcomers so that they can avoid mistakes. I hope you will share any relevant rPi HAT facts or experience that can help the community to avoid mistakes – gatorback Jan 31 '20 at 04:53
  • thank you for your explanation on why you would like to use HATs. I very much agree that HATs are very appropriate for newbies. An example is Rpi's SensHat (which I already fried two!) which I think is very good (but a bit expensive for poor hobbyists like me) for community, ... PS - I have appended my failure experiences in the reference section of my answer, more about that later. – tlfong01 Jan 31 '20 at 05:14

1 Answers1

2

Answer

Remark: Just a quick and dirty answer. Perhaps more details later.

Warning: no guarantee no nothing won't meltdown or blow up.


I skimmed the datasheets and quickly concluded that there is 80% chance OK, for the following reasons:

(1) Touch display is SPI, and relay is I2C,

(2) I2C relay has well documented instructions to change addresses, and further more, if you use Ri4B, you can choose one of the multiple (max 5, stable 3) I2C channels to avoid any GPIO pin conflicts.


References:

(1) Rpi I2C Four Channel Relay (with demo python program) - DockerPi

(2) Docker Pi 4 Channel Relay Module - Seeed Studio

(3) Rpi SPI 3.5" 480x320 Touch Screen TFT LCD - WaveShare

(4) DockerPi GitHub

(5) 52Pi Rpi Modules Catalog

(6) How to use a stackable Rpi relay HAT to control 220V AC mains power?

(7) How to tap/tee/fork the Rpi GPIO pins covered/blocked by a HAT/pHAT/bonnet?

(8) Choosing between relays of 3V/5V/12V, High/Low logical level trigger, Rpi compatible/incompatible (and how to modify/get around Rpi incompatible relay to make it compatible), Cheap/Expensive, Risky/Reliable/Newbie proof, Hobbyist/Industrial/professional grade, Direct/Optically isolated, ...

(9) Smart home/building/city learning/research project notes/references 1/2 - tlfong01 2018/2019

(10) Smart home/building/city learning/research project notes/references 2/2 - tlfong01 2018/2019


End of answer

tlfong01
  • 4,384
  • 3
  • 9
  • 23
  • 1
    Thank you for adding a list of reference, which documents your insights and experience. The list is an excellent asset for the community to learn from. I am a little envious that it must be very fast to buy electronics from your neighbors to the north. It takes weeks for it to arrive in the USA – gatorback Jan 31 '20 at 05:11
  • Ah, I think you can buy from AdaFruit and SparkFun. Their open hardware boards are are perhaps more expensive, but I think for serious projects it is worth it. For hobbyists it is OK to buy the not so good quality controlled stuff from Amazon, AliExpress and so on. – tlfong01 Jan 31 '20 at 08:21