# FujitsuAC | faircon

Fujitsu AC Wifi controller.

This library reverse-engineers parts of the communication used by Fujitsu air conditioners, including those using the FGLair® mobile app.

FGLair is a registered trademark of Fujitsu General Limited. This project is not affiliated with or endorsed by Fujitsu. 
FGLair® app is not required when using this integration - **everything runs local here**.

This library can be used to replace these dongles:
* UTY-TFSXW1
* Z series
  * UTY-TFSXZ1 (confirmed. For: Europe)
  * UTY-TFSXZ2 (not confirmed yet. For: North America, Australia, New Zealand, Thailand, India, Singapore)
  * UTY-TFSXZ4 (not confirmed yet. For: China)
* F series
  * UTY-TFSXF1 (not confirmed yet. For: North America)
  * UTY-TFSXF2 (not confirmed yet. For: Europe)
  * UTY-TFSXF3 (confirmed. For: Oceania)
* H Series:
  * UTY-TFSXH4 (not confirmed yet. For: USA, Canada (sold as direct replacement for FGLair UTY-TFSXF1)
  * UTY-TFSXH3 (not confirmed yet. For: every other regions)

Tested aircons list: https://github.com/Benas09/FujitsuAC/discussions/24

# Support

<p>
  If you find this project useful, you can support its development here.<br/>
 
  <a href="https://donate.stripe.com/8x23cvdbXdht57Zfym1sQ05">
    <img src="https://img.shields.io/badge/Support%20Project-Stripe-635BFF?style=for-the-badge&logo=stripe&logoColor=white">
  </a>
</p>

<p>
  Or you can purchase <strong>ready-to-use</strong> dongle.<br/>

  <a href="https://buy.stripe.com/6oU28r6Nz3GT8kbbi61sQ06">
    <img src="https://img.shields.io/badge/Purchase%20the%20dongle-Stripe-635BFF?style=for-the-badge&logo=stripe&logoColor=white">
  </a>
  
  <i>If you have any questions or want to purchase multiple dongles you can contact me via email benas.rag@gmail.com</i>
</p>

<p align="center">
  <img src="/images/faircon-usb.jpg" width="45%" />
  <img src="/images/faircon-jst.jpg" width="45%" />
</p>

Or you can build it yourself - you will find instructions below :)

# Screenshots
#### HomeAssistant Integration (MQTT Autodiscovery)

<p align="center">
  <img src="/images/ha-controls.png" width="45%" />
  <img src="/images/ha-sensors.png" width="45%" />
  <img src="/images/ha-diagnostic.png" width="45%" />
  <img src="/images/ha-climate.png" width="45%" />
</p>

#### Credentials page
*This page is available at 192.168.1.1 when connected to the access point created by the dongle, when no config saved yet, or impossible to connect to WiFi*<br/>

<p align="center">
  <img src="/images/web.png" width="45%" />
</p>

# Building the module

### Required parts
* DC/DC converter 12 -> 5 V (~2.65 € for bundle of 5pcs)<br/>
*Choose 5V version, also ensure you get right one. in case of bigger voltage, you will pass too high voltage to AC UART and risk to damage it*<br/>
(https://www.aliexpress.com/item/1005008257960729.html)
* ESP32 30 pin (~4.40 €)
* Connector (4P, 10cm/20cm) (~3.00 € for bundle of 5pcs, https://www.aliexpress.com/item/1005006294406922.html)
* Board (4x6, needs to be trimmed a little bit) (~2.00 € for bundle of 5pcs, https://www.aliexpress.com/item/1005007024264426.html)
* Logic level converter (~2.50 € for bundle of 5pcs, https://www.aliexpress.com/item/1005006968679749.html)

* Total parts cost for a dongle:
  * ~ 15.00 € (if you build one)
  * ~ 6.50 € each (if you build 5)

  You can also crimp your own plug (Connector PAP-04V-S, pins to crimp: SPHD-002T-P0.5) <- very time consuming if you do not have right tools for it.

### Connection

**!!! IMPORTANT !!!**

**Do not connect anything from air conditioner to external device, like your computer. If you touch AC GND with, lets say laptop GND, it will fry your laptop USB port and/or AC mainboard fuse.**
AC pins are not galvanically isolated and these voltages are not relative to earth GND.

<table>
  <thead>
    <tr>
     <td width="50%">JST Type wiring</td>
     <td width="50%">USB Type wiring</td>
    </tr>
  </thead>
  <tbody>
   <tr>
     <td>
       Pins from left to right 1 2 3 4
     </td>
     <td>
       Circuit for JST type connector
     </td>
   </tr>
   <tr>
     <td>
       <img src="/images/socket.jpg"/>
     </td>
     <td>
       <img src="/images/circuit.png"/>
     </td>
   </tr>
  </tbody>
</table>

#### JST-type wiring
```
 AC Socket       CN3903                 ESP32
1 (+12V) ------> V in+ ---> V out+ ---> 5V
2 (GND)  ------> V in- ---> V out- ---> GND
3 (DATA) -----------------------------> RX/16 (AC -> ESP)
4 (DATA) -----------------------------> TX/17 (AC <- ESP)
```

#### USB-type wiring
```
Pinout for USB style socket:
Pin 1 - 12v
Pin 2 - AC_TX - 16 pin
Pin 3 - AC_RX - 17 pin
Pin 4 - GND
```

USB Pinout from top to bottom <br/>
![](/images/usb_plug.png)
<br/>

#### Uploading the code first time
1. Download Arduino IDE (I used 2.3)
2. File -> Preferences -> Additional boards manager URLs: http://arduino.esp8266.com/stable/package_esp8266com_index.json
3. Download required libraries:
   * this library - FujitsuAC (Benas09)
   * PubSubClient 2.8 (Nick O'Leary)
4. Open Arduino IDE -> File -> Examples -> FujitsuAC -> Controller
5. Select your ESP32 board:
   * Choose your board type Tools -> Board -> esp32 -> ESP32 Dev module
   * Choose your port Tools -> Port -> /dev/ttyUSB0 (or similar)
   * Sketch -> Upload using programmer (when uploading from MAC, you have to set upload speed to lowest - 460800, otherwise you will get an error while uploading)

*Additional button can be used for credentials reset functionality - uncomment RESET_BUTTON and set to corresponding pin. When you press this button (pull corresponding pin to GND) - controller deletes given credentials, reboots and goes to point*

#### Configuring credentials
1. When controller boots up, it will create access point *faircon-uniqueId*
2. Connect to this access point with your computer/mobile phone
3. Go to 192.168.1.1
4. Fill in WiFi, MQTT credentials, name your device and click Submit. (Device password will be required for OTA updates)
5. Dongle will reboot and connect to your wifi network.
6. If everything is ok, new AC device should appear in HomeAssistant MQTT integration

#### OTA Update
1. Open Arduino IDE
2. File -> Examples -> FujitsuAC -> Controller
3. Select your ESP32 board:
   * Choose your board type Tools -> Board -> esp32 -> ESP32 Dev module
   * Choose your port Tools -> Port -> Network ports -> "YourDongleName at your-dongle-ip" (disappears time by time, so wait or reload Arduino IDE to apear again)
   * Sketch -> Upload

#### Network update
Since 1.1.6 one-click network update is available. The dongle checks for new version every 24 hours (and immediately after reboot). To update, just click "update firmware" button in HA and wait.

Chip list for prebuilt firmwares:
* ESP32
* ESP32-S3
* ESP32-C3
* others will ignore update request

# DIY Module (Logic level shifter is not included here yet)
<p align="center">
  <img src="/images/board_front.jpg" width="45%" />
  <img src="/images/board_back.jpg" width="45%" />
  <img src="/images/board_case.jpg" width="45%" />
  <img src="/images/installed.jpg" width="45%" />
</p>

# FAQ

### Does the dongle disables the use of other controllers?
Product has been tested with IR and wall controller (UTY-RLRY). Functionality of these controllers remains available when using the dongle.
IR is a one-way channel without feedback where UTY-RLRY is two-way and displays changes made by the dongle.

### How can I reset the dongle configuration?
There is a small hole in the enclosure. Click the button through that hole with a toothpick and all credentials will be cleared.
When building DIY dongle, you have attach a button to the RESET_BUTTON pin to use that feature.

### What do the LED statues mean?
When building DIY dongle, you have attach LEDS to the correspinding pins (Red - 19, White - 18 for esp32) that feature.
* Only red blinking - connecting to wifi
* Only red shining - AP is created
* Red + White shining - connected to wifi and mqtt

### What's AP fallback mode?
When wifi gets disconnected, the dongle reboots to AP mode for several minutes (credentials are not cleared yet, they just are not shown in AP webpage). If Wifi becomes available when AP is enabled, the dongle reboots after a couple minutes to normal mode and connects to it.

### I'm missing some features to control my AC.
The dongle reads the AC information and only displays available options. When you believe you are missing options, please create an issue and post your logfile.

### How to collect a logfile?
‎SSH to your MQTT setup and use these commands.
* mosquitto_sub -h 192.168.1.100 -t fujitsu/# -v for all your dongles
* mosquitto_sub -h 192.168.1.100 -t fujitsu/80f3dabb15f0/# -v for exact one, just change with your unique id

### The total number of swing positions is incorrectly displayed.
There is a registry which reports how many louver grille positions available. When you believe number of positions are incorrect, please send us your logfile.
You'll be able to override the displayed value in a future release.

### What does energy_saving_fan option do?
Power saving function to control the indoor unit fan rotation when the outdoor unit is stopped during cooling operation. 
Enabled, the indoor fan operates intermittently at a very low speed when outdoor unit is stopped.

### I'm missing the OutdoorUnitLowNoise feature
By manufacturer design, this option will not be available when using a multi-split system (multiple indoor units connected to one outdoor unit).

### Available dongle status messages
* MqttBridge started (connected to mqtt and HA configuration started)
* Init1 Send - first stage of handshake between esp and aircon
* Init2 Send - second stage of handshake between esp and aircon
* Running - handshake successful and communication is running
* Updating - when updating through network started



