KalbeAbbas
Published © MIT

Advanced Weather Station with XinaBox and Ubidots

Learn how to make your own weather station that displays weather values on xChip OLED OD01. Also, the weather values can be viewed remotely.

BeginnerFull instructions provided15 minutes1,279
Advanced Weather Station with XinaBox and Ubidots

Things used in this project

Hardware components

CW01
XinaBox CW01
×1
IP01
XinaBox IP01
×1
OD01
XinaBox OD01
×1
SL01
XinaBox SL01
×1
SW01
XinaBox SW01
×1
XC10
XinaBox XC10
×1
(Optional) USB cable extension
×1

Software apps and online services

Arduino IDE
Arduino IDE
Ubidots
Ubidots

Story

Read more

Code

Weather Station Arduino Code

Arduino
#include "UbidotsMicroESP8266.h"

#define TOKEN  ""  // Put here your Ubidots TOKEN
#define WIFISSID "" // Put here your Wi-Fi SSID
#define PASSWORD "" // Put here your Wi-Fi password

Ubidots client(TOKEN);

#include <xCore.h>
#include <xOD01.h>
#include <xSL01.h>
#include <xSW01.h>

const int DELAY_TIME = 2000;

xSW01 SW01;
xSL01 SL01;
xOD01 OD01;

char *temp;

void setup() {
  // Starts the I2C communication
Serial.begin(115200);
client.wifiConnection(WIFISSID, PASSWORD);
#ifdef ESP8266
  Wire.pins(2, 14);
#endif
  Wire.begin();
  
  // Start the OLED Display OD01
  OD01.begin();

  // Start the  SW01 Sensor
  SW01.begin();
  
  // Start the  SL01 Sensor
  SL01.begin();
   
  // send command to clear the display
  OD01.clear();

  delay(DELAY_TIME);
}

void loop() {
  // Create a variable to store the data read from SL01
  float uva,uvb,lux;
  float tempC,humidity,pressure,alt;
  
  uva = 0;
  uvb = 0;
  lux = 0;

  tempC = 0;
  humidity = 0;
  pressure = 0;
  alt = 0;

  // Poll Sensor for collect data
  SW01.poll();
  SL01.poll();

  
  tempC = SW01.getTempC(); // Temperature in Celcuis
  humidity = SW01.getHumidity();
  pressure = SW01.getPressure();
  uva = SL01.getUVA();
  lux = SL01.getLUX();
  
  //Display readings on OD01

  OD01.clear(); //send command to clear display
  
  OD01.print("Temperature: ");OD01.print(tempC);OD01.println(" C");
  OD01.print("Humidity: ");OD01.print(humidity);OD01.println(" %");
  OD01.print("Pressure: ");OD01.print(pressure);OD01.println("Pa");
  OD01.print("UVA:");OD01.print(uva);OD01.println("mW/m^2");
  OD01.print("LUX: ");OD01.print(lux);OD01.println(" lx");
  
  //Upload dots to Ubidots

  client.add("Temperature (*C)",tempC);
  client.add("Humidity (%)",humidity);
  client.add("Pressure (Pa)",pressure);
  client.add("UVA (uW/cm^2)",uva);
  client.add("Amb. Light (LUX)",lux);

  client.sendAll(true);
  
  // delay between sensor reads, Set for your own choice 1sec=10000msec
  delay(30000);  
}

Credits

KalbeAbbas

KalbeAbbas

25 projects • 20 followers
An enthusiastic and dedicated Electronic engineer graduated from SSUET Karachi, Pakistan. Loves to discover Embedded electronics projects.
Thanks to XinaBox.

Comments