Here is a temperature logging system based on PIC16F887 microcontroller (MCU), Wi-Fi and ThingSpeak application programming interface (API). ThingSpeak is an open source Internet of Things (IoT) application and API to store and retrieve data from things over the Internet. It enables you to collect, store, analyse, visualise and act on the data received from sensors or electronic circuits.
Block diagram of the temperature-logging system is shown in Fig. 1. Author’s prototype is shown in Fig. 2. Temperature data transmitted from the circuit board can be accessed on a smartphone or PC through Wi-Fi using ThingSpeak API.
Circuit and working
Circuit diagram of the IoT Wi-Fi temperature-logging system is shown in Fig. 3. It is built around PIC16F887 MCU (IC4), ESP8266 Wi-Fi module, logic-level shifter, LM35 temperature sensor (IC3), 3.3V regulator LM1117-3.3 (IC2), 5V regulator 7805 (IC1) and 16×2 LCD module (LCD1).
This is a high-performance RISC CPU, 8-bit CMOS MCU, and has 8192-word flash memory, 368 bytes SRAM, 256 bytes EEPROM and 35 I/Os. It supports up to 20MHz oscillator/clock input and has a wide operating voltage range of 2.0V-5.5V. Its inbuilt A/D converter has a 10-bit resolution and three internal timers. It supports enhanced USART module, in-circuit serial programming (ICSP), 3-wire SPI and I2C.
ESP8266 Wi-Fi module
ESP8266 Wi-Fi module (Fig. 4) is a self-contained system on chip (SoC) with an integrated TCP/IP protocol stack that can give any MCU access to your Wi-Fi network. ESP8266 is capable of either hosting an application or offloading all Wi-Fi networking functions from another application processor.
Each ESP8266 module comes pre-programmed with an AT command set firmware. This means that you can simply hook this up to your Arduino device and get about as much Wi-Fi ability as a Wi-Fi shield can offer (and that is just out of the box). ESP8266 module is an extremely cost-effective board with a huge and an ever-growing community.
This module requires a 3.3V DC regulated supply. Power consumption of the ESP module is around 250mA when transmitting. You need proper power supply. Do not power it directly from a 5V supply source. It also needs a level shifting/conversion to protect the 3.3V device from 5V.
ESP8266 module is not capable of converting 5V to 3.3V. We used an external logic shifter/converter as shown in Fig. 5. +3.3V, CH_PD and RST pins are kept at 3.3V for normal functioning of ESP8266. Logic-level converter is a device that safely steps down 5V signal to 3.3V.
LM35 temperature sensor
The LM35 series is of precision integrated circuit temperature sensors, whose output voltage is linearly proportional to Celsius (Centigrade) temperature. LM35 is rated to operate over -55°C to +150°C, while LM35C is rated for a -40°C to a +110°C temperature range. This sensor has a linear scale factor of 10mV/°C and operates from 4V to 30V.
Power supply section includes a 5V regulator 7805 (IC1) and a 3.3V regulator LM1117-3.3 (IC2). The MCU, logic-level shifter and LCD are powered by 5V and ESP Wi-Fi module by 3.3V supply. Voltage for ESP8266 for all its pins is 3.3V. If you are using an adjustable voltage regulator, carefully set proper voltage to 3.3V.
In this project, temperature data from LM35 sensor is fed to pin 2 of PIC16F887 MCU. This data is given to ESP8266 Wi-Fi module through a logic-level shifter. Temperature data transmitted from the Wi-Fi module can be accessed on a remote device like a smartphone or laptop using ThingSpeak’s website.
ESP8266 Wi-Fi module has two GPIO pins that can be used for connecting to the Internet through an MCU using specific firmware. However, these are not used in this project and it works on the default firmware.
ESP8266 Wi-Fi module is used here to connect to your Wi-Fi modem and upload temperature data to ThingSpeak. You can view that data from a smartphone or laptop in the form of a plotted-line graph.
In this project, an LCD is also used as a user interface device to see circuit configuration status and temperature data. Data lines (D0 through D7) of the LCD are connected to port B of IC4.