LoRa with Electron v Arduino Mini


#21

@PeaTearDial, you always need the LiPo to provide peak current though in your case, you are turning off the modem. It would be interesting to do this test with a Photon.


#22

Interesting! I’ll try the Photon, I have one here somewhere!


#23

Another thing I did was have an Arduino + RFM95w Radio board talk with a Photon over the UART bus. This way you could keep using the Arduino Mini that is working for you and just has the Electron receive and parse the data from the Arduino mini so you can do what you want with it.

Here is the code I used on the Photon to read incoming data from an Arduino using a RFM95w radio. Can’t find the Arduino code but this may help you get started.

#include "Particle.h"

// Constants
const size_t READ_BUF_SIZE = 256;

// Structures
typedef struct {
    int temperature;
    int humidity;
    int pressure;
    int luminosity;
    int winddir;
    int windspeed;
    int rainfall;
} WeatherData;

// Forward declarations
void processBuffer();
void handleWeatherData(const WeatherData &data);

// Global variables
int counter = 0;
unsigned long lastSend = 0;

char readBuf[READ_BUF_SIZE];
size_t readBufOffset = 0;

void setup() {
    Serial.begin(19200);

    // Serial1 RX is connected to Arduino TX (1)
    // Serial2 TX is connected to Arduino RX (0)
    // Photon GND is connected to Arduino GND
    Serial1.begin(19200);
}

void loop() {

    // Read data from serial
    while(Serial1.available()) {
        if (readBufOffset < READ_BUF_SIZE) {
            char c = Serial1.read();
            if (c != '\n') {
                // Add character to buffer
                readBuf[readBufOffset++] = c;
            }
            else {
                // End of line character found, process line
                readBuf[readBufOffset] = 0;
                processBuffer();
                readBufOffset = 0;
            }
        }
        else {
            Serial.println("readBuf overflow, emptying buffer");
            readBufOffset = 0;
        }
    }

}

void processBuffer() {
    // Serial.printlnf("Received from Arduino: %s", readBuf);
    WeatherData data;

    if (sscanf(readBuf, "%d,%d,%d,%d,%d,%d,%d", &data.temperature, &data.humidity, &data.pressure,
            &data.luminosity, &data.winddir, &data.windspeed, &data.rainfall) == 7) {

        handleWeatherData(data);
    }
    else {
        Serial.printlnf("invalid data %s", readBuf);
    }
}

void handleWeatherData(const WeatherData &data) {
    Serial.printlnf("got temperature=%d humidity=%d pressure=%d luminosity=%d winddir=%d windspeed=%d rainfall=%d",
            data.temperature, data.humidity, data.pressure, data.luminosity, data.winddir, data.windspeed, data.rainfall);
}

#24

The 3.3v rail on the Photon can only supply 100mA max, the radio needs more than that I’m pretty sure.


#25

That’s true for the Photon, but @PeaTearDial is working with an Electron :wink:


#26

Yes, but Paul asked him to try it with the Photon.


#27

Missed that :flushed:


#28

@RWB, the Photon may provide enough power for the test. The issue seems to be either an interference issue or possibly a power supply issue, given that the Arduino Mini uses a linear regulator and the Electron uses a switching regulator.

@PeaTearDial, try decoupling the 3V3 line at the SX1276 pin with a 0.1uF capacitor to see if that makes any difference.


#29

Your right, it’s showing the RFM95w radios using 120mA at max transmit power, I could have sworn I was seeing more like 500mA from my testing but looks like I was wrong about that.


#30

Hey, I connected up a photon. no difference - same as electron. Cant receive messages below about 100 RSSI and has much shorter range than the mini.

I’ll try the capacitor now.


#31

I tried the Capacitor. unfortunately it didnt help. i’m very confused! :rage:


#32

So if we look at some of the data I received during the last test. below is the arduino and lora:
T1 acts as a packet counter. as you can see all the data is there between packet 1692 and 1715.

Received packet 'ID=82231t1=1692.00t2=-12.34t3=-19.20v=4.15' with RSSI -112
with SNR 7.25
Received packet 'ID=82231t1=1693.00t2=-12.34t3=-19.20v=4.15' with RSSI -118
with SNR 7.25
Received packet 'ID=82231t1=1694.00t2=-12.34t3=-19.20v=4.15' with RSSI -116
with SNR 7.25
Received packet 'ID=82231t1=1695.00t2=-12.34t3=-19.20v=4.15' with RSSI -112
with SNR 11.75
Received packet 'ID=82231t1=1696.00t2=-12.34t3=-19.20v=4.15' with RSSI -114
with SNR 7.25
Received packet 'ID=82231t1=1697.00t2=-12.34t3=-19.20v=4.15' with RSSI -110
with SNR 7.25
Received packet '£Ð÷v¼Üè¡}111698.00t2=-12.34t3=-19.20v=4.15' with RSSI -115
with SNR 7.25
Received packet 'ID=82231t1=1699.00t2=-12.34t3=-19.20v=4.15' with RSSI -110
with SNR 7.25
Received packet 'ID=82231t1=1700.00´21
4.15' with RSSI -117                  t$P
with SNR 7.25
Received packet 'ID=82231t1=1701.00t2=-12.34t3=-19.20v=4.15' with RSSI -117
with SNR 7.25
Received packet 'ID=82231t1=1702.00t2=-12.34t3=-19.20v=4.15' with RSSI -117
with SNR 7.25
Received packet 'ID=82231t1=1704.00t2=-12.34t3=-19.20v=4.15' with RSSI -117
with SNR 7.25
Received packet 'ID=82231t1=1707.00t2=-12.34t3=-19.20v=4.15' with RSSI -117
with SNR 7.25
Received packet 'ID=82231t1=1708.00t2=-12.34t3=-19.20v=4.15' with RSSI -117
with SNR 12.25
Received packet 'ID=82231t1=1709.00t2=-12.3p42,,0 .¢"W?5.15' with RSSI -118
with SNR 7.25
Received packet 'ID=82231t1=1711.00t2=-12.34t3=-19.20v=4.15' with RSSI -115
with SNR 7.25
Received packet 'ID=82231t1=1712.00t2=-12.34t3=-19.20v=4.15' with RSSI -109
with SNR 11.75
Received packet 'ID=82231~1=1713.80t2=7:.34t3=-19.20v=4.15' with RSSI -108
with SNR 12.00
Received packet 'ID=82231t1=1714.00t2=-12.34t3=-19.20v=4.15' with RSSI -105
with SNR 7.25
Received packet 'ID=82231t1=1715.00t2=-12.34t3=-19.20v=4.15' with RSSI -103

Compare that to the Particle + Lora;

Received packet ‘ID=82231t1=1692.00t2=-12.34t3=-19.20v=´&±5’ with RSSI -93
with SNR 8.25
Received packet ‘ID=82231t1=1715.00t2=-12.34t3=-19.20v=4.15’ with RSSI -91

it missed all the data!!!


#33

@PeaTearDial, so you placed the cap between Vcc and GND of the SX1276 near the module?

I am also confused. You could try making an aluminium foil Faraday “shield” around the Electron and grounding it to see if the RSSI gets better. Be sure not to short anything out with the foil.


#34

Hey I only had an SMD cap so I tacked wires onto it and put it between Vbatt and GND on the lora module.


#35

Unfortunately I don’t have any foil a the moment. Will try that test tomorrow…


#36

I used an external FTDI connector to power the LoRa didn’t help either!!


#37

@PeaTearDial, I would add the LiPo to the Electron regardless, just to be sure. Also, when I said the cap needs to be near the SX1276, I meant like right next to the pins. Those long leads defeat the purpose!


#38

Ok, I’ll shorten them!

What about Isolating the boards from each other entirely?

https://www.digikey.ca/product-detail/en/silicon-labs/SI8441AB-D-IS/336-1761-5-ND/2170668


#39

Hey added the Cap up close. no improvement unfortunately.


#40

@PeaTearDial, I’m running out of ideas! The foil shield is the next thing to try.