Simple Weather Node

Here’s a very simple setup that includes a Moteino with RFM69CW radio and WeatherShield (R2). This setup uses a small LiPo 500mAh battery as power source. A JST connector can be soldered directly to the Moteino GND-VIN pins to accept the typical LiPo battery with a mating connector.

Notice that only the few required header pins need to be soldered for connecting to the Moteino, the others can be left unpopulated.

The Moteino will need at least 3.5V to run above the dropout voltage of the onboard MCP1703 LDO regulator. Whether you use a LiPo battery or any other VIN source (ex. 3xAAA) you should always make sure the polarity is correct to avoid damage to the boards.

Let’s try a simple sketch that will just read the sensor data and voltage monitor and display this to the serial monitor. Make sure you have installed the Sparkfun BME280 library that is required.

//******************************************************************************
//This code is released under the [MIT License](http://opensource.org/licenses/MIT).
//Please review the LICENSE.md file included with this example. If you have any questions 
//or concerns with licensing, please contact techsupport@sparkfun.com.
//Distributed as-is; no warranty is given.
//******************************************************************************
#include  //Get it here: https://github.com/sparkfun/SparkFun_BME280_Arduino_Library
#include 
#include 
//******************************************************************************
#define BATT_MONITOR  A7
#define BATT_FORMULA(reading) reading * 0.00322 * 1.53 //fine tune this to match your Batt Voltage when fully charged
#define SERIAL_BAUD   115200
BME280 bme280;
//******************************************************************************

void setup()
{
  Serial.begin(SERIAL_BAUD);
  Serial.print("Program Started\n");
  Serial.print("Starting BME280... result of .begin(): 0x");
  
  delay(10);  //BME280 requires 2ms to start up.
  
  bme280.settings.commInterface = I2C_MODE;
  bme280.settings.I2CAddress = 0x77;
  bme280.settings.runMode = 3; //Normal mode
  bme280.settings.tStandby = 0;
  bme280.settings.filter = 0;
  bme280.settings.tempOverSample = 1;
  bme280.settings.pressOverSample = 1;
  bme280.settings.humidOverSample = 1;
  bme280.begin();
  
  Serial.print("Chip ID(0xD0): 0x");
  Serial.println(bme280.readRegister(BME280_CHIP_ID_REG), HEX);
  Serial.println(); 
}

char Pstr[10];
char Fstr[10];
char Hstr[10];
char buffer[100];
float batteryVolts = 5;
char BATstr[10];

void loop()
{
  batteryRead();

  bme280.begin();
  dtostrf(bme280.readTempF(), 3,2, Fstr);
  dtostrf(bme280.readFloatHumidity(), 3,2, Hstr);
  dtostrf((bme280.readFloatPressure()/100)*0.0295333727, 3,2, Pstr);
  sprintf(buffer, "Temperature_F:%s  Humidity_%%:%s  Pressure_inHg:%s VIN:%s", Fstr, Hstr, Pstr, BATstr);
  Serial.println(buffer);
  bme280.writeRegister(BME280_CTRL_MEAS_REG, 0x00); //sleep the BME280
  delay(2000);
}

void batteryRead()
{
  unsigned int readings=0;
  for (byte i=0; i<10; i++) //take 10 samples, and average
    readings+=analogRead(BATT_MONITOR);
  batteryVolts = BATT_FORMULA(readings / 10.0);
  dtostrf(batteryVolts, 3,2, BATstr);
}

Load this to your Moteino and you should then see output like this in your serial monitor:

Now let’s try to send this to another Moteino wirelessly. Load this sketch instead, and adjust the settings to match your transceiver hardware. If you have an IoT Gateway setup you will see the new Weather Sensor node pop up in the dashboard as soon as power is applied. Click on that new node, configure it as Weather Sensor, then it will look like this:

In the details, you should see all the details, including the voltage:

After some time collecting data you can start seeing patterns, here’s a day worth of temperature readings:

If you just have another receiving Moteino with RFM69 transceiver on the other end (use this sketch and make sure radio settings match!), you will simply see the message in that receiver’s serial monitor.


You may also find this 3rd party video useful where John shows his WeatherShield + Moteino assembly and setup and data visualization: