Remote Monitoring UV sensor data using LoRa Ebyte E32 Transceiver:

Components:
- 2 x ESP8266 D1 Mini
- 2 x Lora Ebyte E32 Transceiver module
- 1 x ML8511 UV Sensor

Send and receive UV sensor data using Arduino EBYTE library.
Link: https://github.com/KrisKasprzak/EBYTE

Data Receiver:


Data Transmitter:


Installing EBYTE Library on Arduino IDE:

Download the EBYTE-master.zip file from  https://github.com/KrisKasprzak/EBYTE github.
From Arduino IDE, Sketch -> Include Library -> Add Zip library.


Upload the downloaded EBYTE-master.zip file.

Once uploaded, from IDE,  File -> Examples -> EBYTE -> ESP8266 ->


Open Send.ino and Make little change.

Line #84:  MyData.Volts = MyData.Bits * ( 5.0 / 1024.0 ); change to
                MyData.Volts = MyData.Bits * ( 3.3 / 1024.0 );

since we are using 3.3V ref (Supply).
Compile and upload.
It reads the Analog input voltage from UV Sensor module and transmit every second.

Send.ino sketch:

/*

  This example shows how to connect to an EBYTE transceiver
  using an ESP8266

  This code for for the sender


*/

#include <SoftwareSerial.h>
#include "EBYTE.h"

/*
WARNING: IF USING AN ESP8266
DO NOT USE THE PIN NUMBERS PRINTED ON THE BOARD
YOU MUST USE THE ACTUAL GPIO NUMBER
*/

#define PIN_RX 14   //D5 on the board (Connect this to the EBYTE TX pin)
#define PIN_TX 12   //D6 on the board (connect this to the EBYTE RX pin)

#define PIN_M0 5    //D1 on the board (connect this to the EBYTE M0 pin)
#define PIN_M1 4    //D2 on the board (connect this to the EBYTE M1 pin)
#define PIN_AX 16   //D0 on the board (connect this to the EBYTE AUX pin)

// i recommend putting this code in a .h file and including it
// from both the receiver and sender modules

// these are just dummy variables, replace with your own
struct DATA {
  unsigned long Count;
  int Bits;
  float Volts;
  float Amps;

};

int Chan;
DATA MyData;
int i;

// you will need to define the pins to create the serial port
SoftwareSerial ESerial(PIN_RX, PIN_TX);

// create the transceiver object, passing in the serial and pins
EBYTE Transceiver(&ESerial, PIN_M0, PIN_M1, PIN_AX);

void setup() {

  Serial.begin(9600);

  ESerial.begin(9600);
  
  Serial.println("Starting Sender");

  // this init will set the pinModes for you
  Serial.println(Transceiver.init());

  // all these calls are optional but shown to give examples of what you can do

  // Serial.println(Transceiver.GetAirDataRate());
  // Serial.println(Transceiver.GetChannel());
  // Transceiver.SetAddressH(1);
  // Transceiver.SetAddressL(1);
  // Chan = 15;
  // Transceiver.SetChannel(Chan);
  // save the parameters to the unit,
  // Transceiver.SaveParameters(PERMANENT);

  // you can print all parameters and is good for debugging
  // if your units will not communicate, print the parameters
  // for both sender and receiver and make sure air rates, channel
  // and address is the same
  Transceiver.PrintParameters();

}

void loop() {

  // measure some data and save to the structure
  MyData.Count++;
  MyData.Bits = analogRead(A0);
  MyData.Volts = MyData.Bits * ( 3.3 / 1024.0 );

  // i highly suggest you send data using structures and not
  // a parsed data--i've always had a hard time getting reliable data using
  // a parsing method
  Transceiver.SendStruct(&MyData, sizeof(MyData));

    // note, you only really need this library to program these EBYTE units
    // you can call write directly on the EBYTE Serial object
    // ESerial.write((uint8_t*) &Data, PacketSize );


  // let the use know something was sent
  Serial.print("Sending: "); Serial.println(MyData.Count);
  delay(1000);


}

In the receiver side, Receive.ino sketch has been modified to calculate the UV Intensity based on
UV Intensity (
mW/cm²)= (Sensor Volt - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;

Where:  in_min = 0.99
             out_max = 2.8
             out_min = 0.0
             out_max = 15

Upload the modified Receive.ino to the receiver D1 Mini.


Receive.ino:


/*

  This example shows how to connect to an EBYTE transceiver
  using an ESP8266

  This code for for the sender
  Modified by AMP Tech 2022 
*/

#include <SoftwareSerial.h>
#include "EBYTE.h"


/*
WARNING: IF USING AN ESP8266
DO NOT USE THE PIN NUMBERS PRINTED ON THE BOARD
YOU MUST USE THE ACTUAL GPIO NUMBER
*/
#define PIN_RX 14   //D5 on the board (Connect this to the EBYTE TX pin)
#define PIN_TX 12   //D6 on the board (connect this to the EBYTE RX pin)

#define PIN_M0 5    //D1 on the board (connect this to the EBYTE M0 pin)
#define PIN_M1 4    //D2 on the board (connect this to the EBYTE M1 pin)
#define PIN_AX 16   //D0 on the board (connect this to the EBYTE AUX pin)



// i recommend putting this code in a .h file and including it
// from both the receiver and sender modules
struct DATA {
  unsigned long Count;
  int Bits;
  float Volts;
  float Amps;

};

// these are just dummy variables, replace with your own
int Chan;
DATA MyData;
unsigned long Last;

SoftwareSerial ESerial(PIN_RX, PIN_TX);

// create the transceiver object, passing in the serial and pins
EBYTE Transceiver(&ESerial, PIN_M0, PIN_M1, PIN_AX);

void setup() {


  Serial.begin(9600);

  ESerial.begin(9600);
  Serial.println("Starting Reader");

  // this init will set the pinModes for you
  Transceiver.init();

  // all these calls are optional but shown to give examples of what you can do

  // Serial.println(Transceiver.GetAirDataRate());
  // Serial.println(Transceiver.GetChannel());
  // Transceiver.SetAddressH(1);
  // Transceiver.SetAddressL(1);
  // Chan = 15;
  // Transceiver.SetChannel(Chan);
  // save the parameters to the unit,
  // Transceiver.SetPullupMode(1);
  // Transceiver.SaveParameters(PERMANENT);

  // you can print all parameters and is good for debugging
  // if your units will not communicate, print the parameters
  // for both sender and receiver and make sure air rates, channel
  // and address is the same
  Transceiver.PrintParameters();


}

void loop() {

  // if the transceiver serial is available, proces incoming data
  // you can also use Transceiver.available()


  if (ESerial.available()) {

    // i highly suggest you send data using structures and not
    // a parsed data--i've always had a hard time getting reliable data using
    // a parsing method

    Transceiver.GetStruct(&MyData, sizeof(MyData));

    // note, you only really need this library to program these EBYTE units
    // you can call readBytes directly on the EBYTE Serial object
    // ESerial.readBytes((uint8_t*)& MyData, (uint8_t) sizeof(MyData));


    // dump out what was just received
    Serial.print("Count: "); Serial.println(MyData.Count);
    Serial.print("Bits: "); Serial.println(MyData.Bits);
    Serial.print("Volts: "); Serial.println(MyData.Volts);
    // if you got data, update the checker
    float uvIntensity = mapfloat(MyData.Volts, 0.99, 2.8, 0.0, 15.0);
    Serial.print("uvIntensity: "); Serial.print(uvIntensity);Serial.println("mW/cm²");
    Serial.println("--------------------------------------");
    Last = millis();

  }
  else {
    // if the time checker is over some prescribed amount
    // let the user know there is no incoming data
    if ((millis() - Last) > 1000) {
      Serial.println("Searching: ");
      Last = millis();
    }

  }
}
//--------------------------------------
//Calculate UV Intensity based on the Vout from UV Sensor data
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
Serial Monitor output (Receiver):

 

Mode (HEX/DEC/BIN): C0/192/11000000

AddH (HEX/DEC/BIN): 0/0/0

AddL (HEX/DEC/BIN): 0/0/0

Sped (HEX/DEC/BIN): 1A/26/11010

Chan (HEX/DEC/BIN): 17/23/10111

Optn (HEX/DEC/BIN): 44/68/1000100

Addr (HEX/DEC/BIN): 0/0/0

 

SpeedParityBit (HEX/DEC/BIN)    : 0/0/0

SpeedUARTDataRate (HEX/DEC/BIN) : 3/3/11

SpeedAirDataRate (HEX/DEC/BIN)  : 2/2/10

OptionTrans (HEX/DEC/BIN)       : 0/0/0

OptionPullup (HEX/DEC/BIN)      : 1/1/1

OptionWakeup (HEX/DEC/BIN)      : 0/0/0

OptionFEC (HEX/DEC/BIN)         : 1/1/1

OptionPower (HEX/DEC/BIN)       : 0/0/0

----------------------------------------

Count: 990

Bits: 391

Volts: 1.26

uvIntensity: 2.24mW/cm²

--------------------------------------

Count: 991

Bits: 391

Volts: 1.26

uvIntensity: 2.24mW/cm²

--------------------------------------

Count: 992

Bits: 391

Volts: 1.26

uvIntensity: 2.24mW/cm²

--------------------------------------

Count: 993

Bits: 391

Volts: 1.26

uvIntensity: 2.24mW/cm²

--------------------------------------









&

0Comments

For Comment you need to Login


Related Product

ML8511 UVB UV Rays Sensor Breakout Test Module For Arduino

ML8511 UVB UV Rays Sensor Breakout Test Module For Arduino

ML8511 UVB UV Rays Sensor Breakout Test Module For Arduino:The ML8511 sensor breakout is a..

$12.50

ESP8266 ESP-12 ESP-12F CH340G V2 USB WeMos D1-Mini WIFI Development Board

ESP8266 ESP-12 ESP-12F CH340G V2 USB WeMos D1-Mini WIFI Development Board

NodeMCU Lua IOT Board 3.3V With Pins D1 Mini is mini WiFi board based on ESP8266 Compatible with M..

$7.90

LoRa E32 / AS32 SX1278 433 MHz TTL100 UART Ebyte Long Range RF Transceiver Module + SMA Antenna

LoRa E32 / AS32 SX1278 433 MHz TTL100 UART Ebyte Long Range RF Transceiver Module + SMA Antenna

LoRa E32 / AS32 SX1278 433 MHz TTL100 UART Ebyte Long Range RF Transceiver Module:E32 / AS..

$20.50