Smart Thermometer Using Esp-01F and Web Socket [Arduino IDE]

by Neutrino-1 in Circuits > Arduino

7327 Views, 101 Favorites, 0 Comments

Smart Thermometer Using Esp-01F and Web Socket [Arduino IDE]

vlcsnap-2021-07-18-18h56m35s118.png
vlcsnap-2021-07-18-18h56m27s106.png
vlcsnap-2021-07-18-18h56m05s890 (2).png
How to make a Smart Thermometer using ESP8285 and Web sockets [Arduino IDE]

In one of the previous instructable, we saw how to make a simple thermometer with ATTINY 85 which can last for 140days with a single battery and it still works great after 40+ days with the same battery I showed in the video.

But it was a tiny bit clumsy when it came to the electronics and the programming. So, in this instructable, let me show you how to make a thermometer on steroids with features nobody asked for, but by doing so I hope you will definitely learn plenty of electronics along the way.

The device will have the following features:

  • Realtime reading using WebSockets
  • Auto sleep on when not in use
  • Control the thermometer from a webpage
  • Sleek PCB design
  • Integrated esp-01F programmer
  • Integrated lipo charging circuit
  • 3d printed case

Supplies

These are the list of products that can help you do this project with ease

(Affiliate Link)

Why ESP-01F?

vlcsnap-2021-07-18-22h59m02s310.png
vlcsnap-2021-07-18-22h58m46s384.png
2021-07-04 18-04-22.00_01_01_00.Still002.png
2021-07-04 18-04-22.00_01_24_29.Still003.png

In version 1 the flash storage was very limited, hardly 8kb, I had struggled a bit for running different libraries. So, this time I chose the esp-01f, which comes with a 1MB of flash memory, which is 128times greater than the ATTINY 85. Along with this it also has features like WiFi, UART, higher clock speed up to 160MHz. Even though it won’t matter for this particular project we can flex the specs to make the thermometer look more muscular.

But it does come with a cost, the esp-01f is a very power-hungry module because of the onboard wifi connectivity, but this power consumption can be reduced greatly by putting the module to deep-sleep where it should consume just 20uA according to the datasheet.

Other Components

vlcsnap-2021-07-18-23h20m48s405.png
vlcsnap-2021-07-18-23h22m07s866.png
vlcsnap-2021-07-18-23h22m23s522.png

The other components are similar to the thermometer version 1. For the display, I’m going to use the same 0.91inch 128X32 OLED display, for the temperature sensor DS18B20 probe, and finally for the battery a small 150MAh lipo battery.

Everything looks easy to put together but with great power comes great responsibilities. There are so many smaller details that we are missing to complete this project at least to a bare minimum.

Smaller Details

vlcsnap-2021-07-18-23h27m09s085.png

To begin with, the size of the esp-01f is so compact that there is no antenna built-in. So either we have to build one on the PCB or add an external one, if not there will be stability issues and a shorter range for wifi connectivity.

But I’m going to do neither of those because I haven’t found myself any true purpose of having wifi integrated with the thermometer yet maybe someday I will but until then I can manage without the antenna.

Anyway, apart from this programming this module is clumsy and super hard because of the tiny footprint and not being able to solder this on any perf board. So many of my previous methods and technique for programming would not work quite well with this.

USB to Serial Convertor

2021-07-04 18-04-22.00_03_02_27.Still005.png
2021-07-04 18-04-22.00_03_06_18.Still004.png
vlcsnap-2021-07-18-23h34m20s701.png

That’s the reason I plan to integrate a USB to serial converter to program the esp-01f. Just like the ones on the development boards like Arduino, Nodemcu, etc. So, technically if you could give more pinout to the thermometer it can be used as a development board, well that’s one of the reasons I said it was on steroids.

To implement the serial programmer there are plenty of options, we can use CH340 which would be the cheapest, mostly seen on Arduino clone, or FTDI which would be the most expensive one, which was previously used in the original Arduino development boards. But I’m going to use neither of them because their IC package is quite large and quite bigger than the wifi module itself.

CP2102 USB to Serial

cp2102-usb-ttl-bridge-ic-800x800.jpg
vlcsnap-2021-07-18-23h37m26s564.png

So, I chose the CP2012. Which is a USB to serial converter by silicon labs that is mostly used in the NodeMCU and the ESP32 development board and their pricing is pretty moderate compared to FTDI and also the size of the IC package is quite small which is perfect for our device.

Charging Circuit

vlcsnap-2021-07-18-23h40m48s017.png
vlcsnap-2021-07-18-23h40m59s214.png
vlcsnap-2021-07-18-23h41m29s092.png

Finally, there is one issue, the Lithium polymer battery. Since it’s a rechargeable battery we need to have a provision to charge it. One way we could do this is by just taking the battery out and charge it, and slap it back on when it’s done. But it gets us back to the old problem again. Beginning clumsy and not elegant. So, we’ll add a tp4056 IC and a micro USB to have an onboard charging circuit.

Need to Develop This Project Into a PCB?

PCB-Cupid-logo-Design_Black_070123.png

Getting a electronics project into production would be nightmare. To ease you into the production world we have developed a platform (PCB CUPID) for PCB enthusiasts and hobbyists to ask and answer questions related to PCB design, fabrication, and assembly.

In addition to the Q&A feature, this website also has a wealth of blog posts and useful resources to help you learn about developing and manufacturing printed circuit boards. Whether you're a beginner looking for a crash course on PCB basics, or an experienced designer looking for tips and tricks, you'll find something of value on the site

So head on over and check it out, and don't forget to participate in the Q&A community to get help and share your own knowledge. Thanks!

Printing PCBs With PCBWay

vlcsnap-2021-07-18-23h45m53s823.png
pcbway.png
vlcsnap-2021-07-18-23h52m22s429.png
Capture.PNG

I sent the Gerber file for manufacturing with this project PCB sponsor PCBWay.

If you need custom PCBs for your project, they offer 10 custom PCBs for as low as 5$ and a variety of customization that you can choose for your PCB, like the color of the solder mask, silk layer, and surface finish. And on your first order, you get a coupon of 5$! So, basically, you will be just paying for your shipping during your first order. So check out the link in the description to visit their website.

Since now the PCB (Gerber) is ready. It’s time for soldering!

Soldering!!

vlcsnap-2021-07-18-23h55m32s751.png
vlcsnap-2021-07-18-23h56m15s585.png
vlcsnap-2021-07-19-00h09m43s252.png
vlcsnap-2021-07-18-23h56m50s399.png
vlcsnap-2021-07-19-00h10m00s256.png
vlcsnap-2021-07-19-00h10m10s316.png
vlcsnap-2021-07-18-23h57m29s442.png
vlcsnap-2021-07-18-23h58m07s469.png

Everything worked great and looked good until I realized the mistake I made. The OLED display was facing the other way around. But the fix was pretty simple. I had to just solder the OLED with wires instead of the header pins.

From here on the circuit was sleek. Just plug in the micro USB and the charging circuit charges the battery and just by connecting this micro USB to a PC, you can program the esp-01f using Arduino IDE.

Programming the Smart Thermometer

vlcsnap-2021-07-19-00h08m21s056.png
vlcsnap-2021-07-19-00h09m02s019.png
vlcsnap-2021-07-19-00h09m26s352.png

Programming is totally simple in this version. Just open the code (Github) "Thermometer V2.ino" in Arduino IDE and set up the Arduino IDE to upload code to the esp8285. When you press the upload button, the code should automatically flash the esp8285 with the latest code, but if it doesn't, just click and hold the program button as shown in the first image during the upload process.

Webpage

vlcsnap-2021-07-19-16h26m57s179.png
Capture.PNG
vlcsnap-2021-07-18-19h07m32s893 (2).png

I kinda hate web development, but still anyway I managed to build a sloppy webpage with WebSockets to show some real-time temperature reading from the temperature sensor. It doesn't use any fancy libraries or fancy frameworks. It's written on HTML, CSS, and Vanilla Javascript (code).

3d Printing and Assembly!

vlcsnap-2021-07-19-00h13m54s671.png
vlcsnap-2021-07-19-00h13m34s643.png
vlcsnap-2021-07-19-00h12m59s857.png
vlcsnap-2021-07-19-16h03m46s994.png
vlcsnap-2021-07-19-16h04m13s649.png
vlcsnap-2021-07-19-16h04m25s263.png
vlcsnap-2021-07-19-16h04m33s739.png

Since the board is ready, I wanted to build a funky case for the thermometer. I thought of making a smoking pipe, but unfortunately, I didn’t have the same idea when I was doing the PCB design. So it was quite difficult to build and was not that good looking so I had to ditch that idea.

Instead, I measured the exact dimension of the PCB and started designing a simple elegant case while still managing to have the same easy accessibility to the circuitry without any fasteners just like version 1.

Then the rest was just 3d printing and assembly!

3d printing

  • Printer - Ender 3v2 (Cura slicer)
  • Supports - Turned on
  • Layer height - 0.2mm
  • Filament - PLA+
  • Nozzle Temperature - 210c
  • Nozzle Heat bed - 72c

Testing the Smart Thermometer

vlcsnap-2021-07-19-16h10m04s540.png
vlcsnap-2021-07-19-16h26m57s179.png
vlcsnap-2021-07-19-16h10m12s324.png
vlcsnap-2021-07-18-19h07m32s893 (2).png

Let me quickly walk you through how it works.

Just click on the top button, this will reset the esp and wake it up from sleep mode. Once the device is active it will turn on an access point where we can connect. After connection opens any web browser and searches for the IP address assigned in the code or by searching "http://temperature.local". That’s it now we can measure the temperature by clicking the start and see the real-time data on the webpage.

You can also put the thermometer to sleep by click on the sleep button. Which would clear the display and put the thermometer to deep sleep.

If the device is turned on for more than a minute and nobody made the connection to the webpage the device will go to deep sleep automatically to save power.

Power Consumption

vlcsnap-2021-07-19-16h09m27s315.png
vlcsnap-2021-07-19-16h09m57s687.png
vlcsnap-2021-07-19-16h30m02s075.png
vlcsnap-2021-07-19-16h10m21s716.png
vlcsnap-2021-07-19-16h30m13s283.png
Screenshot_2021-07-16-17-11-13-733_it.android.demi.elettronica.jpg

As I told you at the start of the instructable, the power consumption going to be higher than version 1, because of the ESP-01F. So, if you see the multimeter reading when the Access point is turned on and a client has connected, the power consumption is around 93mA. When the thermometer is in deep sleep it consumes around 1.8mA which is quite significant when compared to the previous version where it consumed under 60uA.

Considering the ESP-01F consuming around 20uA (from the datasheet), the total circuit should still consume less than 100uA. The reason why it consumes 1.8mA is because of the other features we added like the charging circuit and the onboard CP2102 USB to Serial programmer.

Final Thoughts!

How to make a Smart Thermometer using ESP8285 and Web sockets [Arduino IDE]
vlcsnap-2021-07-18-18h56m35s118.png

This device doesn't have much value when compared to the existing thermometer, but building a device with all the user-friendly interfaces like the buttons and onboard programmer is quite challenging for beginners and even for some intermediate learners. I hope at least this instructable gave you few ideas about building a bit more sophisticated project and how to approach it.

So, if you like the video make sure to hit the like button and be subscribe to watch more upcoming videos. And I promise I will definitely come up with something better than a thermometer. Until then you can watch my other video from the link on the screen or the link in the description.