@BearWithBeard I have upgraded the library V.2.3.2 and it compiles now.
Thanks for your help!
@BearWithBeard I have upgraded the library V.2.3.2 and it compiles now.
Thanks for your help!
Hello,
Here an update of the original sketch with a small modif to add a buzzer for validating the keypress.
It will beep once for short key press and twice for the long one.
The buzzer is connected on D3 and the beep length can be adjusted in the function.
Your feedback and improvement ideas are welcome.
Best regards,
Jef
#define MY_DEBUG
#define MY_RADIO_NRF24
// Set LOW transmit power level as default, if you have an amplified NRF-module and
// power your radio separately with a good regulator you can turn up PA level.
/* - RF24_PA_MIN = -18dBm
* - RF24_PA_LOW = -12dBm
* - RF24_PA_HIGH = -6dBm
* - RF24_PA_MAX = 0dBm
*/
#define MY_RF24_PA_LEVEL RF24_PA_HIGH
// Enabled repeater feature for this node
#define MY_REPEATER_FEATURE
// activate signal report
// #define MY_SIGNAL_REPORT_ENABLED
#include <SPI.h>
#include <MySensors.h>
#include <Keypad.h>
#define NODE_ID AUTO // or set to AUTO if you want gw to assign a node id for you.
#define SN "Keypad Scene Controller"
#define SV "2.1"
#define KEYPAD_CHILD_ID 95
MyMessage scene(KEYPAD_CHILD_ID, V_SCENE_ON); //scene ON
MyMessage scene2(KEYPAD_CHILD_ID, V_SCENE_OFF); //scene OFF
int buzzer = 3; // buzzer pin
const byte ROWS = 4; //four rows
const byte COLS = 1; //one column
char keys[ROWS][COLS] = {
{'1'},
{'2'},
{'3'},
{'4'}
};
byte rowPins[ROWS] = {6, 7, 4, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
byte lastState;
void setup() {
sendSketchInfo(SN, SV);
present(KEYPAD_CHILD_ID, S_SCENE_CONTROLLER);
keypad.addEventListener(keypadEvent);
pinMode(buzzer, OUTPUT);
}
/*
* Declare the buzzer function.
* Adjust the delay to fit your preferences
*/
void beep()
{
digitalWrite(buzzer, HIGH);
delay(50);
digitalWrite(buzzer, LOW);
}
void loop() {
char key = keypad.getKey();
}
void keypadEvent(KeypadEvent key) {
switch (keypad.getState()) {
case PRESSED:
lastState = 1;
beep();
break;
case HOLD:
lastState = 2;
beep();
break;
case RELEASED:
int keyInt = key - '0'; //Quick way to convert Char to Int so it can be sent to controller
if (lastState == 2) {
//keyInt = keyInt + 4; //If button is held, add 4. If using more than 4 buttons this number will need to be changed
send(scene2.set(keyInt));
} else {
send(scene.set(keyInt));
}
//break;
}
}
Greetings from Switzerland!
Let me share with you a small project I did to monitor the radio-activity and temperature (2 sensors).
The device is installed in my garage and one or the temp. probe is installed in the laundry.
It is built around the following Geiger counter module : https://www.ebay.com/itm/Geiger-counter-dosimeter-kit-assembled-w-SBT11A-tube-iR-USB-Arduino-compat/162946293010
Since I have a RFM69 based network, I got the 3.3V module version.
The tube is an SBT-11a detecting the alpha, beta & gamma radiations and the temp sensors are 2 x 1 wire Dallas DS18B20.
Here the output (Domoticz)
The script is really simple. I used the temp sample https://www.mysensors.org/build/temp
and modified it to push the data to the controller when the geiger counter sends the value to the serial port. To get it working, I had to place the geiger counter in RADLOGGER mode using the IR remote control. Then by adjusting the LOG PERIOD parameters I have defined the frequency at which the counter is pushing the data to the serial port, thus triggering the transmission to the controller (every 5 mn here).
//------------------
#define CHILD_ID_RADIATION 90 // Id of the Geiger child
#include <SPI.h>
#include <MySensors.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
#define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected
#define MAX_ATTACHED_DS18B20 2
//unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature.
float lastTemperature[MAX_ATTACHED_DS18B20];
int numSensors = 0;
bool receivedConfig = false;
bool metric = true;
// Initialize temperature message and geiger
MyMessage msg(0, V_TEMP);
MyMessage msg_rad(CHILD_ID_RADIATION, V_LEVEL);
void before()
{
// Startup up the OneWire library
sensors.begin();
}
void setup()
{
// requestTemperatures() will not block current thread
sensors.setWaitForConversion(false);
// initialize the serial communications (must be 9600 for the geiger counter):
Serial.begin(9600);
}
void presentation() {
// Send the sketch version information to the gateway and Controller
sendSketchInfo("Geiger & Temperature Sensors", "2.0");
// Fetch the number of attached temperature sensors
numSensors = sensors.getDeviceCount();
// Present all sensors to controller
for (int i = 0; i < numSensors && i < MAX_ATTACHED_DS18B20; i++) {
present(i, S_TEMP);
}
present(CHILD_ID_RADIATION, S_DUST);
}
void loop()
{
if (Serial.available()) {
delay(200);
String str_cpm = Serial.readStringUntil("\n"); //update str_cpm with serial entry
send(msg_rad.set(str_cpm.toInt())); // Send to gateway wiLL BE TRIGGERED WHEN VALUE IS RECEIVED FROM THE COUNTER.ADJUST THE TIMEFRAME FROM THE COUNTER WITH IR REMOTE CONTROL.
// Fetch temperatures from Dallas sensors
sensors.requestTemperatures();
// query conversion time and sleep until conversion completed
int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
// sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
wait(conversionTime);
// Read temperatures and send them to controller
for (int i = 0; i < numSensors && i < MAX_ATTACHED_DS18B20; i++) {
// Fetch and round temperature to one decimal
float temperature = static_cast<float>(static_cast<int>((getControllerConfig().isMetric ? sensors.getTempCByIndex(i) : sensors.getTempFByIndex(i)) * 10.)) / 10.;
// Only send data if temperature has changed and no error
#if COMPARE_TEMP == 1
if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
#else
if (temperature != -127.00 && temperature != 85.00) {
#endif
// Send in the new temperature
send(msg.setSensor(i).set(temperature, 1));
// Save new temperatures for next compare
lastTemperature[i] = temperature;
}
}
//sleep(SLEEP_TIME);
}
}
To code is really not optimised but it works at least :)) Feel free to optimise / share
There is another possible approach to work with this counter. It is possible to generate an impulse on an output pin at every tube discharge. This is then possible to read these impulses from the arduino then convert them to the right value (CPM, ยตSv/h...).
Stay safe !
All the best !
Jef
@BearWithBeard I have upgraded the library V.2.3.2 and it compiles now.
Thanks for your help!
Hello,
when compiling the standard example https://github.com/mysensors/MySensors/blob/master/examples/DimmableLEDActuator/DimmableLEDActuator.ino
on the IDE 1.8.12 :
Return this error :
C:\Users\James\Documents\Arduino\sketch_may16a-test\sketch_may16a-test.ino: In function 'void receive(const MyMessage&)':
sketch_may16a-test:88:15: error: 'const class MyMessage' has no member named 'getType'; did you mean 'setType'?
if (message.getType() == V_LIGHT || message.getType() == V_DIMMER) {
^~~~~~~
setType
sketch_may16a-test:88:47: error: 'const class MyMessage' has no member named 'getType'; did you mean 'setType'?
if (message.getType() == V_LIGHT || message.getType() == V_DIMMER) {
^~~~~~~
setType
sketch_may16a-test:94:33: error: 'const class MyMessage' has no member named 'getType'; did you mean 'setType'?
requestedLevel *= ( message.getType() == V_LIGHT ? 100 : 1 );
^~~~~~~
setType
exit status 1
'const class MyMessage' has no member named 'getType'; did you mean 'setType'?
Can someone help?
All the best!
Greetings from Switzerland!
Let me share with you a small project I did to monitor the radio-activity and temperature (2 sensors).
The device is installed in my garage and one or the temp. probe is installed in the laundry.
It is built around the following Geiger counter module : https://www.ebay.com/itm/Geiger-counter-dosimeter-kit-assembled-w-SBT11A-tube-iR-USB-Arduino-compat/162946293010
Since I have a RFM69 based network, I got the 3.3V module version.
The tube is an SBT-11a detecting the alpha, beta & gamma radiations and the temp sensors are 2 x 1 wire Dallas DS18B20.
Here the output (Domoticz)
The script is really simple. I used the temp sample https://www.mysensors.org/build/temp
and modified it to push the data to the controller when the geiger counter sends the value to the serial port. To get it working, I had to place the geiger counter in RADLOGGER mode using the IR remote control. Then by adjusting the LOG PERIOD parameters I have defined the frequency at which the counter is pushing the data to the serial port, thus triggering the transmission to the controller (every 5 mn here).
//------------------
#define CHILD_ID_RADIATION 90 // Id of the Geiger child
#include <SPI.h>
#include <MySensors.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
#define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected
#define MAX_ATTACHED_DS18B20 2
//unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature.
float lastTemperature[MAX_ATTACHED_DS18B20];
int numSensors = 0;
bool receivedConfig = false;
bool metric = true;
// Initialize temperature message and geiger
MyMessage msg(0, V_TEMP);
MyMessage msg_rad(CHILD_ID_RADIATION, V_LEVEL);
void before()
{
// Startup up the OneWire library
sensors.begin();
}
void setup()
{
// requestTemperatures() will not block current thread
sensors.setWaitForConversion(false);
// initialize the serial communications (must be 9600 for the geiger counter):
Serial.begin(9600);
}
void presentation() {
// Send the sketch version information to the gateway and Controller
sendSketchInfo("Geiger & Temperature Sensors", "2.0");
// Fetch the number of attached temperature sensors
numSensors = sensors.getDeviceCount();
// Present all sensors to controller
for (int i = 0; i < numSensors && i < MAX_ATTACHED_DS18B20; i++) {
present(i, S_TEMP);
}
present(CHILD_ID_RADIATION, S_DUST);
}
void loop()
{
if (Serial.available()) {
delay(200);
String str_cpm = Serial.readStringUntil("\n"); //update str_cpm with serial entry
send(msg_rad.set(str_cpm.toInt())); // Send to gateway wiLL BE TRIGGERED WHEN VALUE IS RECEIVED FROM THE COUNTER.ADJUST THE TIMEFRAME FROM THE COUNTER WITH IR REMOTE CONTROL.
// Fetch temperatures from Dallas sensors
sensors.requestTemperatures();
// query conversion time and sleep until conversion completed
int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
// sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
wait(conversionTime);
// Read temperatures and send them to controller
for (int i = 0; i < numSensors && i < MAX_ATTACHED_DS18B20; i++) {
// Fetch and round temperature to one decimal
float temperature = static_cast<float>(static_cast<int>((getControllerConfig().isMetric ? sensors.getTempCByIndex(i) : sensors.getTempFByIndex(i)) * 10.)) / 10.;
// Only send data if temperature has changed and no error
#if COMPARE_TEMP == 1
if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
#else
if (temperature != -127.00 && temperature != 85.00) {
#endif
// Send in the new temperature
send(msg.setSensor(i).set(temperature, 1));
// Save new temperatures for next compare
lastTemperature[i] = temperature;
}
}
//sleep(SLEEP_TIME);
}
}
To code is really not optimised but it works at least :)) Feel free to optimise / share
There is another possible approach to work with this counter. It is possible to generate an impulse on an output pin at every tube discharge. This is then possible to read these impulses from the arduino then convert them to the right value (CPM, ยตSv/h...).
Stay safe !
All the best !
Jef
Hello,
Here an update of the original sketch with a small modif to add a buzzer for validating the keypress.
It will beep once for short key press and twice for the long one.
The buzzer is connected on D3 and the beep length can be adjusted in the function.
Your feedback and improvement ideas are welcome.
Best regards,
Jef
#define MY_DEBUG
#define MY_RADIO_NRF24
// Set LOW transmit power level as default, if you have an amplified NRF-module and
// power your radio separately with a good regulator you can turn up PA level.
/* - RF24_PA_MIN = -18dBm
* - RF24_PA_LOW = -12dBm
* - RF24_PA_HIGH = -6dBm
* - RF24_PA_MAX = 0dBm
*/
#define MY_RF24_PA_LEVEL RF24_PA_HIGH
// Enabled repeater feature for this node
#define MY_REPEATER_FEATURE
// activate signal report
// #define MY_SIGNAL_REPORT_ENABLED
#include <SPI.h>
#include <MySensors.h>
#include <Keypad.h>
#define NODE_ID AUTO // or set to AUTO if you want gw to assign a node id for you.
#define SN "Keypad Scene Controller"
#define SV "2.1"
#define KEYPAD_CHILD_ID 95
MyMessage scene(KEYPAD_CHILD_ID, V_SCENE_ON); //scene ON
MyMessage scene2(KEYPAD_CHILD_ID, V_SCENE_OFF); //scene OFF
int buzzer = 3; // buzzer pin
const byte ROWS = 4; //four rows
const byte COLS = 1; //one column
char keys[ROWS][COLS] = {
{'1'},
{'2'},
{'3'},
{'4'}
};
byte rowPins[ROWS] = {6, 7, 4, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
byte lastState;
void setup() {
sendSketchInfo(SN, SV);
present(KEYPAD_CHILD_ID, S_SCENE_CONTROLLER);
keypad.addEventListener(keypadEvent);
pinMode(buzzer, OUTPUT);
}
/*
* Declare the buzzer function.
* Adjust the delay to fit your preferences
*/
void beep()
{
digitalWrite(buzzer, HIGH);
delay(50);
digitalWrite(buzzer, LOW);
}
void loop() {
char key = keypad.getKey();
}
void keypadEvent(KeypadEvent key) {
switch (keypad.getState()) {
case PRESSED:
lastState = 1;
beep();
break;
case HOLD:
lastState = 2;
beep();
break;
case RELEASED:
int keyInt = key - '0'; //Quick way to convert Char to Int so it can be sent to controller
if (lastState == 2) {
//keyInt = keyInt + 4; //If button is held, add 4. If using more than 4 buttons this number will need to be changed
send(scene2.set(keyInt));
} else {
send(scene.set(keyInt));
}
//break;
}
}
Hello,
I have a Strange problem appearing since I have started to upgrade my network from 2.1.1 to 2.2.0
I am using a Domoticz v.3.8153 / Raspbian + a serial GW on NRF.
Some of the devices are communicating to the GW through a repeater node equipped with a nrf24l01 PA LNA since they are just too far from the GW.
Not all of the nodes are upgraded to 2.2.0, some are still running 2.1.1
the battery level reporting disappeared from all of the connected node (but one is still working : a senserblender micro with the original TempHum sketch)
The repeater node sometime stopped relaying the connection to the GW (on random time ?). Only thing I found is to restart this node)
Any ideas ?
Thanks a lot.
Jef