Go Down

Topic: Problems sending messages with mkr Fox 1200 (Read 102 times) previous topic - next topic

msaborido

Hello, i am a noobie with this board, right now i have 2 soil sensors and one humidity and temperature  sensor. the thing is i send messages to sigfox but just once when i upload the sketch i do not understand why the board do not send message every 15 minutes.

here is my code:

#include <SHT1x.h>
#define dataPin  10
#define clockPin 11
#include <SigFox.h>
#include <ArduinoLowPower.h>
SHT1x sht1x(dataPin, clockPin);
int oneshot = true;



const int analogInPinOnTheGround = A0;         
int minADCground = 39;                     
int maxADCground = 895;



const int analogInPinUnderground = A4;       
int minADCunderground = 60;                       
int maxADCunderground = 1000;     


 
int moistureOnTheGroundValue, mappedOnTheGroundValue;


int moistureUndergroundValue, mappedUndergroundValue;
 
void setup() {
 Serial.begin(115200);
 delay(500);
 
if (oneshot == true) {
    // Wait for the serial
    Serial.begin(115200);
    while (!Serial) {}
  }

  if (!SigFox.begin()) {
    // Something is really wrong, try rebooting
    // Reboot is useful if we are powering the board using an unreliable power source
    // (eg. solar panels or other energy harvesting methods)
    reboot();
  }

  //Send module to standby until we need to send a message
  SigFox.end();

  if (oneshot == true) {
    // Enable debug prints and LED indication if we are testing
    SigFox.debug();
  }
 
}

void loop() {

 
// SENSOR A RAS DE SUELO
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
 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);

   // Iniciamos el módulo SigFox
  SigFox.begin();
  // Esperamos 100 ms hasta que se conecte
  delay(100);


   // Limpieza de todas las interrupciones pendientes
  SigFox.status();
  delay(1);

  // Comenzamos el proceso para transmitir el mensaje
  SigFox.beginPacket();

  // Escribimos el mensaje
  SigFox.write(temp_c);
  SigFox.write(humidity);
  SigFox.write(mappedUndergroundValue);
  SigFox.write(mappedOnTheGroundValue);

 

  int ret = SigFox.endPacket(true);  // send buffer to SIGFOX network and wait for a response
  if (ret > 0) {
    Serial.println("No transmission");
  } else {
    Serial.println("Transmission ok");
  }

  // Apagamos el módulo
  SigFox.end();

if (oneshot == true) {
    // spin forever, so we can test that the backend is behaving correctly
    while (1) {}
  }

  //Sleep for 15 minutes
  LowPower.sleep(15 * 60 * 1000);
}


void reboot() {
  NVIC_SystemReset();
  while (1);
}


this is my serial monitor:


ADC = 397, Moisture value on the ground = 41%
ADC = 393, Moisture value Underground (1.5 m) = 35%
Temperature: 24.8799972534C / 76.8559951782F. Humidity: 36.19%
No transmission


Always said no transmission but i can see the messages on sigfox.


Please help...

Sorry for my bad spelling and thank you for your help.

Andonoc

Hello,
try to turn the oneshoot flag to false, otherwise the program runs in the while(1) loop.
and another thing, two resistive soil sensors will disturb each other(the wet soil connect the GND of both sensors together), make sure you have disconnected them properly with a tristate output or similar.
hope it helps

Go Up