sensebox / React-Ardublockly

This repository contains the new senseBox learn- and programming environment powered by google Blockly and React
Apache License 2.0
2 stars 7 forks source link

[Blockly][Codegenerator] CHange SMT50 code for MCU-S2 #311

Closed Thiemann96 closed 2 weeks ago

Thiemann96 commented 3 months ago

Change SMT50 code for the MCU-S2 to;

float getSMT50Temperature(int analogPin){
  float voltage = analogReadMilliVolts(analogPin)/1000.0;
   return (voltage - 0.5) * 100;
}
float getSMT50Moisture(int analogPin){
    float voltage = analogReadMilliVolts(analogPin)/1000.0;
   return (voltage * 50) / 3;
}

Additionally, set analogReadResolution(12); in the setup()

Block description

Describe the current behaviour if the block already exist

Expected block behaviour

Describe how the block should work or which block should be added.

janwirwahn commented 2 months ago

function for soil moisture reading is linear only to 3V, according to SMT50 datasheet. set max value for voltage reading to 3.0V (or 50% volumetric water content)

float getSMT50Moisture(int analogPin){ 
    float voltage = analogReadMilliVolts(analogPin)/1000.0;
    if (voltage >= 3) voltage = 3.0;   
    return (voltage * 50.0) / 3.0;
}