Recent Posts

Pages: 1 ... 7 8 [9] 10
81
SoilWatch 10 / Re: SoilWatch 10 with particle boards
« Last post by pinolec on February 28, 2019, 12:57:07 AM »
Hi,

The measured volume is low with the most significant portion being soil right next to the sensor.

Particle boards have an onboard regulator so the microcontroller is powered with a constant voltage regardless of the voltage you supply to the board.
I think Particleboard doesn't have the internal reference at least not 1.1V. Sorry I am not familiar with the Particleboard.
You will be good with default ADC reference which is 3.3V for your board. You don't have to state you gonna use default ADC because is set as default. You would have to state it if you use different analogReference elsewhere in the code.

Hope this makes sense.

Best,
Piotr
82
SoilWatch 10 / Re: SoilWatch 10 with particle boards
« Last post by mannydeleon99 on February 26, 2019, 05:44:27 PM »
Thanks for the info,

I have another quick question.  Can you tell me the sphere of influence for these sensors (new sensors).  How much area will one sensor cover.

Another question is about powering the sensor.  Im using a transistor to control power.  In your calibration sheet you say, "It is recommended to use a constant reference voltage either internal or powering ADC with constant voltage (regulated).   

I delete this part of the code

  analogReference(INTERNAL); //set ADC reference to internal 1.1V


If not I get errors. 

Im new to all this and just making sure im understanding the quote above.  Should I be doing something for a reference voltage while using 3.3V

Or
Do I need to add the following code

  analogReference(DEFAULT); //set ADC reference to internal 1.1V
83
SoilWatch 10 / Re: Problems with soilwatch in mkr Fox 1200
« Last post by pinolec on February 18, 2019, 02:29:44 PM »
Hi Martin,

To read the battery voltage you can use a voltage divider to bring the voltage to the safe level for ADC.

You are welcome :)
Let us know how the tests go.

Regards,
Piotr
84
SoilWatch 10 / Re: Problems with soilwatch in mkr Fox 1200
« Last post by martin.i.tycgis on February 18, 2019, 12:40:21 PM »
It works!

I made that code to read the level of the batteries, now the 2 sensors work, I have to find a better way to know the level of the batteries,

As always thanks you Piotr, and the rest of the team in PINOTECH,

 I will let you know how the field test go,

Thanks for all

Martín


85
SoilWatch 10 / Re: Problems with soilwatch in mkr Fox 1200
« Last post by pinolec on February 18, 2019, 11:42:28 AM »
Hi Martin,

You change ADC reference to internal 1.0V with:
Code: [Select]
analogReference(AR_INTERNAL1V0); //AR_DEFAULT: the default analog reference of 3.3V // AR_INTERNAL1V0: a built-in 1.0V reference
Once you change it, all readings will be taken with this reference. Because as far as I remember, you have 3V version sensor, you should set analogReference to AR_DEFAULT before reading sensor.
Some boards need some time after the reference has been changed. Some may cause first reading after the change to be corrupted. Check if this is not the case with MKR FOX 1200.

Regards,
Piotr
86
SoilWatch 10 / Re: Problems with soilwatch in mkr Fox 1200
« Last post by martin.i.tycgis on February 18, 2019, 10:11:10 AM »
Hi Piotr,

Here´s the code:

 #include <SHT1x.h>
#define dataPin  9
#define clockPin 10
#include <SigFox.h>
#include <ArduinoLowPower.h>
#define LED 6

SHT1x sht1x(dataPin, clockPin);
int oneshot = false; 
float voltagepercentage;
const int nMOS= 2;
const int groundMOS= 3;
const int nMOSSen0148= 1;

const int analogInPinOnTheGround = A4;
int minADCground = 130;
int maxADCground = 1000;



const int analogInPinUnderground = A0;
int minADCunderground = 130;
int maxADCunderground = 1000;



int moistureOnTheGroundValue, mappedOnTheGroundValue;


int moistureUndergroundValue, mappedUndergroundValue;

void setup() {
  LowPower.attachInterruptWakeup(RTC_ALARM_WAKEUP, dummy, CHANGE);

  Serial.begin(115200);

 
  pinMode(nMOS,OUTPUT);//SELECCIONAMOS EL PIN
  pinMode(groundMOS,OUTPUT);
  pinMode(nMOS,OUTPUT);//SELECCIONAMOS EL PIN
  while (!Serial);
  if ( ! SigFox.begin() ) {
    Serial.println("Error ... rebooting");
    NVIC_SystemReset();
    while (1);
  }
  SigFox.reset();
  delay(100);
  SigFox.debug();
  SigFox.end();

  // We need to have to time to program the Arduino after a reset
  // Otherwise it does not respond when in low-power mode
  Serial.println("Booting...");
  digitalWrite(LED, HIGH);
  delay(1000);
  digitalWrite(LED, LOW);
}

typedef struct __attribute__ ((packed)) sigfox_message {
  uint8_t hum;
  float temp;
  uint8_t humidityburied;
  uint8_t humidityground;
  uint8_t batterylevel;
} SigfoxMessage;



void loop() {

digitalWrite(nMOS,HIGH); //ENCENDEMOS EL CIRCUITO

digitalWrite(nMOSSen0148,HIGH);

digitalWrite(groundMOS,HIGH);

  delay(500);

  // SENSOR A RAS DE SUELO
  delay(100);
  moistureOnTheGroundValue = analogRead(analogInPinOnTheGround);
   

  Serial.print("ADC = " );
  Serial.print(moistureOnTheGroundValue);
  Serial.print(", " );

  mappedOnTheGroundValue = map(moistureOnTheGroundValue, minADCground, maxADCground, 0, 100);

  Serial.print("Moisture value on the ground = " );
  Serial.print(mappedOnTheGroundValue);
  Serial.println("%");

  delay(2000);



  //SENSOR ENTERRADO A 1.5 METROS DEL SUELO
  delay(100);
  moistureUndergroundValue = analogRead(analogInPinUnderground);

  Serial.print("ADC = " );
  Serial.print(moistureUndergroundValue);
  Serial.print(", " );

  mappedUndergroundValue = map(moistureUndergroundValue, minADCunderground, maxADCunderground, 0, 100);

  Serial.print("Moisture value Underground (1.5 m) = " );
  Serial.print(mappedUndergroundValue);
  Serial.println("%");

  delay(2000);



  //SENSOR DE TEMPERATURA AMBIENTE Y HUMEDAD
  float temp_c;
  float temp_f;
  float humidity;

  // Read values from the sensor
  temp_c = sht1x.readTemperatureC();
  temp_f = sht1x.readTemperatureF();
  humidity = sht1x.readHumidity();

  // Print the values to the serial port
  Serial.print("Temperature: ");
  Serial.print(temp_c, DEC);
  Serial.print("C / ");
  Serial.print(temp_f, DEC);
  Serial.print("F. Humidity: ");
  Serial.print(humidity);
  Serial.println("%");

  delay(2000);

  analogReadResolution(10);
  analogReference(AR_INTERNAL1V0); //AR_DEFAULT: the default analog reference of 3.3V // AR_INTERNAL1V0: a built-in 1.0V reference
 
  // read the input on analog pin 0:
  int sensorValue = analogRead(ADC_BATTERY);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 4.3V):
  float voltage = sensorValue * (3 / 1023.0);


//convertimos valor a porcentaje.

  voltagepercentage = (voltage/3)*100;

  // print out the value you read:
  Serial.print(voltagepercentage);
  Serial.println("%");

  delay(500);

  SigFox.begin();
  delay(100);

  SigFox.status();
  SigfoxMessage msg;
  msg.temp = (float)sht1x.readTemperatureC();
  msg.hum = (uint8_t)sht1x.readHumidity();
  msg.humidityground = (uint8_t) mappedOnTheGroundValue;
  msg.humidityburied = (uint8_t) mappedUndergroundValue;
  msg.batterylevel =(uint8_t) voltagepercentage;
  SigFox.beginPacket();

  SigFox.write(msg.temp);
  SigFox.write(msg.hum);
  SigFox.write(msg.humidityground);
  SigFox.write(msg.humidityburied);
  SigFox.write(msg.batterylevel);
  SigFox.endPacket(false);
  SigFox.end();

digitalWrite(nMOS,LOW); //APAGAMOS EL CIRCUITO
digitalWrite(nMOSSen0148,LOW);
digitalWrite(groundMOS,LOW);

  // Wait for 10 minutes.
  // Low Power version - be carefull of bug
  LowPower.sleep(30*60*1000);

}


void dummy() {
  volatile int aaa=0;
}

the dummy void is just to awake the board.

Thanks for all the support,

 Martín
87
SoilWatch 10 / Re: Problems with soilwatch in mkr Fox 1200
« Last post by pinolec on February 18, 2019, 09:33:55 AM »
Hi Martin,

It shouldn't be possible to have over 200 value if you mapped it to 0-100. My guess would be that you somehow changed 10bit reading to 12bit. This would explain values over 200.
Erratic readings may be caused by trying to read sensor to quickly. You need to add a 100ms delay after you switch the sensor on and before you take the readings. Make sure you turn on the correct sensor before taking the readings.  ;)
Show us the code.

Regards,
Piotr
88
SoilWatch 10 / Re: Problems with soilwatch in mkr Fox 1200
« Last post by martin.i.tycgis on February 18, 2019, 08:49:34 AM »
Hello Piotr!

Well I´ve done fields test and so far the mosfet prevents the uncontrolled battery comsuption, I start the test  January 31st and today the batteries still on the 82%
 8) but i get some erratic readings, i think it´s because the batteries, when the MKR FOX 1200 was on the USB this doesn´t happen.

At first i get erratic readings in all the sensors, the 2 Soilwatch 10 and the SEN0148, I split the sensors with 1 transistor for controlling each one, i managed to get normal readings with the SEN0148, but still getting weird readings with the 2 Soilwatchs 10, and I didn´t really know how to solve this problem.

This is what i get in the Sigfox Backend in the messages of my device:

the mapped value it´s a percentage of teh humidity, based on the max adc and the minimum adc. I am using the 3 V Soilwatch version, should i get the 1.1V one ? I don´t know, what is the cause of this readings.



2019-02-18 09:40:26   5c8fb2411b44fc52
temperature: 22.32
humidity: 27
mappedUndergroundValue: 68
mappedOnTheGroundValue: 252
BatteryLevel: 82
             
2019-02-18 09:10:09   0000ac411b666652
temperature: 21.5
humidity: 27
mappedUndergroundValue: 102
mappedOnTheGroundValue: 102
BatteryLevel: 82   
          
2019-02-18 08:39:53   e07aac411afc5f53
temperature: 21.559998
humidity: 26
mappedUndergroundValue: 252
mappedOnTheGroundValue: 95
BatteryLevel: 83
             
2019-02-18 08:09:35   e07aac411a444d53
temperature: 21.559998
humidity: 26
mappedUndergroundValue: 68
mappedOnTheGroundValue: 77
BatteryLevel: 83
             
2019-02-18 07:39:19   3c0aad411a5c1853
temperature: 21.629997
humidity: 26
mappedUndergroundValue: 92
mappedOnTheGroundValue: 24
BatteryLevel: 83
             
2019-02-18 07:09:01   1e85ad411a340e52
temperature: 21.689999
humidity: 26
mappedUndergroundValue: 52
mappedOnTheGroundValue: 14
BatteryLevel: 82
             
2019-02-18 06:38:44   0000ae411a3b3152
temperature: 21.75
humidity: 26
mappedUndergroundValue: 59
mappedOnTheGroundValue: 49
BatteryLevel: 82
             
2019-02-18 06:08:27   703dae411b333a53
temperature: 21.779999
humidity: 27
mappedUndergroundValue: 51
mappedOnTheGroundValue: 58
BatteryLevel: 83
             
2019-02-18 05:38:11   46e1ae411b24fd53
temperature: 21.859997
humidity: 27
mappedUndergroundValue: 36
mappedOnTheGroundValue: 253
BatteryLevel: 83
             
2019-02-18 05:07:53   ae47af411b46fb53
temperature: 21.91
humidity: 27
mappedUndergroundValue: 70
mappedOnTheGroundValue: 251
BatteryLevel: 83   
          
2019-02-18 04:37:36   14aeaf411a190953
temperature: 21.96
humidity: 26
mappedUndergroundValue: 25
mappedOnTheGroundValue: 9
BatteryLevel: 83
             
2019-02-18 04:07:20   84ebaf411a501053
temperature: 21.989998
humidity: 26
mappedUndergroundValue: 80
mappedOnTheGroundValue: 16
BatteryLevel: 83
             
2019-02-18 03:37:02   e07ab0411a46fe53
temperature: 22.059998
humidity: 26
mappedUndergroundValue: 70
mappedOnTheGroundValue: 254
BatteryLevel: 83   
          
Kind regards,

Martín
89
SoilWatch 10 / Re: When to use 1.1 volt v.s. 3 volt?
« Last post by kamloops on February 04, 2019, 05:36:36 PM »
Thanks! This helps a lot. Nice to know that I’m good either way.

I finally figured out that the aref is actually an input for a custom voltage reference, which makes it much clearer for me now.

I will order soon and appreciate the help 👍

W
90
SoilWatch 10 / Re: When to use 1.1 volt v.s. 3 volt?
« Last post by pinolec on February 04, 2019, 08:30:12 AM »
Hi,

This is a very good question.

Both sensors are the same construction and the only difference is the output range (0-1.1 and 0-3V). Both sensors read close to 0 in the air and close to 1.1V or 3V when submerged in water. The sensitivity is the same just in different range.
So when to choose 1.1V and when 3V. The first step is to check your ADC capabilities for maximum voltage. Some ADC allows the maximum voltage of 1.1V then 1.1V version is a good fit. Of course, you can achieve the same result by adding a voltage divider to the 3V version to bring it down to 1.1V.
When you power your device or development board form batteries or power supply is unstable then you will need a stable ADC voltage reference. Arduino UNO R3 offers a stable 1.1V internal reference. Then 1.1V version is well suited.

I assume you have you have a stable power supply so both versions will suit your needs.

Kind regards,
Piotr
Pages: 1 ... 7 8 [9] 10