I have added the C5 capacitor (on the "My Slim 2AA node"), and replaced the nrf24 from my GW with a NRF24L01+PA+LNA.
It's way better
So far, no problem .. I will keep you updated in the following days
Anyway, thanks for your help
I have added the C5 capacitor (on the "My Slim 2AA node"), and replaced the nrf24 from my GW with a NRF24L01+PA+LNA.
It's way better
So far, no problem .. I will keep you updated in the following days
Anyway, thanks for your help
what about your nodes after several months ?
I finally have found the problem : I had only Vcc.h in my VCC folder ... So the .cpp file was misisng !!
--> noob alert
@gloob said:
What type of sensors are they? Do they act like simple "switches" or what kind of signal do they offer on the output?
For the door, I assume they are like reed switch (with magnet fixed on the door itself)
For the movement ... I don't know !
@fleinze
Hi, do you think it's possible to connect de Dallas sensor to pin 7, 8 and 9 of the arduino ?
Like this :
#define ONE_WIRE_BUS 8 // Pin where dallase sensor is connected
#define ONE_WIRE_GND 9
#define ONE_WIRE_VCC 7
I have tried, and the temperature is always 85°C ...
Hello @mrc-core
You can use the Vcc.h library, and mesure the voltage without any wire
Hi guys !
I'm trying to convert a temperature sketch with CR2032 battery monitoring, and the OneWire without resistor lib (to avoid the 4.7k resistor attached to the Dallas)
But, it seems I have not well followed the instructions to convert a sketch from 1.5.4 to 2.0, because it won't compile !
Here is the original sketch (1.5) :
// avec mesure de la batterie avec Vcc.h
// ok avec pile CR2032 et docATmega328 8Mhz MYSBootloader et efuse 0x07
// pour DS18B20 SANS resistance
// nécessite la lib OneWire : OneWireNoResistor-master.zip
//
// boards.txt :
//proMYSBL.name=docATmega328 8Mhz MYSBootloader
//proMYSBL.upload.tool=avrdude
//proMYSBL.upload.protocol=arduino
//proMYSBL.upload.maximum_size=30720
//proMYSBL.upload.maximum_data_size=2048
//proMYSBL.upload.speed=115200
//proMYSBL.bootloader.tool=avrdude
//proMYSBL.bootloader.low_fuses=0xE2
//proMYSBL.bootloader.high_fuses=0xDA
//proMYSBL.bootloader.extended_fuses=0x07
//proMYSBL.bootloader.unlock_bits=0x3F
//proMYSBL.bootloader.lock_bits=0x0F
//proMYSBL.bootloader.file=MySBootloader/MYSBootloader.hex
//proMYSBL.build.mcu=atmega328p
//proMYSBL.build.f_cpu=8000000L
//proMYSBL.build.board=AVR_UNO
//proMYSBL.build.core=arduino:arduino
//proMYSBL.build.variant=arduino:standard
#include <MySensor.h>
#include <SPI.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#include <Vcc.h>
#define ONE_WIRE_BUS 4 // Pin where dallase sensor is connected
#define ONE_WIRE_GND 5
#define ONE_WIRE_VCC 3
#define ID_BatPcnt 1
#define ID_Bat 2
#define MAX_ATTACHED_DS18B20 16
// 60000 = 1 minute
// 12000 = 2 minutes
// 300000 = 5 minutes
// 600000 = 10 minutes
#define SLEEP_TIME 300000 // Sleep time between reads (in milliseconds)
const float VccMin = 2.3; // Vcc mini attendu, en Volts.
const float VccMax = 3; // Vcc Maximum attendu, en Volts (2 piles AA neuves)
const float VccCorrection = 2.52/2.6; // calibration : Vcc mesuré au multimètre / Vcc mesuré par l'Arduino par vcc.Read_Volts() dans sketch 1/2
Vcc vcc(VccCorrection);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
MySensor gw;
MyMessage msgBAT_PCNT(ID_BatPcnt,V_VAR1); // on utilise le type V_VAR1 pour le % de charge des piles
MyMessage msgBAT(ID_Bat,V_VAR2); // on utilise le type V_VAR2 pour la tension des piles
float lastTemperature[MAX_ATTACHED_DS18B20];
uint8_t numSensors = 0;
boolean receivedConfig = false;
boolean metric = true;
// Initialize temperature message
MyMessage msg(0, V_TEMP);
int oldvalue = 0;
int node_id = 30; // on donne un ID au node
void setup()
{
// Startup OneWire
#ifdef ONE_WIRE_VCC
pinMode(ONE_WIRE_VCC, OUTPUT);
digitalWrite(ONE_WIRE_VCC, HIGH);
#endif
#ifdef ONE_WIRE_GND
pinMode(ONE_WIRE_GND, OUTPUT);
digitalWrite(ONE_WIRE_GND, LOW);
#endif
analogReference(INTERNAL);
pinMode(BATT_IN_PIN, INPUT);
pinMode(BATT_VCC_PIN, OUTPUT);
digitalWrite(BATT_VCC_PIN, LOW);
sensors.begin();
// Startup and initialize MySensors library. Set callback for incoming messages.
// gw.begin();
gw.begin(NULL, node_id, true);
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("Temperature Sensor", "1.0");
// Fetch the number of attached temperature sensors
numSensors = sensors.getDeviceCount();
sensors.setWaitForConversion(false);//saves a few mAs per read :-) to debug
// Present all sensors to controller
gw.present(ID_BatPcnt, S_CUSTOM); // type S_CUSTOM pour le capteur "% de charge"
gw.present(ID_Bat, S_CUSTOM); // type S_CUSTOM pour le capteur "tension"
for (int i = 0; i < numSensors && i < MAX_ATTACHED_DS18B20; i++) {
gw.present(i, S_TEMP);
}
}
void loop()
{
// Process incoming messages (like config from server)
//gw.process();
// mesure de Vcc
float v = vcc.Read_Volts();
// calcul du % de charge batterie
float p = 100 * ((v - VccMin) / (VccMax - VccMin));
// On envoie les données des capteurs et de l'état de la batterie au Gateway
//gw.sendBatteryLevel(p); // Inutile...
gw.send(msgBAT_PCNT.set(p, 1)); // 1 décimale
gw.send(msgBAT.set(v, 3)); // 2 décimales
// Fetch temperatures from Dallas sensors
// Fetch temperatures from Dallas sensors
sensors.requestTemperatures();
gw.sleep(750);//wait for conversion in sleep mode
// 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>((gw.getConfig().isMetric ? sensors.getTempCByIndex(i) : sensors.getTempFByIndex(i)) * 10.)) / 10.;
// Only send data if temperature has changed and no error
gw.send(msg.setSensor(i).set(temperature, 1));
lastTemperature[i] = temperature;
//if (lastTemperature[i] != temperature && temperature != -127.00) {
// Send in the new temperature
//}
}
gw.sleep(SLEEP_TIME);//wake on interrupt or after sleep-time
}
Here is my "converted" sketch :
// avec mesure de la batterie avec Vcc.h
// ok avec pile CR2032 et docATmega328 8Mhz MYSBootloader et efuse 0x07
// pour DS18B20 SANS resistance
// nécessite la lib OneWire : OneWireNoResistor-master.zip
//
// boards.txt :
//proMYSBL.name=docATmega328 8Mhz MYSBootloader
//proMYSBL.upload.tool=avrdude
//proMYSBL.upload.protocol=arduino
//proMYSBL.upload.maximum_size=30720
//proMYSBL.upload.maximum_data_size=2048
//proMYSBL.upload.speed=115200
//proMYSBL.bootloader.tool=avrdude
//proMYSBL.bootloader.low_fuses=0xE2
//proMYSBL.bootloader.high_fuses=0xDA
//proMYSBL.bootloader.extended_fuses=0x07
//proMYSBL.bootloader.unlock_bits=0x3F
//proMYSBL.bootloader.lock_bits=0x0F
//proMYSBL.bootloader.file=MySBootloader/MYSBootloader.hex
//proMYSBL.build.mcu=atmega328p
//proMYSBL.build.f_cpu=8000000L
//proMYSBL.build.board=AVR_UNO
//proMYSBL.build.core=arduino:arduino
//proMYSBL.build.variant=arduino:standard
#include <MySensors.h>
#include <SPI.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#include <Vcc.h>
#define ONE_WIRE_BUS 4 // Pin where dallase sensor is connected
#define ONE_WIRE_GND 5
#define ONE_WIRE_VCC 3
#define ID_BatPcnt 1
#define ID_Bat 2
#define MAX_ATTACHED_DS18B20 16
#define MY_NODE_ID 123
#define MY_RADIO_NRF24
// 60000 = 1 minute
// 12000 = 2 minutes
// 300000 = 5 minutes
// 600000 = 10 minutes
#define SLEEP_TIME 300000 // Sleep time between reads (in milliseconds)
const float VccMin = 2.3; // Vcc mini attendu, en Volts.
const float VccMax = 3; // Vcc Maximum attendu, en Volts (2 piles AA neuves)
const float VccCorrection = 2.52/2.6; // calibration : Vcc mesuré au multimètre / Vcc mesuré par l'Arduino par vcc.Read_Volts() dans sketch 1/2
Vcc vcc(VccCorrection);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
//MySensor gw;
MyMessage msgBAT_PCNT(ID_BatPcnt,V_VAR1); // on utilise le type V_VAR1 pour le % de charge des piles
MyMessage msgBAT(ID_Bat,V_VAR2); // on utilise le type V_VAR2 pour la tension des piles
float lastTemperature[MAX_ATTACHED_DS18B20];
uint8_t numSensors = 0;
boolean receivedConfig = false;
boolean metric = true;
// Initialize temperature message
MyMessage msg(0, V_TEMP);
int oldvalue = 0;
void before()
{
// Startup up the OneWire library
sensors.begin();
}
void setup()
{
// Startup OneWire
#ifdef ONE_WIRE_VCC
pinMode(ONE_WIRE_VCC, OUTPUT);
digitalWrite(ONE_WIRE_VCC, HIGH);
#endif
#ifdef ONE_WIRE_GND
pinMode(ONE_WIRE_GND, OUTPUT);
digitalWrite(ONE_WIRE_GND, LOW);
#endif
analogReference(INTERNAL);
pinMode(BATT_IN_PIN, INPUT);
pinMode(BATT_VCC_PIN, OUTPUT);
digitalWrite(BATT_VCC_PIN, LOW);
}
void presentation()
{
// Startup and initialize MySensors library. Set callback for incoming messages.
// gw.begin();
//gw.begin(NULL, node_id, true);
// Send the sketch version information to the gateway and Controller
sendSketchInfo("TS sR batt", "2.0");
// Fetch the number of attached temperature sensors
numSensors = sensors.getDeviceCount();
sensors.setWaitForConversion(false);//saves a few mAs per read :-) to debug
// Present all sensors to controller
present(ID_BatPcnt, S_CUSTOM); // type S_CUSTOM pour le capteur "% de charge"
present(ID_Bat, S_CUSTOM); // type S_CUSTOM pour le capteur "tension"
for (int i = 0; i < numSensors && i < MAX_ATTACHED_DS18B20; i++) {
present(i, S_TEMP);
}
}
void loop()
{
// Process incoming messages (like config from server)
//gw.process();
// mesure de Vcc
float v = vcc.Read_Volts();
// calcul du % de charge batterie
float p = 100 * ((v - VccMin) / (VccMax - VccMin));
// On envoie les données des capteurs et de l'état de la batterie au Gateway
//gw.sendBatteryLevel(p); // Inutile...
send(msgBAT_PCNT.set(p, 1)); // 1 décimale
send(msgBAT.set(v, 3)); // 2 décimales
// Fetch temperatures from Dallas sensors
// Fetch temperatures from Dallas sensors
sensors.requestTemperatures();
sleep(750);//wait for conversion in sleep mode
// 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>((gw.getConfig().isMetric ? sensors.getTempCByIndex(i) : sensors.getTempFByIndex(i)) * 10.)) / 10.;
// Only send data if temperature has changed and no error
send(msg.setSensor(i).set(temperature, 1));
lastTemperature[i] = temperature;
//if (lastTemperature[i] != temperature && temperature != -127.00) {
// Send in the new temperature
//}
}
sleep(SLEEP_TIME);//wake on interrupt or after sleep-time
}
And the error given by the Arduino IDE :
In file included from /home/carmelo/Arduino/tmp/tmp_tempbattv2/tmp_tempbattv2.ino:28:0:
/home/carmelo/Arduino/libraries/MySensors/MySensors.h:332:2: error: #error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless.
#error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless.
^
exit status 1
Erreur de compilation pour la carte Arduino Pro or Pro Mini
ok ! I will check the wires and signal output from the movement sensors
@gloob said:
What type of sensors are they? Do they act like simple "switches" or what kind of signal do they offer on the output?
For the door, I assume they are like reed switch (with magnet fixed on the door itself)
For the movement ... I don't know !
Hello,
In my house, I have an old alarm system installed, with :
All the sensors are wired, and all the cables are going un a closet, where the old alarm system is installed.
I don't want to use the old alarm because it is broken, but I want to reuse the sensors. I have electric power in the closet, so it will not be a batteries powered node, so is my idea realisable :
is it correct ?
Thanks a lot for your answer
I must be an idiot but ... I can't compile your sketch ... Which version of MySensors lib are you using ? (I'm with 1.5.4)
Hello,
Is it possible to have 1.5.4 and 2.0 MySensors on the same computer ?
@sghazagh said:
@m26872 Thank you very much mate.
I just added the battery reporting part and it works like a charm.Many many thanks...
Did you add 1MOhm resistor between the Input pin and the reed switch ?