Arduino Sim800l v2 module and SX1278 LoRa Code
I have a flood level detection system project that uses arduino uno as it microcontroller board. I have two microcontrollers; one for the receiver and one for the transmitter. Can someone fix the errors and the missing lines in my code? Here's my flow chart, circuit diagram and code.
15 Replies
Check your braces placement closely.
The last one's double, for example.
In some places it seems to be missing one
like
The code indentation makes it seem like the
if (waterLevelCM >= 3) { should be closed before the if (currentMillis - previousMillis >= interval) { statement
The whole code seems a bit AI generated to me and then poorly copy pasted togetherto be honest, some are AI generated
I fixed it
But, how do I make it so that the water level sensor doesn't make false alarms?
Like for example, when it rains, the water level sensor may think of it as flood
Well, did you analyze the signal coming out of it? Is it only a temporary glitch so that one sensor value is off, causing it to send the alarm?
You have to analyze how your signal behaves and what behavior you want to have, add filters, etc.
like a low pass filter only letting through the slower changes and ignoring any high speed temporary changes.
or sampling your signal multiple times, taking the (moving) averages etc.
The rssi shown is -26, -27, 42, -158
RSSI? That's signal strength of the packet.
positive 42 should be impossible
wait, which signal do you mean?
Ahh wait
The LoRa signal.
the average RSSI of the received packet that is.
it sends at +14 dBm by standard, and the signal strength will drop over distance and with obstacles added
the sensitivity of LoRa is extremely good, with even packets having RSSI close to -120 dBm still being decodable
but +42 is more than your TX power
and -158 is way too low
-26 is like "the transmitter and receiver are sitting right next to each other". beware of near-field effects.
Its common value is -23, but sometimes -158

While you are using SF12, even -158 is undecodable. probably a bad print or weird near field effects.
lower the transmit power if you're having receiver and transmitter right besides each other, and give them some more distance
how low?
I mean +0 dBm if you can.
https://github.com/sandeepmistry/arduino-LoRa/blob/5e0e6f0794eae6829315233db5d1257f5cae373b/src/LoRa.h#L69
It has
LoRa.setTxPower(int level)
So you can just say LoRa.setTxPower(0); for 0 dBm TX power (1 milliwatt)But if I intend to place both in longer distances, do I just remove it once it's done?
yes.
I observed that even when the water level hasn't reached the sensor's threshold, the red signal still sends
I'm gonna sleep now, I still got school tom so I'll be back after
Hello. I tried plugging the arduino uno in and now I don't receive any signals anymore
the RSSI messages aren't being shown in the serial monitor anymore
But both LoRas are on and working


