How can I record temperature?

Hi, I want to record temperature, pressure and altitude but it-s showing me just 0.00. I am Using Mblocks but you can just use Arduino.

Have you tried de watchX bloc software? You can find it in download section and it works very well

I have tried but it show just 0.00.

Hello Dear Andrei,

Can you please share the watchX Blocks code ?

#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>

#include "watchX.h"
#include <SPI.h>

double angle_rad = PI/180.0;
double angle_deg = 180.0/PI;
unsigned char animation_offsetY=0;
int oledPosX;
int oledPosY;
bool needClear = false;
void writeText(int line, int oledPos, String oledText)
{oledPosY = line * 8;
    oledPosX = (64 - (oledText.length() * 3)) * oledPos;
drawString(oledPosX,oledPosY,oledText.c_str() ,smallFont);}
#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 11
#define BMP_CS 10
Adafruit_BMP280 bme;
float dataBmp_0, dataBmp_1, dataBmp_2;

void setup(){
    SPI.begin();
    ssd1306_configure();
    clearAll();
    bme.begin();
    writeText(0, 0, ((String)"Temp").c_str());
    needClear = true;
    writeText(0, 2, ((String)dataBmp_2).c_str());
    needClear = true;
}

void loop(){
    _loop();
}

void _delay(float seconds){
    long endTime = millis() + seconds * 1000;
    while(millis() < endTime)_loop();
}

void _loop(){
    if(needClear){
        ssd1306_drawBuffer(0, 0, 128,64, mbuf);
        clearAll();
        needClear = false;
    }
    dataBmp_0 = bme.readAltitude(1013.25);
    dataBmp_1 = bme.readPressure();
    dataBmp_2 = bme.readTemperature();
}

Here is the code for Arduino

Hello Dear Andrei please use the watchX Blocks software since we no longer support the mblock software. However based on the screen shot you need to put bottom two blocks inside a forever loop present in Control section. Your code does not get sensor value continuously, it only gets for once and that’s why you see 0 on the display.

1 Like

Thank you for helping me.

1 Like