Skip to content

Commit

Permalink
v1.2.24
Browse files Browse the repository at this point in the history
- added firmware `#` configuration parameters to `smart-sensor` example
- refactored `smart-sensor*` code
  • Loading branch information
genemars committed Jun 22, 2024
1 parent bd33135 commit a2522f2
Show file tree
Hide file tree
Showing 37 changed files with 234 additions and 286 deletions.
22 changes: 0 additions & 22 deletions examples/color-light/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,6 @@ A smart light device with addressable RGB LEDs.
| `stld-typ` | Status LED type | RGB/RGBW order mask (see code for ref.) |
| `stld-spd` | Status LED speed | 0 (0=800kHz, 256=400kHz) |

*Example **setting** configuration from a terminal connected to the serial port of the device:*

```
#SET:leds-pin=5
#SET:leds-cnt=25
#SET:leds-typ=6
#SET:leds-spd=0
#SET:stld-pin=10
#SET:stld-typ=82
#SET:stld-spd=0
#RESET
```

*Example **getting** configuration value:*

```
#GET:stl-pin
```
response:
```
#GET:stl-pin=10
```

## Manual build and install

Expand Down
38 changes: 37 additions & 1 deletion examples/smart-sensor-display/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,37 @@
Smart sensor with display and HomeGenie Mini UI.

# smart-sensor

Smart multi-sensor device with display. HomeGenie Mini UI example use.

- [Documentation and firmware install page](https://homegenie.it/mini/1.2/examples/smart-sensor/)


## Firmware configuration (in addition to default system options)

| Key | Description | Default |
|------------|-------------------------------------|---------|
| `ligh-typ` | Light sensor type | -1 |
| `ligh-pin` | Light sensor GPIO# | -1 |
| `motn-typ` | Motion sensor type | -1 |
| `motn-pin` | Motion sensor GPIO# | -1 |
| `soth-typ` | Temperature sensor type | -1 |
| `soth-pin` | Temperature sensor GPIO# | -1 |
| `sdht-typ` | Temperature + Humidity sensor type | -1 |
| `sdht-pin` | Temperature + Humidity sensor GPIO# | -1 |


### Manual build and install

You can also manually build and install the firmware from source code
as explained in the [Getting started](../../getting-started#custom-firmware) page
and using the following commands for flashing the firmware:

```bash
pio run -e smart-sensor[<target>] -t upload
```

where the optional `<target>` suffix can be one of the following:
- ESP32 + display
`-display`
- ESP32-S3 + display
`-display-s3`
18 changes: 0 additions & 18 deletions examples/smart-sensor-display/configuration.h

This file was deleted.

2 changes: 1 addition & 1 deletion examples/smart-sensor-display/io/BatterySensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include "BatterySensor.h"

namespace IO { namespace Env {
namespace IO { namespace Sensors {

void BatterySensor::begin() {
pinMode(sensorPin, INPUT);
Expand Down
6 changes: 2 additions & 4 deletions examples/smart-sensor-display/io/BatterySensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@

#include <HomeGenie.h>

#include "../configuration.h"
#define BATTERY_SENSOR_NS_PREFIX "IO::Sensors::BatterySensor"

#define BATTERY_SENSOR_NS_PREFIX "IO::Env::BatterySensor"

namespace IO { namespace Env {
namespace IO { namespace Sensors {

class BatterySensor: Task, public IIOEventSender {
public:
Expand Down
61 changes: 0 additions & 61 deletions examples/smart-sensor-display/io/LightSensor.cpp

This file was deleted.

33 changes: 10 additions & 23 deletions examples/smart-sensor-display/smart-sensor-display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
*
*/

#include "configuration.h"

#include <HomeGenie.h>

#include <ui/Dashboard.h>
Expand All @@ -39,17 +37,15 @@
#include <ui/activities/utilities/DigitalClockActivity.h>
#include <ui/activities/utilities/SystemInfoActivity.h>

#include "smart-sensor/CommonSensors.h"

#include "display/activities/SensorValuesActivity.h"
#include "io/DHTxx.h"
//#include "../smart-sensor/io/LightSensor.h"
//#include "io/BatterySensor.h"
#include "io/MotionSensor.h"

// Accelerometer and Gyroscope
//#include "io/QMI8658.h"


using namespace IO::Env;
using namespace Service;
using namespace UI::Activities::Control;
//using namespace UI::Activities::Examples;
Expand All @@ -68,9 +64,6 @@ Dashboard* dashboard;
void setup() {

//uint8_t batterySensorPin = 1;
uint8_t motionSensorPin = CONFIG_MotionSensorPin;

PowerManager::setWakeUpGPIO((gpio_num_t)motionSensorPin);

homeGenie = HomeGenie::getInstance();
miniModule = homeGenie->getDefaultModule();
Expand Down Expand Up @@ -98,22 +91,16 @@ void setup() {
homeGenie->addIOHandler(batterySensor);
//*/

// Motion sensor
auto motionSensor = new MotionSensor(motionSensorPin);
motionSensor->setModule(miniModule);
homeGenie->addIOHandler(motionSensor);

/*
// Light sensor
auto lightSensor = new LightSensor();
lightSensor->setModule(miniModule);
homeGenie->addIOHandler(lightSensor);
//*/
includeCommonSensors(homeGenie, miniModule);

// Temperature and humidity sensor
auto dhtSensor = new DHTxx(22);
dhtSensor->setModule(miniModule);
homeGenie->addIOHandler(dhtSensor);
#ifdef CONFIG_ENABLE_POWER_MANAGER
// Enable power manager (deep sleep on motion timeout)
if (Config::getSetting("motn-typ").equals("switch") && Config::getSetting("motn-pms").equals("sleep")) {
uint8_t motionSensorPin = Config::getSetting("motn-pin", "16").toInt();
PowerManager::setWakeUpGPIO((gpio_num_t) motionSensorPin);
}
#endif

// add custom properties to default module
controlModuleParameter = new ModuleParameter("RemoteControl.EndPoint", Config::getSetting("ctrl-mod"));
Expand Down
54 changes: 54 additions & 0 deletions examples/smart-sensor/CommonSensors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// Created by gene on 21/06/24.
//

#ifndef HOMEGENIE_MINI_COMMONSENSORS_H
#define HOMEGENIE_MINI_COMMONSENSORS_H

#include "HomeGenie.h"

#include "io/sensors/DS18B20.h"
#include "io/sensors/MotionSensor.h"
#include "io/sensors/DHTxx.h"
#include "io/sensors/LightSensor.h"

using namespace IO::Sensors;

void includeCommonSensors(HomeGenie* homeGenie, Module* miniModule) {

// Light sensor
if (Config::getSetting("ligh-typ").equals("ldr")) {
auto lightSensor = new LightSensor(Config::getSetting("ligh-pin").toInt());
lightSensor->setModule(miniModule);
homeGenie->addIOHandler(lightSensor);
}

// Motion sensor
if (Config::getSetting("motn-typ").equals("switch")) {
uint8_t motionSensorPin = Config::getSetting("motn-pin").toInt();
auto motionSensor = new MotionSensor(motionSensorPin);
motionSensor->setModule(miniModule);
homeGenie->addIOHandler(motionSensor);
}

// Temperature sensor
if (Config::getSetting("soth-typ").equals("ds18b20")) {
auto temperatureSensor = new DS18B20(Config::getSetting("soth-pin").toInt());
temperatureSensor->setModule(miniModule);
homeGenie->addIOHandler(temperatureSensor);
}

// DHT-xx Temperature and humidity sensor
uint8_t dhtSensorPint = Config::getSetting("sdht-pin").toInt();
if (Config::getSetting("sdht-typ").equals("22")) {
auto dhtSensor = new DHTxx(22, dhtSensorPint);
dhtSensor->setModule(miniModule);
homeGenie->addIOHandler(dhtSensor);
} else if (Config::getSetting("sdht-typ").equals("11")) {
auto dhtSensor = new DHTxx(11, dhtSensorPint);
dhtSensor->setModule(miniModule);
homeGenie->addIOHandler(dhtSensor);
}
}

#endif //HOMEGENIE_MINI_COMMONSENSORS_H
36 changes: 36 additions & 0 deletions examples/smart-sensor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# smart-sensor

A smart multi-sensor device.

- [Documentation and firmware install page](https://homegenie.it/mini/1.2/examples/smart-sensor/)


## Firmware configuration (in addition to default system options)

| Key | Description | Default |
|------------|-------------------------------------|---------|
| `ligh-typ` | Light sensor type | -1 |
| `ligh-pin` | Light sensor GPIO# | -1 |
| `motn-typ` | Motion sensor type | -1 |
| `motn-pin` | Motion sensor GPIO# | -1 |
| `soth-typ` | Temperature sensor type | -1 |
| `soth-pin` | Temperature sensor GPIO# | -1 |
| `sdht-typ` | Temperature + Humidity sensor type | -1 |
| `sdht-pin` | Temperature + Humidity sensor GPIO# | -1 |


### Manual build and install

You can also manually build and install the firmware from source code
as explained in the [Getting started](../../getting-started#custom-firmware) page
and using the following commands for flashing the firmware:

```bash
pio run -e smart-sensor[<target>] -t upload
```

where the optional `<target>` suffix can be one of the following:
- ESP8266
`-d1-mini`
- ESP32 D1 Mini
`-d1-mini-esp32`
16 changes: 0 additions & 16 deletions examples/smart-sensor/configuration.h

This file was deleted.

Loading

0 comments on commit a2522f2

Please sign in to comment.