Blink Now we can upload our first demo - Blink to Seeeduino LoRaWAN. Open your Arduino IDE and click on File > Examples > 01.Basics > Blink to open the sketch or copy the blow code: void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
And Then, - Click on Tools > Board > Seeeduino LoRaWAN
- Click on Tools > Port to select a right port number. (Don’t choose COM1)
Then click on the Upload button on the left-top of Arduino IDE, seconds later the sketch was uploaded successful. If the uploading is success, you should the some info in red and please the on-board LED, it’s blinking. Battery You can power the board via a 3.7V Lipo battery. There’s a JST2.0 cable included, use it if you can’t get a battery with JST2.0 connector. Warning Make sure the positive and negative end of your battery is connected right, otherwise the board may be damaged. Charge status pin and positive pin of the battery had beed connect to A4 and A5, which allow you to detect the charge status and measure voltage of the battery via coding. Copy and upload the below code to detect the battery status. const int pin_battery_status = A5;
const int pin_battery_voltage = A4;
void setup() {
SerialUSB.begin(115200);
pinMode(pin_battery_status, INPUT);
}
void loop() {
int a = analogRead(pin_battery_voltage);
float v = a/1023.0*3.3*11.0;
SerialUSB.print(v, 2);
SerialUSB.print('t');
SerialUSB.println(digitalRead(pin_battery_status));
delay(1000);
}
Note Charge status return 0 while charging, return 1 while charge done or no battery insert. Send and Receive Example There is a well written library for the LoRaWAN modules, for simple applications you even don’t need to know much about the protocol about LoRa, which is complex and hard to read. And please note that you till need some acknowledge about LoRa protocol if you want an advanced application. You don’t need to download the library, it’s included in the package already. You can open it at File > Examples > LoRaWAN. You need 2 piece of Seeeduino LoRaWAN to complete this example, one for sending and another for receiving. Sending Open your Arduino IDE and click on File > Examples > LoRaWAN > p2p_tx to open the sketch or you can copy the code below. This sketch will broadcast a string “Hello World!” every 3000 ms. #include <LoRaWan.h> void setup(void) {
SerialUSB.begin(115200);
lora.init();
lora.initP2PMode(433, SF12, BW125, 8, 8, 20);
}
void loop(void) {
lora.transferPacketP2PMode("Hello World!");
SerialUSB.println("Send string.");
delay(3000);
}
Receiving Open your Arduino IDe and click on File > Examples > LoRaWAN > p2p_rx to open the sketch or you can copy the code below.
#include <LoRaWan.h>
unsigned char buffer[128] = {0, };
void setup(void)
{
SerialUSB.begin(115200);
lora.init();
lora.initP2PMode(433, SF12, BW125, 8, 8, 20);
}
void loop(void)
{
short length = 0;
short rssi = 0;
memset(buffer, 0, 128);
length = lora.receivePacketP2PMode(buffer, 128, &rssi, 1);
if(length)
{
SerialUSB.print("Length is: ");
SerialUSB.println(length);
SerialUSB.print("RSSI is: ");
SerialUSB.println(rssi);
SerialUSB.print("Data is: ");
for(unsigned char i = 0; i < length; i ++)
{
SerialUSB.print("0x");
SerialUSB.print(buffer[i], HEX);
SerialUSB.print(" ");
}
SerialUSB.println();
}
}
After both of the sketch is well uploaded, open the serial monitor of the receiving board, check if you can get some data as below. Note There will be a gateway kit for LoRa soon, and we will add getting started about APB and OTAA mode at wiki of the kit. Examples We had provide many useful examples. You can open File > Examples > LoRaWan get more details. Those examples include: GPS Data Note This chapter works with Seeeduino LoRaWAN W/GPS only. Copy below code you Seeeduino LoRaWAN W/GPS. void setup()
{
Serial.begin(9600);
SerialUSB.begin(115200);
}
void loop()
{
while(Serial.available())
{
SerialUSB.write(Serial.read());
}
while(SerialUSB.available())
{
Serial.write(SerialUSB.read());
}
}
Open Serial Monitor then you will get data from GPS. Low Power The minimum current is 80uA(for Seeeduino LoRaWAN) under our testing. Please follow below steps. - Remove PWR LED (If you don’t remove this LED, the current will > 2mA)
- Remove CHG LED
- Upload below code to your board.
#include <LoRaWan.h> #include <EnergySaving.h>
EnergySaving nrgSave;
void blink() {
for(unsigned char i = 0; i < 5; i ++)
{
digitalWrite(13,HIGH);
delay(500);
digitalWrite(13,LOW);
delay(500);
}
}
void setup() {
for(unsigned char i = 0; i < 26; i ++)
{
pinMode(i, OUTPUT);
digitalWrite(i, HIGH);
}
lora.init();
blink();
lora.setDeviceLowPower();
blink();
nrgSave.begin(WAKE_EXT_INTERRUPT, 7, dummy);
nrgSave.standby();
}
void loop() {
blink();
nrgSave.standby();
}
void dummy(void) {
}
Update firmware The firmware version of is 2.0.10, if you want to update firmware, few steps need to follow. If you want to check version of you board, please upload below code to your board. void setup()
{
Serial1.begin(9600);
SerialUSB.begin(115200);
}
void loop()
{
while(Serial1.available())
{
SerialUSB.write(Serial1.read());
}
while(SerialUSB.available())
{
Serial1.write(SerialUSB.read());
}
}
Open your Serial Monitor and INPUT AT+VER Then you will get the version of your board. Step1 Copy and upload below code to your board. #include <Arduino.h> void setup() {
SerialDBG.begin(115200);
SerialUSB.begin(115200);
}
void loop() {
while(SerialDBG.available())
{
SerialUSB.write(SerialDBG.read());
}
while(SerialUSB.available())
{
SerialDBG.write(SerialUSB.read());
}
}
Step2 Remove the board form USB and reconnect again, then press the DFU Button, after the Firmware mode led blinking you can go to the next step. Step3 Click to download the latest firmware, which is a .bin file. Step4 Open PuTTy and connect to the board Step5 After connect your board to PuTTy successful, you will find the char ‘C’ print on the monitor continually. Click on Files Transfer > Ymodem > Send, and select the .bin file we had downloaded at Step4. Then the updating is started. Resources Help us make it better Thank you for choosing Seeed. A couple of months ago we initiated a project to improve our documentation system. What you are looking at now is the first edition of the new documentation system. Comparing to the old one, here is the progresses that we made: - Replaced the old documentation system with a new one that was developed from Mkdocs, a more widely used and cooler tool to develop documentation system.
- Integrated the documentation system with our official website, now you can go to Bazaar and other section like Forum and Community more conveniently.
- Reviewed and rewrote documents for hundreds of products for the system’s first edition, and will continue migrate documents from old wiki to the new one.
An easy-to-use instruction is as important as the product itself. We are expecting this new system will improve your experience when using Seeed’s products. However since this is the first edition, there are still many things need to improve, if you have any suggestions or findings, you are most welcome to submit the amended version as our contributor or give us suggestions in the survey below, Please don’t forget to leave your email address so that we can reply. Happy hacking |