The sensor uses an ESP8266 board with the protocol Lightweight M2M to communicate the temperature read by DS18B20 to the gateway. The sources of the project are available on GitHub: https://github.com/brusdev/smart-solar-heating-system/tree/master/sensor
The ESP8266 is a low-cost Wi-Fi microchip with full TCP/IP stack and microcontroller capability produced by Espressif Systems. The avalability of same SDK allows the chip to be programmed, removing the need for a separate microcontroller. To program the microchip i use the SDK Arduino core for ESP8266 WiFi chip and PlatformIO, that is an open source ecosystem for IoT development.
Lightweight M2M is a protocol from the Open Mobile Alliance for M2M or IoT device management and communication. It uses CoAP, a light and compact protocol with an efficient resource data model, for the application layer communication between LWM2M Servers and LWM2M Clients.
Each service on a constrained device/sensor/actor is modelled as an LWM2M object instance. An object has a unique identifier and may have instances. Some LWM2M object identifiers are standardised via the OMA Object & Resource Registry (http://technical.openmobilealliance.org/Technical/technical-information/omna/lightweight-m2m-lwm2m-object-registry).
libWakaamaEmbI use libWakaamaEmb by David Gräff, to enable LwM2M on the ESP8266, with a little change to fix the connection to a server without a bootstrap server. You can find the changes at following repository: https://github.com/brusdev/libWakaamaEmb/tree/patch-esp8266.
The library libWakaamaEmb is published to the PlatformIO library registry and Arduino library registry and available on Github. I use the PlatformIO and copy the library direcory under my project "lib" folder but i need to select lwip version 2. PlatformIO doesn't allow to select lwip version 2 so i need to change manually the file .platformio/packages/framework-arduinoespressif8266/tools/platformio-build.py replacing lwip with lwip2.To expose the temperature i implement the object 3300 that rapresents a generic sensor.
To connect a server witouth the bootstrap server i need to add manually the server address:
DS18B20The DS18B20 digital thermometer provides 9-bit to 12-bit Celsius temperature measurements and has an alarm function with nonvolatile user-programmable upper and lower trigger points. The DS18B20 communicates over a 1-Wire bus that by definition requires only one data line (and ground) for communication with a central microprocessor. In addition, the DS18B20 can derive power directly from the data line ("parasite power"), eliminating the need for an external power supply.
I use the DallasTemperature library of arduino to read the temperature by DS18B20.