Skip to content
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
M

Markus.

@Markus.
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store
About
Posts
56
Topics
7
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Soil moisture sensor - strange readings
    M Markus.

    now it Looks better :-)
    reversed D2 and D6

    D2 -> Input 10K resistor-> Output 10K Input Fork and A1-> Output fork -> D6
    The values now makes sense :-)
    However...Would be great if someone can have a look on the Sketch because Ihave removed the OTA part and not sure If it was correct on this way.

    Many thanks
    Markus

    Hardware

  • Soil moisture sensor - strange readings
    M Markus.

    Well its measuring "something"

    Fork in water
    Value1=0 1.00
    Value2=730 33.95

    Fork dry
    Value1=218 27.25
    Value2=0 100.00

    Hardware

  • Soil moisture sensor - strange readings
    M Markus.

    Would be great If someone can check this Sketch.Because its giving me Always the same results

    Value1=219 27.37
    Value2=0 100.00
    Result = 63.69% (6.51cb)
    VCC = 3.39 Volts
    VCC% = 32 %
    
    #define MY_DEBUG
    #define MY_SPECIAL_DEBUG
    #define MY_SIGNAL_REPORT_ENABLED
    
    // Enable and select radio type attached 
    //#define MY_RADIO_NRF24
    #define MY_RADIO_RFM69
    //#define MY_RS485
    #define MY_RFM69_FREQUENCY RFM69_868MHZ
    
    #define MY_BAUD_RATE 38400
    
    #include <MySensors.h>
    #include <SPI.h>
    #include <Vcc.h>
    #include <Streaming.h>
    #include <math.h>
    
    //#define SLEEP_TIME_15min  900000    // 15min x 60s = 900000 ms -13% = 783000                (my arduinos show a delay of 8s/min = 13%)
    #define SLEEP_TIME_15min  5000
    #define SLEEP_TIME_1h     3600000   // 1 h = 1*60*60000 = 3600000 ms -13% = 3132000 ms
    #define SLEEP_TIME_2h     7200000   // 2 h = 2*60*60000 = 7200000 ms -13% = 6264000 ms
    #define SLEEP_TIME_3h     10800000  // 3 h = 3*60*60000 = 10800000 ms -13% = 9396000 ms
    
    #define VERSION "3.0"
    #define PIN_ALIM1 2                                   // Connect to input of resistor
    #define PIN_ALIM2 6                                   // Connect to input of measuring probe
    #define PIN_LECTURA A1
    
    #define AGUA_DIR            800.0
    #define AGUA_INV            160.0
    #define AIRE_DIR            0.0
    #define AIRE_INV            1023.0
    #define TIEMPO_LECTURA      10
    #define MAX_REP_LECTURA     20
    #define MAX_REPORTING_LOOPS 4
    
    // Battery calibration (Li-ion)
    const float VccMin   = 3.0;                         // Minimum expected Vcc level, in Volts.
    const float VccMax   = 4.2;                         // Maximum expected Vcc level, in Volts.
    const float VccCorrection = 3.82/3.74;              // Measured Vcc by multimeter divided by reported Vcc
    
    #define CHILD_MOIST_ID 1
    MyMessage msgmoist(CHILD_MOIST_ID, V_LEVEL);
    Vcc vcc(VccCorrection);
    
    int count=0;
    signed int oldv1=0, oldv2=0;
    float oldresultcb=0;
    
    void setup() {
    #ifdef MY_DEBUG
      Serial.begin(38400);
    #endif
      analogReference(DEFAULT);
      pinMode(PIN_LECTURA, INPUT);
      pinMode(PIN_ALIM1, OUTPUT);
      pinMode(PIN_ALIM2, OUTPUT);
    }
    
    void presentation(){
        sendSketchInfo("Sensor de humedad", VERSION);
        present(CHILD_MOIST_ID, S_MOISTURE, "Humedad suelo");
    }
    
    void loop()
    {
      {
       signed int value1=0, value2=0, i=0;
        float result1, result2, resultp, resultcb;
    
        //Loop until readings are stable or max number of readings is reached
        do {
          oldv1=value1; oldv2=value2;
          wait(TIEMPO_LECTURA);
          digitalWrite(PIN_ALIM1, HIGH);
          digitalWrite(PIN_ALIM2, LOW);
          wait(TIEMPO_LECTURA);
          value1 = analogRead(PIN_LECTURA);
    
          digitalWrite(PIN_ALIM1, LOW);
          digitalWrite(PIN_ALIM2, HIGH);
          wait(TIEMPO_LECTURA);
          value2 = analogRead(PIN_LECTURA);;
          digitalWrite(PIN_ALIM1, LOW);
          digitalWrite(PIN_ALIM2, LOW);
        } while (((oldv1 != value1) && (oldv2 != value2)) || (i == MAX_REP_LECTURA));
    
    /*
          0-10 Saturated Soil. Occurs for a day or two after irrigation 
          10-20 Soil is adequately wet (except coarse sands which are drying out at this range) 
          20-60 Usual range to irrigate or water (most soils except heavy clay soils). 
          60-100 Usual range to irrigate heavy clay soils 
          100-200 Soil is becoming dangerously dry
        */
        result1=constrain(value1/(AGUA_DIR-AIRE_DIR)*100.0, 1, 100);
        result2=constrain(100-(value2-AGUA_INV)/(AIRE_INV-AGUA_INV)*100.0,1,100);
        resultp = (result1+result2)/2.0;
        resultcb = resultcb + constrain(square((-2.96699 + 351.395/resultp)),0,200);                           //Equation fit using stat software
        count++;
      
        //Send the data - only if moisture changed to save battery (send anyways once every 4 readings). If moisture sent, send battery level.
        if ((oldresultcb!=resultcb) || (count==MAX_REPORTING_LOOPS)) {
          send(msgmoist.set((unsigned int)resultcb));
          oldresultcb=resultcb;
          //Measure battery voltage and send level
          float v = vcc.Read_Volts();  
          int p = vcc.Read_Perc(VccMin, VccMax);
          p=constrain(p,0,100);
          sendBatteryLevel(p);
          #ifdef MY_DEBUG
            Serial << "Value1=" << value1 << " " << result1 << endl << "Value2=" << value2 << " " << result2 << endl << "Result = " << resultp << "% (" << resultcb << "cb)" << endl;
            Serial << "VCC = " << v << " Volts" << endl << "VCC% = " << p << " %" << endl;
          #endif
        }
      
        if (count==MAX_REPORTING_LOOPS) count=0;
        //sleep(SLEEP_TIME_3h, true);
        sleep(SLEEP_TIME_15min, true);
      }
    }
    

    its connected on following Schema

    D2 -> Input 10K resistor-> Output 10K Input Fork and A1-> Output fork -> D6
    I am using a Adruino pro mini 3,3V on an Easy PCB Board.

    Many thanks

    Markus

    Hardware

  • Soil moisture sensor - strange readings
    M Markus.

    @manutremo
    ….I used two digital pins (4 and 7 in my case) which I enable and disable so I can polarize the fork in one direction or the opposite. Be aware that the resistor should be connected to pin in this case, and the fork to pin 7; otherwise the formula of the voltage divider needs to be modified..

    Hi Manutremo,
    The resistor must be connected to D4 in your example? and the fork "end" to D7? The sampling pint then to A0? Or a equivalent Analog Input..?

    Thanks

    Markus

    Hardware

  • Mulitple Gatways and NodeID0
    M Markus.

    Hi All,
    I have two Gateways connected to one Controller and I want to attach on each Gateway, which have different Radios, a sensor. I know always NodeID 0 is assigned to a sensor attached to the Gateways.
    Is there any chance to give a sensor attached to the Gateway another NodeID?
    Thanks

    Markus

    General Discussion

  • Serial Gateway Sketch with si7021
    M Markus.

    @gohan ;-) will try it.... -> Learning leasson... :-)

    General Discussion

  • Serial Gateway Sketch with si7021
    M Markus.

    the sensor conenction was the Problem at the end. Changed SCD and SCL and now it Looks good so far. At the Moment is the Gateway not connected to a Controller. Hope the sensor will be then also send the values...

     __  __       ____
    |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
    | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
    | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
    |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
            |___/                      2.2.0-beta
    
    0;255;3;0;9;53 MCO:BGN:INIT GW,CP=RRNGA---,VER=2.2.0-beta
    0;255;3;0;9;83 TSM:INIT
    0;255;3;0;9;92 TSF:WUR:MS=0
    0;255;3;0;9;100 TSM:INIT:TSP OK
    0;255;3;0;9;108 TSM:INIT:GW MODE
    0;255;3;0;9;118 TSM:READY:ID=0,PAR=0,DIS=0
    0;255;3;0;9;129 MCO:REG:NOT NEEDED
    0;255;3;0;14;Gateway startup complete.
    0;255;0;0;18;2.2.0-beta
    0;255;3;0;11;Gateway_SI7021
    0;255;3;0;12;1.0 161017
    0;0;0;0;6;
    0;1;0;0;7;
    0;255;3;0;9;159 MCO:BGN:STP
    Serial started
    Node and 2 children presented.
    0;255;3;0;9;684 MCO:BGN:INIT OK,TSP=1
    Loop1 started
    T: 21.49
    TempDiff :121.49
    0;0;1;0;0;21.5
    T sent!
    H: 64
    HumDiff  :164.00
    0;1;1;0;1;64
    H sent!
    Before first sleep
    0;255;3;0;9;733 MCO:SLP:MS=300000,SMS=0,I1=255,M1=255,I2=255,M2=255
    0;255;3;0;9;768 !MCO:SLP:REP
    0;255;3;0;9;124672 TSF:MSG:READ,106-106-0,s=0,c=1,t=1,pt=7,l=5,sg=0:63.3
    106;0;1;0;1;63.3
    0;255;3;0;9;124702 TSF:MSG:READ,106-106-0,s=255,c=3,t=0,pt=1,l=1,sg=0:90
    106;255;3;0;0;90
    0;255;3;0;9;124735 TSF:MSG:READ,106-106-0,s=3,c=1,t=38,pt=7,l=5,sg=0:3.71
    106;3;1;0;38;3.71
    After first sleep
    Loop1 started
    T: 21.64
    TempDiff :0.15
    H: 65
    HumDiff  :0.00
    Before first sleep
    0;255;3;0;9;300797 MCO:SLP:MS=300000,SMS=0,I1=255,M1=255,I2=255,M2=255
    0;255;3;0;9;300830 !MCO:SLP:REP
    0;255;3;0;9;428443 TSF:MSG:READ,106-106-0,s=255,c=3,t=0,pt=1,l=1,sg=0:90
    106;255;3;0;0;90
    0;255;3;0;9;428476 TSF:MSG:READ,106-106-0,s=3,c=1,t=38,pt=7,l=5,sg=0:3.72
    106;3;1;0;38;3.72
    

    But how can I prevent the Situation that a defect or missing sensor on the Gateway blocks also the Gateway function ?

    Thanks

    Markus

    General Discussion

  • Serial Gateway Sketch with si7021
    M Markus.

    the Code stops here

    si7021_env data = humiditySensor.getHumidityAndTemperature();
    

    Anything wrong with the sensor I guess. But how can I handle such things?

    General Discussion

  • Serial Gateway Sketch with si7021
    M Markus.

    @gohan how can i do this ? :-(

    General Discussion

  • Serial Gateway Sketch with si7021
    M Markus.

    tried now the Sketch... Seems that something is wrong with the sensor.

     __  __       ____
    |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
    | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
    | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
    |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
            |___/                      2.2.0-beta
    
    0;255;3;0;9;53 MCO:BGN:INIT GW,CP=RRNGA---,VER=2.2.0-beta
    0;255;3;0;9;83 TSM:INIT
    0;255;3;0;9;92 TSF:WUR:MS=0
    0;255;3;0;9;100 TSM:INIT:TSP OK
    0;255;3;0;9;108 TSM:INIT:GW MODE
    0;255;3;0;9;118 TSM:READY:ID=0,PAR=0,DIS=0
    0;255;3;0;9;129 MCO:REG:NOT NEEDED
    0;255;3;0;14;Gateway startup complete.
    0;255;0;0;18;2.2.0-beta
    0;255;3;0;11;Gateway_SI7021
    0;255;3;0;12;1.0 161017
    0;0;0;0;6;
    0;1;0;0;7;
    0;255;3;0;9;159 MCO:BGN:STP
    Serial started
    Node and 2 children presented.
    0;255;3;0;9;684 MCO:BGN:INIT OK,TSP=1
    

    Also the issue with the attached sensor blocks completly the Gateway function.Means that the Gateway didn't receive anything. Is it possible to prevent such issue? what I mean, is it possible to seperate both functions in the Sketch in that way If something is wrong with the sensor, the Gateway can still operate?
    THX
    Markus

    General Discussion

  • Serial Gateway Sketch with si7021
    M Markus.

    not yet ;-) Will try it later....

    General Discussion

  • Serial Gateway Sketch with si7021
    M Markus.

    can it work like this?

    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    
    // Enable and select radio type attached
    #define MY_RADIO_RFM69
    #define MY_RFM69_FREQUENCY RFM69_868MHZ
    
    #include <Wire.h>
    #include <SI7021.h>
    #include <SPI.h>
    #include <RunningAverage.h>
    
    
    #ifdef MY_DEBUG
    #define DEBUG_SERIAL(x) Serial.begin(x)
    #define DEBUG_PRINT(x) Serial.print(x)
    #define DEBUG_PRINTLN(x) Serial.println(x)
    #else
    #define DEBUG_SERIAL(x)
    #define DEBUG_PRINT(x) 
    #define DEBUG_PRINTLN(x) 
    #endif
    
    #define CHILD_ID_TEMP 0
    #define CHILD_ID_HUM 1
    // #define SLEEP_TIME 15000 // 15s for DEBUG
    #define SLEEP_TIME 300000   // 5 min
    #define FORCE_TRANSMIT_CYCLE 36  // 5min*12=1/hour, 5min*36=1/3hour 
    #define HUMI_TRANSMIT_THRESHOLD 3.0  // THRESHOLD tells how much the value should have changed since last time it was transmitted.
    #define TEMP_TRANSMIT_THRESHOLD 0.5
    #define AVERAGES 2
    
    int measureCount = 0;
    float lastTemperature = -100;
    int lastHumidity = -100;
    
    RunningAverage raHum(AVERAGES);
    SI7021 humiditySensor;
    
    
    // Enable serial gateway
    #define MY_GATEWAY_SERIAL
    
    // Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
    #if F_CPU == 8000000L
    #define MY_BAUD_RATE 38400
    #endif
    
    // Enable inclusion mode
    #define MY_INCLUSION_MODE_FEATURE
    
    // Set inclusion mode duration (in seconds)
    #define MY_INCLUSION_MODE_DURATION 60
    
    // Set blinking period
    #define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    // Inverses the behavior of leds
    //#define MY_WITH_LEDS_BLINKING_INVERSE
    
    // Flash leds on rx/tx/err
    // Uncomment to override default HW configurations
    //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
    //#define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
    //#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED
    
    #include <MySensors.h>
    
    MyMessage msgTemp(CHILD_ID_TEMP,V_TEMP); // Initialize temperature message
    MyMessage msgHum(CHILD_ID_HUM,V_HUM);
    
    
    void setup()
    {
      DEBUG_SERIAL(38400);    // <<<<<<<<<<<<<<<<<<<<<<<<<< Note BAUD_RATE in MySensors.h
      DEBUG_PRINTLN("Serial started");
      delay(500); // Allow time for radio if power useed as reset
      DEBUG_PRINT("Node and "); DEBUG_PRINTLN("2 children presented.");
       raHum.clear();
      
    }
    
    void presentation()
    { 
      sendSketchInfo("Gateway_SI7021", "1.0 161017");
      present(CHILD_ID_TEMP, S_TEMP);   // Present sensor to controller
      present(CHILD_ID_HUM, S_HUM);
    }
    
    
    void loop()
    { 
    
      measureCount ++;
      bool forceTransmit = false;
      
      if (measureCount > FORCE_TRANSMIT_CYCLE) {
        forceTransmit = true; 
      }
      sendTempHumidityMeasurements(forceTransmit);
    /*
      // Read and print internal temp
      float temperature0 = static_cast<float>(static_cast<int>((GetInternalTemp()+0.5) * 10.)) / 10.;
      DEBUG_PRINT("Internal Temp: "); DEBUG_PRINT(temperature0); DEBUG_PRINTLN(" *C");        
    */
     
      sleep(SLEEP_TIME);
    }
    
    /*********************************************
     * * Sends temperature and humidity from Si7021 sensor
     * Parameters
     * - force : Forces transmission of a value (even if it's the same as previous measurement)
     *********************************************/
    void sendTempHumidityMeasurements(bool force) {
      bool tx = force;
    
      si7021_env data = humiditySensor.getHumidityAndTemperature();
      
      float temperature = data.celsiusHundredths / 100.0;
      DEBUG_PRINT("T: ");DEBUG_PRINTLN(temperature);
      float diffTemp = abs(lastTemperature - temperature);
      DEBUG_PRINT(F("TempDiff :"));DEBUG_PRINTLN(diffTemp);
      if (diffTemp > TEMP_TRANSMIT_THRESHOLD || tx) {
        send(msgTemp.set(temperature,1));
        lastTemperature = temperature;
        measureCount = 0;
        DEBUG_PRINTLN("T sent!");
      }
      
      int humidity = data.humidityPercent;
      DEBUG_PRINT("H: ");DEBUG_PRINTLN(humidity);
      raHum.addValue(humidity);
      humidity = raHum.getAverage();  // MA sample imply reasonable fast sample frequency
      float diffHum = abs(lastHumidity - humidity);  
      DEBUG_PRINT(F("HumDiff  :"));DEBUG_PRINTLN(diffHum); 
      if (diffHum > HUMI_TRANSMIT_THRESHOLD || tx) {
        send(msgHum.set(humidity));
        lastHumidity = humidity;
        measureCount = 0;
        DEBUG_PRINTLN("H sent!");
      }
    
    }
    
    
    General Discussion

  • Serial Gateway Sketch with si7021
    M Markus.

    the Problem is I cnnaot find any simple Mysensors Sketch to read a SI7021 :-(
    Only with battery Monitoring which I don't Need...

    General Discussion

  • Serial Gateway Sketch with si7021
    M Markus.

    Did a mistake with the Libary. Used now the SI7021 from MySensorsArduinoExamples-master and this seems to be okay now

    General Discussion

  • Serial Gateway Sketch with si7021
    M Markus.

    Well the Problem seems to be in the first step to get a working SI7021 Sketch for MySensors 2.2.0 Beta or 2.1.1.
    I did Try to complie this one now:

    /* Sketch with Si7021 and battery monitoring.
    by m26872, 20151109 
    */
    
    #define MY_DEBUG
    #define MY_RADIO_NRF24
    #define MY_NODE_ID 5             // <<<<<<<<<<<<<<<<<<<<<<<<<<<   Enter Node_ID
    #define MY_BAUD_RATE 115200
    
    #include <MySensors.h>  
    #include <Wire.h>
    #include <SI7021.h>
    #include <SPI.h>
    #include <RunningAverage.h>
    
    //#define DEBUG
    
    #ifdef DEBUG
    #define DEBUG_SERIAL(x) Serial.begin(x)
    #define DEBUG_PRINT(x) Serial.print(x)
    #define DEBUG_PRINTLN(x) Serial.println(x)
    #else
    #define DEBUG_SERIAL(x)
    #define DEBUG_PRINT(x) 
    #define DEBUG_PRINTLN(x) 
    #endif
    
    #define CHILD_ID_TEMP 0
    #define CHILD_ID_HUM 1
    // #define SLEEP_TIME 15000 // 15s for DEBUG
    #define SLEEP_TIME 300000   // 5 min
    #define FORCE_TRANSMIT_CYCLE 36  // 5min*12=1/hour, 5min*36=1/3hour 
    #define BATTERY_REPORT_CYCLE 2880   // Once per 5min   =>   12*24*7 = 2016 (one report/week)
    #define VMIN 1900
    #define VMAX 3300
    #define HUMI_TRANSMIT_THRESHOLD 3.0  // THRESHOLD tells how much the value should have changed since last time it was transmitted.
    #define TEMP_TRANSMIT_THRESHOLD 0.5
    #define AVERAGES 2
    
    int batteryReportCounter = BATTERY_REPORT_CYCLE - 1;  // to make it report the first time.
    int measureCount = 0;
    float lastTemperature = -100;
    int lastHumidity = -100;
    
    RunningAverage raHum(AVERAGES);
    SI7021 humiditySensor;
    
    MyMessage msgTemp(CHILD_ID_TEMP,V_TEMP); // Initialize temperature message
    MyMessage msgHum(CHILD_ID_HUM,V_HUM);
    
    
    void presentation()  
    { 
      sendSketchInfo("EgTmpHumBat5min", "1.0 151106");
      present(CHILD_ID_TEMP, S_TEMP);   // Present sensor to controller
      present(CHILD_ID_HUM, S_HUM);
    }
    
    
    void setup() {
      DEBUG_SERIAL(115200);    // <<<<<<<<<<<<<<<<<<<<<<<<<< Note BAUD_RATE in MySensors.h
      DEBUG_PRINTLN("Serial started");
      
      DEBUG_PRINT("Voltage: ");
      DEBUG_PRINT(readVcc()); 
      DEBUG_PRINTLN(" mV");
    /*
      delay(500);
      DEBUG_PRINT("Internal temp: ");
      DEBUG_PRINT(GetInternalTemp()); // Probably not calibrated. Just to print something.
      DEBUG_PRINTLN(" *C");
    */  
      delay(500); // Allow time for radio if power useed as reset
      DEBUG_PRINT("Node and "); DEBUG_PRINTLN("2 children presented.");
      
      raHum.clear();
      
    }
    
    void loop() { 
    
      measureCount ++;
      batteryReportCounter ++;
      bool forceTransmit = false;
      
      if (measureCount > FORCE_TRANSMIT_CYCLE) {
        forceTransmit = true; 
      }
      sendTempHumidityMeasurements(forceTransmit);
    /*
      // Read and print internal temp
      float temperature0 = static_cast<float>(static_cast<int>((GetInternalTemp()+0.5) * 10.)) / 10.;
      DEBUG_PRINT("Internal Temp: "); DEBUG_PRINT(temperature0); DEBUG_PRINTLN(" *C");        
    */
      // Check battery
      if (batteryReportCounter >= BATTERY_REPORT_CYCLE) {
        long batteryVolt = readVcc();
        DEBUG_PRINT("Battery voltage: "); DEBUG_PRINT(batteryVolt); DEBUG_PRINTLN(" mV");
        uint8_t batteryPcnt = constrain(map(batteryVolt,VMIN,VMAX,0,100),0,255);   
        DEBUG_PRINT("Battery percent: "); DEBUG_PRINT(batteryPcnt); DEBUG_PRINTLN(" %");
        sendBatteryLevel(batteryPcnt);
        batteryReportCounter = 0;
      }
      
      sleep(SLEEP_TIME);
    }
    
    // function for reading Vcc by reading 1.1V reference against AVcc. Based from http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/
    // To calibrate reading replace 1125300L with scale_constant = internal1.1Ref * 1023 * 1000, where internal1.1Ref = 1.1 * Vcc1 (per voltmeter) / Vcc2 (per readVcc() function) 
    long readVcc() {
      // set the reference to Vcc and the measurement to the internal 1.1V reference
      ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
      delay(2); // Wait for Vref to settle
      ADCSRA |= _BV(ADSC); // Start conversion
      while (bit_is_set(ADCSRA,ADSC)); // measuring
      uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH  
      uint8_t high = ADCH; // unlocks both
      long result = (high<<8) | low;
      result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
      return result; // Vcc in millivolts
    }
    // function for reading internal temp. From http://playground.arduino.cc/Main/InternalTemperatureSensor 
    double GetInternalTemp(void) {  // (Both double and float are 4 byte in most arduino implementation)
      unsigned int wADC;
      double t;
      // The internal temperature has to be used with the internal reference of 1.1V. Channel 8 can not be selected with the analogRead function yet.
      ADMUX = (_BV(REFS1) | _BV(REFS0) | _BV(MUX3));   // Set the internal reference and mux.
      ADCSRA |= _BV(ADEN);  // enable the ADC
      delay(20);            // wait for voltages to become stable.
      ADCSRA |= _BV(ADSC);  // Start the ADC
      while (bit_is_set(ADCSRA,ADSC));   // Detect end-of-conversion
      wADC = ADCW;   // Reading register "ADCW" takes care of how to read ADCL and ADCH.
      t = (wADC - 88.0 ) / 1.0;   // The default offset is 324.31.
      return (t);   // The returned temperature in degrees Celcius.
    }
    
    /*********************************************
     * * Sends temperature and humidity from Si7021 sensor
     * Parameters
     * - force : Forces transmission of a value (even if it's the same as previous measurement)
     *********************************************/
    void sendTempHumidityMeasurements(bool force) {
      bool tx = force;
    
      si7021_env data = humiditySensor.getHumidityAndTemperature();
      
      float temperature = data.celsiusHundredths / 100.0;
      DEBUG_PRINT("T: ");DEBUG_PRINTLN(temperature);
      float diffTemp = abs(lastTemperature - temperature);
      DEBUG_PRINT(F("TempDiff :"));DEBUG_PRINTLN(diffTemp);
      if (diffTemp > TEMP_TRANSMIT_THRESHOLD || tx) {
        send(msgTemp.set(temperature,1));
        lastTemperature = temperature;
        measureCount = 0;
        DEBUG_PRINTLN("T sent!");
      }
      
      int humidity = data.humidityPercent;
      DEBUG_PRINT("H: ");DEBUG_PRINTLN(humidity);
      raHum.addValue(humidity);
      humidity = raHum.getAverage();  // MA sample imply reasonable fast sample frequency
      float diffHum = abs(lastHumidity - humidity);  
      DEBUG_PRINT(F("HumDiff  :"));DEBUG_PRINTLN(diffHum); 
      if (diffHum > HUMI_TRANSMIT_THRESHOLD || tx) {
        send(msgHum.set(humidity));
        lastHumidity = humidity;
        measureCount = 0;
        DEBUG_PRINTLN("H sent!");
      }
    
    }
    

    But I get always follwoing error...

    exit status 1
    'si7021_env' has no member named 'humidityPercent'
    

    So I am a bit lost at the Moment due to my limited coding Knowledge.. :-(

    General Discussion

  • Serial Gateway Sketch with si7021
    M Markus.

    Hi All,
    I have biuld a Serial Gateway based on RFM69 and a ProMini. Its working great so far. But I want to implement in this Sketch also a Sensor si7021. I have currently no idea how i can implent the sensor part into the Gateway Sketch. Hope someone can help me there.

    Thanks

    Markus

    General Discussion

  • šŸ’¬ NRF2RFM69
    M Markus.

    @gohan yes and i didn't checked the PCB Label...shit happends

    OpenHardware.io rfm69 adapter converter nrf24l01

  • šŸ’¬ NRF2RFM69
    M Markus.

    @gohan the arrow goes to the Jumper close to the cap on the NRF socket.
    [link text]https://www.openhardware.io/view/4/EasyNewbie-PCB-for-MySensors(link url)
    But the other Jumper isthe right one . Well, could be also wrong interpreted frommy site, however ist now working and the range is also fine so far...

    OpenHardware.io rfm69 adapter converter nrf24l01

  • šŸ’¬ NRF2RFM69
    M Markus.

    @gohan ohhhh helllll... its working.. As usual.. the Problem was infront of the Monitor... :-) So, two Problems. the first mistake i did was to use a HW module as Gateway. The power source was a FTDI adaptor which has only max Output current of 50mA (HW module Needs 120mA Minimum). The result was randomly reboot of the Gateway. The second and main Problem was the Jumper of the IRQ on the Easy PCB boards. I checked only the domumentation and there is the Jumper wrong descriped. So i placed the Jumper wrong. I have corrected this now on my two test boards and use a W module on the Gateway.. now its working :-)
    Many thanks for all the Patience... :-)

    OpenHardware.io rfm69 adapter converter nrf24l01

  • šŸ’¬ NRF2RFM69
    M Markus.

    @gohan 10uF electrolyt cap direct on the radios already tierd beside the 4,7uF on the Radio socket.

    OpenHardware.io rfm69 adapter converter nrf24l01
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular