Tino Hempel
Published © CC BY

Calliope mini und Grove Temperatur Sensor V1.2

Das Projekt erklärt die Berechnung der Temperatur aus den Messdaten des Sensors am Calliope für MakeCode und NEPO.

IntermediateProtip1 hour4,514
Calliope mini und Grove Temperatur Sensor V1.2

Things used in this project

Hardware components

Calliope mini
Calliope mini
×1
Grove - Temperature Sensor
Seeed Studio Grove - Temperature Sensor
×1

Software apps and online services

NEPO Open Roberta Lab
Calliope-PXT/MakeCode

Story

Read more

Custom parts and enclosures

NEPO

Nepo-Datei

PXT

PXT-Datei

Schematics

Schaltung

Code

Nepo

XML
NEPO-Code
<export xmlns="http://de.fhg.iais.roberta.blockly"><program><block_set xmlns="http://de.fhg.iais.roberta.blockly" robottype="calliope" xmlversion="2.0" description="" tags=""><instance x="-231" y="-161"><block type="robControls_start" id="uIlDo@YY+Rn_#Yo,Yhe~" intask="true" deletable="false"><mutation declare="true"></mutation><field name="DEBUG">TRUE</field><statement name="ST"><block type="robGlobalVariables_declare" id="-d-`Z@jRs;[CW`i|7t6w" intask="true" deletable="false" movable="false"><mutation next="true" declaration_type="Number"></mutation><field name="VAR">Temperatur</field><field name="TYPE">Number</field><value name="VALUE"><block type="math_number" id="e*/=`88G%583LOl@bv4G" intask="true"><field name="NUM">0</field></block></value></block><block type="robGlobalVariables_declare" id="!eiGV%:]yZg:6Pqq7-c}" intask="true" deletable="false" movable="false"><mutation next="false" declaration_type="Number"></mutation><field name="VAR">Kehrwert_Temperatur</field><field name="TYPE">Number</field><value name="VALUE"><block type="math_number" id=";,MKv{5OzNs1VAsd.bn," intask="true"><field name="NUM">0</field></block></value></block></statement></block><block type="robControls_loopForever" id="9c^-.)=GqgKpcK0Cyy#F" intask="true"><statement name="DO"><block type="variables_set" id="p+3@N|~tr[d;eo%cOz96" intask="true"><mutation datatype="Number"></mutation><field name="VAR">Kehrwert_Temperatur</field><value name="VALUE"><block type="math_arithmetic" id="e,G`yHSlG3J%8m6!f+}=" intask="true"><field name="OP">ADD</field><value name="A"><block type="math_arithmetic" id="o8ifXuS5mW.(MrtY7NP;" intask="true"><field name="OP">DIVIDE</field><value name="A"><block type="math_number" id="K3?GwJp#}::SMljUu=Q2" intask="true"><field name="NUM">1</field></block></value><value name="B"><block type="math_number" id="VaepNc,IfZ;j){;?Tk*O" intask="true"><field name="NUM">298.15</field></block></value></block></value><value name="B"><block type="math_arithmetic" id="PaMIL7QU?66!uF0{j%P+" intask="true"><field name="OP">DIVIDE</field><value name="A"><block type="math_single" id="*al_8ScpTx7dz=IKMbbi" intask="true"><field name="OP">LN</field><value name="NUM"><block type="math_arithmetic" id="x=LD[DG;-ay?i[)LM831" intask="true"><field name="OP">MINUS</field><value name="A"><block type="math_arithmetic" id="|Y%}N:~4W{|NAt?[!Yz~" intask="true"><field name="OP">DIVIDE</field><value name="A"><block type="math_number" id="RpDwc=lJEyI.I,NEmiT3" intask="true"><field name="NUM">1023</field></block></value><value name="B"><block type="mbedSensors_pin_getSample" id="^{R9huz?#BYVwJz4v_S;" intask="true"><mutation protocol="ANALOG"></mutation><field name="VALUETYPE">ANALOG</field><field name="PIN">5</field></block></value></block></value><value name="B"><block type="math_number" id="Exy6;5n4t;qc02;u:-4u" intask="true"><field name="NUM">1</field></block></value></block></value></block></value><value name="B"><block type="math_number" id="zZ(dCm6Wr6KRTI*#lUKe" intask="true"><field name="NUM">4250</field></block></value></block></value></block></value></block><block type="variables_set" id="3fh2f)8Fh@V.A;^wfr-h" intask="true"><mutation datatype="Number"></mutation><field name="VAR">Temperatur</field><value name="VALUE"><block type="math_arithmetic" id="HW4/rrd%D0AN=%7(fwv:" intask="true"><field name="OP">MINUS</field><value name="A"><block type="math_arithmetic" id="Pm(2n(AZ;16=i%{tQonC" intask="true"><field name="OP">DIVIDE</field><value name="A"><block type="math_number" id="gWWu[kvoZdTy,GWW{lsw" intask="true"><field name="NUM">1</field></block></value><value name="B"><block type="variables_get" id="tR|-M8olO9{Ao3%N.v,," intask="true"><mutation datatype="Number"></mutation><field name="VAR">Kehrwert_Temperatur</field></block></value></block></value><value name="B"><block type="math_number" id="H;4ZCV?[iMbBe|novJ]c" intask="true"><field name="NUM">273.15</field></block></value></block></value></block><block type="mbedActions_display_text" id="J|q-%@`S#0v-c)tv~PU)" intask="true"><field name="TYPE">TEXT</field><value name="OUT"><block type="variables_get" id="5V!ayy{.@v)O^R^2M)[~" intask="true"><mutation datatype="Number"></mutation><field name="VAR">Temperatur</field></block></value></block><block type="robControls_wait_time" id="}P%;w;.lx}4r)EkFKX^-" intask="true"><value name="WAIT"><block type="math_number" id="GykzSn_hMT+D-WTgBln3" intask="true"><field name="NUM">1000</field></block></value></block></statement></block></instance></block_set></program><config><block_set robottype="calliope" xmlversion="2.0" description="" tags="" xmlns="http://de.fhg.iais.roberta.blockly"><instance x="138" y="88"><block type="mbedBrick_Calliope-Brick" id="1" intask="true"></block></instance></block_set></config></export>

NEPO-Code C++

C/C++
NEPO-Code C++
#define _GNU_SOURCE

#include "MicroBit.h" 
#include <array>
#include <stdlib.h>
MicroBit uBit;


int initTime = uBit.systemTime(); 

double Temperatur;
double Kehrwert_Temperatur;
int main() 
{
    uBit.init();
    Temperatur = 0;
    Kehrwert_Temperatur = 0;
    
    while ( true ) {
        Kehrwert_Temperatur = ( 1 / ((float) 298.15) ) + ( log(( 1023 / ((float) uBit.io.P2.getAnalogValue()) ) - 1) / ((float) 4250) );
        Temperatur = ( 1 / ((float) Kehrwert_Temperatur) ) - 273.15;
        uBit.display.scroll(ManagedString(Temperatur));
        uBit.sleep(1000);
        uBit.sleep(1);
    }
    release_fiber();
}

PXT-Code

JavaScript
PXT-Code
let Temperatur = 0
let n = 0
basic.forever(() => {
    n = pins.analogReadPin(AnalogPin.C16)
    if (n >= 270 && n <= 699) {
        Temperatur = pins.map(
            n,
            270,
            699,
            5,
            42
        )
        basic.showNumber(Temperatur)
    } else {
        basic.showString("nicht darstellbar!")
    }
    basic.pause(1000)
})

Credits

Tino Hempel

Tino Hempel

12 projects • 6 followers

Comments