
Source Seeeduino
#include <Wire.h>
#include <SeeedOLED.h>
#include <LoRaWan.h>
int sensorPin = A0;
int sensorValue = 0;
int telling;
String q;
char buffer[256];
void setup() {
Wire.begin();
SeeedOled.init(); //initialze SEEED OLED display
SerialUSB.begin(115200);
SeeedOled.clearDisplay(); //clear the screen and set start position to top left corner
SeeedOled.setNormalDisplay(); //Set display to normal mode (i.e non-inverse mode)
SeeedOled.setPageMode(); //Set addressing mode to Page Mode
SeeedOled.setTextXY(0, 0); //Set the cursor to Xth Page, Yth Column
SeeedOled.putString(“Starting Up..”); //Print the String
SeeedOled.setTextXY(6, 0); //Set the cursor to Xth Page, Yth Column
SeeedOled.putString(“Q-Strip Demo”); //Print the String
lora.init();
memset(buffer, 0, 256);
// void setId(char *DevAddr, char *DevEUI, char *AppEUI);
lora.setId(“XXXXXXXX”, “XXXXXXXXXXXXXXXX”, “XXXXXXXXXXXXXXXX”);
// setKey(char *NwkSKey, char *AppSKey, char *AppKey);
lora.setKey(“XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”, “XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”, “XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”);
lora.setDeciveMode(LWABP);
lora.setDataRate(DR0, EU868);
lora.setChannel(0, 868.1);
lora.setChannel(1, 868.3);
lora.setChannel(2, 868.5);
lora.setReceiceWindowFirst(868.0, DR3);
lora.setReceiceWindowSecond(868.1, DR3);
lora.setPower(20);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
SerialUSB.print(“sensor = ” );
SerialUSB.println(sensorValue);
q = String(analogRead(sensorPin));
telling = telling + 1;
String qstripString = String(q);
int length = qstripString.length();
char qlevel[length];
qstripString.toCharArray(qlevel, 4 );
if (telling == 60) {
bool result = false;
result = lora.transferPacket(qlevel, 12);
SeeedOled.setTextXY(0, 0); //Set the cursor to Xth Page, Yth Column
SeeedOled.putString(“** **”); //Print the String
telling = 1; //reset count
}
SeeedOled.setTextXY(0, 0); //Set the cursor to Xth Page, Yth Column
SeeedOled.putString(” TTN DEMO”); //Print the String
SeeedOled.setTextXY(3, 0); //Set the cursor to Xth Page, Yth Column
SeeedOled.putString(“Send value”); //Print the String
SeeedOled.setTextXY(3, 12); //Set the cursor to Xth Page, Yth Column
SeeedOled.putString(” “); //Print the String
SeeedOled.setTextXY(3, 12); //Set the cursor to Xth Page, Yth Column
SeeedOled.putString(qlevel); //Print the String
SeeedOled.setTextXY(6, 0); //Set the cursor to Xth Page, Yth Column
SeeedOled.putString(” www.q-strip.nl “); //Print the String
delay(1000);
}