kriswiner / CMWX1ZZABZ

Collection of sketches using the Arduino core for Murata's CMWX1ZZABZ (STM32L082 and SX1276)
93 stars 29 forks source link

STM32L0.sleep() and STM32L0.stop() not working on B-L072Z-LRWAN1 #6

Closed jaimelaborda closed 6 years ago

jaimelaborda commented 6 years ago

I'm using a B-L072Z-LRWAN1 but methods sleep() and stop() of the STM32L0 library seems to be not working. It compiles without error, but the programs just keeps running no matter what value you put into the methods.

My code:

#include <STM32L0.h>
#include <Adafruit_SHT31.h>
#include <Adafruit_TSL2591.h>
#include "LoRaWAN.h"

const char *appEui = "XXXXXXXXXXXXXXXX";
const char *appKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const char *devEui = "XXXXXXXXXXXXXXXX";

#define LPP_DATATYPE_TEMPERATURE 0x67
#define LPP_DATATYPE_HUMIDITY 0x68
#define LPP_DATATYPE_ILLUMINANCE 0x65

Adafruit_SHT31 sht31;
Adafruit_TSL2591 tsl = Adafruit_TSL2591(2591);

void setup( void )
{

    Serial.begin(115200);
    sht31.begin(0x44);

    tsl.begin();
    tsl.setGain(TSL2591_GAIN_MED);
    tsl.setTiming(TSL2591_INTEGRATIONTIME_100MS);

    LoRaWAN.begin(EU868);
    LoRaWAN.addChannel(3, 867100000, 0, 5);
    LoRaWAN.addChannel(4, 867300000, 0, 5);
    LoRaWAN.addChannel(5, 867500000, 0, 5);
    LoRaWAN.addChannel(6, 867700000, 0, 5);
    LoRaWAN.addChannel(7, 867900000, 0, 5);
    LoRaWAN.setDataRate(5);
    LoRaWAN.joinOTAA(appEui, appKey, devEui);
}

void loop( void )
{

    uint16_t temp = (uint16_t) (sht31.readTemperature() * 10);
    uint16_t rh = (uint16_t) (sht31.readHumidity() * 2);
    Serial.println("Temp: "+String(temp/10));
    Serial.println("RH:   "+String(rh/2));

    uint32_t lum = tsl.getFullLuminosity();
    uint16_t ir, full;
    ir = lum >> 16;
    full = lum & 0xFFFF;
    uint16_t lux = tsl.calculateLux(full, ir);
    Serial.println("Lux:   "+String(lux));

    if (!LoRaWAN.busy() && LoRaWAN.joined())
    {
        int lpp_channel = 0;
        LoRaWAN.beginPacket();
        LoRaWAN.write(lpp_channel++);
        LoRaWAN.write(LPP_DATATYPE_TEMPERATURE);
        LoRaWAN.write((temp >> 8) & 0xFF);
        LoRaWAN.write(temp & 0xFF);
        LoRaWAN.write(lpp_channel++);
        LoRaWAN.write(LPP_DATATYPE_HUMIDITY);
        LoRaWAN.write(rh & 0xFF);
        LoRaWAN.write(lpp_channel++);
        LoRaWAN.write(LPP_DATATYPE_ILLUMINANCE);
        LoRaWAN.write((lux >> 8) & 0xFF);
        LoRaWAN.write(lux & 0xFF);
        LoRaWAN.endPacket();
    }

    STM32L0.stop(5000);
}
kriswiner commented 6 years ago

From Thiomas:

Can you let her/him run this WITHOUT Adafruit_TSL2591 ?

Also ask her/him, whether this is TOT off github, or installed via the json file ?

Can you answer these questions?

On Fri, Jun 22, 2018 at 12:06 PM, Jaime Laborda notifications@github.com wrote:

I'm using a B-L072Z-LRWAN1 but methods sleep() and stop() of the STM32L0 library appears to be not working. It compiles without error, but the programs just runs no matter what value you put into the methods.

My code:

include

include

include

include "LoRaWAN.h"

const char appEui = "XXXXXXXXXXXXXXXX"; const char appKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const char *devEui = "XXXXXXXXXXXXXXXX";

define LPP_DATATYPE_TEMPERATURE 0x67

define LPP_DATATYPE_HUMIDITY 0x68

define LPP_DATATYPE_ILLUMINANCE 0x65

Adafruit_SHT31 sht31; Adafruit_TSL2591 tsl = Adafruit_TSL2591(2591);

void setup( void ) {

Serial.begin(115200); sht31.begin(0x44);

tsl.begin(); tsl.setGain(TSL2591_GAIN_MED); tsl.setTiming(TSL2591_INTEGRATIONTIME_100MS);

LoRaWAN.begin(EU868); LoRaWAN.addChannel(3, 867100000, 0, 5); LoRaWAN.addChannel(4, 867300000, 0, 5); LoRaWAN.addChannel(5, 867500000, 0, 5); LoRaWAN.addChannel(6, 867700000, 0, 5); LoRaWAN.addChannel(7, 867900000, 0, 5); LoRaWAN.setDataRate(5); LoRaWAN.joinOTAA(appEui, appKey, devEui);

}

void loop( void ) {

uint16_t temp = (uint16_t) (sht31.readTemperature() 10); uint16_t rh = (uint16_t) (sht31.readHumidity() 2); Serial.println("Temp: "+String(temp/10)); Serial.println("RH: "+String(rh/2));

uint32_t lum = tsl.getFullLuminosity(); uint16_t ir, full; ir = lum >> 16; full = lum & 0xFFFF; uint16_t lux = tsl.calculateLux(full, ir); Serial.println("Lux: "+String(lux));

if (!LoRaWAN.busy() && LoRaWAN.joined()) { int lpp_channel = 0; LoRaWAN.beginPacket(); LoRaWAN.write(lpp_channel++); LoRaWAN.write(LPP_DATATYPE_TEMPERATURE); LoRaWAN.write((temp >> 8) & 0xFF); LoRaWAN.write(temp & 0xFF); LoRaWAN.write(lpp_channel++); LoRaWAN.write(LPP_DATATYPE_HUMIDITY); LoRaWAN.write(rh & 0xFF); LoRaWAN.write(lpp_channel++); LoRaWAN.write(LPP_DATATYPE_ILLUMINANCE); LoRaWAN.write((lux >> 8) & 0xFF); LoRaWAN.write(lux & 0xFF); LoRaWAN.endPacket(); }

STM32L0.stop(5000);

}

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kriswiner/CMWX1ZZABZ/issues/6, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qhvwjRMlnQyAqVZwXr9ORm8ZPodlks5t_UAygaJpZM4U0SUO .

jaimelaborda commented 6 years ago

Hi Thiomas,

Thank you for your reply.

Test it with a simple sketch and it works sleep() either stop() methods:

#include <STM32L0.h>

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);

}
void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Wake!");
  STM32L0.sleep(30000);
}

Cannot do it works with the library LoRaWAN. Maybe due to OTAA join? I don't know if it has a lot of sense.

I think i installed the library directly by cloning the github repository. I will try to update it.

Thank you for your help.

Regards, Jaime.

kriswiner commented 6 years ago

Try installing the latest STM32L0 core and test the simple examples to verify function. It works for us with LoRaWAN.

On Sat, Jun 23, 2018 at 3:24 AM, Jaime Laborda notifications@github.com wrote:

Hi Thiomas,

Thank you for your reply.

Test it with a simple sketch and it works sleep() either stop() methods: `#include

void setup() { // put your setup code here, to run once: Serial.begin(115200);

} void loop() { // put your main code here, to run repeatedly: Serial.println("Wake!"); STM32L0.sleep(30000); }`

Cannot do it works with the library LoRaWAN. Maybe due to OTAA join? I don't know if it has a lot of sense.

I think i installed the library directly by cloning the github repository. I will try to update it.

Thank you for your help.

Regards, Jaime.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/CMWX1ZZABZ/issues/6#issuecomment-399662604, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qkEy1xJgFACTK1OzcB-6flhvVW2cks5t_hdggaJpZM4U0SUO .

jaimelaborda commented 6 years ago

Yep, It works! Was working with an older version from May. I updated and works!.

Thank you very much for your help! I close the issue.

Regards,