Electronics

PLEN

A Sonoff NSPanel as a wall panel for my boiler controller

Instead of building a wall screen from scratch, I took a ready-made Sonoff NSPanel switch and replaced all of its software. Two days of work, a few traps, and the question of whether it was the right choice.

Przednia płytka Sonoff NSPanel w obudowie: osłona układu ESP32, złącze do wgrywania programu, pola zasilania 5 V i puste miejsce na czujnik światła

Przednia płytka NSPanelu ze złączem do wgrywania programu.

My boiler controller has a browser app, but not everyone at home wants to reach for a phone just to check the temperature. It needed a screen on the wall. There was a Sonoff NSPanel, US version, sitting in a drawer: a wall switch with a vertical 3.5-inch touchscreen, an ESP32 chip inside, two buttons and two 230 V relays. Ready-made screen, ready-made case, about 250 zł. I asked the agent whether we could turn it into a thermostat panel.

The agent agreed, with two caveats. The factory software only talks to the manufacturer’s cloud, so we would have to flash our own. And the NSPanel is no good for a product to sell, because it is someone else’s case with a 230 V power supply, which can’t be certified as our own. For the house, it is perfectly fine.

The brain by the boiler, eyes and fingers in the room

Before the panel even existed, we settled the division of roles. Decisions are made by the controller next to the boiler, because it has a permanent power supply and sees the boiler. Every module in a room, sensor or screen, is just a client of its API. The panel calculates nothing about heating. It shows data and sends requests. A screen on the wall can be switched off, restarted or broken by an update, and the boiler must not depend on it. Thanks to that split, the panel could be written in two days.

Mock-ups that became screens

I wanted to draw the screens in a design program first. The agent suggested something else: seven screens as a single HTML page with coordinates in display pixels (320 × 480), turned into 1:1 images by a browser. The same files later became the backgrounds in the display, and a script pulled the field positions out of them for the firmware.

Teardown

I took the panel apart and photographed both boards. The photos showed a header for flashing firmware over a cable, where the wires just push in without soldering. There is also a thermistor, the panel’s thermometer, placed on a tongue of the board cut off by slots, so the heat from the electronics doesn’t skew the reading. The spot for a light sensor turned out to be empty. So the “brightness follows room light” plan died right there in the photo.

Before we flashed anything, the agent read out a full copy of the original firmware and verified it byte by byte. Going back to the old software was always possible.

Version 0.1: the way back comes first

I set one condition: the first version had to allow updates over the network, because then I could unplug the cables — OTA. So version 0.1 didn’t draw anything yet. It opened the relays from the very first instruction after boot, connected to Wi-Fi, showed its status and accepted new versions. A new version has to connect to Wi-Fi within 120 seconds and survive for 10 seconds. If it doesn’t, the chip goes back to the previous one on its own.

After flashing over the cable, the firmware “didn’t start”. The cause was trivial: the IO0 wire was still shorted to ground, and in that state the chip goes back into flashing mode after every boot. The next morning, the Wi-Fi update from 0.1.0 to 0.1.1 went through and confirmed itself.

A display that is a separate computer

The screen in the NSPanel is a Nextion. It has its own processor and closed firmware, and the ESP32 doesn’t draw pixels on it; it sends text commands over a single wire. We went with a “blank sheet” approach: the screen file holds only backgrounds, a flame icon and four fonts, and every label, number and touch zone is handled by the ESP32 firmware. The Nextion editor only runs on Windows, so it is needed only when backgrounds or fonts change. Changing the layout of the labels is an ordinary Wi-Fi update.

There were a few traps along the way:

  • Saving the wrong window. The agent reported that the screen project was saved, while my screenshot showed 0 in the image list. Ctrl+S had gone to the font generator window. The agent admitted plainly that it hadn’t checked. Since then the instructions say: save with the button and check that it has turned grey — the agent was working the actual program on Windows 11.
  • White screen. After a restart the screen glowed white. The panel was powered only from the converter’s 3.3 V pin, which isn’t enough for an ESP32 with Wi-Fi and a display at the same time. Once assembled and powered from 230 V, the picture was fine.
  • Upside down. I assembled the panel and the picture was upside down. There is no rotate command on this model; rotation has to be set in the screen project.
  • No gestures. Scrolling the room list with a finger didn’t work. Instead of fixing it blind, the agent added a touch log and asked me for one slow swipe. The display only sends “pressed” and “released”, both with the same point. Scrolling moved to “Up” and “Down” buttons.

The screen file is 788 kB and loads into the display over Wi-Fi in 73 seconds, without opening the case.

Two buttons, four functions

A short press switches tabs. A long press toggles relay 1 or 2, with a beep from the buzzer. Along the way the thermostat panel became a light switch too, with no extra hardware, because the relays were inside from the start. After boot they are always open.

First start with a QR code

A new panel doesn’t know the home Wi-Fi, so it opens its own network with a random password shown on the screen, along with a QR code. After scanning it, the phone connects without typing the password, and the setup page opens by itself, like the login window on hotel Wi-Fi. The network has a password for a specific reason: over an open network the home Wi-Fi password would travel in plain text. I thought this was good enough that the controller should get the same thing.

One thing remained unexplained. In version 0.6.0 the setup page wouldn’t open on the phone, even though the panel’s network worked. After changes in the next two versions it started working.

The panel doesn’t carry the keys to the whole system

When pairing, you enter the controller’s address and the controller’s admin password on the panel’s page. The panel logs in with it only once, creates its own account on the controller with a random password and logs straight out. A device on the wall that anyone can take down doesn’t store the admin password. After that it reads the state every 5 seconds and draws real data: the house temperature, rooms, boiler and weather.

Updates work the same way as in the controller and the room sensor. Once a day the panel checks the public releases repository, downloads only a newer version, and checks the checksum and the digital signature. The first update over the internet, from 0.7.9 to 0.8.0, went through straight away. Automatic installation is off by default.

The first action from the panel

On 8 November I noticed that the “Hot water” button on the screen did nothing. I suggested a screen with the boost temperature and a confirmation; the agent added an end time. The first attempt ended with the message “Controller does not support boost”, and that was expected, because the boiler was still running the old controller firmware. After updating it, the boost passed a test on the live boiler: the boiler confirmed a setpoint of 54 °C. Along the way we agreed on a rule: the same function lives in the controller for the app, the panel and Home Assistant, so they never calculate it differently.

Changing the temperature from the panel, plus and minus, isn’t there yet. It is waiting for my decision, because such a change goes straight to the boiler.

Was it the right choice?

Three days after starting, I came across a board with a screen and an ESP32-P4 chip for about 204 zł and wrote to the agent that the NSPanel is more expensive and probably limits us more. I know its limits well by now: no gestures, no light sensor, fonts baked into the screen file, an editor that only runs on Windows. The largest font has only basic characters, so a temperature written in the biggest digits is missing its degree sign.

The price comparison is incomplete, though. The NSPanel’s price includes a wall case, a 230 V power supply and relays, and a bare board with a screen doesn’t. I haven’t decided to switch hardware. For now the panel sits on my desk as a development board, and mounting it on the wall is still ahead of me.

Related posts

Comments

No comments yet

Leave a comment

Your email address will not be published. Comments appear after approval.