I am making good progress toward completing the sensor software that I need for my thermal and submersion testing. I thought it would be a good time to elaborate what I am doing. The final implementation details and code will be covered in the Final Summary Blog.
I am going to implement the following sensors:
- lattePanda core temperature and power
- enclosure environment (temperature, humidity, pressure, gas, altitude)
- internal thermistor
- external thermistor
- water leak detector (this is a new addition)
Software Selection
Limited space on C drive
I thought that it is necessary to mention that I made different software choices than I might normally have used for development because of the lack of "disk" space on the lattePanda. The units that were provided for the challenge had 2GB of RAM and 32GB of eMMC memory that is used for the Windows C drive. I had hoped that there might be 10GB of free space on the drive, but out-of-the box there was only 4-5GB available (this value varies because the disk is also used for swap space).
I had hoped for some low hanging fruit (files to delete), but there was nothing obvious like restore points or downloaded update files to delete.
A quick look showed that WIndows itself (not surprisingly) was the biggest culprit.
And the largest component was WinSxS. What is WinSxS? WinSxS (short for “Windows Side by Side”) is a folder where Windows stores files required for installing Windows and backups or versions of those files. Whenever you need to recover system files or add or remove Windows features, this is where Windows will search for the files required to perform an action.
Of course, Microsoft has a caveat:
But it provides a tool in Task Scheduler - StartComponentCleanup - to do the job safely.
Unfortunately, it is set to run automatically and has run in the past week - so that doesn't help (although I did try re-running it).
So, that leaves me with a couple of options:
- Use a different OS with a smaller disk footprint - like Linux (I think that one of the other challengers is doing this)
- Restrict development software to tools that do not have a large disk space requirement
I decided for option 2 as the simplest for moving ahead with the challenge. Maybe to make the lattePanda more useful after the challenge I'll switch to Linux.
Selected tools
My primary requirements are to operate sensors using the integrated Arduino co-processor and to make the sensor data available remotely.
Here are the set of tools that I decided to use:
- TightVNC
- Open Hardware Monitor
- Arduino IDE (version 1.8.16 was already pre-installed)
- Node.js
- Node-Red
The total footprint for the software that I'm using is about 500MB and the largest component is the Arduino IDE which was already installed (350MB).
BME680 Program
Shown below is the hardware setup. I am using an Adafruit BME680 module with QWIIC connectors and I have it plugged into the Arduino header I2C pins on the lattePanda using a QWIIC to male pin cable..
The integrated Arduino component shows up in the IDE as a "LattePanda Leonardo" board on COM3:
I needed to install the Adafruit_Sensor and Adafruit_BME680 libraries. Running the "bme680test" example from the Adafruit_BME680 library produced the following output:
Thermistor Program
Shown below are the 100K NTC (negative temperature coefficient) thermistors that I am using.
The internal thermistor will be connected between the A1 pin and +5V with a 100K pulldown between A1 and ground as shown below. I haven't decided which point on the lattePanda board that I will monitor with it. I'll try getting a thermal image of the board to see if there are any points of interest. The external thermistor will have the same attachment to A2.
Doing an analogRead(A1) at 1 second intervals produces a fairly noisy plot. I'll probably need to add a capacitor across the pulldown resistor.
A quick try using a 30 point moving average does a good job of smoothing. The peak is caused by holding the thermistor between my fingers. I'll need to take some data to get an analog value to temperature correlation.
Uploading Sensor Data
The lattePanda documentation recommends using Arduino Firmata and Windows apps written with C# using Visual Studio to interface with GPIO pins and sensors on the Arduino. I decided not to go that route because of the lack of availability of free disk space. A similar approach using Firmata with Python would require less disk space, but I decided the simplest approach would be to interface the Arduino program communicating with Node-Red through the Serial Port using JSON strings. Node-Red will also allow me to access the Open Hardware Monitor data using WMIC.
Install node.js
I downloaded the 64-bit Windows Installer (.msi) and installed node.js. This is required to run Node-Red.
Install Node-Red
Node-Red is installed using the package manager from the command prompt - npm install -g --unsafe-perm node-red.
I did not install node.js build tools because they require too much disk space.
Within Node-Red I needed to install two additional pallettes to get the serial port interface and dashboard nodes. My current pallette looks like this:
Arduino Program Changes
I want to format the sensor data as JSON strings to upload via the serial port. This required adding the ArduinoJson library to my program to include the formatting functions.
Node-Red Flow
Interface Nodes
I need 3 communication interfaces (nodes) to process the sensor data:
- Serial Port to get data from the Arduino
- Exec to get data from the Open Hardware Monitor
- MQTT to upload the data to the network
Serial Port Nodes
Exec Node
I am using WMIC (Windows Management Instrumentation command-line) to read the outputs from the Open Hardware Monitor (OHM). OHM needs to be running.
Then the following command line will e.g. extract the CPU Core #1 Temperature:
wmic /namespace:\\root\OpenHardwareMonitor path sensor where "Name like '%CPU Core #1%' and SensorType='Temperature'" get Value /value
This is the command that I am using in the exec node.
MQTT Nodes
This particular node is configured to send data to a Node-Red Dashboard that I have running on a RPi4 on my LAN.
lattePanda Flow
Node-Red-Dashboard
Next Steps
I need to finish the Arduino program to add the two thermistors and the water leak detector. This will require some testing and calibration.
I am still waiting for the boot/backshell for the external RJ45 cable. This will require drilling a couple of mounting holes in the enclosure, so I can't assemble the enclosure until that is finished.
I am also trying to figure out how to fixture the submersion test. I am not going to test it at the rated 1 meter depth as I am not equipped to do that. I just want to test it fully submerged in a setup where I can abort quickly if a large leak is visually detected.