For a while now, I’ve been curious just how poor the air quality around me gets when I’m soldering. It never really feels like it’s that good, and I always try to limit the my time and exposure to the fumes, but it would be interesting to actually gather the numbers.

When the new MicroMod Ethernet Function board came across my desk, I knew it would be ideal for testing out this curiosity (and not just because of the lack of soldering needed to set the project up!). I wanted to use the Ethernet function board with the Environmental Function board and the MicroMod Teensy Processor as it’s probably the quickest way to put together this project. The Ethernet adds value to the project because it makes it applicable in an end-use industrial environment. It would be great to monitor the air quality of the soldering station here at SparkFun all day, from my desk, as people come and go to solder. I chose the Teensy Processor board as they’ve got a really easy Ethernet library to use for this W5500 chip.

SparkFun MicroMod Ethernet Function Board - W5500

SparkFun MicroMod Ethernet Function Board – W5500

COM-18708

$29.95

SparkFun MicroMod Environmental Function Board

SparkFun MicroMod Environmental Function Board

SEN-18632

$149.95

SparkFun MicroMod Teensy Processor

SparkFun MicroMod Teensy Processor

DEV-16402

$21.50

3


The Hookup

The Hookup is about as simple as it gets! All you need is a screwdriver. However, I will say that when using two function boards like we’re doing, it’s important to make sure they are fully set in the M.2 connector, and also to tighten all of the screws equally (not move from one to the other).

alt text


The Code
The code is also fairly simple, it’s just a mixture of creating a web server and sending the VOC levels from the SGP40 to that server.

/* Industrial air quality remote sensor A simple web server that shows the VOC levels using a Teensy Processor board, the MicroMod Ethernet Function board and the MicroMod Environmental Function board. Taken by Paul Clark's SGP40 code and the built in Arduino example for an Ethernet web server, thanks to David A. Mellis, Tom Igoe and Arturo Guadalupi */ #include <SPI.h>
#include <Ethernet.h>
#include "SparkFun_SGP40_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_SGP40
#include <Wire.h> // Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(192, 168, 1, 177); SGP40 mySensor; //create an object of the SGP40 class // Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80); void setup() { Ethernet.init(10); // For the Teensy // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } Serial.println("Ethernet WebServer Example"); // start the Ethernet connection and the server: Ethernet.begin(mac, ip); // Check for Ethernet hardware present if (Ethernet.hardwareStatus() == EthernetNoHardware) { Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :("); while (true) { delay(1); // do nothing, no point running without Ethernet hardware } } if (Ethernet.linkStatus() == LinkOFF) { Serial.println("Ethernet cable is not connected."); } // start the server server.begin(); Serial.print("server is at "); Serial.println(Ethernet.localIP()); Wire.begin(); if (mySensor.begin() == false) { Serial.println(F("SGP40 not detected. Check connections. Freezing...")); while (1) ; // Do nothing more } } void loop() { // listen for incoming clients EthernetClient client = server.available(); if (client) { Serial.println("new client"); // an http request ends with a blank line boolean currentLineIsBlank = true; while (client.connected()) { if (client.available()) { char c = client.read(); Serial.write(c); // if you've gotten to the end of the line (received a newline // character) and the line is blank, the http request has ended, // so you can send a reply if (c == '\n' && currentLineIsBlank) { // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println("Connection: close"); // the connection will be closed after completion of the response client.println("Refresh: 5"); // refresh the page automatically every 5 sec client.println(); client.println("<!DOCTYPE HTML>"); client.println("<html>"); clinet.println("VOC Index is"); client.println("<br />"); client.println(mySensor.getVOCindex()); client.println("</html>"); break; } if (c == '\n') { // you're starting a new line currentLineIsBlank = true; } else if (c != '\r') { // you've gotten a character on the current line currentLineIsBlank = false; } } } // give the web browser time to receive the data delay(1); // close the connection: client.stop(); Serial.println("client disconnected"); }
}

Testing

Okay, time to test it out and see how the air quality changes when we solder! I found that it took a bit of time for the SGP40 to just calibrate to the room’s natural VOC level. And there’s probably some specific distance that the sensor should sit from the soldering station, but I thought since I sit so close to the fumes, the sensor should be equally close. Turns out, even with the lead free solder, the VOC levels still skyrocketed above the normal VOC numbers.

Project Test

I suppose I’m not surprised; soldering is still introducing new compounds into the air that add to the VOC level. But it was still a good way to build an air quality sensor that can be monitored from anywhere in the building – not just at the soldering station on the serial monitor. And in this case, ethernet was one of the fastest ways to bring this project into the internet space. There are, of course, other ways to build a similar unit, depending on what you have…this could have also been done with a single Ethernet function board and a Qwiic environmental sensor. And of course, there are always ways to make an HTML web server page more spiffy, so that’s something to explore too.

My question for you is what other applications might you chose Ethernet over other IoT protocols? When does it serve you best? Comment below, thanks for following along, and happy hacking!

comments | comment feed

Read more about this on: Sparkfun Commerce Blog