An Open-Source platform to create digital devices and interactive objects that sense and control physical devices. | Arduino Tutorials | |
Arduino Projects |
I am prototyping a an Intelligent Buoy (that evolved into a boat) that uses LoRa to communicate with a base station using the Arduino MKR WAN 1300. This post covers making a more robust prototype board for field testing and the issues encountered.
Daughter Board
All work up until now has been on breadboards and it is time to make something sturdier that can be used in the field. For now, only an Invensys ICP-10100 Barometric Pressure and Temperature Sensor is hooked up to the Arduino Relay Shield.
The video below outlines a daughter board which features a 120 x 160 TFT screen as well as some real estate to hook up sensors in the future. The TFT screen will be used primarily for debugging and testing prior to deployment and is easily removed when desired.
Firmware
An incomplete outline of the code is shown below...
#include <MKRWAN.h> #include "ArduinoLowPower.h" #include <Adafruit_GFX.h> #include <Adafruit_ST7735.h> #include <SPI.h> #include <LoRa.h> #include <icp101xx.h> struct data{ unsigned long numMeasures; float pressPa; float tempC; } readings; const unsigned long SLEEP_TIME = 5000; const unsigned long LISTEN_TIME = 200; void setup(void) { initGPIO(); splashScreen(); initLoRa(); initPressure(); } void loop() { getReadings(readings); sendLoRa(readings); listenLoRa(); delay(SLEEP_TIME); }
To add a new sensor it is necessary to:
- #include the appropriate library
- add values to the data struct which store the sensor readings
- add an initializing function in setup()
- add a reading function in getReadings()
- add print statement(s) for the values in sendLoRa()
The function listenLoRa() waits a short period to see if the base station returns a command. For now, it just returns RSSI. Note the delay(SLEEP_TIME) function call at the bottom of the loop. I tried using LowPower.deepSleep(SLEEP_TIME) which is in the low power library for the Arduino SAMD21 but need to address these two concerns:
- The loop executes quite quickly and then in my code sleeps for 5 seconds. While sleeping the USB port closes on my Windows 10 computer and then the Arduino IDE cannot flash updates when modifying the code. I finally overcame this by holding the reset button on the MKR WAN 1300 until just before the IDE began the flash and releasing it which works as a somewhat hit and miss kludge but I find it disconcerting and for now am using delay().
- Even in deep sleep the MKR WAN 1300 draws more than 1 mA according to posts on the Arduino forum. I have not tested this on my board yet but plan to do so in the coming week.
I would be interested if others are seeing these problems and how they address them.
Field Tests
There is a view of the Puget Sound from the deck at the back of my house and the plan is to test the buoy first from a little public beach beside the ferry dock. It is clear most of the way with some trees and an embankment partially blocking.
The beach is about a kilometer away as the crow flies. The MKR WAN 1300 serving as the base unit was hoisted up on a pole and clamped to the house to get the antenna as high as possible and give the clearest view.
It looks like I need to scrub the gutter :-). Then I took my battery powered buoy unit down to the beach and leaned it against a log to see what the reception is like.
The limit seems to be around -122 for reliable reception.
Moving my body in front of the antenna was enough to cut off reception. If I lifted it up to waist height and pointed the antenna towards the house the reception improves to around -118 or so. I conclude that I can probably do some testing in the area below my house but it is less than ideal. Maybe a directional antenna for the base station?
I plan to hold off publishing schematics and full code listings until further in development but if something interests you just ask and I will shoot it your way. The landing page for all the posts in this project is the first link given below. Comments, corrections, and ideas are always welcome!
Links
Top Comments