Handheld Weather Station

by JustMakeStuff in Circuits > Sensors

673 Views, 1 Favorites, 0 Comments

Handheld Weather Station

titleImage.jpeg
E6A572DF-80DF-4B32-A548-160125DD23D8_1_105_c.jpeg
annotated.jpeg
2111515F-0129-48B4-AB08-444E312BAE37_1_105_c.jpeg
55D17F1A-406F-4495-B237-5BC95761809D_1_105_c.jpeg

In this Instructable we will be using an Arduino, an oled display, and a SparkFun environmental sensor combo with CCS811 and BME280 sensors on board to build a handheld device that measures temperature, humidity, TVOC levels, barometric pressure, and carbon dioxide levels. You can use any Arduino with the provided code, but I am using a SparkFun Qwiic pro micro. If you are a beginner, I suggest you use the same parts I am using, just to keep things simple. I chose the SparkFun Qwiic pro micro board for its small size and the Qwiic connector, making it easy to connect your components. If you are using a different board, make sure to buy a Qwiic hat, phat, or shield to fit your board. https://www.sparkfun.com/phats.

Supplies:

Tools:

  • Hot glue sticks and hot glue gun
  • Scissors
  • Razor blade or x-acto knife, capable of cutting through your project box

Mark and Cut Holes and Put in Window Screen

B1E21213-74E6-47E9-BECD-EBA0025D13BE_1_105_c.jpeg
E79ECD1B-7D20-431C-BD57-1A7F8C4E8779_1_105_c.jpeg
C09F7620-301B-4E8E-B5A4-208B093C80C4_1_105_c.jpeg
F96DE8E4-5506-4F00-86B8-F86832E5A33E_1_105_c.jpeg
3EF43D3B-5017-4238-8DE6-4BB992DE3124_1_105_c.jpeg
PickMe.jpeg
D0DDB929-5226-434B-B27A-58981C24A57A_1_105_c.jpeg
621695C3-D7E0-4788-BDB6-9CB698E6C58A_1_105_c.jpeg
8A09820B-E562-4F1E-953A-9AE12E2383CE_1_105_c.jpeg
7B3CCD23-B084-4AC3-AFB3-E1DF5060C29A_1_105_c.jpeg
A00B3AB1-3765-4759-A917-A0DB67A98208_1_105_c.jpeg

We will mark and cut holes for the oled, environmental sensor and USB-C connector for programming and power.

  1. Line up your components where you want them and mark the screw holes.
  2. Mark squares, for the oled, a square the size of the screen and for the environmental sensor, a square a little bigger that the 2 sensors (see pictures above).
  3. Mark the space for the USB-C connector. My Qwiic Pro Micro board had headers soldered on it already so I put in into a piece of foam and marked it. If yours does not, lay it flat against the bottom of the case to mark the hole.
  4. Drill the marked holes and cut out the USB-C connector. The drilled holes should be big enough to let the screws go through.
  5. Cut a square of window screen a little bigger than the hole for the sensor. Cut out space on the window screen for the screw hole and the mounting post (see pictures above).
  6. Hot glue the screen into place.

Mount Oled and Sensor

675AB5D5-DADE-4DCA-8EF0-71FFF9DF3D94_1_201_a.jpeg
A3CECA56-D5D7-44E2-9A96-470F73B439EB_1_105_c.jpeg
C9B6E7D4-D092-4699-B9BF-D3F2A79E24E1_1_105_c.jpeg

Mount the oled and environmental sensor in the case. The bigger screws go in the holes you drilled and the smaller screws go into the posts in the corner of the case lid. Use the washers for spacers. For the bigger screws, see the diagram above for clarification. You may need to use more than one washer for spacing.

Mount Arduino and Connect Components

BAF17049-10BD-498B-B72E-38C754A1BF0B_1_105_c.jpeg
DD9BA00D-6CB7-4134-8E9B-3E8CEDB9AAC6_1_105_c.jpeg
0D5FFEB7-AB2D-4576-B26D-338232CD2371_1_105_c.jpeg
  1. My Qwiic Pro Micro board had headers soldered on it already so I put in into a piece of foam and glued it down. If yours does not have headers, glue it down to the bottom of the case. Ensure that there is enough room for the Qwiic cable to connect.
  2. Connect the components with the Qwiic connectors. Neither the order nor the side the Qwiic connector is on matter. See the pictures above for clarification.
  3. Now you can snap your project box together. Make that the Qwiic cables are connected tightly and do not get pinched.

Code

To get your Qwiic pro micro board up and running follow this tutorial.

Once that's done, the code is below of you can find it on GitHub here.

#include 	
#include
#include
#include

#define PIN_RESET 9
#define DC_JUMPER 1
#define CCS811_ADDR 0x5B //Default I2C Address

MicroOLED oled(PIN_RESET, DC_JUMPER);
CCS811 myCCS811(CCS811_ADDR);
BME280 myBME280;

void setup() {
delay(100);
Wire.begin();
oled.begin(); // Initialize the OLED

oled.clear(ALL); // Clear the display's internal memory
oled.display(); // Display what's in the buffer (splashscreen)
oled.clear(PAGE); // Clear the buffer.

randomSeed(analogRead(A0) + analogRead(A1));
//Initialize BME280
//For I2C, enable the following and disable the SPI section
myBME280.settings.commInterface = I2C_MODE;
myBME280.settings.I2CAddress = 0x77;
myBME280.settings.runMode = 3; //Normal mode
myBME280.settings.tStandby = 0;
myBME280.settings.filter = 4;
myBME280.settings.tempOverSample = 5;
myBME280.settings.pressOverSample = 5;
myBME280.settings.humidOverSample = 5;
CCS811Core::CCS811_Status_e returnCode = myCCS811.beginWithStatus ();
//Calling .begin() causes the settings to be loaded
delay(10); //Make sure sensor had enough time to turn on. BME280 requires 2ms to start up.
byte id = myBME280.begin(); //Returns ID of 0x60 if successful
delay(10000);
}

void print_data() {
oled.setFontType(0);

oled.setCursor(0, 0);
oled.print("TMP");
oled.setCursor(25, 0);
oled.print(round(myBME280.readTempF()));

oled.setCursor(0, 10);
oled.print("HUM");
oled.setCursor(25, 10);
oled.print(round(myBME280.readFloatHumidity()));

oled.setCursor(0, 20);
oled.print("VOC");
oled.setCursor(25, 20);
oled.print(round(myCCS811.getTVOC()));

oled.setCursor(0, 30);
oled.print("BAR");
oled.setCursor(25, 30);
oled.print(round(myBME280.readFloatPressure()));

oled.setCursor(0, 40);
oled.print("CO2");
oled.setCursor(25, 40);
oled.print(round(myCCS811.getCO2()));

oled.display();
}

void loop() {
delay(2000);
//Check to see if data is available
if (myCCS811.dataAvailable()) {
//Calling this function updates the global tVOC and eCO2 variables
myCCS811.readAlgorithmResults();
//printData fetches the values of tVOC and eCO2

float BMEtempC = myBME280.readTempC();
float BMEhumid = myBME280.readFloatHumidity();

//This sends the temperature data to the CCS811
myCCS811.setEnvironmentalData(BMEhumid, BMEtempC);
}
print_data();
delay(2000);
}

Paste the code in the Arduino IDE and compile it. The screen should show the SparkFun logo for a few seconds, and then begin displaying the live conditions. The conditions update about every 2 seconds. Thanks for reading.

Got a Question?

Leave a comment or email me here