
Raspberry Pi 5 Climate Monitor with TCA9548A - Proteus Simulation

Hello friends, I hope you all are doing great. Today, I am going to share the Raspberry Pi 5 Climate Monitor with TCA9548A - Proteus Simulation, the ninety-sixth project of our IoT Projects series. If you have searched for how to use several I2C sensors with the same address, a TCA9548A with a Raspberry Pi, a multi-room temperature and humidity monitor, or an HT16K33 14-segment display in Python, here is a complete one in a Proteus simulation. Sooner or later every I2C project hits the same wall: you want four sensors, and all four have the same address burned into the chip.
This project watches four rooms, the living room, the bedroom, the bathroom and the freezer, each with an AHT20 temperature and humidity sensor at the fixed address 0x38. A TCA9548A I2C multiplexer sits between the Raspberry Pi 5 and the sensors and connects one of them at a time. The Pi reads every room every two seconds, checks each reading's CRC, works out the dew point and watches for trouble: the bathroom so humid that mould can grow, the freezer warming up, a room too hot or too cold. An HT16K33 14-segment display shows each room in turn and blinks on an alarm until someone acknowledges it from the dashboard. In this tutorial, we will go through the circuit, why I2C addresses clash and how a multiplexer solves it, the AHT20's measurement and its CRC, the dew point, the HT16K33's segments, and the code. Then we take a shower in the bathroom and leave the freezer door open in the simulation. At the end, you can download the project with the program and every library file.
NOTICE: Our team has put a lot of effort into this project: the circuit, the code and every part in the simulation are our own work, and you get them all free. Your feedback is the fuel that keeps us going, so please tell us what you think in the comments below. And if our free projects help you, you can buy us a coffee. So, let's get started with the Raspberry Pi 5 climate monitor with TCA9548A in Proteus simulation:
What Does This Climate Monitor Do?
- Four rooms, one address: four AHT20 sensors at 0x38, each on its own TCA9548A channel.
- Trustworthy numbers: every reading's CRC-8 is checked; a sensor that does not answer is reported LOST.
- Dew point: the temperature at which water would condense, for every room.
- Alarms with hysteresis: living room 18 - 27 C, bedroom 16 - 24 C, bathroom over 70 % RH, freezer above -12 C.
- A display that nags: the HT16K33 shows the rooms in turn and blinks until the alarm is acknowledged.
- A dashboard: every room with its dew point and state, NEXT and ACK, and the data as JSON.
It is a great project for learning how I2C really works: addresses, a multiplexer, a sensor's raw bytes and a display controller's RAM, all from Python. In the simulation, each AHT20's pop-up shows the air it measures and every byte it sends, and the multiplexer's pop-up counts the transactions on every channel.
Components Used in the Proteus Simulation
All the parts come from our Proteus libraries, each with its own tutorial. The project zip at the end includes every LIB and DLL file and our TEP Pi runtime.
| Part | Proteus device | Library post | Connection |
|---|---|---|---|
| Raspberry Pi 5 | RASPBERRY PI 5 | Raspberry Pi 5 Library for Proteus | PI1, climate.py, Ethernet 192.168.1.51:8000 |
| TCA9548A I2C multiplexer | MUXTCA9548ATEP | TCA9548A I2C Multiplexer Library for Proteus | U1 at 0x70 on I2C1 (GPIO2 / GPIO3) |
| AHT20 sensors (4) | AHT20ADVTEP | AHT20 Sensor Library for Proteus | U2 - U5 at 0x38, on channels 0 - 3 |
| HT16K33 14-segment display | HT16K33ALPHATEP | HT16K33 Alphanumeric Display Library for Proteus | U6 at 0x71 on the main bus |
| Laptop WiFi Monitor | LAPTOP WIFI MONITOR | Laptop WiFi Monitor | PC1 |
| Mobile WiFi Monitor | MOBILE WIFI MONITOR | Mobile WiFi Monitor | MOB1 |
Proteus Simulation of the Climate Monitor: the Circuit
| Signal | Pi 5 pin | Goes to |
|---|---|---|
| SDA / SCL | GPIO2 (3) / GPIO3 (5) | the TCA9548A's host side and the HT16K33 (the main bus) |
| SD0 / SC0 | - | channel 0: the LIVING room's AHT20 |
| SD1 / SC1 | - | channel 1: the BEDROOM's AHT20 |
| SD2 / SC2 | - | channel 2: the BATHROOM's AHT20 |
| SD3 / SC3 | - | channel 3: the FREEZER's AHT20 |
| 3V3 | pin 1 | every board's supply |
The Pi's I2C bus goes to two places: the TCA9548A's host pins and the HT16K33. Behind the multiplexer, each AHT20 has its own pair of wires, SDn and SCn, and sees nothing of the others. The HT16K33's address is moved to 0x71 with its A0 jumper, because 0x70 is the multiplexer's. Channels 4 to 7 are free for four more rooms.
How the Climate Monitor Works
Why Four AHT20s Cannot Share a Bus
Every I2C transfer starts with an address. All the devices on the bus listen, and the one whose address matches answers. Many chips let you change a bit or two of their address with a pin; the AHT20 does not: it is always 0x38. Put four on one bus and all four would answer at the same moment, each pulling SDA low for its own bits: the Pi would read a mixture of them, and the CRC would fail every time.
The TCA9548A Multiplexer
The TCA9548A is an I2C slave itself, at 0x70 - 0x77, with eight downstream channels. It has a single register: the Pi writes one byte, and every bit that is 1 connects that channel's SDn / SCn to the host bus. Writing 0x01 connects channel 0, 0x04 channel 2, 0x00 none. The switch is a set of transistors, so the signals pass both ways and the devices behind it talk to the Pi directly. The program connects one room, reads it, and switches the channel off again before the next one.
Reading an AHT20
The AHT20 measures on command. The Pi writes AC 33 00, waits 80 ms, and reads seven bytes: a status byte (bit 7 busy, bit 3 calibrated), 20 bits of humidity, 20 bits of temperature, and a CRC-8 over the first six bytes with the polynomial 0x31. Relative humidity = raw / 2^20 x 100 %, temperature = raw / 2^20 x 200 - 50 C. A reading with a wrong CRC is thrown away; a sensor that does not acknowledge its address is reported LOST.
The Dew Point and the Alarms
Relative humidity alone does not say whether walls get wet. The dew point does: the temperature at which the water in the air would condense. The Magnus formula gives it from the temperature and the humidity. A bathroom at 30 C and 90 % has a dew point of 28 C: any surface colder than that, a window or a cold wall, gets wet, and that is how mould starts. Each room has its own alarm; to avoid flickering at the edge, an alarm clears only 1 C or 3 % inside its limit.
The HT16K33 Display
The HT16K33 drives up to 16 x 8 LEDs from its own RAM. On this backpack each character is two RAM bytes: bit 0 is segment A, through to bit 13 for N and bit 14 for the decimal point. The Pi starts the oscillator (21h), switches the display on (81h) and writes all four characters in one transfer from address 00h. 83h makes the whole display blink at 2 Hz, without the Pi doing anything else: that is the alarm.
The Python Code Explained
The program is climate.py; it needs only lgpio, which is in our TEP Pi runtime. One handle serves all four sensors, because the multiplexer decides which of them hears it, and one byte switches the channel:
aht = lgpio.i2c_open(1, AHT) # (one handle: the multiplexer decides which AHT20 hears it)
lgpio.i2c_write_byte(mux, (1 << ch) if ch is not None else 0)
A measurement: the command, 80 ms, seven bytes, the CRC check, then the two 20-bit values:
lgpio.i2c_write_device(aht, [0xAC, 0x33, 0x00]) # trigger a measurement
n, d = lgpio.i2c_read_device(aht, 7)
if crc8(d[:6]) != d[6]:
c = ((c << 1) ^ 0x31) & 0xFF if c & 0x80 else (c << 1) & 0xFF
hum = ((d[1] << 12) | (d[2] << 4) | (d[3] >> 4)) / 1048576.0 * 100.0
temp = (((d[3] & 0x0F) << 16) | (d[4] << 8) | d[5]) / 1048576.0 * 200.0 - 50.0
The dew point by Magnus, and the hysteresis of the alarms:
g = math.log(max(rh, 0.1) / 100.0) + 17.62 * t / (243.12 + t)
band = 1.0 if what == 'temp' else 3.0 # (the hysteresis: an alarm clears only that far inside the limit)
The display: each character's 14-segment pattern with the decimal point as bit 14, and the blinking switched by one command:
v = pattern(c) | (0x4000 if i == dot else 0)
lgpio.i2c_write_byte(disp, 0x83 if blink else 0x81)
The dashboard's links are Refresh, NEXT and ACK; /data gives every room as JSON.
How to Run the Proteus Simulation
- Download the project zip below and install the library files and the TEPPi folder (the steps are under the download button).
- Open Pi-5-Multi-Room-Climate.pdsprj from the Proteus Simulation folder. Keep climate.py and the DLL files next to it.
- Press Play. The display shows the rooms one after the other.
- Click an AHT20 for its pop-up and change the air: HUMID in the bathroom, +5 twice in the freezer.
- Open the Laptop WiFi Monitor (press Go) for the rooms and the alarms, and ACK to stop the blinking.
Simulation Results: Four Rooms in Proteus
We pressed Play and let the Pi read the four rooms, then changed the air with the AHT20 pop-ups: a shower in the bathroom, the freezer door left open, the alarms acknowledged on the laptop, and both rooms back to normal. Each AHT20's pop-up shows the air it measures and the bytes it sent; the multiplexer's pop-up counts the transactions on each channel. The times are the program's clock; the whole run took 33.0 simulated seconds.
Four Rooms at One Address
Within 0.3 s all four rooms had answered: LIVING 23.0 C and 45 %, BEDROOM 20.0 C and 50 %, BATHROOM 24.0 C and 60 %, FREEZER -18.0 C and 70 %. Four chips at the same address 0x38, each read on its own channel and each reading with a good CRC. The living room's pop-up shows the exchange byte by byte: the status 0x18 (ready, calibrated), the humidity 0x73302 = 45.00 %, the temperature 0x5D6D5 = 22.99 C and the CRC, 0x05, that matches the first six bytes. The display ran through the rooms, LIVE, 23.0C, BED, 20.0C and so on. Between two reads the multiplexer has no channel connected, which is what its pop-up caught; its counters show the work done on channels 0 to 3.
A Shower in the Bathroom
We set the bathroom's AHT20 to HUMID, 30 C and 90 %. At the next read, 9.6 s, the Pi reported ALARM BATHROOM: 90 % RH (over 70 % RH: mould risk). The dew point jumped to 28.2 C: a window colder than that is wet. The display switched to the alarm room only, BATH and RH90, and started blinking at 2 Hz: the HT16K33 pop-up shows blink 2 Hz.
The Freezer Door Left Open
Then we raised the freezer's temperature by 5 C twice, to -8 C, as an open door would. At 14.3 s: ALARM FREEZER: -8.0 C (warmer than -12 C). The dashboard now showed 2 ALARMS - not acknowledged, and the display blinked through both alarm rooms.
Acknowledged
ACK on the laptop at 18.7 s: the alarms stay on the dashboard until the rooms recover, but the display stops blinking and goes back to all four rooms in turn. That is the usual way of an alarm panel: the person has seen it, the panel stops shouting, the condition is still shown.
Back to Normal
We set the bathroom to DRY (25 C, 15 %) and the freezer back to -18 C. At 23.5 s BATHROOM OK, at 25.9 s FREEZER OK. By the end, the multiplexer had carried 186 transactions without a lost sensor or a CRC error. The phone shows the same dashboard, and the Pi's terminal holds every event and a line with all four rooms every ten seconds.
One multiplexer, one byte a room, and four sensors with the same address behaved as four separate buses: every reading arrived with a good CRC, both alarms came and went at their limits, and the display stopped blinking the moment it was acknowledged.
Download the Project Files
Click the button below to download Raspberry-Pi-5-Climate-Monitor-TCA9548A-Proteus-Simulation-v1.0.zip (about 13.8 MB, without the source code of the models):
Raspberry Pi 5 Climate Monitor with TCA9548A - Proteus Simulation V1.0- Proteus Simulation: Pi-5-Multi-Room-Climate.pdsprj, climate.py and copies of the models.
- Python Code: climate.py, the program.
- Proteus Library Files: the LIB files of every part.
- Proteus Model Files: the DLL models and the TEPPi folder (Python and our Pi runtime).
- README.txt: the installation steps, the properties, the test results and the links to every library post.
No Proteus yet? Read How to Download and Install Proteus 7 and 8. New to libraries? Follow How to Install a New Library in Proteus.
How to Install the Project Files
- Close Proteus and extract the whole zip file, for example to your Desktop.
- Copy the files from Proteus Library Files into the LIBRARY folder of Proteus.
- Copy everything in Proteus Model Files, the DLL files and the TEPPi folder, into the MODELS folder.
- Start Proteus and open the project from the Proteus Simulation folder.
Changing the Code
climate.py is plain Python: edit it next to the project and press Play again. The rooms, their limits and the period are near the top. On a real Raspberry Pi 5, enable I2C with raspi-config and install python3-lgpio.
Ideas to Extend the Project
- Use the four free channels for four more rooms, or a second sensor type with its own fixed address.
- Log every room to a CSV file and draw a day of temperatures on the dashboard.
- Switch a bathroom fan with a relay when the humidity rises.
- Send the freezer alarm as a message to a phone.
- Add a buzzer that sounds until the alarm is acknowledged.
- Chain a second TCA9548A at 0x71 for sixteen rooms.
From Simulation to Real Hardware
- Pull-ups: the TCA9548A board and every AHT20 board carry their own pull-up resistors; with many boards in parallel, remove some.
- Cable length: I2C is made for short distances; for rooms far apart, use an I2C bus extender or one small board a room.
- The freezer: the AHT20 works down to -40 C, but keep condensation away from the sensor when the door opens.
- The display address: close the A0 jumper on the HT16K33 backpack for 0x71.
- Self-heating: measuring every 2 s barely warms the AHT20; much faster readings would.
Troubleshooting
- All four rooms read the same: the multiplexer is not switching; check its SDA / SCL and its address.
- A room LOST: its SDn / SCn pair or its supply, and the channel number in the program.
- The display is dark: its address must be 0x71 here; 21h starts the oscillator, 81h switches it on.
- CRC errors: long or noisy wires; slow the bus down.
Limitations of the Simulation
- The TCA9548A, the AHT20 and the HT16K33 are our libraries' models, built from their datasheets, not every detail of real parts.
- The air in each room is what its AHT20 pop-up sets; a real room changes slowly, the pop-up's presets change it at once.
- The bus has no length or capacitance in the simulation; a real bus with four sensors and long wires needs care.
- Raspberry Pi is a trademark of Raspberry Pi Ltd; this project is not made or endorsed by Raspberry Pi Ltd or by Labcenter.
So, that was all about the Raspberry Pi 5 Climate Monitor with TCA9548A - Proteus Simulation. I hope it helps you understand why I2C addresses clash, how a multiplexer gives every sensor its own bus, how to read an AHT20 byte by byte and trust its numbers, and how a small display can nag until someone looks, all tested in a simulation before you buy four sensors. More projects with the ESP32 and the Raspberry Pi 5 are coming. If you have any questions, ask in the comments and I will help you out. Till the next tutorial, take care and have fun!






















Comments
0