Skip to content

sthorshaug/esp8266-controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ESP8266-controller

This software is intended as a generic framework for controlling an ESP8266 module.
The framework does nothing fancy by itself.

What does it do?

The framework supports the following:

  • Connect to a WiFi network
  • Sync to UTC time
  • Connect to a MQTT broker
  • Publish alive messages with some usefull(?) information
  • Subscribes to MQTT topics and decodes requests
  • Perform basic IO operations

How to use

Requirements

This SW uses PubSubClient for MQTT communication.
The default value of MQTT_MAX_PACKET_SIZE defined in pubsubclient.h is 128. This means that the maximum size of the mqtt header and payload is 128 bytes. Too allow larger payloads, this value must be modified to suit your own needs.

This SW uses NtpClient for UTC timesync. This will be made optional later.

Modify the code

In the esp8266-controller.ino file, modify the following:
NETWORK_SSID - Set to your wanted SSID
NETWORK_PASSWORD - Set to your prefered password
MQTT_SERVER - IP of MQTT broker to connect to
MQTT_TOPIC_STATUS_BASE - Base topic this software will publish info to
MQTT_TOPIC_SUBSCRIBE - Topic to subscribe to

Modify the function configurePinIO() in the same file. This function configures the allowed IO pins and their properties.

Upload the program using your preferred method.

Communicate using MQTT

You should shortly after boot (given that the SSID is correct and the application is able to connect to the MQTT broker) see a message in the /alive topic with parent topic defined by MQTT_TOPIC_STATUS_BASE.

Send a message to the the subscribed MQTT topic defined by MQTT_TOPIC_SUBSCRIBE.
The message syntax is command;pin;waittime
An example is ToggleOnOff;4;500.
This means Toggle pin number 4 on, wait for 500ms, then toggle pin number 4 off.

The response will be given in the /response topic under the parent defined by MQTT_TOPIC_STATUS_BASE. The reponse contains the command, a boolean status and a string describing what happened.

Supported commands

This is the currently supported commands. If you miss something, implement or make a request :-).

ToggleOnOff

Toggle a pin high for a given amount of time.

About

Code for generic control of an esp8266 using Arduino

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages