Published © Apache-2.0

Read Temperature, Humidity, Pressure and Display at the Web

No server needed ! Temperature, pressure, humidity displays on your private WebPage at the chart, or display actual measuremen on request.

BeginnerFull instructions provided30 minutes4,695
Read Temperature, Humidity, Pressure and Display at the Web

Things used in this project

Story

Read more

Schematics

Connections

For temperature, pressure and humidity on request green wire is not needed. Green wire is used to self-wakeup ESP

Code

arduino - data on request

Arduino
this file is used for first part of project -data on request
#include <stdint.h>
#include "SparkFunBME280.h"

#include "Wire.h"
#include "SPI.h"

#define WIFI_NAME ""
#define WIFI_PASSWORD ""
#define DEVICE_ID 204
#define DEVICE_NAME "temperatureOnRequest"
#define TOKEN ""

#include <ArduinoHttpClient.h>
#include <RemoteMe.h>
#include <ESP8266WiFi.h>

#include <ESP8266WiFiMulti.h>


ESP8266WiFiMulti WiFiMulti;
RemoteMe& remoteMe = RemoteMe::getInstance(TOKEN, DEVICE_ID);

BME280 mySensor;

// the setup function runs once when you press reset or power the board
void setup() {
	
	mySensor.settings.commInterface = I2C_MODE;
	mySensor.settings.I2CAddress = 0x76;


	//***Operation settings*****************************//

	//runMode can be:
	//  0, Sleep mode
	//  1 or 2, Forced mode
	//  3, Normal mode
	mySensor.settings.runMode = 3; //Forced mode

								   //tStandby can be:
								   //  0, 0.5ms
								   //  1, 62.5ms
								   //  2, 125ms
								   //  3, 250ms
								   //  4, 500ms
								   //  5, 1000ms
								   //  6, 10ms
								   //  7, 20ms
	mySensor.settings.tStandby = 0;

	//filter can be off or number of FIR coefficients to use:
	//  0, filter off
	//  1, coefficients = 2
	//  2, coefficients = 4
	//  3, coefficients = 8
	//  4, coefficients = 16
	mySensor.settings.filter = 0;

	//tempOverSample can be:
	//  0, skipped
	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
	mySensor.settings.tempOverSample = 1;

	//pressOverSample can be:
	//  0, skipped
	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
	mySensor.settings.pressOverSample = 1;

	//humidOverSample can be:
	//  0, skipped
	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
	mySensor.settings.humidOverSample = 1;
	delay(10);  //Make sure sensor had enough time to turn on. BME280 requires 2ms to start up.         Serial.begin(57600);

	mySensor.begin();

	//--------
	WiFiMulti.addAP(WIFI_NAME, WIFI_PASSWORD);
	while (WiFiMulti.run() != WL_CONNECTED) {
		delay(100);
	}

	remoteMe.setUserSyncMessageListener(onUserSyncMessage);
	remoteMe.setupTwoWayCommunication();

	remoteMe.sendRegisterDeviceMessage(DEVICE_NAME);

	
}


void onUserSyncMessage(uint16_t senderDeviceId, uint16_t dataSize, uint8_t* data, uint16_t &returnDataSize, uint8_t *&returnData)
{
	uint16_t pos = 0;

	returnDataSize = 12;//3 data each float so 4 bytes
	returnData = (uint8_t*)malloc(returnDataSize);
	

	RemoteMeMessagesUtils::putFloat(returnData,pos, (mySensor.readTempC()));
	RemoteMeMessagesUtils::putFloat(returnData, pos, (mySensor.readFloatPressure() ));
	RemoteMeMessagesUtils::putFloat(returnData, pos, (mySensor.readFloatHumidity() ));
	
}


void loop()
{
	remoteMe.loop();
}

arduino - data into chart

Arduino
this file is used for second part of project - sending data into server
#define WIFI_NAME "ania24"
#define WIFI_PASSWORD "tuchowkrakow"
#define DEVICE_ID 2045
#define DEVICE_NAME "Weather Station"
#define TOKEN "~5335_Xy7sIFKNpSVj("

#define WEBPAGE_DEVICE_ID 1001


#include <stdint.h>
#include "SparkFunBME280.h"

#include "Wire.h"
#include "SPI.h"



#include <ArduinoHttpClient.h>
#include <RemoteMe.h>
#include <ESP8266WiFi.h>

#include <ESP8266WiFiMulti.h>

ESP8266WiFiMulti WiFiMulti;
RemoteMe& remoteMe = RemoteMe::getInstance(TOKEN, DEVICE_ID);

BME280 mySensor;





void sort(double a[], int size) {
    for(int i=0; i<(size-1); i++) {
        for(int o=0; o<(size-(i+1)); o++) {
                if(a[o] > a[o+1]) {
                    double t = a[o];
                    a[o] = a[o+1];
                    a[o+1] = t;
                }
        }
    }
}



// the setup function runs once when you press reset or power the board
void setup() {
  
  Serial.begin(9600);
 while(!Serial){
  ;
  }

  
  
  //--------
  
  WiFiMulti.addAP(WIFI_NAME, WIFI_PASSWORD);
  while (WiFiMulti.run() != WL_CONNECTED) {
    delay(100);
  }


    remoteMe.setupTwoWayCommunication();


    remoteMe.sendRegisterDeviceMessage(DEVICE_NAME);

  

    mySensor.settings.commInterface = I2C_MODE;
    mySensor.settings.I2CAddress = 0x76;
  
  
    //***Operation settings*****************************//
  
    //runMode can be:
    //  0, Sleep mode
    //  1 or 2, Forced mode
    //  3, Normal mode
    mySensor.settings.runMode = 3; //Forced mode
  
                     //tStandby can be:
                     //  0, 0.5ms
                     //  1, 62.5ms
                     //  2, 125ms
                     //  3, 250ms
                     //  4, 500ms
                     //  5, 1000ms
                     //  6, 10ms
                     //  7, 20ms
    mySensor.settings.tStandby = 0;
  
   
    mySensor.settings.filter = 4;
  
   
    mySensor.settings.tempOverSample = 5;
    mySensor.settings.pressOverSample = 5;
    mySensor.settings.humidOverSample = 5;
   
   
   mySensor.begin();
 

  
}

void loop(){
  
  
  double temp[10];
  double pressure[10];
  double humm[10];
  for(int i=0;i<9;i++){
    temp[i]= mySensor.readTempC();
    pressure[i]= mySensor.readFloatPressure();
    humm[i]= mySensor.readFloatHumidity();
    delay(100);
  }

  sort(temp,10);
  sort(humm,10);
  sort(pressure,10);




    remoteMe.sendAddDataMessage(1, RemotemeStructures::_5M, 0, temp[5]);
    remoteMe.sendAddDataMessage(2, RemotemeStructures::_5M, 0, pressure[5]);
    remoteMe.sendAddDataMessage(3, RemotemeStructures::_5M, 0,humm[5]);

    remoteMe.disconnect();
  
    ESP.deepSleep(1e6*60*4);//4min

  
}

webPage - first part of project - data on request

Just drag drop files from repository into you webPage device at RemoteMe

webPage - second part or project- saving data int database

Just drag drop files from repository into you webPage device at RemoteMe

Credits

Comments