
My Domoticz is installed on a RPI2
Sonoff Memory upgrade
you will need:
• Sonoff wifi smart switch
• Solder iron and solder
• Winbond 25Q32FV in SOP-8 package, which is a 32Mbit (4MByte) chip
1. Solder off the old chip, do this by applying a lot of solder to the 4 pins on one side and heat them all at the same time while trying to lift the chip with a screwdriver.
2. Clean up all the solder pads by stroking them with the solder tip
3. Position the new chip on the location and keep in mind that the dot on the new chip must be aligned with the marking on the board.
4. Then press the solder iron to all the pins off the chip to solder them to the board
Watch https://www.youtube.com/watch?v=8mz5sCAvDAY&t=340 for a detailed video
Flash new firmware
Sonoff Basic

Pinout:
5V(GPIO14) - Not Used
VCC – VCC (3.3v)
RX – TX
TX – RX
GND – GND
you will need
• Solder a male of female header onto the board
• CP2102 module USB to TTL serial
• Male/female header
1. Download and install the Arduino IDE: https://www.arduino.cc/en/Main/Software
2. Download the ESP software for Arduino
a. File --> Preferences --> Settings
b. Paste the following link in the additional Boards Manager URLs:
c. http://arduino.esp8266.com/stable/packa ... index.json
d. And press ok
e. Tool --> Boards --> Boards Manager
f. Filter on esp
g. Download esp8266 by ESP8266 Community
3. Download the new Sonoff firmware: https://github.com/arendst/Sonoff-Tasmota
4. Place all the files in the appropriate folders on your pc
5. Open C:\Program Files (x86)\Arduino\libraries\pubsubclient-2.6\src\ PubSubClient.h and change “#define MQTT_MAX_PACKET_SIZE” to 427
6. Open the Arduino software and load the Sonoff sketch
7. Change the user_config.h to your liking
a. Domoticz
b. MQTT
c. WIFI Credentials
8. DISCONNECT THE MAIN POWER!!!!!
9. Connect the Sonoff to the serial adapter according to the pinout above, DON’T CONNECT THE 5 V!
10. Connect the USB serial adapter to your pc.
11. The Sonoff must be in programming mode before you can flash the Sonoff with new software
a. Disconnect the VCC,
b. hold down the button
c. reconnect the VCC and release the button
12. Setup the correct settings in the Arduino IDE under Tools
13. Compile the sketch to see if there are no errors.

14. Make sure the Port is set on the right COM Port!
15. Upload the sketch to your Sonoff (this might take a few minutes).
16. Now you can connect to your device using a web browser and browse to the IP-address given by your router
Install Mosquitto – MQTT Broker
1. Ssh to Domoticz (I use Putty)
2. Download and install mosquitto
Code: Select all
• sudo adduser mosquito
• sudo apt-get update
• sudo apt-get install build-essential libwrap0-dev libssl-dev libc-ares-dev uuid-dev xsltproc
• sudo apt-get install mosquito
• sudo mosquitto_passwd -c /etc/mosquitto/pwfile <USERNAME>
• sudo chown -R mosquitto:mosquitto /var/lib/mosquitto/
• sudo cp /etc/mosquitto/mosquitto.conf.example /etc/mosquitto/mosquitto.conf
• sudo nano /etc/mosquitto/mosquitto.conf
Code: Select all
bind_address <yourIP>
port 1883
autosave_on_changes true
persistence true
persistence_file mosquitto.db
persistence_location /var/lib/mosquitto/
#change log_dest into one of below and add the other two below
Code: Select all
log_dest syslog
log_dest stdout
log_dest topic
Code: Select all
log_type error
log_type warning
log_type notice
log_type information
connection_messages true
log_timestamp true
allow_anonymous false
password_file /etc/mosquitto/pwfile
• add the following line to /etc/rc/local right before “exit 0”
/usr/local/sbin/mosquitto –d
Sudo nano /etc/rc.local
• save the file with CTRL+O and exit CTRL+X
next configure Domoticz
Configure MQTT in Domoticz
1. Open Domoticz web GUI
2. Setup --> Hardware

3. Use your own credentials you have created at point 2 from “Install Mosquitto – MQTT Broker”
sudo mosquitto_passwd -c /etc/mosquitto/pwfile <USERNAME>
4. Test if your Domoticz can talk to MQTT
a. In your console (putty ssh session) enter the following command
mosquitto_sub -h <YOUR IPADDRESS> -v -t "#"
b. The # represents all topics
c. If all steps done correctly you should see something similar as:

Exit with CTRL+C
5. Create a dummy switch Setup --> Hardware

6. The name doesn’t do anything so you can enter anything
7. Create a virtual sensor


9. Also the name does not matter.
10. After adding the switch it will be visible in Setup --> Devices. Sort on Idx. The switch is the last one in the list.

11. Open your Sonoff browser --> Configuration --> Configure Domoticz
12. And fill in the Idx of the Sonoff switch you want to control
13. Save and after the Sonoff rebooted you can control it with Domoticz.
If something is not correct please let me know so i can correct it.
--Plaagje--