My goals is to add some sensors via MQTT to my stations which are all RPi 3
and use WeeWx 3.8.0. I am running the Mosquitto broker on the same RPi as
WeeWx
One station uses a Ultimeter 2100 driver -* can I use WeeWxMQTT as a
service*?
Other stations are a combination of OWFS and FileParse (using a python
program to read from i2c bus on RPi).
The station I am testing/developing (driving myself crazy) on now has
WeeWxMQTT set as driver and OWFS as a service. It gives me errors like:
Apr 6 09:22:44 ru-pi weewx[17871]: wxMesh: Working on queue of 0
Apr 6 09:22:44 ru-pi weewx[17871]: wxMesh: Sleeping for 5
This tells me that WeeWxMqTT is not finding the MQTT messages in the
correct format.
I am struggling with getting the esp8266 to output anything resembling the
expected:
TIME:0,AMBT: 7.23,BARP:1001.97,RHUM:70.92,HUMT:
4.44,IRRA:12,BATV:974,PHOV:673,SYST:33.20,WIND: 0.0,WDIR: 0.0 (from the
WeeWxMQTT
wiki)
The output is have managed to send is like this:
* {"temperature":69.12} *
*My Arduino sketch for the esp8266 is:*
// use OWFS temperature sensor
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 5
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
// Update these with values suitable for your network.
const char* ssid = "My Network";
const char* password = "MyPW";
const char* mqtt_server = "10.0.0.161";
char* topic ="weather";
WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
float temp = 0;
int inPin = 5;
String dataString;
char charBuf[150];
void setup_wifi() {
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void reconnect() {
// Loop until we're reconnected
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
// Attempt to connect
if (client.connect("arduinoClient_temperature_sensor")) {
Serial.println("connected");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
}
}
}
void setup()
{
Serial.begin(115200);
setup_wifi();
client.setServer(mqtt_server, 1883);
pinMode(inPin, INPUT);
sensors.begin();
}
void loop()
{
if (!client.connected()) {
reconnect();
}
client.loop();
long now = millis();
if (now - lastMsg > 5000) {
lastMsg = now;
sensors.setResolution(12);
sensors.requestTemperatures(); // Send the command to get temperatures
temp = sensors.getTempCByIndex(0);
Serial.println(temp);
temp = (temp *1.8) + 32; // convert to F
Serial.println(temp);
if((temp > -20) && (temp <110))
dataString = String("{\"temperature\":") + temp + String("}");
dataString.toCharArray(charBuf, 150);
{
client.publish(topic,charBuf );
}
}
}
*Any advice would be greatly appreciated. *
--
You received this message because you are subscribed to the Google Groups
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.