Hi Guys kinda new to Arduino, been at it for a few months, have done a few simples project, but I am stuck at the new one, I am using Arduino uno R3 for the tx and rx side both with sx1278 lora, the tx arduino is fitted with a gps( NEO M8N) and a pressure transducer(5V) got everything working and sending fine, but on the rx side I want to dim a led, and send the value to blynk with the gps location, I can see all of the values and location on the serial monitor, but are having difficulty extracting the data for controlling an led(analogWrite), and sending the value to blynk and the gps data to blynk
Know that every helper is a newbie facing Your project. It's quiet advanced also.
Please post a block diagram showing the various major blocks. Please post the code for the unit that is supposed that LED.
This Shakespeare type of description is not what engineers wants to see.
Perhaps show us your wiring.
In general UNOs are not the most easy to use platform for the SX1278 modules, since they are mostly 3.3V logic level and the UNOs are 5V.
A 3.3V Pro Mini might be a better Arduino to use.
//Board 1;Arduino uno with, pressure transducer 5V, with lora sx1278 and gps( NEO M8N) for TX of data
#include <SPI.h>
#include <LoRa.h>
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 4800;
TinyGPSPlus gps;
SoftwareSerial ss(RXPin, TXPin);
int pot = A0;//pressure sensor input
void setup()
{
Serial.begin(115200);
ss.begin(GPSBaud);
while (!Serial);
pinMode(pot,INPUT);
Serial.println("LoRa Sender");
if (!LoRa.begin(433E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
}
void loop() {
int sensorVal=analogRead(A0);
float voltage = (sensorVal*5.0)/1024.0;
float pressure_pascal = (0.4590*((float)voltage-0.5))*1000000.0;
float pressure_bar = pressure_pascal/10e5;
LoRa.beginPacket();
LoRa.print(sensorVal);
LoRa.endPacket();
Serial.println(pressure_pascal/10e5);
Serial.print(F(" Lat="));
Serial.print(gps.location.lat(), 6);
Serial.print(F(" Long="));
Serial.println(gps.location.lng(), 6);
delay(50);
while (ss.available() > 0)
gps.encode(ss.read());
if (gps.location.isUpdated());
}
[/code]
//Board 2;Arduino uno, with Lora sx1278 for RX and TX of data
#include <LoRa.h>
#include <SPI.h>
int LED_red = 6;
int LED_blue = 7;
String inString = ""; // string to hold input
int val = 0;
void setup() {
Serial.begin(9600);
pinMode(LED_blue, OUTPUT);//LED for flashing when lora is reciving data
pinMode(LED_red,OUTPUT);//function for dim and bright of LED
Serial.println("LoRa Receiver Callback");
if (!LoRa.begin(433E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
}
void loop() {
// try to parse packet
int packetSize = LoRa.parsePacket();
if (packetSize) {
// read packet
while (LoRa.available())
{
int inChar = LoRa.read();
inString += (char)inChar;
val = inString.toInt();
}
inString = " ";
LoRa.packetRssi();
}
float voltage = (val*5.0)/1024.0;
float pressure_pascal = (0.4590*((float)voltage-0.5))*1000000.0;
float pressure_bar = pressure_pascal/10e5;
Serial.println(pressure_pascal/10e5);
analogWrite(LED_red,val);
digitalWrite(LED_blue,packetSize);
delay(100);
}
Lora | arduino TX |
---|---|
1 | G |
2 | G |
9 | G |
16 | G |
3 | 3V |
4 | D9 |
5 | D2 |
15 | D10 |
14 | D11 |
13 | D3 |
12 | D13 |
GPS | |
VCC | 3V |
GND | G |
RX | D3 |
TX | D4 |
Pres transducer | |
5V | 5V |
G | G |
Signal | A0 |
Lora | arduino RX |
1 | G |
2 | G |
9 | G |
16 | G |
3 | 3V |
4 | D9 |
5 | D2 |
15 | D10 |
14 | D11 |
13 | D3 |
12 | D13 |
LED blue | 7 |
LED red | 6 |
Board 2 is suposed te communicate with another Lora(wemos esp32 wifi D1 R32, this board will also be fitted with a Lora sx1278, the wemos board will be connected with wifi for communicating with Blynk but on Blynk I will have a push button for turning another LED on and off on Board 2+ a widget LED on Blynk to tell if the LED did turn on and off, and I know there should be a relay added to Board 2 for giving a signal to activate the widget LED, I did not mention this in my original post(figured I wil figure it out along the way and also gives me a chance to learn more, thanks for the response
Thanks, my idee was for when the coding is done to use a arduino nano, I am not sure if it is better Than the Pro Mini, I have notice that I should get and additional 3V power sours(I read it on a blog ore somewhere)your opinion will help, Thanks for the response
Mised point really.
LoRa devices are 3.3V logic level devices and so must not be connected directly to 5V logic level devices such as Nanos and UNOs.
Use a 3.3V logic level device such as a 3.3V Pro Mini.
HI srnet currently I have the Lora connected to the 3.3V pin, but you specific said that it should be a 3.3V logic, if I may, what are the difference between 3.3V logic and the arduino uno 3.3V pin, Thanks
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.