Difference between revisions of "Spacestate sensors"

From Hackerspace ACKspace
Jump to: navigation, search
m (migration to MQTT)
(revamped the project; tossing away the ESP-01 and migrating to Tasmota)
Line 1: Line 1:
 
{{Project
 
{{Project
|Featured=No
+
|Featured=Yes
|State=Planned
+
|State=Active
 
|Members=Xopr
 
|Members=Xopr
 
|Description=You can't manage what you don't measure
 
|Description=You can't manage what you don't measure
 
|GitHub=SpaceAPI-sensors
 
|GitHub=SpaceAPI-sensors
 
}}
 
}}
{{Marked as outdated|The system-to-be-installed uses Tasmota firmware combined with an [[MQTT]] script}}
+
__TOC__
  
Note: Onewire sensors are part of the [[ESP8266-SpaceState]] ([[SpaceAPI]]).
+
This project ties strongly with the [[MQTT]] setup (to connect to the [[SpaceAPI]]) as it uses [https://tasmota.github.io/ Tasmota] on [[ESP]] devices for feature bang and ease of use.
Some code is already in place, and using [[ESP8266]] wifi modules make it very modular.
+
 
The temperature sensors are connected to fuse group [[Fuse group::A]].
+
Note that you're more than welcome to add any sensor (or actuator) that you might see fit for our hackerspace. Think: 3D printer nozzle temperature or filament weight, outside radiation, air quality, motion sensing, window opener and the likes; this project is proof anyone that can handle a screwdriver and PC can do this.
  
 
=== synopsis ===
 
=== synopsis ===
Line 16: Line 16:
  
 
=== intro ===
 
=== intro ===
After implementing the [[Space state]] switch, a [[Spacestate indicator]],its [[Mobile Spacestate Indicator|mobile implementation]] and some different types of temperature sensors, it is time to make it modular.
+
After some iterations of the [[Space state]] switch and [[Mobile Spacestate Indicator|some versions]] of the [[Spacestate indicator]], some different types of temperature sensors, it was time to make it easy on ourselves: switch to [[MQTT]] and use [https://tasmota.github.io/ Tasmota].
 +
 
 +
In most cases, an off-the-shelf ESP device will suffice, but since not all devices are not galvanically isolated from mains, it's more practical to use an ESP-12 PCB for things where contacts are bare (like the Space state switch).
 +
 
 +
Here are the steps to setup such a device
 +
 
 +
=== configuring a spacestate sensor from scratch ===
 +
Most of this (apart from the MQTT configuration) only applies to the Spacestate sensor board (see image); it will setup a pinout template that matches the board.
 +
* Under '''Configuration''', click '''Configure Other'''
 +
* Paste this template: <code>{"NAME":"ACKsensor","GPIO":[0,0,0,0,0,0,0,0,1,0,0,0,1,1],"FLAG":0,"BASE":18}</code> and check '''Activate'''
 +
* Fill in '''Device Name''' (<code>ACKtemp</code> or <code>ACKstate</code>) and '''Friendly Name 1''' (<code>Space state switch</code> or leave as is)
 +
* Save (will reboot)
 +
* Click '''Configure Module'''
 +
* Make sure '''Module type''' is <code>ACKsensor (0)</code>
 +
* Set functions for '''GPIO17 (ADC)''', '''GPIO16''' (Typically <code>Switch 1</code> or <code>Button 1</code>) and '''GPIO12''' (<code>DS18x20</code> which is connected to 3.3v using ~4k7 pull up), see [https://tasmota.github.io/docs/GPIO-Conversion/ GPIO-Conversion] for details
 +
* Save (will reboot again)
 +
* Click '''Configure MQTT'''
 +
* Set '''Host''' (<code>192.168.1.42</code>), User (<code>temperature</code> or <code>spacestate</code>), '''Password''' (currently, only xopr knows these passwords), '''Topic''' (<code>temperature</code>, <code>switch</code> or <code>spacestate</code>) and '''Full Topic''' (<code>ackspace/hackspace/%topic%/%prefix%/</code>)
 +
* Save (will reboot yet again)
 +
 
 +
=== details and troubleshooting ===
 +
==== ADC/GPIO17 ====
 +
Note that the analog in is 0-1V maximum; use a voltage divider to limit its input (also see [https://tasmota.github.io/docs/ADC/ the Tasmota ADC] and [https://tasmota.github.io/docs/Commands/#adcparam calibration/tuning] pages).
 +
 
 +
==== multiple switches on the spacestate sensor ====
 +
If you want to provide MQTT state for multiple switches without having corresponding relay outputs, you need some rule magic; see [https://tasmota.github.io/docs/Rules/#distinguish-switch1-and-switch2-without-the-use-of-relay1-and-relay2 this rule section] to do so.
 +
 
 +
==== recovery ====
 +
When a device doesn't respond or won't connect to wifi, you might need to [https://tasmota.github.io/docs/Device-Recovery/ trigger recovery mode] by:
 +
* power it off for 30 seconds
 +
* power on 7 times with less than 10 second interval
 +
Note that this only works if <code>SetOption65</code> is <code>0</code> (which one would have disabled if brown-outs occur often.

Revision as of 20:28, 21 November 2021

Project: Spacestate sensors
Featured: Yes
State Active
Members Xopr
GitHub SpaceAPI-sensors
Description You can't manage what you don't measure
Picture
Spacestate sensors Picture.jpg

This project ties strongly with the MQTT setup (to connect to the SpaceAPI) as it uses Tasmota on ESP devices for feature bang and ease of use.

Note that you're more than welcome to add any sensor (or actuator) that you might see fit for our hackerspace. Think: 3D printer nozzle temperature or filament weight, outside radiation, air quality, motion sensing, window opener and the likes; this project is proof anyone that can handle a screwdriver and PC can do this.

synopsis

Create a modular repository of sensors and outputs to keep an eye on temperatures (and/or other stuff), especially for monitoring the server room, and optionally, the [sl|h|st]ackspace(s), including the space state switch.

intro

After some iterations of the Space state switch and some versions of the Spacestate indicator, some different types of temperature sensors, it was time to make it easy on ourselves: switch to MQTT and use Tasmota.

In most cases, an off-the-shelf ESP device will suffice, but since not all devices are not galvanically isolated from mains, it's more practical to use an ESP-12 PCB for things where contacts are bare (like the Space state switch).

Here are the steps to setup such a device

configuring a spacestate sensor from scratch

Most of this (apart from the MQTT configuration) only applies to the Spacestate sensor board (see image); it will setup a pinout template that matches the board.

  • Under Configuration, click Configure Other
  • Paste this template: {"NAME":"ACKsensor","GPIO":[0,0,0,0,0,0,0,0,1,0,0,0,1,1],"FLAG":0,"BASE":18} and check Activate
  • Fill in Device Name (ACKtemp or ACKstate) and Friendly Name 1 (Space state switch or leave as is)
  • Save (will reboot)
  • Click Configure Module
  • Make sure Module type is ACKsensor (0)
  • Set functions for GPIO17 (ADC), GPIO16 (Typically Switch 1 or Button 1) and GPIO12 (DS18x20 which is connected to 3.3v using ~4k7 pull up), see GPIO-Conversion for details
  • Save (will reboot again)
  • Click Configure MQTT
  • Set Host (192.168.1.42), User (temperature or spacestate), Password (currently, only xopr knows these passwords), Topic (temperature, switch or spacestate) and Full Topic (ackspace/hackspace/%topic%/%prefix%/)
  • Save (will reboot yet again)

details and troubleshooting

ADC/GPIO17

Note that the analog in is 0-1V maximum; use a voltage divider to limit its input (also see the Tasmota ADC and calibration/tuning pages).

multiple switches on the spacestate sensor

If you want to provide MQTT state for multiple switches without having corresponding relay outputs, you need some rule magic; see this rule section to do so.

recovery

When a device doesn't respond or won't connect to wifi, you might need to trigger recovery mode by:

  • power it off for 30 seconds
  • power on 7 times with less than 10 second interval

Note that this only works if SetOption65 is 0 (which one would have disabled if brown-outs occur often.