ricaun / LoRaNow-18-months

LoRaNow Board 18 Months sending data to TTN
MIT License
9 stars 1 forks source link

Arduino nano 1 MHz #1

Closed Samuel-ZDM closed 3 years ago

Samuel-ZDM commented 3 years ago

Hi!

Have you tried using the Arduino Nano with 1MHz? I'm trying to do this but the device sends only 1 or 2 messages and stops sending. I wonder if you can help me with this. I am doing this to reduce the consumption of the device.

Thanks in advance.

ricaun commented 3 years ago

Hello.

I always use 8MHz and sleep for some time.

Maybe with 1MHz, the SPI clock is too high or something.

If you want to slow down your MCU you can change by code.

#include <avr/power.h>

void setprescaler(void)
{
  //clock_prescale_set(clock_div_1);
  //clock_prescale_set(clock_div_2); // 8M Hz - 0.62mA
  //clock_prescale_set(clock_div_16); // 1M Hz - 0.45mA - 450uA / 5uA
  //clock_prescale_set(clock_div_256);
}

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  // Blink with 1 second
  clock_prescale_set(clock_div_1);
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);

  // Blink with 2 second
  clock_prescale_set(clock_div_2);
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);
}

This code breaks with the delay() and millis()

Probably is not a good idea to change the clock with SPI running.

You should try your code with 8HMz and see if works or breaks.

See yaa!

Samuel-ZDM commented 3 years ago

Thank you very much!

I will do these tests. If I use the internal oscillator can it influence the operation too? But I believe that it is, because I am using the MCCI LMIC to try to do this and I changed the SPI frequency to the lowest one and it still doesn't work. This library takes up a lot of Atmega328p memory, I don't know what I'm going to do to make it consume less.

ricaun commented 3 years ago

Hello,

Yep LMIC is really big and Atmega328p memory is small for the library.

I kinda create a really simple LoraWAN package to use with the Lora.h.

The library only handles the encryption and decryption of the LoRaWAN protocol and ignore mac commands.

The frequency, SF, and other specifications of the LoRa you need to control or make a one channel node.

See yaa!

Samuel-ZDM commented 3 years ago

Thanks a lot for the help!

I'll start using and testing this one.

Does this library work for downlink messages?