Project showcase
Remote & Base Sensor Station - Now with IoT!

Remote & Base Sensor Station - Now with IoT! © LGPL

This is a project I put together that is basically two sensor stations: a base and a remote station.

  • 2,853 views
  • 2 comments
  • 12 respects

Components and supplies

Apps and online services

About this project

About This Project

This is a project I put together that is basically two sensor stations: a base and a remote station. The base station features the powerhouse of the 'duinos; the almighty MEGA! Its connected to the internet by a ESP8266-01 and connects to the remote station via 2.4GHZ nRF24L01 chips. A DHT22 rides on its back via a proto board that the ESP and nRF chips share with it. The remote station can reach anywhere in my house and relays back its sensor data roughly every 2 min. It features a doughty BMP280 for temperature and barometric pressure data, another strapping young DHT22 sensor for humidity, and between it all, a crafty voltage divider for measuring the ever fleeting 18650 lithium batteries. The batteries I have currently are suffering from fatigue and don't stay around much longer than five to seven days. It took me a couple days of wrestling with the nRF24L01 chips to get them to play nice together but finally got it. I'm currently working on adding in another remote station that feeds its data back to the Mega and runs on battery too hopefully for much longer.

I use the sensor data from this project to feed a couple other projects info as you may have noticed from my other ones. The first set of code if the base station, the second is the remote station.

Mega code:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <CayenneESP8266Shield.h>
#include <DHT.h>
#include <SimpleTimer.h>
#define DHTPIN 7
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;
float dataInfo[6];
float far;
RF24 radio(9, 10);
const uint64_t pipe[2] = {0xE8E8F0F0E1LL, 0xE8E8F0F0E1LL};
float hum1;
float temp1;
char token[] = "your token";
char ssid[] = "your wifi";
char password[] = "password";
#define EspSerial Serial3
ESP8266 wifi(EspSerial);
void setup() {
	Serial.begin(9600);
	delay(10);
	EspSerial.begin(9600);
	delay(10);
	Cayenne.begin(token, wifi, ssid, password);
	radio.begin();
	radio.setDataRate(RF24_250KBPS);
	radio.openReadingPipe(1, pipe[1]);
	radio.openReadingPipe(2, pipe[2]);
	radio.startListening();
	dht.begin();
	timer.setInterval(15000, getTemp);
}
void loop()
{
	Cayenne.run();
	timer.run();
	if ( radio.available() )
		{
			Cayenne.virtualWrite(V0, 1);
			digitalWrite(12, HIGH);
			getData();
		}
}
void getData()
{
	radio.read(&dataInfo, sizeof(dataInfo));
	delay(200);
	digitalWrite(12, LOW);
	Cayenne.virtualWrite(V0, 0);
	far = ((dataInfo[0] * 1.8) + 32);
	Cayenne.virtualWrite(V1, dataInfo[0]);
	Cayenne.virtualWrite(V6, far);
	Cayenne.virtualWrite(V2, dataInfo[1]);
	Cayenne.virtualWrite(V3, dataInfo[2]);
	Cayenne.virtualWrite(V4, dataInfo[3]);
	Cayenne.virtualWrite(V5, dataInfo[4]);
	Cayenne.virtualWrite(V11, dataInfo[4]);
	Cayenne.virtualWrite(V10, dataInfo[2]);
	Cayenne.virtualWrite(V12, far);
}
void getTemp()
{
	temp1 = dht.readTemperature(true);
	delay(100);
	hum1 = dht.readHumidity();
}
CAYENNE_OUT(V13)
{
	Cayenne.virtualWrite(V13, temp1);
	Cayenne.virtualWrite(V15, temp1);
}
CAYENNE_OUT(V14)
{
	Cayenne.virtualWrite(V14, hum1);
	Cayenne.virtualWrite(V16, hum1);
}

Remote Code:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <SimpleTimer.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT22
SimpleTimer timer;
Adafruit_BMP280 bmp;
DHT dht(DHTPIN, DHTTYPE);
RF24 radio(9, 10);
const uint64_t pipe = 0xE8E8F0F0E1LL;
float pressurePa;
float pressureIn;
float temperature; 
int altimeter;
float volts;
float dataInfo[6];
int motion;
int hum;
void setup() {
  Serial.begin(9600);
  bmp.begin();
  dht.begin();
  
  radio.begin();
  radio.setDataRate(RF24_250KBPS);
  radio.openWritingPipe(pipe);
  
  timer.setInterval(300000, getReadings);
}
void loop()
{
   timer.run();
}
void getReadings()
{
//   radio.powerUp();
   pressurePa = bmp.readPressure();
   temperature = bmp.readTemperature();
   altimeter = bmp.readAltitude (1050.35);
   delay(250);
   pressureIn = pressurePa * 0.000295;
   hum = dht.readHumidity();
   delay(250);
   volts = ((analogRead(A2) * (5.0 / 1023.0)) / 0.08933);
  dataInfo[0] = temperature;
  dataInfo[1] = hum;
  dataInfo[2] = pressureIn;
  dataInfo[3] = altimeter;
  dataInfo[4] = volts;
  dataInfo[5] = motion;
  
  radio.write(dataInfo, sizeof(dataInfo));
//  Serial.println(temperature);
//  Serial.println(hum);
//  radio.powerDown();
}

What's Connected

  • Arduino Mega
  • Arduino Nano R3
  • ESP8266-01
  • 2x nRF24L01 RF Chips
  • 2x DHT22 sensors
  • BMP280 sensor
  • 2x 18650 Lipo batts
  • LM1113 v3
  • LDO linear regulator
  • 3D Printed PLA batt holder
  • A couple resistors and a capacitor

Triggers & Alerts

I use the remote temp to trigger my fireplace on and off.

Scheduling

NA - All sensor data

Dashboard Screenshots

Photos of the Project

Code

Code snippet #1Arduino
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <CayenneESP8266Shield.h>
#include <DHT.h>
#include <SimpleTimer.h>

#define DHTPIN 7
#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);

SimpleTimer timer;

float dataInfo[6];
float far;

RF24 radio(9, 10);
const uint64_t pipe[2] = {0xE8E8F0F0E1LL, 0xE8E8F0F0E1LL};

float hum1;
float temp1;


char token[] = "your token";
char ssid[] = "your wifi";
char password[] = "password";

#define EspSerial Serial3
ESP8266 wifi(EspSerial);

void setup() {
	Serial.begin(9600);
	delay(10);

	EspSerial.begin(9600);
	delay(10);

	Cayenne.begin(token, wifi, ssid, password);


	radio.begin();
	radio.setDataRate(RF24_250KBPS);
	radio.openReadingPipe(1, pipe[1]);
	radio.openReadingPipe(2, pipe[2]);
	radio.startListening();


	dht.begin();

	timer.setInterval(15000, getTemp);

}




void loop()
{
	Cayenne.run();
	timer.run();

	if ( radio.available() )
		{
			Cayenne.virtualWrite(V0, 1);
			digitalWrite(12, HIGH);
			getData();
		}
}


void getData()
{
	radio.read(&dataInfo, sizeof(dataInfo));
	delay(200);

	digitalWrite(12, LOW);
	Cayenne.virtualWrite(V0, 0);

	far = ((dataInfo[0] * 1.8) + 32);

	Cayenne.virtualWrite(V1, dataInfo[0]);
	Cayenne.virtualWrite(V6, far);
	Cayenne.virtualWrite(V2, dataInfo[1]);
	Cayenne.virtualWrite(V3, dataInfo[2]);
	Cayenne.virtualWrite(V4, dataInfo[3]);
	Cayenne.virtualWrite(V5, dataInfo[4]);
	Cayenne.virtualWrite(V11, dataInfo[4]);
	Cayenne.virtualWrite(V10, dataInfo[2]);
	Cayenne.virtualWrite(V12, far);
}


void getTemp()
{
	temp1 = dht.readTemperature(true);
	delay(100);
	hum1 = dht.readHumidity();
}



CAYENNE_OUT(V13)
{
	Cayenne.virtualWrite(V13, temp1);
	Cayenne.virtualWrite(V15, temp1);
}

CAYENNE_OUT(V14)
{

	Cayenne.virtualWrite(V14, hum1);
	Cayenne.virtualWrite(V16, hum1);
}
Code snippet #2Arduino
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <SimpleTimer.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
#include <DHT.h>

#define DHTPIN 2
#define DHTTYPE DHT22

SimpleTimer timer;
Adafruit_BMP280 bmp;
DHT dht(DHTPIN, DHTTYPE);

RF24 radio(9, 10);
const uint64_t pipe = 0xE8E8F0F0E1LL;

float pressurePa;
float pressureIn;
float temperature; 
int altimeter;
float volts;
float dataInfo[6];
int motion;
int hum;


void setup() {
  Serial.begin(9600);

  bmp.begin();
  dht.begin();
  
  radio.begin();
  radio.setDataRate(RF24_250KBPS);
  radio.openWritingPipe(pipe);
  
  timer.setInterval(300000, getReadings);
}


void loop()
{
   timer.run();

}

void getReadings()
{
//   radio.powerUp();

   pressurePa = bmp.readPressure();
   temperature = bmp.readTemperature();
   altimeter = bmp.readAltitude (1050.35);
   delay(250);
   pressureIn = pressurePa * 0.000295;

   hum = dht.readHumidity();
   delay(250);
   volts = ((analogRead(A2) * (5.0 / 1023.0)) / 0.08933);

  dataInfo[0] = temperature;
  dataInfo[1] = hum;
  dataInfo[2] = pressureIn;
  dataInfo[3] = altimeter;
  dataInfo[4] = volts;
  dataInfo[5] = motion;
  
  radio.write(dataInfo, sizeof(dataInfo));
//  Serial.println(temperature);
//  Serial.println(hum);
//  radio.powerDown();
}

Comments

Similar projects you might like

Arduino Based Weather Station with Remote Sensor Unit

Project showcase by antiElectron

  • 10,236 views
  • 7 comments
  • 46 respects

Single Device to Control Many Arduinos with NRF24L01+ Sensor

Project showcase by xkid2023

  • 4,278 views
  • 0 comments
  • 22 respects

IoT Fireplace

Project showcase by vapor83

  • 824 views
  • 0 comments
  • 2 respects

Smart Home Using Remote Sensing, Control & Monitoring (IoT)

Project showcase by Mohammed_Hany

  • 1,862 views
  • 0 comments
  • 3 respects

Moisty v2 - a Plant Moisture Sensor

Project showcase by Mitch K

  • 1,772 views
  • 1 comment
  • 13 respects

Bright Ball IoT

Project tutorial by Tittiamo

  • 1,380 views
  • 2 comments
  • 4 respects
Add projectSign up / Login