Recent Posts

Pages: [1] 2 3 ... 10
1
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
2
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


3
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
4
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
5
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
6
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
7
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
8
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
9
SoilWatch 10 / Re: Problems with soilwatch in mkr Fox 1200
« Last post by pinolec on February 04, 2019, 08:04:54 am »
That's great!  :)

Please let me know how the field tests go.

Piotr
10
SoilWatch 10 / When to use 1.1 volt v.s. 3 volt?
« Last post by kamloops on February 01, 2019, 06:43:59 pm »
First, I apologize if this has been covered or is so obvious that the question didn't need to be asked. I have googled the daylights out of this and can't find the info, so know I tried  ;D

My big question is, why and when would you would use the 1.1 volt v.s. the 3 volt sensor?

I currently have an Arduino UNO R3 with the inferior resistance-style sensors, but it has allowed me to get things going at least.

I have two sensors and two pumps running off of one Arduino and would like to keep it that way with the SoilWatch 10's if that's possible.

I am getting confused on whether I am restricted to either the 1.1 or the 3, or whether each offers different levels of sensitivity or other qualities, and whether you can run more than one sensor with the internal reference if using the aref on the board.

Can I just use the analog inputs with the 3volt version and be good to go?

Thanks in advance for any guidance you can give me before I order.

Cheers

Pages: [1] 2 3 ... 10