Skip to content

Arduino ESP8266 firmware to count events from a light barrier and post them to a MQTT broker.

License

Notifications You must be signed in to change notification settings

vvmev/vvm-visitorcounter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vvm-visitorcounter

This projects contains an Arduino sketch for the ESP8299 Wifi module that counts pulses from a light barrier connected to the module and posts the counter value to a MQTT broker.

The broker hostname, login username and password are configured in the sketch.

The pulse input is defined there as well, and defaults to GPIO2. This allows using an ESP-01 module.

For feedback, the sketch switches the primary Serial from GPIO1 and GPIO3, and uses GPIO1 to indicate activity. On ESP-01 modules, GPIO1/TXD is connected to a blue LED. While starting up, the LED will blink with 1Hz while a connection to the Wifi network is established. Once a connection has been established, the LED will be on. It will shortly turn off once a second as a heartbeat, and turn off while the GPIO2 input is low (active).

The circuit used to connect the light barrier to the module is in schematics.

MQTT Messages

The sketch will post the following messages. The sketch will post the messages regularly (approximately every 60 seconds).

/vvm/visitorcounter/counter

The current counter value. The message is posted with retain=true, so new clients will receive the current counter value immediately.

/vvm/visitorcounter/uptime

Seconds since the module booted. The value might not be accurate, but allows a client to gauge whether the module is active and working. The module registers this message with a value of 0 as its last-will-and-testament, so when the module goes offline, the broker will post an uptime of 0. Both messages are posted with retain=true, so clients connecting to the broker will learn the current status of the module immediately.

Test Client

As a quick way to see messages posted by the sketch, you can use the Paho test client in paho-testclient. To set up your Python, you should use Virtualenv.

Example setup:

virtualenv paho-testclient
source paho-testclient/bin/activate
pip install paho-mqtt
paho-testclient/testclient.py

About

Arduino ESP8266 firmware to count events from a light barrier and post them to a MQTT broker.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages