I’m trying to make a temperature sensor device which detects and sends an email/sms message to the user when the temperature near the device exceeds 40 degrees. To do this, the main components of my circuit design include 2 halves, the transmitter and receiver sides. The transmitter side include the temperature sensor, an LM75 voltage regulator, and Arduino Nano and a LoRa transmitter. The receiver side uses a buzzer, LoRa receiver module and an ESP8266 mini WI-FI module. I used open source code to program the circuits and I have followed all the instructions given, I personally think it’s an issue to do with the soldering quality or a physical wire connection issue, however, I just wanna make sure it isn’t anything else before I star dismantling the circuit.
The issue I’ve been having is that when I try to connect the esp8266 wifi module to the blynk app, the device name consistently has an offline symbol next to it. I have tried updating the libraries, checking the Wi-Fi id and password, etc but nothing is working and I don’t even thing that it’s connected to my android phone at least. I’m from the UK and I have pasted my entire code below for both the transmitter and receiver side.
Transmitter Side:
// I2C Temperature Sensors derived from the LM75 - Version: Latest
#include <Temperature_LM75_Derived.h>
//Lora with Transmitter arduino nano
#include <SPI.h> // include libraries
#include <LoRa.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <LM75A.h>
#include <Adafruit_SSD1306.h>
LM75A lm75a_sensor(false, // A0 LM75A pin state (connected to ground = false)
false, // A1 LM75A pin state (connected to ground = false)
false); // A2 LM75A pin state (connected to ground = false)
// Equivalent to "LM75A lm75a_sensor;"
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
String outgoing; // outgoing message
byte msgCount = 0; // count of outgoing messages
byte MasterNode = 0xFF;
byte Node1 = 0xBB;
float ctemp;
float ftemp;
String Mymessage = "";
void setup() {
Serial.begin(9600); // initialize serial
Wire.begin();
if (!LoRa.begin(433E6)) {
Serial.println("LoRa init failed. Check your connections.");
while (true); // if failed, do nothing
}
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
delay(2000);
display.clearDisplay();
display.setTextColor(WHITE);
}
void loop() {
float temperature_in_degrees = lm75a_sensor.getTemperatureInDegrees();
if (temperature_in_degrees == INVALID_LM75A_TEMPERATURE)
{
Serial.println("Error while getting temperature");
}
else
{
// Serial.print("Temperature: ");
// Serial.print(temperature_in_degrees);
// Serial.print(" degrees ");
//Serial.print(LM75A::degreesToFahrenheit(temperature_in_degrees));
ftemp= LM75A::degreesToFahrenheit(temperature_in_degrees);
// Serial.print(ftemp);
// Serial.println(" fahrenheit)");
display.clearDisplay();
display.setCursor(25,0);
display.setTextSize(1);
display.setTextColor(WHITE);
display.println(" Temperature");
display.setCursor(10,20);
display.setTextSize(2);
//display.print("C: ");
display.print(temperature_in_degrees);
display.print((char)247);
display.print("C");
display.setCursor(10,45);
display.setTextSize(2);
//display.print("F: ");
display.print(ftemp);
display.print((char)247);
display.print("F");
display.display();
Mymessage = Mymessage + temperature_in_degrees + "," + ftemp;
sendMessage(Mymessage,MasterNode,Node1);
delay(100);
Mymessage = "";
}
}
void sendMessage(String outgoing, byte MasterNode, byte otherNode) {
LoRa.beginPacket(); // start packet
LoRa.write(MasterNode); // add destination address
LoRa.write(Node1); // add sender address
LoRa.write(msgCount); // add message ID
LoRa.write(outgoing.length()); // add payload length
LoRa.print(outgoing); // add payload
LoRa.endPacket(); // finish packet and send it
msgCount++; // increment message ID
}
Receiver Side:
// Blynk - Version: Latest
// Blynk - Version: Latest
#include <BlynkSimpleEsp8266.h>
#define BLYNK_TEMPLATE_ID "blynk template id"
#define BLYNK_TEMPLATE_NAME "ESP8266 BLYNK APP"
#define BLYNK_AUTH_TOKEN "auth token"
/*
ESP8266 LoRa Gateway, receiver side
*/
#include <SPI.h> // include libraries
#include <LoRa.h>
#include <Wire.h>
#include <Blynk.h>
#define Nss 15 // D8 pin CS
#define rst 16 // D0
#define dio0 2 // D4
int buzzer = D3;
char auth[] = "-HrsXL8bXKhJrZdFOmVQgK6VfzGoVQqv";
///Connect SCL to D1 and Connect SDA to D2
/* WiFi credentials */
char ssid[] = "network name";
char pass[] = "password";
byte MasterNode = 0xFF;
byte Node1 = 0xBB;
String SenderNode = "";
String outgoing; // outgoing message
byte msgCount = 0; // count of outgoing messages
String incoming = "";
float ctemp;
float ftemp;
void setup() {
Serial.begin(9600); // initialize serial
LoRa.setPins(Nss, rst, dio0);
if (!LoRa.begin(433E6)) { // initialize ratio at 915 MHz
Serial.println("LoRa init failed. Check your connections.");
while (true); // if failed, do nothing
}
// Serial.println("LoRa init succeeded.");
Blynk.begin(auth, ssid, pass);
}
void loop() {
Blynk.run();
// parse for a packet, and call onReceive with the result:
onReceive(LoRa.parsePacket());
}
void onReceive(int packetSize) {
if (packetSize == 0) return; // if there's no packet, return
// read packet header bytes:
int recipient = LoRa.read(); // recipient address
byte sender = LoRa.read(); // sender address
if( sender == 0XBB )
SenderNode = "Node1:";
byte incomingMsgId = LoRa.read(); // incoming msg ID
byte incomingLength = LoRa.read(); // incoming msg length
while (LoRa.available()) {
incoming += (char)LoRa.read();
}
if (incomingLength != incoming.length()) { // check length for error
//Serial.println("error: message length does not match length");
;
return; // skip rest of function
}
// if the recipient isn't this device or broadcast,
if (recipient != Node1 && recipient != MasterNode) {
// Serial.println("This message is not for me.");
;
return; // skip rest of function
}
// if message is for this device, or broadcast, print details:
//Serial.println("Received from: 0x" + String(sender, HEX));
//Serial.println("Sent to: 0x" + String(recipient, HEX));
//Serial.println("Message ID: " + String(incomingMsgId));
// Serial.println("Message length: " + String(incomingLength));
// Serial.println("Message: " + incoming);
//Serial.println("RSSI: " + String(LoRa.packetRssi()));
// Serial.println("Snr: " + String(LoRa.packetSnr()));
// Serial.println();
String q=getValue(incoming, ',', 0);
String r =getValue(incoming, ',', 1);
ctemp = q.toFloat();
Serial.print(ctemp);
Serial.println(" C");
ftemp = r.toFloat();
Serial.print(ftemp);
Serial.println(" F");
Blynk.virtualWrite(V1,ctemp);
Blynk.virtualWrite(V2,ftemp);
if (ctemp >= 40 )
{
Blynk.notify("Temperature Exceeded!!!");
digitalWrite( buzzer, HIGH);
}
if (ctemp < 40 )
{
digitalWrite( buzzer, LOW);
}
//delay(1000);
incoming = "";
}
String getValue(String data, char separator, int index)
{
int found = 0;
int strIndex[] = { 0, -1 };
int maxIndex = data.length() - 1;
for (int i = 0; i <= maxIndex && found <= index; i++) {
if (data.charAt(i) == separator || i == maxIndex) {
found++;
strIndex[0] = strIndex[1] + 1;
strIndex[1] = (i == maxIndex) ? i+1 : i;
}
}
return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
}