The WORKBENCH part 1

my first steps with platformIO are not very succesfull…
I can compile ‘blink’ but not upload it to an arduino nano :roll_eyes:

platformIOerror

BoRRoZ,

rf95.sleep();

Is only needed with the Adafruit client/server test. Adafruit’s examples are based on the RadioHead RFM9X library examples. Someone correct me if I’m wrong, I assumed HPD13/A were just copies of the HopeRF RFM95/W?

http://www.rocketscream.com/blog/2017/08/21/the-sx1276-modules-shootout-hoperfs-rfm95w-vs-nicerfs-lora1276-c1-vs-hpdteks-hpd13/

For TTN-ABP examples the LMIC lib handles the sleeping of the radio so the direct sleep of the radio is unnecessary.

Here’s the Adafruit client code with my additions for sleep:

// Feather9x_TX
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messaging client (transmitter)
// with the RH_RF95 class. RH_RF95 class does not provide for addressing or
// reliability, so you should only use RH_RF95 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example Feather9x_RX

#include <SPI.h>
#include <RH_RF95.h>
#include "LowPower.h"

/* for feather32u4 */
#define RFM95_CS 8
#define RFM95_RST 4
#define RFM95_INT 7

/* for feather m0  
#define RFM95_CS 8
#define RFM95_RST 4
#define RFM95_INT 3
*/

/* for shield 
#define RFM95_CS 10
#define RFM95_RST 9
#define RFM95_INT 7
*/


/* for ESP w/featherwing 
#define RFM95_CS  2    // "E"
#define RFM95_RST 16   // "D"
#define RFM95_INT 15   // "B"
*/

/* Feather 32u4 w/wing
#define RFM95_RST     11   // "A"
#define RFM95_CS      10   // "B"
#define RFM95_INT     2    // "SDA" (only SDA/SCL/RX/TX have IRQ!)
*/

/* Feather m0 w/wing 
#define RFM95_RST     11   // "A"
#define RFM95_CS      10   // "B"
#define RFM95_INT     6    // "D"
*/

/* Teensy 3.x w/wing 
#define RFM95_RST     9   // "A"
#define RFM95_CS      10   // "B"
#define RFM95_INT     4    // "C"
*/

// Change to 434.0 or other frequency, must match RX's freq!
#define RF95_FREQ 915.0

// Singleton instance of the radio driver
RH_RF95 rf95(RFM95_CS, RFM95_INT);

void setup() 
{
  pinMode(RFM95_RST, OUTPUT);
  digitalWrite(RFM95_RST, HIGH);

  while (!Serial);
  Serial.begin(9600);
  delay(100);

  Serial.println("Feather LoRa TX Test!");

  // manual reset
  digitalWrite(RFM95_RST, LOW);
  delay(10);
  digitalWrite(RFM95_RST, HIGH);
  delay(10);

  while (!rf95.init()) {
    Serial.println("LoRa radio init failed");
    while (1);
  }
  Serial.println("LoRa radio init OK!");

  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
  if (!rf95.setFrequency(RF95_FREQ)) {
    Serial.println("setFrequency failed");
    while (1);
  }
  Serial.print("Set Freq to: "); Serial.println(RF95_FREQ);
  
  // Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on

  // The default transmitter power is 13dBm, using PA_BOOST.
  // If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then 
  // you can set transmitter powers from 5 to 23 dBm:
  rf95.setTxPower(23, false);
}

int16_t packetnum = 0;  // packet counter, we increment per xmission

void loop()
{
  Serial.println("Sending to rf95_server");
  // Send a message to rf95_server
  
  char radiopacket[20] = "Hello World #      ";
  itoa(packetnum++, radiopacket+13, 10);
  Serial.print("Sending "); Serial.println(radiopacket);
  radiopacket[19] = 0;
  
  Serial.println("Sending..."); delay(10);
  rf95.send((uint8_t *)radiopacket, 20);

  Serial.println("Waiting for packet to complete..."); delay(10);
  rf95.waitPacketSent();
  // Now wait for a reply
  uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
  uint8_t len = sizeof(buf);

  Serial.println("Waiting for reply..."); delay(10);
  if (rf95.waitAvailableTimeout(1000))
  { 
    // Should be a reply message for us now   
    if (rf95.recv(buf, &len))
   {
      Serial.print("Got reply: ");
      Serial.println((char*)buf);
      Serial.print("RSSI: ");
      Serial.println(rf95.lastRssi(), DEC);    
    }
    else
    {
      Serial.println("Receive failed");
    }
  }
  else
  {
    Serial.println("No reply, is there a listener around?");
  }

  //delay(1000);

  rf95.sleep();

  //USBDevice.detach(); doesn't work on 32u4
  // Disable USB clock
  USBCON |= _BV(FRZCLK);
  // Disable USB PLL
  PLLCSR &= ~_BV(PLLE); 
  // Disable USB
  USBCON &= ~_BV(USBE); 

  // ATmega32U4 sleep
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);  

  // Reattach USB to have Serial working again
  USBDevice.attach();
}

Let me know how you get on…

PlatformIO now and then has some quirks than can sometimes be a real pita.
PlatformIO dynamically installs packages when needed and that is exactly where it can give problems (also with updates).
Sometimes it helps to temporarily disable anti-virus.

Some (other tips):

Two examples of platformio.ini files:

This one for Heltec Wifi LoRa 32

[env:heltec_wifi_lora_32]
platform = espressif32
board = heltec_wifi_lora_32
framework = arduino

upload_speed = 921600
monitor_baud = 115200

lib_deps =
    U8g2
    LMIC-Arduino

and this one for Things UNO

[env:leonardo]
platform = atmelavr
board = leonardo
framework = arduino

monitor_baud = 115200

lib_deps =
    TheThingsNetwork

monitor_baud sets the serial monitor speed
upload_speed sets the upload speed

with lib_deps you define the libraries you want to use (per project), these will be automatically downloaded to the project’s .piolibdeps directory. (No need to use global libraries and no need to manually download libraries, unless they are unknown in the PlatformIO Registry).

You cannot upload a sketch when the serial monitor is running (this is different from Arduino IDE).
If serial monitor is running, close it before uploading a (new) sketch.

(I use PlatformIO with Visual Studio Code, not with Atom).

well… not

I changed one thing in my basic sleeptest, first disable the usb before sending the 32U4 to sleep :sunglasses:
but you are talking about the LoRa otaa example while I am talking LoRaWAN, so off course I don’t use radiohead lib but LMIC.
So how you get that low current is still a mystery to me …

good one… will try

  • nope … tried some other ‘solutions’ and decided to stick with my old combo arduino IDE / sublime text

BoRRoZ,

I would think that your basic sleep test code will not see low power usage if you don’t bring up the radio then put it to sleep - via RadioHead or some other library that controls the radio.

As I said above I was able to replicate the same power usage as the Adafruit/RadioHead example above using the LMIC TTN-ABP example.

For instance using this example but adding the USB detach code before sleeping should show the same low power usage.

1 Like

good point… will test that to

  • nope… and I don’t see it, there is only one solution left and just move on for now

x710

:rage:

1 Like

wirecast%208

playing with WIRECAST 8 - wow cool app !

Have you played with OBS Studio

NO… looks good and open source ! tnx :sunglasses:

I used to use Wirecast but found OBS works much smoother. especially if you have the right hardware for offloading (Intel CPU with quicksync, nvidia or newer AMD GPU).

I’m not into 'live streaming video… but I see possibilities in connection with our LoRaWAN hobby :sunglasses:

328pb3

I’m happy… blink is working :sunglasses: 328PB

x713

powerled removed and deepsleep with standard lowpower lib.
this MCU have more interfaces… don’t know if everything is switched of now :roll_eyes:

compare

what if I attach a RN2483A… then it could run the TTN lib :thinking:

Could this be the new magic stick? Time to find out!
IMG_20180305_134124~01

seems to be a good one :sunglasses:

It’s a good day to go to the roof :slight_smile:
15202552077723505430656121718317

1 Like

yep the snow is gone (NL) … time for LoRaWAN :sunglasses:

not at all places :wink:
some_snow_small

4 Likes

wow… beautifull !

so that’s a topic… what enclosures to use in different climates :sunglasses:

Exciting times :slight_smile:
41525854

4 Likes