I managed to purchase a second WiFi booster pack although the TI discount voucher I won here was not accepted This booster pack has allowed me to assemble a second system consisting of a MSP-EXP432P401RMSP-EXP432P401R a CC3100ModBoost and a 430BOOST-SHARP96430BOOST-SHARP96 I have programmed the second system as an MQTT client subscribing to the IHEF data being published by my sensor platform which has the same cards plus my custom sensor booster pack Both systems use Wi-Fi to access my MQTT broker
The following video shows both systems booting up with MQTTLENS running in the background all interacting with my Mosquitto broker.
Here is the subscriber program such as it is at this moment:
/*
Invisible Hazardous Environmental Factors
by Doug Wong 2017-04-08
Remote Display via MQTT
- connects to an MQTT server
- subscribes to the topic "IHEF"
- displays Alcohol, CO, Air Quality, CO2, UV
*/
#include <SPI.h>
#include <WiFi.h>
#include <PubSubClient.h>
#include <LCD_SharpBoosterPack_SPI.h>
// your network name also called SSID
char ssid[] = "AccessPoint";
// your network password
char password[] = "NetworkPassword";
// MQTTServer to use
char server[] = "brokerURL";
LCD_SharpBoosterPack_SPI myScreen;
//callback section retrieves subscribed data and displays it
void callback(char* topic, byte* payload, unsigned int length) {
char *cstring = (char *) payload;
if (cstring[0] == 49) // ALC
{
myScreen.text(5, 17, cstring);
myScreen.text(65, 17, " ppm ");
}
if (cstring[0] == 50) // CO
{
myScreen.text(5, 32, cstring);
myScreen.text(65, 32, " ppm ");
}
if (cstring[0] == 51) // AQ
{
myScreen.text(5, 47, cstring);
myScreen.text(65, 47, " ppm ");
}
if (cstring[0] == 52) // CO2
{
myScreen.text(5, 62, cstring);
myScreen.text(65, 62, " ppm ");
}
if (cstring[0] == 53) // UV
{
myScreen.text(5, 77, cstring);
myScreen.text(65, 77, " idx ");
}
myScreen.flush();
}
WiFiClient wifiClient;
PubSubClient client(server, 1883, callback, wifiClient);
void setup()
{ //initiallization section connects to MQTT broker
Serial.begin(115200);
// attempt to connect to Wifi network:
myScreen.begin();
myScreen.clearBuffer();
myScreen.setFont(0);
myScreen.text(5, 1, "Connecting...");
myScreen.flush();
// Start Ethernet with the build in MAC Address
// attempt to connect to Wifi network:
// Connect to WPA/WPA2 network
WiFi.begin(ssid, password);
while ( WiFi.status() != WL_CONNECTED) {
// print dots while we wait to connect
delay(300);
}
myScreen.text(5, 9, "WiFi Connected ");
myScreen.text(5, 18, "Waiting for ip");
myScreen.flush();
while (WiFi.localIP() == INADDR_NONE) {
delay(300);
}
myScreen.text(5, 27, "IP obtained");
myScreen.text(5, 36, WiFi.localIP());
myScreen.flush();
delay(300);
}
void loop()
{
// Reconnect if the connection was lost
if (!client.connected()) {
if(!client.connect("IHEF")) {
} else {
if(client.subscribe("IHEF")) {
myScreen.text(5, 45, "Subcribed");
myScreen.text(5, 54, "IHEF");
myScreen.flush();
delay(1200);
myScreen.clear();
myScreen.text(20, 3, "MQTT IHEF");
myScreen.flush();
}
}
}
// Check if any message were received
// on the topic we subsrcived to
client.poll();
delay(1000);
}
My next blog will likely be about the invisible hazards of microwaves, but I am also close to starting on packaging all my instrumentation in a wearable format. The main things still missing from my project are some minor components for my custom sensor circuit card, and there is still some software work to produce calibrated sensor readings.
All links to blogs related to this project can be found in the first blog here:
Safe and Sound - Invisible Hazardous Environmental Factors Monitoring System - blog 1
Top Comments