Add radio NRF24 to sketch
-
Hi people. I have a little question to ask. Today I made this sketch for arduino uno. This sketch let me read temperature and humidity on a lcd i2c and it works great. But in this way, it works alone. I would like to connect it to domoticz. So I have to add radio and relative child id
(#define CHILD_ID_HUM 0
#define CHILD_ID_TEMP 1)
to the sketch to connect it in Domoticz.
this is the sketch:
//Libraries
#include <DHT.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>//Constants
#define DHTPIN 4 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino//ALWAYS USE THIS WITH LCD I2C and Addres 0x3F
#define I2C_ADDR 0x3F
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);//Variables
int chk;
float hum; //Stores humidity value
float temp; //Stores temperature valuevoid setup()
{
Serial.begin(9600);
dht.begin();
lcd.begin(16,2);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
}void loop()
{delay(2000);
//Read data and store it to variables hum and temp
hum = dht.readHumidity();
temp = dht.readTemperature();
//Print temp and humidity values to serial monitor
Serial.print("Humidity: ");
Serial.print(hum);
Serial.print(" %, Temp: ");
Serial.print(temp);
Serial.println(" Celsius");lcd.clear();
lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.print(temp);
lcd.print(" ");
lcd.print((char)223);
lcd.print("C");
lcd.setCursor(0,1);
lcd.print("Hum: ");
lcd.print(hum);
lcd.print(" %");delay(2000); //Delay 2 sec.
}
so, can you help me to add radio NRF24 and connect it to domoticz?
Thanks so much from Italy -
Hi people. I have a little question to ask. Today I made this sketch for arduino uno. This sketch let me read temperature and humidity on a lcd i2c and it works great. But in this way, it works alone. I would like to connect it to domoticz. So I have to add radio and relative child id
(#define CHILD_ID_HUM 0
#define CHILD_ID_TEMP 1)
to the sketch to connect it in Domoticz.
this is the sketch:
//Libraries
#include <DHT.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>//Constants
#define DHTPIN 4 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino//ALWAYS USE THIS WITH LCD I2C and Addres 0x3F
#define I2C_ADDR 0x3F
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);//Variables
int chk;
float hum; //Stores humidity value
float temp; //Stores temperature valuevoid setup()
{
Serial.begin(9600);
dht.begin();
lcd.begin(16,2);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
}void loop()
{delay(2000);
//Read data and store it to variables hum and temp
hum = dht.readHumidity();
temp = dht.readTemperature();
//Print temp and humidity values to serial monitor
Serial.print("Humidity: ");
Serial.print(hum);
Serial.print(" %, Temp: ");
Serial.print(temp);
Serial.println(" Celsius");lcd.clear();
lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.print(temp);
lcd.print(" ");
lcd.print((char)223);
lcd.print("C");
lcd.setCursor(0,1);
lcd.print("Hum: ");
lcd.print(hum);
lcd.print(" %");delay(2000); //Delay 2 sec.
}
so, can you help me to add radio NRF24 and connect it to domoticz?
Thanks so much from Italy@jordantheripper Hi!
Check this out: https://www.mysensors.org/about/arduino#basic-structure-of-sketchesYou can also check out any example in https://www.mysensors.org/build to get an idea how it should be written.
Its very easy, just give it a try.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login