element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Just Encase
  • Challenges & Projects
  • Design Challenges
  • Just Encase
  • More
  • Cancel
Just Encase
Blog Blog#4 Testing Part 1 (Case Enclosure Reliability Monitor)
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Just Encase to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: skruglewicz
  • Date Created: 24 Feb 2022 12:04 AM Date Created
  • Views 1541 views
  • Likes 8 likes
  • Comments 3 comments
Related
Recommended

Blog#4 Testing Part 1 (Case Enclosure Reliability Monitor)

skruglewicz
skruglewicz
24 Feb 2022
Blog#4  Testing Part 1 (Case Enclosure Reliability Monitor)

imageBLOG#4 Testing Part 1 (Case Enclosure Reliability Monitor)

Test#2 -  Enclosure1554UGY Test Design

This is my 1st Test design to test the reliability of the Hammond Enclosure 1554UGY

The following components are being used::Arduino MKR WAN 1300 with LoRa radio antenna,DS18B20 Temperature Sensor,Mini OLED I2C Display (SSD1306)   

A project sponsored by Hammond Manufacturing for the Design Challenge: Just Encase

<<< PREVIOUS BLOG NEXT BLOG  >>>

Blog#3 Implementation (Case Enclosure Reliability Monitor)

Blog#5 Testing - Part 2 (Case Enclosure Reliability Monitor)

Table of Contents

  • TEST 1 - Measure the Temperature outside of an enclosure
    • Description
    • Software design
      • SENDER 
      • The Wiring Diagram
      • THE CODE
      • RECEIVER
      • The Wiring Diagram
      • THE CODE
      • Nano IoT 33  Sketch
      • THE CODE
    • Libraries 
    • Dashboard GUI Design
    • Running the Test
      • The Lora sender
      • Putting the LoRa Sender into an 1554UGY Enclosure
      • The LoRa receiver/CloudUpLoader and The Dashboard 
      • Video: Receive_ Cloud_upload.mp4 
      • Dashboard on my Phone
    • Test Conclusions
  • Appendix A - Running the MKRWAN 1300 on Battery power.
  • REFERENCES

TEST 1 - Measure the Temperature outside of an enclosure

Description

  • This simple test design, will measure the temperature outside the  1554UGY enclosure and send the values to a dashboard on the Arduino IoT Cloud
  • My original plan was to run the MKR inside the enclosure,  powered by batteries. (Refer to Appendix A below where I describe how to run on batteries.)
    • But I found out that I needed 5V for the temp sensor circuit, so I reverted to USB power
  • Also there needs to be a LoRa antenna connected to MKR to communicate the data to a second LorRa antenna attached to a second MKR. This design is describe in Blog#3..
  • I will modify the sketches and dashboard used in Blog#3 to send the temperature data through the design.

Software design

SENDER 

  • First off I will make modifications to the Sender sketch
    • This sketch runs on  MKR1
  • I added code for a Temp sensor and an OLED display
    • DS18B20 Temperature Sensor 
    • OLED I2C Display (SSD1306)
  • The additions to the Basic Sketch are as follows.
    • Include the single wire library OneWire.h
    • include a function displayValues(float v) to print the value to the OLED
    • In SETUP()
      • Add configuration code.
      • initialize the I2C for the OLED
    • in the LOOP()
      • Get the temperature value
      • put the temp value in to a value pair variable intemp;:<value>
      • Call the OLED function to write the temp value
      • Send the string in a LoRa packet to the MKR2.

The Wiring Diagram

  • This diagram shows how to connect the following components to the MKR WAN 1300.
  • DS18B20 Temperature Sensor
    • Used to take the current Temperature.
  • Mini OLED I2C Display (SSD1306)
    • Used to display the current Temperature value before sending it to the LoRa receiver.

image

THE CODE


/*
MKR_LoRa_SENDER_InTemp
This sketch will get the temprture from a DS18B20 Temperature Sensor attached to the MKR WAN 1300
Each time the loop runs, we will send a "packet" containing the message "InTemp:<temp>
the value of <temp> will contain the current tempreture from the sensor
The packet will be sent

1-20-2020 Added OLED Adafruit_SSD1306 support.

*/

// MKRWAN - Version: 1.0.15
#include <MKRWAN.h>

#include <SPI.h>
#include <LoRa.h>

#include <OneWire.h>
#include <DallasTemperature.h>

// Include Adafruit Graphics & OLED libraries
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define ONE_WIRE_BUS 2
//#define ONE_WIRE_BUS 4

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors (&oneWire);

float temperature= 0.0;
float Fahrenheit = 0.0;

// OLED CODE for MKR WAN 1300
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

void setup() {
Serial.begin(9600);
/*while (!Serial);*/

Serial.println("LoRa Sender");

if (!LoRa.begin(915E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}

// OLED CODE
// Start Wire library for I2C
Wire.begin();
// initialize OLED with I2C addr 0x3C
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

}

// oled dispaly tempreture
void displayValues(float v){
// Delay to allow sensor to stabalize
delay(2000);
// Clear the display
display.clearDisplay();
//Set the color - always use white despite actual display color
display.setTextColor(WHITE);
//Set the font size
display.setTextSize(1);
//Set the cursor coordinates
display.setCursor(25,0);
display.print("Temprature");
display.setCursor(33,12);
display.setTextSize(3);
display.print(v);
}

void loop() {
Serial.print("Sending packet: ");
Serial.println(Fahrenheit);

// send packet
LoRa.beginPacket();
LoRa.print("inTemp:");
LoRa.print(Fahrenheit);
LoRa.endPacket();

//getting temperature
sensors.requestTemperatures(); //send command for readings

temperature = sensors.getTempCByIndex(0); // VALUE RETURNED IN cELCIUS
// Why "byIndex"?
// You can have more than one DS18B20 on the same bus.
// 0 refers to the first IC on the wire

//Fahrenheit = temperature;
Fahrenheit=sensors.toFahrenheit(temperature); // convert temp into Fahrenheit
//Serial.println(Fahrenheit);

// display the temp on OLED
displayValues(Fahrenheit);
display.display();

delay(5000);
}

RECEIVER

  • No changes to this sketch, Which runs on MKR2
  • It's a passthrough sketch to relay the Telemetry Data send by the MRK1
  • I did add some OLED code to it 

The Wiring Diagram

  • Showing the MKR WAN 1300 with a  LoRa Antenna connected via a serial connection to the Nano 33 IoT 
  • image

THE CODE

/*
MKR_LoRa_Receiver
we will not be creating any packets. Instead, we will listen to incoming ones.
1-20-2020 Added OLED Adafruit_SSD1306 support.

*/
// MKRWAN - Version: 1.0.15
#include <MKRWAN.h>

#include <SPI.h>
#include <LoRa.h>

// Include Adafruit Graphics & OLED libraries
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

// CODE for MKR WAN 1300
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

String inputString = ""; // a String to hold incoming data

void setup() {
Serial.begin(9600);
Serial1.begin(9600);
while (!Serial);

Serial.println("LoRa Receiver");

if (!LoRa.begin((915E6))) {
Serial.println("Starting LoRa failed!");
while (1);
}

// reserve 200 bytes for the inputString:
inputString.reserve(200);

//OLED CODE
// Start Wire library for I2C
Wire.begin();
// initialize OLED with I2C addr 0x3C
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

}

// OLED DISPLAY FUNCTION to display numbers.
void displayValues(String v){
// Delay to allow sensor to stabalize
delay(2000);
// Clear the display
display.clearDisplay();
//Set the color - always use white despite actual display color
display.setTextColor(WHITE);
//Set the font size
display.setTextSize(1);
//Set the cursor coordinates
display.setCursor(25,0);
display.print("Rcvd Packet");
display.setCursor(33,12);
display.setTextSize(3);
display.print(v);
}

void loop() {
// try to parse packet
int packetSize = LoRa.parsePacket();
if (packetSize) {
// received a packet
Serial.print("Received packet '");

// read packet
while (LoRa.available()) {
//Serial.print((char)LoRa.read());
// get the new byte:
char inChar = (char)LoRa.read();
// add it to the inputString:
inputString += inChar;
}

// display on OLED
displayValues(inputString);
display.display();

Serial.print(inputString);
Serial1.print(inputString);
Serial1.print('\n');
// print RSSI of packet
Serial.print("' with RSSI ");
Serial.print(LoRa.packetRssi());
Serial.println("");
inputString = "";
}
}

Nano IoT 33  Sketch

  • This sketch is generated by the Arduino cloud, when you create a temperature Thing on the Arduino Cloud
  • The same code used in the sketch in blog#3 will be modified to add the processing of the temperature
    • Serial RX connection for the Packet coming from MKR2
    • Break out the value pairs (intemp:<value>) sent from the MKR1

THE CODE

/*
Sketch generated by the Arduino IoT Cloud Thing "Counter"
https://create.arduino.cc/cloud/things/8365259b-0af3-440e-add6-fc53e82ea22d

Arduino IoT Cloud Variables description

The following variables are automatically generated and updated when changes are made to the Thing

String counter;
int int_Counter;

Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"
String inputString = ""; // a String to hold incoming data
bool stringComplete = false; // whether the string is complete

float retFloat(String stringOne) {
// Given a tuple pair in the form varname:value ex. inTemp:1.1
// return a float value to the right of the cloen character
//Serial.println(stringOne);
int firstClosingBracket = stringOne.indexOf(':');
String value = String(stringOne.substring(firstClosingBracket+1));
//Serial.println(value);
float Temp = value.toFloat();
return Temp;
}
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
Serial1.begin(9600);

while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

// Defined in thingProperties.h
initProperties();

// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);

/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}

void loop() {
ArduinoCloud.update();
// Your code here

// use the string when a newline arrives:
if (stringComplete) {
Serial.print("received on RX PIN:");
Serial.print(inputString);


//USE THE InputString HERE
counter = inputString;
int_Counter++;
inTemp = retFloat(inputString);
Serial.print("Sending value = ");
Serial.println(inTemp);
//ArduinoCloud.update();
// clear the string:
inputString = "";
stringComplete = false;
}

//At the very end of the loop check for serial data
serialEvent();
}

/*
Since Counter is READ_WRITE variable, onCounterChange() is
executed every time a new value is received from IoT Cloud.
*/
void onCounterChange() {
// Add your code here to act upon Counter change
}

/*
SerialEvent occurs whenever a new data comes in the hardware serial RX. This
routine is run between each time loop() runs, so using delay inside loop can
delay response. Multiple bytes of data may be available.
*/
void serialEvent() {
while (Serial1.available()) {
// get the new byte:
char inChar = (char)Serial1.read();
// add it to the inputString:

inputString += inChar;
// if the incoming character is a newline, set a flag so the main loop can
// do something about it:
if (inChar == '\n') {
stringComplete = true;
}
}
}


/*
Since IntCounter is READ_WRITE variable, onIntCounterChange() is
executed every time a new value is received from IoT Cloud.
*/
void onIntCounterChange() {
// Add your code here to act upon IntCounter change


}

Libraries 

  • // MKRWAN - Version: 1.0.15
    #include <MKRWAN.h>

  • #include <SPI.h>

  • #include <LoRa.h>

  • // Include Adafruit Graphics & OLED libraries
    #include <Adafruit_GFX.h>
    #include <Adafruit_SSD1306.h>

  • #include <OneWire.h>
    #include <DallasTemperature.h>

Dashboard GUI Design

  • the Dashboard is similar to blog#3 in that it display a value using widgets.
  • I uses the device Nano IoT 
    • image
  • For the INSIDE_TEMPRETURE , I created thing for temperature.
    • image
  • I then created a dashboard with widgets to visualize the temperature.
  • Widgets Used:
    • The packet received
    • Value sent
    • Graph the temp
    • Gauge of the incoming temps
    • image

Running the Test

The Lora sender

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Putting the LoRa Sender into an 1554UGY Enclosure

  • I placed these components into the enclosure1554UGY
  • I'm using 2 Hammond Manufacturing Cable Glands That I placed on the cover of the enclosure 
    • 1427 CG16 - for the Power USB connector
    • 1427 NCGPG7G - for the Temperature Sensor wire.
  • The follow pictorial shows how I stuffed the circuit into the 1554UGY and attached the Cable glands to it.
  • I then placed the enclosure in several environments to test how the enclosure stood up. 
  • I placed the Enclosure in my office, garage, outside overnight in the snow and in a 106 degrees.Fahrenheit. and the electronics still continued to operate.

  • First I drilled the holes for the cable glands.

    I used the drill bits shown in this picture to drill the holes

    on the cover of the enclosure.

    I then Attached the cable glands shown.

    image

    Then I ran the USB and the sensor cables through the

    Cable glands. I stuffed the 3 breadboards  into the 

    Case and connected the sensor cable ends to the

    Alligator clips. I then attached the USB cable to the 

    MKR WAN 1300. The OLED display started to display the current tempreture.

    SUCESS!!!!

    Next Close it up and  plug it in.

    image
    image image

    Here is an example of using the waterproof Temperature Sensor to

    Check out the Water temp in my wife's Beta fish Tank. We just purchased

    a heater that is suppose to keep the water at a automatic temp Of 75 degrees Fahrenheit.

    Which I was happy it did the job. 

    image

  • Here are a few pictures of the environments that I subjected the temperature enclosure to  

II placed it in my garage a few hours

image

I placed  it outside overnight.

It was about 27F that night and a dusting of snow fell during the night

image

In the morning I placed the temp probe into the snowbank
and to my surprise the temperature only lowered a few degrees. 

image

My final test was to place the Enclosure into my personal sauna
for about 6 hours.
I was able to get the Temperature in the Sauna up to 107F degrees.

image

image

Here are the graphs showing the temperature changes as I moved the 
Enclosure to the different Environments

GRAPH of all environments over 24 hours

image

GRAPH of the time of the enclosure in my sauna

image

The LoRa receiver/CloudUpLoader and The Dashboard 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image
 

Dashboard on my Phone

image

Test Conclusions

  • Once I implemented the Design outside the enclosure successfully, all the test ran very smoothly
  • In the next Blog, I redesigned the Basic design to add different sensors and use the 2nd Enclosure case. 

Appendix A - Running the MKRWAN 1300 on Battery power.

  • The MKR will run on battery power. I was able to connect a Battery Holder that I purchased on Amazon to the MKRWAN 1300.
  • Here is what needs to be done to upload and run sketches under battery power.
  1. Get a Battery holder with leadsimage
    1. I purchased a pack of 3 from Amazon
    2. LAMPVPATH (Pack of 3) 2 AA Battery Holder with Leads
    3. Type of AA Battery Holder: 2 AA battery holder, 2x 1.5V aa battery holder with wires
    4. Voltage Output of One Double A Battery Holder: 3V, 2 x 1.5v aa batteries = 3v aa battery holder
  2. Connect the battery holder to the MKR WAN 1300
    1. Connect the Leads from the holder to the GREEN connector on the MKR WAN 1300 as described in pic below.
    2. image
    3. DO not insert the AA batteries yet. We need to perform an upload with the serial cable.
    4. Some Holders I've seen have an on/off switch. THe one I'm using does not.
  3. Test the Battery Holder
    1. Use the BLINK example to test thebattery holder connection.
    2. With the Serial USB cable connected , upload and run the blink example.
    3. NEXT, disconnect the serial cable and place the 2 AA bateries into the Holder.
    4. BLINK, should now be running. SUCESS, your running on battery power.
    5. If the BLINK example does not run then check the following:
      1. Assure that there is no code that checks for a serial cable,
      2. check with other batteries
      3. Make sure the Leads are connected properly.

 

<<< PREVIOUS BLOG NEXT BLOG  >>>

Blog#3 Implementation (Case Enclosure Reliability Monitor)

Blog#5 Testing - Part 2 (Case Enclosure Reliability Monitor)

 

REFERENCES

OLED on an MKR
5pcs DS18B20 Temperature Sensor Temperature Probe
Enclosure 1554UGY
1427NCGPG7G  Cable Gland
1427CG16 Cable Gland
  • Icon.png
  • View
  • Hide
  • Sign in to reply
Parents
  • skruglewicz
    skruglewicz over 3 years ago

    I've finished this design challenge

    I hope everyone had as much fun as I did.

    CHECK the other blogs in this series with this search.

    • ALL THE BLOGS IN THE Just Encase Series

    Steve K  (skruglewicz)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • skruglewicz
    skruglewicz over 3 years ago

    I've finished this design challenge

    I hope everyone had as much fun as I did.

    CHECK the other blogs in this series with this search.

    • ALL THE BLOGS IN THE Just Encase Series

    Steve K  (skruglewicz)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube