We describe two tests (TEST1, TEST2) in this article. Before downloading the code in Smart Wi-Fi, you will need to connect it to the PC using a micro-USB cable. Start ESPlorer tool and set the port and baud rate [9600 default] and press Open Tab to open the port. It is ready to use now. We have used ESPlorer v0.2.0-rc2 version, and the corresponding test procedure is described below.
Temperature sensor interface with Smart Wi-Fi
The code here is for data read on the ADC and sent to the serial port locally. Open Temperature_Interface.lua file (given in DVD), type =call(“Temperature_Interface.lua”) on the left side of Send and press Send.
We can now observe data into the serial terminal of ESPlorer tool. The code will keep sending data over the serial port every 15 seconds. In the code, we use internal timer # 1 of ESP to call an inline function every 15 seconds. The function reads ADC0 value, which it receives in terms of millivolts, and divides it by ten. As the resolution of LM35 is 10mV per degree Celsius, dividing by ten provides the actual temperature in Celsius. We can print this value to the serial port using print function:
tmr.alarm(1, 15000, 1, function()
current_temp = adc.read(0)/10;
print(fmt(“Temperature : %3.1f C”, current_temp));
Temperature data upload on the Internet using ThingSpeak API
In Test 1, we connected a temperature sensor and observed the data locally. This data can be used in multiple ways as per the application. In Test 2, we will make the same data available on the Internet and it would be accessible from anywhere in the world.
We use ThingSpeak API, which is a freely-available tool used to access and present data over the Internet. Before using ThingSpeak API, you need to create a user account for ThingSpeak and a channel. You will get an API key (Fig. 6) for the channel and then you can upload your data and present it in a graphical form. The only limitation is the frequency of posts, which is limited to 15 seconds.