Close

In The Air – Week 18

I needed to work on a few things before tomorrow’s final summary post and challenge deadline. Here’s a quick overview.

Boosterpack

The little boosterpack I soldered last week works! I am able to make more stable measurements using the CC3200’s ADC. The Energia sketch was updated to make the conversion back to the actual voltage and then convert it to dust concentration (mg/m3) based on the graph provided in the dust sensor’s datasheet.

Screen Shot 2015-02-26 at 20.54.55 Screen+Shot+2014-12-11+at+22.14.26

OpenHAB

I’ve also been working on the OpenHAB config to get all monitored parameters nicely categorized and organized. A debug menu has also been foreseen, providing additional values for troubleshooting purposes.

Here are some code snippets to better understand how I’ve created my openHAB configs.

The items file contains the monitored parameters of a remote sensor using MQTT. In the item definition below, you’ll see how every item takes the value from a specific MQTT topic. The item file can easily be expanded with new items for extra parameters or extra remote sensors.

Group All

String livingroom "Living Room" 
String office "Office" 
String bedroom1 "Bedroom #1" 
String bedroom2 "Bedroom #2" 

Number FT_Voltage_Period "Chart Period"
Number FT_TimeToEmpty_Period "Chart Period"
Number FT_StateOfCharge_Period "Chart Period"
Number FT_Temperature_Period "Chart Period"
Number DS_Density_Period "Chart Period"
Number DS_Voltage_Period "Chart Period"

Number FT_Voltage "Battery Voltage [%d mV]" (All) {mqtt="<[eclipseIot:cc3200-fvan/voltage:state:default]"}
Number FT_TimeToEmpty "Battery Time to empty [%d min]" (All) {mqtt="<[eclipseIot:cc3200-fvan/tte:state:default]"}
Number FT_StateOfCharge "Battery [%d %%]"  (All) {mqtt="<[eclipseIot:cc3200-fvan/soc:state:default]"}
Number FT_Temperature "Temperature [%d C] " (All) {mqtt="<[eclipseIot:cc3200-fvan/temp:state:default]"}
Number DS_Density "Dust [%.2f mg/m]"  (All) {mqtt="<[eclipseIot:cc3200-fvan/ddens:state:default]"}
Number DS_Voltage "Dust Voltage [%.2f V]" (All) {mqtt="<[eclipseIot:cc3200-fvan/dvolt:state:default]"}

String Launchpad "Launchpad [%s]" (All) {serial="/dev/ttyO0"}
Switch Socket "Filter" 

The sitemap structures all the data in the web interface. I opted for a view per room, with every room containing all the monitored parameters. Just like the items file, the sitemap can easily be expanded to contain more rooms.

Frame {
        Text item=livingroom {
                Frame {
                        Text item=FT_Temperature valuecolor=[>35="red",>25="orange",>15="green",<15="blue"] {
                                Switch item=FT_Temperature_Period label="Chart Period" mappings=[0="Hour", 1="Day", 2="Week"]
                                Chart item=FT_Temperature period=h refresh=6000 visibility=[FT_Temperature_Period==0, FT_Temperature_Period=="Uninitialized"]
                                Chart item=FT_Temperature period=D refresh=30000 visibility=[FT_Temperature_Period==1]
                                Chart item=FT_Temperature period=W refresh=30000 visibility=[FT_Temperature_Period==2]
                        }
                        Text item=DS_Density {
                                Switch item=DS_Density_Period label="Chart Period" mappings=[0="Hour", 1="Day", 2="Week"]
                                Chart item=DS_Density period=h refresh=6000 visibility=[DS_Density_Period==0, DS_Density_Period=="Uninitialized"]
                                Chart item=DS_Density period=D refresh=30000 visibility=[DS_Density_Period==1]
                                Chart item=DS_Density period=W refresh=30000 visibility=[DS_Density_Period==2]
                        }
                        Text item=FT_StateOfCharge valuecolor=[>79="green",>29="orange",<30="red"] {
                                Switch item=FT_StateOfCharge_Period label="Chart Period" mappings=[0="Hour", 1="Day", 2="Week"]
                                Chart item=FT_StateOfCharge period=h refresh=6000 visibility=[FT_StateOfCharge_Period==0, FT_StateOfCharge_Period=="Uninitialized"]
                                Chart item=FT_StateOfCharge period=D refresh=30000 visibility=[FT_StateOfCharge_Period==1]
                                Chart item=FT_StateOfCharge period=W refresh=30000 visibility=[FT_StateOfCharge_Period==2]
                        }
                        Switch item=Socket
                }
                Frame {
                        Text label="Debug" icon="debug" {
                         ...
                         }
               }
     }
}

The rules files contains some logic to trigger actions depending certain values. For example, when the socket's state is set to ON or OFF a specific value is sent to the MSP430FR5969 Launchpad in order to control the fan with filter. Turning the socket ON or OFF is based on the measured dust concentration.

rule "Fan Control"
when
     Item Socket changed
then
      if(Socket.state == ON) {
                sendCommand (Launchpad , "#A")
        } else {
        sendCommand (Launchpad , "#U")
        }
end

rule "Dust Filtering"
when
        Item DS_Density changed
then
        if(DS_Density.state > 0.1) {
                sendCommand (Socket, ON)
        }
        else if(DS_Density.state < 0.05) {
                sendCommand (Socket, OFF)
        }
end

The events log shows that the fan is triggered to filter when the dust density reached a value higher than 0.1mg/m3.

2015-02-26 21:38:30 - DS_Voltage state updated to 3.534719
2015-02-26 21:38:30 - DS_Density state updated to 0.489120
2015-02-26 21:38:32 - Socket received command ON
2015-02-26 21:38:33 - Launchpad received command #A

The other way around works as well. When the dust density has reached a normal level again, the filtering system is stopped.

2015-02-26 21:40:10 - DS_Voltage state updated to 0.780146
2015-02-26 21:40:10 - DS_Density state updated to 0.030024
2015-02-26 21:40:10 - Socket received command OFF
2015-02-26 21:40:10 - Launchpad received command #U

Screen Shot 2015-02-22 at 13.53.16 Screen Shot 2015-02-22 at 13.52.57

Enclosures

Finally, I've been making progress on the enclosures for both the control unit and the remote sensor. I milled additional "layers" for the control unit, which when combined, result in an enclosure capable of holding all the electronics involved.

photo 2 photo 4

For the remote sensor, I've been running into some issues with my printer. Because the enclosure is too big for my current print platform, I split the part in two. Printing the first part went well and the result was as expected. Things started to go wrong when printing the second part. For some reason, the printer's X-axis is skipping frequently. Why this didn't happen with the first print is a mystery. I've been troubleshooting the issue, but with time running out, alternatives might need to be found. On the bright side, I now know my printer is capable of handling huge bridges without support material, which is rather nice

photo 1 photo 2

The final enclosures will be revealed in tomorrow's final summary post (because I'm still working on them).

Conclusion

We're about to enter the last day of the challenge! The solution works, but there are still a few details I'd like to take care of before the final submission. See you tomorrow!

© Frederick Vandenbosch, 2014-2021. Unauthorised use and/or duplication of this material without express and written permission from this blog’s author and owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to Frederick Vandenbosch with appropriate and specific direction to the original content.