Well that was easy.
Dallas DS18B20.
Soldered a 4k7 across Data and Vcc
Female to female jumper leads
VCC to 3.3V
Data to D2
GND to... well GND
Heat shrink the Dallas sensor
USB wall wart.
Sprinkle some code.
VoilĂ Wifi enabled temp probe.
Stuff it in a corner of a remote room.
Now I have this little set:
paul@localhost /mnt/hub_home/lcd_test/sh $ bash query.sh
BR:21.12:'C,AP:1014.4113:Hpa,AT:22.15:'C,DS:22.125:'C,OD:6.937:'C,HM:37.5819:%
BR: 21.12 'C
AP: 1014.4113 Hpa
AT: 22.15 'C
DS: 22.125 'C
OD: 6.937 'C
HM: 37.5819 %
BR is bedroom - the NodeMCU
DS is downstairs
OD outdoors (hanging out the window on an RJ45)
AP air pressure, HM humidity, AT aux_temp (provided by the pressure/humidity sensor)
All of the above from the living room PI3
Still sucks that the power supply costs more than the flipping NodeMCU. Especially as I could only find a 2A Raspberry PI wall wart and they aren't cheap.
Code:
#include <OneWire.h>
#include <ESP8266WiFi.h>
#include <DallasTemperature.h>
#include <WiFiUdp.h>
// Put your wifi SID and password in a file of this name
// or uncomment and edit these
// const char* ssid = "mysid";
// const char* password = "mypassword";
#include "credentials.h"
#define ONE_WIRE_BUS D1
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup() {
WiFi.begin(ssid, password);
sensors.begin();
}
void loop() {
sensors.requestTemperatures();
double temp = sensors.getTempCByIndex(0);
WiFiUDP Udp;
Udp.beginPacket("10.0.0.3", 9999); // host, port
char data[255];
memset(data, 0, 255);
int len = snprintf(data, 255, "BR:%.2f:'C", temp); // KEY:VALUE:UNIT
Udp.write(data, len);
Udp.endPacket();
delay(5000);
}
EDIT:
References/credits:
http://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/udp-examples.htmlhttps://github.com/esp8266/Arduino/issues/584 WTF?
http://www.hobbytronics.co.uk/ds18b20-arduino