- Changing Mesh name and password. Otherwise homes that are side by side will share the data automatically. Which is wrong. We need to create unique mesh names and passwords
- Add ability to perform an OTA update from gateway.
- Clone the project
- Open the project in VS Code (with Platform IO extension installed)
- To run the project select
release_esp01_1m
environment - Build and upload the code to ESP01 device
- Connect
CH_PD
from ESP01 to VCC - Connect VCC and GND to FTDI VCC and GND
- Connect
TX
of ESP01 toRX
of FTDI - Connect
RX
of ESP01 toTX
of FTDI - Connect
GPIO0
on ESP01 to GND (GPIO0 low puts ESP8266 into bootloader mode for downloading code)
To reset the ESP, connect RST
to gronud for a brief moment. The chip will automatically restart.
Tx - GPIO 1
Rx - GPIO 3
Every time the state of the device is updated. This JSON message will be generated and sent to the gateway.
{
"t": 1,
"rs": 1,
"ss": 0,
"p": 1
}
Configuration messages are those types of messages which the device would use to update it's state.
{
"t": 1, -> Type of the message, future proofing from
"rs": 0, -> Current state of relay
"p": 3 -> Current priority
}
Since IoT core sends the most recent configuration to the device. We need to have all the information required to update the state of the device. Even if it means sending the same information over the wire again.
Changes in configuration will be applied in the following order:
- Check the type of message (for all type 1 messages)
- Update the current state of relay
- Update the priority of the device
There are two GPIO pins using which you can interact with the device.
-
Relay Output Pin - GPIO 0. The relay will be driven on the basis of this output.
- Pin HIGH / 5V -> Relay OFF -> Appliance OFF
- Pin LOW / 0V -> Relay ON -> Appliance ON The reason why the pin is active low is because of the PNP transistor that's present at the output.
-
Switch Input Pin - GPIO 2. The physical state of the switch is known by reading this pin.
- Pin reads HIGH / 5V -> Switch Off
- Pin reads LOW / 0V / GND -> Switch is On
RXD
-> Serial rx pinGPIO0
-> Relay output pinGPIO2
-> Switch input pinTXD
-> Serial tx pin
- If the board keeps restarting without any reason. -> Power ESP01 using a dedicated power supply. Use FTDI power supply ONLY for programming the board and for nothing else. If you use FTDI's power supply it would keep restarting with some error random error every now and then.