Data Logging Using The Ethernet Featherwing.

The Birth of The OPEnS HUB

Abstract

For the past several weeks the primary focus of myself and the other undergraduate researchers at the OPEnS Lab has been to get a working, deployable prototype of an Evaporometer (link here) sensor for use for a partner research group. This project required numerous data transmission protocols and untimely it is our hope to add remote data-logging capabilities using the Ethernet Feathering.  


Our Ethernet Featherwing Shield integrated with the Adafruit  FEATHER 32u4 RFM95   LoRa   Radio  board. Our Ethernet Featherwing Shield integrated with the Adafruit  FEATHER 32u4 RFM95   LoRa   Radio  board. 

Our Ethernet Featherwing Shield integrated with the Adafruit FEATHER 32u4 RFM95 LoRa Radio board. 

Objective

The goal of this project is to establish a means of remotely data logging sensor data to a google sheet via the Ethernet Featherwing shield and the third party cloud based API, PushingBox. For more on how to set up the google sheet and PushingBox service please see a previous project I did using the ESP8266 WIFI chip found here

Materials and Methods

The key components required for this project  were 1) the Ethernet FeatherWing Shield , 2) The Adafruit FEATHER 32u4 RFM95 LoRa Radio – 915 MHz (or Feather board of preference), 3) an authorized Ethernet port with access to the internet, 4) Ethernet cable, 5) Solder, Header pins, and basic electronic skills, 6) and of course a computer with the Arduino Integrated Development Environment (Latest Version downloadable here). 


Bare Ethernet Featherwing ShieldBare Ethernet Featherwing Shield

Bare Ethernet Featherwing Shield

 

More About the Featherwing

The Ethernet FeatherWing plugs into any Feather (all in one microcontroller made by Adafruit, more info here)  and adds hard-wired networking. To make it as cross-platform compatible as possible, the board is set up using SPI, plus one extra configurable pin. This Ethernet option allows for a strong reliable connection to the internet and can allow for fast, real-time updates via any wired access point. 

Results/Discussion

Preliminary testing of the Ethernet Featherwing showed promising results, however more testing and code modification will be needed in order to log data to google sheets using Domain Name Servers. However, below is some sample code used to determine if a connection has been made to the internet using Adafruit servers. 

  1. /*
  2. Web client
  3.  
  4. This sketch connects to a website (http://www.adafruit.com)
  5. using an Arduino Wiznet Ethernet shield/FeatherWing.
  6.  
  7. created 18 Dec 2009
  8. by David A. Mellis
  9. modified 7/14/2017
  10. by Tom DeBell, For use in the OPEnS Lab
  11.  
  12. */
  13.  
  14. #include <SPI.h>
  15. #include <Ethernet2.h>
  16.  
  17. // Enter a MAC address for your controller below.
  18. // Newer Ethernet shields have a MAC address printed on a sticker on the shield
  19. byte mac[] = { 0x(), 0x(), 0x(), 0x(), 0x(), 0x() };
  20. // if you don’t want to use DNS (and reduce your sketch size)
  21. // use the numeric IP instead of the name for the server:
  22. //IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
  23. #define URLHOST “www.adafruit.com” // name address for Adafruit (using DNS)
  24. #define URLPATH “/testwifi/index.html” // url to grab
  25.  
  26. // Set the static IP address to use if the DHCP fails to assign
  27. IPAddress ip(192, 168, 0, 177);
  28.  
  29. // Initialize the Ethernet client library
  30. // with the IP address and port of the server
  31. // that you want to connect to (port 80 is default for HTTP):
  32. EthernetClient client;
  33.  
  34. unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
  35. const unsigned long postingInterval = 10L * 1000L; // delay between updates, in milliseconds
  36. // the “L” is needed to use long type numbers
  37.  
  38. //#define WIZ_RESET 9
  39.  
  40. #if defined(ESP8266)
  41. // default for ESPressif
  42. #define WIZ_CS 15
  43. #elif defined(ESP32)
  44. #define WIZ_CS 33
  45. #elif defined(ARDUINO_STM32_FEATHER)
  46. // default for WICED
  47. #define WIZ_CS PB4
  48. #elif defined(TEENSYDUINO)
  49. #define WIZ_CS 10
  50. #elif defined(ARDUINO_FEATHER52)
  51. #define WIZ_CS 11
  52. #else // default for 328p, 32u4 and m0
  53. #define WIZ_CS 10
  54. #endif
  55.  
  56.  
  57. void setup() {
  58. #if defined(WIZ_RESET)
  59. pinMode(WIZ_RESET, OUTPUT);
  60. digitalWrite(WIZ_RESET, HIGH);
  61. delay(100);
  62. digitalWrite(WIZ_RESET, LOW);
  63. delay(100);
  64. digitalWrite(WIZ_RESET, HIGH);
  65. #endif
  66.  
  67. #if !defined(ESP8266)
  68. while (!Serial); // wait for serial port to connect.
  69. #endif
  70.  
  71. // Open serial communications and wait for port to open:
  72. Serial.begin(115200);
  73. delay(1000);
  74. Serial.println(“\nHello! I am the Ethernet FeatherWing”);
  75.  
  76. Ethernet.init(WIZ_CS);
  77.  
  78. // give the ethernet module time to boot up:
  79. delay(1000);
  80.  
  81. // start the Ethernet connection:
  82. if (Ethernet.begin(mac) == 0) {
  83. Serial.println(“Failed to configure Ethernet using DHCP”);
  84. // no point in carrying on, so do nothing forevermore:
  85. // try to congifure using IP address instead of DHCP:
  86. Ethernet.begin(mac, ip);
  87. }
  88.  
  89. // print the Ethernet board/shield’s IP address:
  90. Serial.print(“My IP address: “);
  91. Serial.println(Ethernet.localIP());
  92. }
  93.  
  94. void loop() {
  95. // if there’s incoming data from the net connection.
  96. // send it out the serial port. This is for debugging
  97. // purposes only:
  98. if (client.available()) {
  99. char c = client.read();
  100. Serial.write(c);
  101. }
  102.  
  103. // if ten seconds have passed since your last connection,
  104. // then connect again and send data:
  105. if (millis() – lastConnectionTime > postingInterval) {
  106. httpRequest();
  107. }
  108.  
  109. }
  110.  
  111. // this method makes a HTTP connection to the server:
  112. void httpRequest() {
  113. // close any connection before send a new request.
  114. // This will free the socket on the WiFi shield
  115. client.stop();
  116.  
  117. // if there’s a successful connection:
  118. if (client.connect(URLHOST, 80)) {
  119. Serial.println(“connecting…”);
  120. // send the HTTP PUT request:
  121. client.println(“GET ” URLPATH ” HTTP/1.1″);
  122. client.println(“Host: ” URLHOST);
  123. client.println(“User-Agent: arduino-ethernet”);
  124. client.println(“Connection: close”);
  125. client.println();
  126.  
  127. // note the time that the connection was made:
  128. lastConnectionTime = millis();
  129. }
  130. else {
  131. // if you couldn’t make a connection:
  132. Serial.println(“connection failed”);
  133. }
  134. }

Below is a screenshot of what the Serial Monitor should print out fallowing a successful test.


Successful Internet Connection Test!Successful Internet Connection Test!

Successful Internet Connection Test!

Future of Project

More updates will be posted here once a connection to Google Sheets has been made. 

 

– Tom DeBell, Beginning/Continuing Researcher Support Program Researcher