2019-07-26 20:53:03 +00:00
---
title: 'Home Automation'
---
# Step 1. - Switches & Firmware
Sonoff Basic [On Amazon Rs. 650 ](https://www.amazon.in/gp/product/B06WWNBD3Y/ref=ppx_yo_dt_b_asin_title_o03_s00?ie=UTF8&psc=1 )
2019-07-26 20:54:06 +00:00
2019-07-26 20:53:03 +00:00
[ESPEasy ](https://github.com/letscontrolit/ESPEasy/releases )
# Step 2. - Load ESP Easy firmware on it
[A good blog ](https://randomnerdtutorials.com/sonoff-basic-switch-esp-easy-firmware-node-red/ )
2019-07-26 20:54:06 +00:00
2019-07-26 21:01:15 +00:00
The firware is `ESP_Easy_mega-20190630_normal_ESP8266_1M`
2019-07-26 20:54:06 +00:00
2019-07-26 20:53:03 +00:00
The pin connection is easy. Add the header to the pin out from the I2C programming board and connect the RX -> TX and TX -> RX. 3.3v.
Just unplug the 3.3v line and press the reset button while connecting it to go into programming mode and then flash using the flasher which is downloaded with the firmware
# Step 3. - Configure the firmware for Sonoff
2019-07-26 20:54:06 +00:00
###### Under "Hardware":
2019-07-26 20:53:03 +00:00
Wifi Status LED -> GPIO-13 (D7)
2019-07-26 20:54:06 +00:00
2019-07-26 20:53:03 +00:00
Inversed LED -> Checked
2019-07-26 20:54:06 +00:00
###### Under "Devices":
2019-07-26 20:53:03 +00:00
Edit Task 1
2019-07-26 20:54:06 +00:00
2019-07-26 20:53:03 +00:00
`Device:` is `Switch input - Switch`
2019-07-26 20:54:06 +00:00
2019-07-26 20:53:03 +00:00
`Name` is `Doesn't Matter`
2019-07-26 20:54:06 +00:00
2019-07-26 20:53:03 +00:00
`Enabled` is `Checked`
2019-07-26 20:54:06 +00:00
2019-07-26 20:53:03 +00:00
`GPIO` is `GPIO-12 (D6)`
2019-07-26 20:54:06 +00:00
2019-07-26 20:53:03 +00:00
`Switch Type` is `Switch`
2019-07-26 20:54:06 +00:00
2019-07-26 20:53:03 +00:00
`Switch Button Type` is `Normal Switch`
# Step 4. - Test
`Off` = `http://${IP_ADDRESS}/control?cmd=GPIO,12,0`
2019-07-26 20:54:06 +00:00
2019-07-26 20:58:25 +00:00
`On` = `http://${IP_ADDRESS}/control?cmd=GPIO,12,0`
# Step 5. - Install Mosquitto on a Raspberry Pi
### First get the repository package signing key, import it into apt, and remove the key file again:
2019-07-26 21:04:16 +00:00
```bash
2019-07-26 21:01:15 +00:00
wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
2019-07-26 20:58:25 +00:00
sudo apt-key add mosquitto-repo.gpg.key
2019-07-26 21:01:15 +00:00
rm mosquitto-repo.gpg.key
```
2019-07-26 20:58:25 +00:00
### Then make the mosquitto repository available to apt:
2019-07-26 21:04:16 +00:00
```bash
2019-07-26 21:01:15 +00:00
cd /etc/apt/sources.list.d/
2019-07-26 20:58:25 +00:00
sudo wget http://repo.mosquitto.org/debian/mosquitto-stretch.list
2019-07-26 21:01:15 +00:00
sudo apt-get update
```
2019-07-26 20:58:25 +00:00
### Now we can install the core packages (server & clients):
2019-07-26 21:04:16 +00:00
```bash
2019-07-26 21:01:15 +00:00
sudo apt-get install mosquitto mosquitto-clients
```