Before creating the topic
- Search forum for similar topics
- Check http://docs.blynk.cc and http://help.blynk.cc/
- Add details :
• Hardware model + communication type. For example: Arduino UNO with Ethernet Shield
• Smartphone OS (iOS or Android) + version
• Blynk server or local server
• Blynk Library version
• Add your sketch code. Code should be formatted as example below.
Simply paste your code between ``` If you don’t format your code, your topic can be deleted by moderators.
/*
Developed by Dhanish Vijayan - Elementz Engineers Guild Pvt. Ltd.
Instructions
Tested with the Elementz Lora board with Arduino Pro mini 8 MHz bootloader
Led blinks at every packet reception
ToDo:
// Receive from multiple EspSerials
// Parameter tuning to achive more range
*/
#define BLYNK_PRINT Serial
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SPI.h>
#include "LoRa.h"
String phrase;
String s;
char copy[50];
int temp, hum, tre;
int LED_BUILTIN1 = 3;
int SyncWord = 0x22;
char auth[] = "0Mgw_IRUnX9H****************6ygloG";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "home WIFI";
char pass[] = "shiv*****************3.";
// Hardware Serial on Mega, Leonardo, Micro...
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
long writingTimer = 17;
long startTime = 0;
long waitTime = 0;
void setup() {
Serial.begin(9600);
LoRa.setSpreadingFactor(12); // ranges from 6-12,default 7 see API docs
LoRa.setSignalBandwidth(62.5E3); // for -139dB (page - 112)
LoRa.setCodingRate4(8); // for -139dB (page - 112)
LoRa.setSyncWord(SyncWord); // ranges from 0-0xFF, default 0x12, see API docs
Serial.print("current spreading factor : ");
Serial.println(LoRa.getSpreadingFactor());
Serial.print("current bandwidth : ");
Serial.println(LoRa.getSignalBandwidth());
Serial.println("LoRa init succeeded.");
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
while (!Serial);
pinMode(LED_BUILTIN1, OUTPUT);
Serial.println("LoRa Receiver");
if (!LoRa.begin(433E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
}
void loop() {
Serial.print("hello");
int packetSize = LoRa.parsePacket();
if (packetSize) {
// received a packet
Serial.print("Received packet '");
// read packet
while (LoRa.available()) {
char c;
c = (char)LoRa.read();
phrase = String(phrase + c);
}
phrase.toCharArray(copy, phrase.length());
//Serial.println(s);
// delay(000);
int v[5], i;
char *string = copy, *ptr = string; i = 0;
while (*ptr) {
if (isdigit(*ptr)) {
long val = strtol(ptr, &ptr, 10);
// Serial.println( val);
v[i] = val; i++;
//Serial.println("neew lin e prointh\n");
} else {
ptr++;
}
temp = v[0];
hum = v[1];
tre = v[2];
// EspSerial.println("-------------------- new data --------------------") ;
}
//
Serial.print("temp:");
Serial.println(temp);
Serial.print("hum:");
Serial.println(hum);
Serial.print("tre:");
Serial.println(tre);
Blynk.virtualWrite(V1, temp);
Blynk.virtualWrite(V2, hum);
Blynk.virtualWrite(V3, tre);
phrase = "";
// print RSSI of packet
digitalWrite(LED_BUILTIN1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200); // wait for a second
digitalWrite(LED_BUILTIN1, LOW); // turn the LED off by making the voltage LOW
delay(200);
}
Blynk.run();
}
this is code i have written according to it . It should connect to Blynk and start receiving the data from another Lora device but when i connect separately it will work but when i combine both esp and Lora with blynk it does not work . Please help me this is my final year project